File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -6,20 +6,20 @@ float_types = [Float32, Float64]
66all_types = vcat (integer_types, float_types)
77
88dev = OpenCL. cl. device ()
9- # Define atomic operations to test
9+ # Define atomic operations to test, with init value and expected value
1010atomic_operations = [
11- :atomic_add! ,
12- :atomic_sub! ,
13- :atomic_and! ,
14- :atomic_or! ,
15- :atomic_xor! ,
16- :atomic_max! ,
17- :atomic_min! ,
18- :atomic_xchg! ,
19- :atomic_cas! ,
11+ ( :atomic_add! , 0 , 1 ) ,
12+ ( :atomic_sub! , 1 , 0 ) ,
13+ ( :atomic_and! , 3 , 1 ) ,
14+ ( :atomic_or! , 2 , 3 ) ,
15+ ( :atomic_xor! , 3 , 2 ) ,
16+ ( :atomic_max! , 0 , 1 ) ,
17+ ( :atomic_min! , 2 , 1 ) ,
18+ ( :atomic_xchg! , 0 , 1 ) ,
19+ ( :atomic_cas! , 0 , 1 ) ,
2020]
2121@testset " atomics" begin
22- for op in atomic_operations
22+ for (op, init_val, expected_val) in atomic_operations
2323 for T in all_types
2424 # Skip Int64/UInt64 if not supported
2525 if sizeof (T) == 8 && T <: Integer && ! (" cl_khr_int64_extended_atomics" in dev. extensions)
@@ -110,8 +110,11 @@ for op in atomic_operations
110110
111111 # Try to compile the kernel - this is the key test
112112 a = OpenCL. zeros (T)
113+ OpenCL. fill! (a, init_val)
113114 kernel_func = @eval $ test_name
114115 OpenCL. @opencl kernel_func (a)
116+ result_val = Array (a)[1 ]
117+ @test result_val == expected_val
115118 end
116119end
117120
You can’t perform that action at this time.
0 commit comments