Skip to content

Instantly share code, notes, and snippets.

@ali-ramadhan
Last active October 7, 2021 22:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ali-ramadhan/3c08156e3cfbcca355bc829b42c23e74 to your computer and use it in GitHub Desktop.
Save ali-ramadhan/3c08156e3cfbcca355bc829b42c23e74 to your computer and use it in GitHub Desktop.
using KernelAbstractions
using OffsetArrays
using AMDGPU
using ROCKernels
using Test
import KernelAbstractions: Event
using ROCKernels: ROCEvent
function Event(::ROCDevice)
queue = AMDGPU.get_default_queue()
event = AMDGPU.barrier_and!(queue, AMDGPU.active_kernels(queue))
MultiEvent(Tuple(ROCEvent(s) for s in event.signals))
end
@kernel function copy_kernel!(A, B)
I = @index(Global)
@inbounds A[I] = B[I]
end
function mycopy!(A, B)
@assert size(A) == size(B)
copy_kernel!(ROCDevice(), 256)(A, B, ndrange=length(A))
end
A = OffsetArray(zeros(Float32, 1024) |> ROCArray, -3)
B = OffsetArray(ones(Float32, 1024) |> ROCArray, -3)
event = mycopy!(A, B)
wait(event)
@test A == B
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment