Skip to content

Commit 0c9c8b7

Browse files
authored
Update SPIRVIntrinsics from 0.2 to 0.5 (#542)
* NEO v25.35.35096 * Fixes for SPIRVIntrinsics 0.5 * Add div(::Float32, ::Float32) override
1 parent 8c987b0 commit 0c9c8b7

File tree

11 files changed

+33
-26
lines changed

11 files changed

+33
-26
lines changed

Project.toml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "oneAPI"
22
uuid = "8f75cd03-7ff8-4ecb-9b8f-daf728133b1b"
33
authors = ["Tim Besard <[email protected]>"]
4-
version = "2.4.0"
4+
version = "2.4.1"
55

66
[deps]
77
AbstractFFTs = "621f4979-c628-5d54-868e-fcf4e3e8185c"
@@ -37,18 +37,19 @@ Adapt = "4"
3737
CEnum = "0.4, 0.5"
3838
ExprTools = "0.1"
3939
GPUArrays = "11.2.1"
40-
GPUCompiler = "1.5"
40+
GPUCompiler = "1.6"
4141
GPUToolbox = "0.1, 0.2, 0.3, 1"
4242
KernelAbstractions = "0.9.1"
4343
LLVM = "6, 7, 8, 9"
44-
NEO_jll = "=25.31.34666"
44+
NEO_jll = "=25.35.35096"
4545
Preferences = "1"
46-
SPIRVIntrinsics = "0.2"
47-
SPIRV_LLVM_Translator_jll = "20"
46+
SPIRVIntrinsics = "0.5"
47+
SPIRV_LLVM_Translator_jll = "21"
48+
SPIRV_Tools_jll = "2025.4.0"
4849
SpecialFunctions = "1.3, 2"
4950
StaticArrays = "1"
5051
julia = "1.10"
51-
oneAPI_Level_Zero_Loader_jll = "1.22"
52+
oneAPI_Level_Zero_Loader_jll = "1.24"
5253
oneAPI_Support_jll = "0.9.2"
5354

5455
[extras]

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ translator](https://github.com/KhronosGroup/SPIRV-LLVM-Translator):
147147

148148
```julia
149149
julia> function kernel()
150-
barrier()
150+
barrier(0)
151151
return
152152
end
153153

src/array.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -279,8 +279,8 @@ end
279279

280280
## interop with GPU arrays
281281

282-
function Base.unsafe_convert(::Type{oneDeviceArray{T,N,AS.Global}}, a::oneArray{T,N}) where {T,N}
283-
oneDeviceArray{T,N,AS.Global}(size(a), reinterpret(LLVMPtr{T,AS.Global}, pointer(a)),
282+
function Base.unsafe_convert(::Type{oneDeviceArray{T,N,AS.CrossWorkgroup}}, a::oneArray{T,N}) where {T,N}
283+
oneDeviceArray{T,N,AS.CrossWorkgroup}(size(a), reinterpret(LLVMPtr{T,AS.CrossWorkgroup}, pointer(a)),
284284
a.maxsize - a.offset*Base.elsize(a))
285285
end
286286

src/compiler/compilation.jl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,17 @@ const oneAPICompilerJob = CompilerJob{SPIRVCompilerTarget,oneAPICompilerParams}
66

77
GPUCompiler.runtime_module(::oneAPICompilerJob) = oneAPI
88

9-
GPUCompiler.method_table(::oneAPICompilerJob) = method_table
9+
GPUCompiler.method_table_view(job::oneAPICompilerJob) =
10+
GPUCompiler.StackedMethodTable(job.world, method_table, SPIRVIntrinsics.method_table)
1011

1112
# filter out OpenCL built-ins
1213
# TODO: eagerly lower these using the translator API
1314
GPUCompiler.isintrinsic(job::oneAPICompilerJob, fn::String) =
1415
invoke(GPUCompiler.isintrinsic,
1516
Tuple{CompilerJob{SPIRVCompilerTarget}, typeof(fn)},
1617
job, fn) ||
17-
in(fn, opencl_builtins)
18+
in(fn, known_intrinsics) ||
19+
contains(fn, "__spirv_")
1820

1921
function GPUCompiler.finish_module!(job::oneAPICompilerJob, mod::LLVM.Module,
2022
entry::LLVM.Function)

src/compiler/execution.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ Adapt.adapt_storage(to::KernelAdaptor, p::ZePtr{T}) where {T} = reinterpret(Ptr{
8888

8989
# convert oneAPI host arrays to device arrays
9090
Adapt.adapt_storage(::KernelAdaptor, xs::oneArray{T,N}) where {T,N} =
91-
Base.unsafe_convert(oneDeviceArray{T,N,AS.Global}, xs)
91+
Base.unsafe_convert(oneDeviceArray{T,N,AS.CrossWorkgroup}, xs)
9292

9393
# Base.RefValue isn't GPU compatible, so provide a compatible alternative.
9494
# TODO: port improvements from CUDA.jl

src/device/quirks.jl

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,13 @@ end
6060

6161
# From Metal.jl to avoid widemul and Int128
6262
@static if VERSION >= v"1.12.0-DEV.1736" # Partially reverts JuliaLang/julia PR #56750
63-
let BitInteger64 = Union{Int64, UInt64}
64-
@device_override function Base.checkbounds(::Type{Bool}, v::StepRange{<:BitInteger64, <:BitInteger64}, i::BitInteger64)
65-
@inline
66-
return checkindex(Bool, eachindex(IndexLinear(), v), i)
67-
end
63+
const BitInteger64 = Union{Int64, UInt64}
64+
@device_override function Base.checkbounds(::Type{Bool}, v::StepRange{<:BitInteger64, <:BitInteger64}, i::BitInteger64)
65+
@inline
66+
return checkindex(Bool, eachindex(IndexLinear(), v), i)
6867
end
68+
69+
# Less accurate division for Float32 than Base Julia which relies on Float64
70+
# https://github.com/JuliaLang/julia/pull/49637
71+
@device_override Base.div(x::Float32, y::Float32) = trunc(x / y)
6972
end

src/mapreduce.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
# perform a reduction
1717
d = 1
1818
while d < items
19-
barrier()
19+
barrier(0)
2020
index = 2 * d * (item-1) + 1
2121
@inbounds if index <= items
2222
other_val = if index + d <= items

src/oneAPI.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ functional() = oneL0.functional[]
3030
import SPIRVIntrinsics
3131
SPIRVIntrinsics.@import_all
3232
SPIRVIntrinsics.@reexport_public
33+
Base.Experimental.@MethodTable(method_table)
3334
include("device/runtime.jl")
3435
include("device/array.jl")
3536
include("device/quirks.jl")

src/oneAPIKernels.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
module oneAPIKernels
22

33
using ..oneAPI
4-
using ..oneAPI: @device_override
4+
using ..oneAPI: @device_override, SPIRVIntrinsics, method_table
55

66
import KernelAbstractions as KA
77

@@ -161,7 +161,7 @@ end
161161
## Synchronization and Printing
162162

163163
@device_override @inline function KA.__synchronize()
164-
barrier()
164+
barrier(0)
165165
end
166166

167167
@device_override @inline function KA.__print(args...)

test/device/intrinsics.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ end
226226

227227
s[t] = d[t]
228228
s2[t] = 2*d[t]
229-
barrier()
229+
barrier(0)
230230
d[t] = s[tr]
231231

232232
return
@@ -252,7 +252,7 @@ end
252252

253253
s[t] = d[t]
254254
s2[t] = d[t]
255-
barrier()
255+
barrier(0)
256256
d[t] = s[tr]
257257

258258
return

0 commit comments

Comments
 (0)