|
3 | 3 | # provides atomic functions that rely on the OpenCL base atomics, as well as the |
4 | 4 | # cl_khr_int64_base_atomics and cl_khr_int64_extended_atomics extensions. |
5 | 5 |
|
| 6 | +const atomic_float_types = [Float32, Float64] |
6 | 7 | const atomic_integer_types = [UInt32, Int32, UInt64, Int64] |
7 | 8 | const atomic_memory_types = [AS.Workgroup, AS.CrossWorkgroup] |
| 9 | +const atomic_types = vcat(atomic_float_types, atomic_integer_types) |
8 | 10 |
|
9 | 11 |
|
10 | 12 | # generically typed |
11 | 13 |
|
12 | | -for gentype in atomic_integer_types, as in atomic_memory_types |
| 14 | +for gentype in atomic_types, as in atomic_memory_types |
13 | 15 | @eval begin |
14 | 16 |
|
15 | 17 | @device_function atomic_add!(p::LLVMPtr{$gentype,$as}, val::$gentype) = |
@@ -45,15 +47,17 @@ for gentype in atomic_integer_types, as in atomic_memory_types |
45 | 47 | @device_function atomic_xor!(p::LLVMPtr{$gentype,$as}, val::$gentype) = |
46 | 48 | @builtin_ccall("atomic_xor", $gentype, |
47 | 49 | (LLVMPtr{$gentype,$as}, $gentype), p, val) |
48 | | - |
49 | | -@device_function atomic_xchg!(p::LLVMPtr{$gentype,$as}, val::$gentype) = |
50 | | - @builtin_ccall("atomic_xchg", $gentype, |
51 | | - (LLVMPtr{$gentype,$as}, $gentype), p, val) |
52 | | - |
53 | | -@device_function atomic_cmpxchg!(p::LLVMPtr{$gentype,$as}, cmp::$gentype, val::$gentype) = |
54 | | - @builtin_ccall("atomic_cmpxchg", $gentype, |
55 | | - (LLVMPtr{$gentype,$as}, $gentype, $gentype), p, cmp, val) |
56 | | - |
| 50 | +end |
| 51 | +if gentype in atomic_integer_types |
| 52 | + @eval begin |
| 53 | + @device_function atomic_xchg!(p::LLVMPtr{$gentype,$as}, val::$gentype) = |
| 54 | + @builtin_ccall("atomic_xchg", $gentype, |
| 55 | + (LLVMPtr{$gentype,$as}, $gentype), p, val) |
| 56 | + |
| 57 | + @device_function atomic_cmpxchg!(p::LLVMPtr{$gentype,$as}, cmp::$gentype, val::$gentype) = |
| 58 | + @builtin_ccall("atomic_cmpxchg", $gentype, |
| 59 | + (LLVMPtr{$gentype,$as}, $gentype, $gentype), p, cmp, val) |
| 60 | + end |
57 | 61 | end |
58 | 62 | end |
59 | 63 |
|
|
0 commit comments