@@ -16,9 +16,8 @@ def test_common_atomicadd(test_context):
1616 #include "xobjects/headers/common.h"
1717 #include "xobjects/headers/atomicadd.h"
1818
19- GPUKERN void test_atomic_add(GPUGLMEM double* out)
19+ GPUKERN void test_atomic_add(GPUGLMEM double* out, int32_t iterations )
2020 {
21- int iterations = 1000;
2221 double sum = 0;
2322 VECTORIZE_OVER(i, iterations);
2423 // If on CPU do some work to avoid the loop being optimized out
@@ -27,7 +26,7 @@ def test_common_atomicadd(test_context):
2726 #endif
2827 atomicAdd(&sum, 1.0);
2928 END_VECTORIZE;
30- * out = sum;
29+ out[0] = sum;
3130 }
3231 """
3332
@@ -44,17 +43,21 @@ def test_common_atomicadd(test_context):
4443 sources = [src ],
4544 kernels = {
4645 "test_atomic_add" : xo .Kernel (
47- args = [xo .Arg (xo .Float64 , pointer = True , name = "out" )],
48- n_threads = n_threads ,
46+ c_name = "test_atomic_add" ,
47+ args = [
48+ xo .Arg (xo .Float64 , pointer = True , name = "out" ),
49+ xo .Arg (xo .Int32 , name = "iterations" ),
50+ ],
51+ n_threads = "iterations" ,
4952 )
5053 },
5154 )
5255
5356 expected = 1000
5457 result = np .array ([0 ], dtype = np .float64 )
5558 result_ctx = test_context .nparray_to_context_array (result )
56- test_context .kernels .test_atomic_add (out = result_ctx )
57- result = test_context .nparray_from_context_array (result_ctx )[ 0 ]
59+ test_context .kernels .test_atomic_add (out = result_ctx , iterations = expected )
60+ result = test_context .nparray_from_context_array (result_ctx )
5861
5962 assert result == expected
6063
0 commit comments