Skip to content

Add GPU to CPU RPC mechanism - #567

Closed
ajuvercr wants to merge 12 commits into
JuliaGPU:mainfrom
ajuvercr:syscall
Closed

Add GPU to CPU RPC mechanism#567
ajuvercr wants to merge 12 commits into
JuliaGPU:mainfrom
ajuvercr:syscall

Conversation

@ajuvercr

@ajuvercr ajuvercr commented Nov 24, 2020

Copy link
Copy Markdown

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 malloc to improve memory management.

This could be a baseline to accept dynamic Julia errors, as unsupported type etc.

Fixes #440

@maleadt
maleadt marked this pull request as draft November 24, 2020 12:22
@maleadt maleadt added cuda kernels Stuff about writing CUDA kernels. enhancement New feature or request labels Nov 24, 2020
@maleadt
maleadt force-pushed the master branch 2 times, most recently from 91db6b0 to 06fe10b Compare January 8, 2021 12:11
@jpsamaroo

Copy link
Copy Markdown
Member

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.

@jpsamaroo

Copy link
Copy Markdown
Member

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

@maleadt maleadt changed the title [WIP]: Extend GPU abstraction on the Julia language with generic syscalls Add GPU to CPU RPC mechanism Feb 17, 2021
@ajuvercr
ajuvercr force-pushed the syscall branch 2 times, most recently from 6813364 to 7f9138b Compare March 28, 2021 12:16
Comment thread src/compiler/cpucall.jl Outdated
return
end

# this code is very fragile

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread src/compiler/execution.jl Outdated
call(kernel, map(cudaconvert, args)...; threads, blocks, kwargs...)
CUDA.record(event, stream())

while !istaskdone(t)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes kernel launches synchronous? That's not OK.

@maleadt
maleadt force-pushed the master branch 15 times, most recently from 5f8f1ce to d29a04e Compare July 29, 2021 13:07
@maleadt

maleadt commented Aug 21, 2026

Copy link
Copy Markdown
Member

#3243

@maleadt maleadt closed this Aug 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cuda kernels Stuff about writing CUDA kernels. enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Hostcall

3 participants