Skip to content

Commit 5eb17ca

Browse files
committed
Update atomic example to be more stable
1 parent 32b0da3 commit 5eb17ca

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

numba_dpex/examples/kernel/atomic_op.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,14 @@
1010
@ndpx.kernel
1111
def atomic_reduction(a):
1212
idx = ndpx.get_global_id(0)
13-
ndpx.atomic.add(a, 0, a[idx])
13+
ndpx.atomic.add(a, 0, a[idx + 1])
1414

1515

1616
def main():
1717
N = 10
18-
a = np.arange(N)
18+
19+
# We are storing sum to the first element
20+
a = np.arange(0, N + 1)
1921

2022
print("Using device ...")
2123
print(a.device)

0 commit comments

Comments
 (0)