Skip to content
This repository has been archived by the owner on May 17, 2020. It is now read-only.

Using Cthulhu with GPUifyLoops on the GPU #95

Closed
mwarusz opened this issue Aug 24, 2019 · 1 comment · Fixed by JuliaDebug/Cthulhu.jl#60
Closed

Using Cthulhu with GPUifyLoops on the GPU #95

mwarusz opened this issue Aug 24, 2019 · 1 comment · Fixed by JuliaDebug/Cthulhu.jl#60

Comments

@mwarusz
Copy link

mwarusz commented Aug 24, 2019

First I tried something similar to this MWE

using GPUifyLoops, Cthulhu, CuArrays, CUDAnative

function kernel!(a, b)
  @inbounds @loop for i in (1:length(a);
                            (blockIdx().x - 1) * blockDim().x + threadIdx().x)
    a[i] = b[i]
  end
  nothing
end

a = CuArray(rand(Float32, 10 ^ 3))
b = similar(a)

threads = 256
blocks = ceil(Int, size(a, 1) / threads)
@descend @launch(CUDA(), threads = threads, blocks = blocks, kernel!(a, b))

and then I tried adding @descend just before the kernel call inside GPUifyLoops. Both approaches failed to allow me to step into kernel!. The second one got me much closer so it seems like there may be two different issues ? Should the above MWE work ?

@vchuravy
Copy link
Owner

vchuravy commented Aug 26, 2019

This should definitely work,

using GPUifyLoops, Cthulhu, CuArrays, CUDAnative

function kernel!(a, b)
  @inbounds @loop for i in (1:length(a);
                            (blockIdx().x - 1) * blockDim().x + threadIdx().x)
    a[i] = b[i]
  end
  nothing
end

a = CuArray(rand(Float32, 10 ^ 3))
b = similar(a)

threads = 256
blocks = ceil(Int, size(a, 1) / threads)
f(a,b) = @launch(CUDA(), threads = threads, blocks = blocks, kernel!(a, b))
@descend f(a,b)

but won't since Cthulhu doesn't see the kwargs call to cufunction. Working on a fix

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants