Skip to content

Commit 323f165

Browse files
committed
fix racy test
1 parent b1fe550 commit 323f165

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

test/private.jl

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,18 @@ end
2020

2121
# This is horrible don't write code like this
2222
@kernel function forloop(A, ::Val{N}) where N
23-
i = @index(Global, Linear)
23+
I = @index(Global, Linear)
24+
i = @index(Local, Linear)
2425
priv = @private Int (N,)
2526
for j in 1:N
26-
priv[j] = A[i, j]
27+
priv[j] = A[I, j]
2728
end
28-
A[i, 1] = 0
29+
A[I, 1] = 0
2930
@synchronize
3031
for j in 1:N
31-
A[j, 1] += priv[j]
32-
@synchronize
32+
k = mod1(j + i - 1, N)
33+
A[k, 1] += priv[j]
34+
@synchronize
3335
end
3436
end
3537

@@ -44,11 +46,7 @@ function harness(backend, ArrayT)
4446
A = ArrayT{Int}(undef, 64, 64)
4547
A .= 1
4648
wait(forloop(backend)(A, Val(size(A, 2)), ndrange=size(A,1), workgroupsize=size(A,1)))
47-
if ArrayT <: Array
48-
@test all(A[:, 1] .== 64)
49-
else
50-
@test_broken all(A[:, 1] .== 64)
51-
end
49+
@test all(A[:, 1] .== 64)
5250
@test all(A[:, 2:end] .== 1)
5351
end
5452

0 commit comments

Comments
 (0)