Skip to content

Commit b30e666

Browse files
fix in tests
1 parent 23373aa commit b30e666

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

tests/test_common.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)