Last active
October 7, 2021 22:35
-
-
Save ali-ramadhan/3c08156e3cfbcca355bc829b42c23e74 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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