Skip to content

Commit 7a7b8e9

Browse files
authored
Pass extensions argument through @opencl (#355)
1 parent a387890 commit 7a7b8e9

File tree

3 files changed

+27
-1
lines changed

3 files changed

+27
-1
lines changed

src/compiler/execution.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export @opencl, clfunction
44
## high-level @opencl interface
55

66
const MACRO_KWARGS = [:launch]
7-
const COMPILER_KWARGS = [:kernel, :name, :always_inline]
7+
const COMPILER_KWARGS = [:kernel, :name, :always_inline, :extensions]
88
const LAUNCH_KWARGS = [:global_size, :local_size, :queue]
99

1010
macro opencl(ex...)

test/Project.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ Preferences = "21216c6a-2e73-6563-6e65-726566657250"
1212
Printf = "de0858da-6303-5e67-8744-51eddeeeb8d7"
1313
REPL = "3fa0cd96-eef1-5676-8a61-b3b8758bbffb"
1414
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
15+
SPIRVIntrinsics = "71d1d633-e7e8-4a92-83a1-de8814b09ba8"
1516
SPIRV_LLVM_Backend_jll = "4376b9bf-cff8-51b6-bb48-39421dff0d0c"
1617
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
1718
SpecialFunctions = "276daf66-3868-5448-9aa4-cd146d93841b"

test/atomics.jl

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
using SPIRVIntrinsics: @builtin_ccall, @typed_ccall, LLVMPtr
2+
13
@testset "atomics" begin
24

35
function atomic_count(counter)
@@ -13,4 +15,27 @@ end
1315
end
1416
end
1517

18+
if "cl_ext_float_atomics" in cl.device().extensions
19+
function atomic_float_add(counter, val)
20+
@builtin_ccall(
21+
"atomic_add", Float32,
22+
(LLVMPtr{Float32, AS.CrossWorkgroup}, Float32),
23+
pointer(counter), val,
24+
)
25+
return
26+
end
27+
28+
@testset "SPV_EXT_shader_atomic_float_add extension" begin
29+
a = OpenCL.zeros(Float32)
30+
@opencl global_size = 1000 extensions = ["SPV_EXT_shader_atomic_float_add"] atomic_float_add(a, 1.0f0)
31+
@test OpenCL.@allowscalar a[] == 1000.0f0
32+
33+
spv = sprint() do io
34+
OpenCL.code_native(io, atomic_float_add, Tuple{CLDeviceArray{Float32, 0, 1}, Float32}; extensions = ["SPV_EXT_shader_atomic_float_add"])
35+
end
36+
@test occursin("OpExtension \"SPV_EXT_shader_atomic_float_add\"", spv)
37+
@test occursin("OpAtomicFAddEXT", spv)
38+
end
39+
end
40+
1641
end

0 commit comments

Comments
 (0)