Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ ArgCheck = "dce04be8-c92d-5529-be00-80e4d2c0e197"
Atomix = "a9b6321e-bd34-4604-b9c9-b65b8de01458"
GPUArraysCore = "46192b85-c4d5-4398-a991-12ede77f4527"
KernelAbstractions = "63c18a36-062a-441e-b654-da1e3ab1ce7c"
PrecompileTools = "aea7be01-6a6a-4083-8856-8a6e6704d82a"

[weakdeps]
CUDA = "052768ef-5323-5732-b1bb-66c8b64840ba"
Expand All @@ -33,5 +34,6 @@ GPUArraysCore = "0.2.1"
KernelAbstractions = "0.9.43, 0.10"
Metal = "1.10.1"
OpenCL = "0.10, 1"
PrecompileTools = "1"
julia = "1.10"
oneAPI = "1, 2"
26 changes: 26 additions & 0 deletions ext/oneAPIExt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ module oneAPIExt

using oneAPI
import AcceleratedKernels as AK
using PrecompileTools: @setup_workload, @compile_workload


# Some Intel GPUs (reportedly Intel UHD Graphics) hang when many threads write one global location,
Expand All @@ -29,4 +30,29 @@ AK.sort_tuning(::oneAPIBackend, ::Type{T}) where {T} =
AK.SortTuning(bitonic_max_len=128, bitonic_max_slice_len=128)


# oneAPI's own workload can't cache these operations: this extension isn't loaded while oneAPI
# precompiles, so the kernels it would compile use the default tunings, not the ones above. The
# sizes are large enough for the kernels that arrays of millions of elements use. Before Julia
# 1.12, compiling GPU code while precompiling can leak device code into the image.
@static if VERSION >= v"1.12-"
@setup_workload begin
# (`can_precompile` checks that the GPU can be used while precompiling)
if isdefined(oneAPI, :can_precompile) && oneAPI.can_precompile()
@compile_workload begin
m = oneArray(ones(Float32, 4096, 64))
v = vec(m)
sum(v)
sum(m; dims=1)
sum(m; dims=2)
cumsum(v)
any(iszero, v)
all(iszero, v)
sum(oneArray(ones(Int, 4096)))
oneAPI.synchronize()
end
end
end
end


end # module oneAPIExt
Loading