From f3b6ca5659bd0e1be0cb0c0ec5113ee7cc910725 Mon Sep 17 00:00:00 2001 From: Tim Besard Date: Tue, 27 Oct 2026 12:39:43 +0100 Subject: [PATCH] Define the KernelAbstractions methods in oneAPI rather than an extension KernelAbstractions is always loaded anyway, since GPUArrays depends on it, so make it a dependency and move the extension's methods into oneAPIKernels. Here the extension did not invalidate anything, and oneAPI does not precompile KernelAbstractions launches, but the other back-ends need this change to keep their precompiled launches valid. Doing the same keeps them uniform, and makes sure the KernelAbstractions methods exist whenever oneAPI's precompiled code is compiled. --- Project.toml | 7 +------ ext/KernelAbstractionsExt.jl | 22 ---------------------- src/oneAPIKernels.jl | 14 ++++++++++++++ 3 files changed, 15 insertions(+), 28 deletions(-) delete mode 100644 ext/KernelAbstractionsExt.jl diff --git a/Project.toml b/Project.toml index c819a1036..8b2f986c7 100644 --- a/Project.toml +++ b/Project.toml @@ -13,6 +13,7 @@ GPUArrays = "0c68f7d7-f131-5f86-a1c3-88cf8149b2d7" GPUCompiler = "61eb1bfa-7361-4325-ad38-22787b887f55" GPUToolbox = "096a3bc2-3ced-46d0-87f4-dd12716f4bfc" IntelITT = "c9b2f978-7543-4802-ae44-75068f23ee64" +KernelAbstractions = "63c18a36-062a-441e-b654-da1e3ab1ce7c" KernelInterface = "4ee993da-d684-4d17-a7dd-4e58e78d92bf" LLVM = "929cbde3-209d-540e-8aea-75f648917ca0" Libdl = "8f399da3-3557-5675-b5ff-fb832c97cbdb" @@ -35,12 +36,6 @@ oneAPI_Level_Zero_Headers_jll = "f4bc562b-d309-54f8-9efb-476e56f0410d" oneAPI_Level_Zero_Loader_jll = "13eca655-d68d-5b81-8367-6d99d727ab01" oneAPI_Support_jll = "b049733a-a71d-5ed3-8eba-7d323ac00b36" -[weakdeps] -KernelAbstractions = "63c18a36-062a-441e-b654-da1e3ab1ce7c" - -[extensions] -KernelAbstractionsExt = "KernelAbstractions" - [compat] AbstractFFTs = "1.5.0" Adapt = "4" diff --git a/ext/KernelAbstractionsExt.jl b/ext/KernelAbstractionsExt.jl deleted file mode 100644 index f9a0d9fcd..000000000 --- a/ext/KernelAbstractionsExt.jl +++ /dev/null @@ -1,22 +0,0 @@ -module KernelAbstractionsExt - -using oneAPI - -import KernelAbstractions as KA - -import Adapt - -Adapt.adapt_storage(::KA.CPU, a::oneArray) = convert(Array, a) - -# sparse arrays (oneMKL is only available on Linux) -@static if Sys.islinux() - import SparseArrays - Adapt.adapt_storage(::KA.CPU, a::oneAPI.oneMKL.oneAbstractSparseMatrix) = SparseArrays.SparseMatrixCSC(a) -end - - -## other - -Adapt.adapt_storage(to::KA.ConstAdaptor, a::oneDeviceArray) = Base.Experimental.Const(a) - -end diff --git a/src/oneAPIKernels.jl b/src/oneAPIKernels.jl index 6923e14b7..a2c7d8869 100644 --- a/src/oneAPIKernels.jl +++ b/src/oneAPIKernels.jl @@ -3,6 +3,7 @@ module oneAPIKernels using ..oneAPI using ..oneAPI: @device_override, SPIRVIntrinsics, method_table, kernel_convert, zefunction +import KernelAbstractions as KA import KernelInterface as KI import Adapt @@ -213,6 +214,19 @@ function KI.multiprocessor_count(::oneAPIBackend)::Int end +## KernelAbstractions + +Adapt.adapt_storage(::KA.CPU, a::oneArray) = convert(Array, a) + +# sparse arrays (oneMKL is only available on Linux) +@static if Sys.islinux() + import SparseArrays + Adapt.adapt_storage(::KA.CPU, a::oneAPI.oneMKL.oneAbstractSparseMatrix) = SparseArrays.SparseMatrixCSC(a) +end + +Adapt.adapt_storage(to::KA.ConstAdaptor, a::oneDeviceArray) = Base.Experimental.Const(a) + + ## Indexing Functions ## COV_EXCL_START