Add GPU to CPU RPC mechanism - #567
Conversation
91db6b0 to
06fe10b
Compare
|
I assume the intent of this PR is to implement a flexible GPU-to-CPU RPC system, like AMDGPU's hostcall? If so, my recommendation is to also provide a buffer where you can pass arguments from the GPU, and return results from the CPU. This would allow you to instead use the flag's value for locking the buffer and communicating syscall state (idle, device-held, host-held, etc.), and you could then pass and return arbitrary bitstype Julia objects. Such a mechanism has been working well for AMDGPU's printing and memory allocation infrastructure (although it's not yet multi-wavefront safe, but that will be fixed). We also have one flag+buffer per executable and per hostcall type, so our kernels will be able to concurrently utilize different hostcalls without contention. |
|
Also, please feel free to study and steal from the hostcall implementation here: https://github.com/JuliaGPU/AMDGPU.jl/blob/master/src/device/gcn/hostcall.jl |
6813364 to
7f9138b
Compare
| return | ||
| end | ||
|
|
||
| # this code is very fragile |
There was a problem hiding this comment.
That won't just be fragile, right? https://stackoverflow.com/questions/23193151/atomic-operations-in-cuda-kernels-on-mapped-pinned-host-memory-to-do-or-not-to
Maybe some kind of ring buffer where the CPU just passively reads would be safer? That may only require atomicity from the GPU's side.
| call(kernel, map(cudaconvert, args)...; threads, blocks, kwargs...) | ||
| CUDA.record(event, stream()) | ||
|
|
||
| while !istaskdone(t) |
There was a problem hiding this comment.
This makes kernel launches synchronous? That's not OK.
5f8f1ce to
d29a04e
Compare
5d585c4 to
c850163
Compare
This tries to enable generic syscalls in GPU abstractions, with a main focus on speed and transparency.
First enable better printing than
@cuprintf, later multiple options are possible, like reading/writing to files.If performance is good enough this can be used for
mallocto improve memory management.This could be a baseline to accept dynamic Julia errors, as unsupported type etc.
Fixes #440