Skip to content

Commit

Permalink
Update Race.jl
Browse files Browse the repository at this point in the history
  • Loading branch information
OsKnoth committed Jul 25, 2024
1 parent d0cbc6f commit a667b64
Showing 1 changed file with 29 additions and 1 deletion.
30 changes: 29 additions & 1 deletion TestKernels/Race.jl
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,44 @@ function index_fun(arr; backend=get_backend(arr))
kernel!(out, arr, ndrange=(size(arr, 1), size(arr, 2)))
KernelAbstractions.synchronize(backend)
end
kernel1! = my_kernel1!(backend)
kernel1!(out, arr, ndrange=(size(arr, 1), size(arr, 2)))
KernelAbstractions.synchronize(backend)
@time for i = 1 : 200
kernel1!(out, arr, ndrange=(size(arr, 1), size(arr, 2)))
KernelAbstractions.synchronize(backend)
end
kernel2! = my_kernel1!(backend)
kernel2!(out, arr, ndrange=(size(arr, 1), size(arr, 2)))
KernelAbstractions.synchronize(backend)
@time for i = 1 : 200
kernel2!(out, arr, ndrange=(size(arr, 1), size(arr, 2)))
KernelAbstractions.synchronize(backend)
end
return out
end

@kernel function my_kernel!(out, arr)
i, j = @index(Global, NTuple)
for k in 1:size(out, 1)
@atomic out[k, i] += arr[i, j]
@atomic :monotonic out[k, i] += arr[i, j]
end
end

@kernel function my_kernel1!(out, arr)
i, j = @index(Global, NTuple)
for k in 1:size(out, 1)
@roc unsafe_fp_atomics=true @atomic :monotonic out[k, i] += arr[i, j]
end
end

@kernel function my_kernel2!(out, arr)
i, j = @index(Global, NTuple)
for k in 1:size(out, 1)
out[k, i] += arr[i, j]
end
end

JuliaDevice = get(ENV, "JuliaDevice", "CPU")
JuliaGPU = get(ENV, "JuliaGPU", "CUDA")

Expand Down

0 comments on commit a667b64

Please sign in to comment.