JuliaGPU / JuliaGPU/KernelAbstractions.jl
`KernelAbstractions.@spawn backend ...` for easy Julia task based concurrency
Nobody has claimed this yet.
- Dominant language
- Julia
- Stars
- 523
- Forks
- 88
- Avg merge
- 1d 11h
- Merged PRs (30d)
- 25
Description
In discussion with @maleadt, we came up with the idea to solve user code like:
kernel(...)
@sync for i in 1:4
@spawn begin
kernel(...) # can race with previous launch on parent stream
end
end
kernel(...) # can race with spawned kernels
by introducing a KernelAbstractions.@spawn backend construct that takes care of creating the synchronization edges between the Julia task and the GPU work on the the child&parent stream.
An sketch of an implementation is below.
struct KAClosure{F, Backend, Token}
f::F
backend::Backend
token::Token
function KATask(f::F, backend::Backend) where {F, Backend}
token = create_token(backend, underlying_stream(backend))
new(f, backend, token)
end
end
function (task::KAClosure{F})() where F
device_barrier!(underlying_stream(task.backend), task.token)
f()
end
struct KATask{Backend}
task::Task
backend::Backend
end
function Base.wait(task::KATask{<:CUDABackend})
stream = task.task.tls[:cuda]
device_barrier!(underlying_stream(task.backend),
create_token(task.backend, stream))
end
# @spawn backend begin
# end
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the proposed KernelAbstractions.@spawn construct and trace the named create_token, underlying_stream, device_barrier!, Base.wait, and CUDABackend entry points. Define how the KAClosure and KATask sketch should create synchronization edges so the parent, child, and spawned GPU work cannot race, then verify the example's ordering semantics.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- julia
- Domain
- backend, performance
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100