JuliaGPU / JuliaGPU/GPUCompiler.jl

Relocatability of `deferred_codegen`

Open
#581 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Julia
Stars
187
Forks
68
Avg merge
1d 12h
Merged PRs (30d)
28

Description

Currently `deferred_codegen` pushes a Job into a runtime dictionary. That runtime dictionary is only valid during the session.

I am wondering if instead we could use a de-virtualization strategy similar to Base.

```
@noinline function gpuc_deferred(f, args...)::Ptr end
@noinline function gpuc_lookup(mi, f, args)::Ptr end
```

Adding an abstract interpretation extension to refine `gpuc_deferred` -> `gpuc_lookup` looking up the corresponding `mi`.

After codegen (since we can't customize that yet) we scan the LLVM IR for `gpuc_lookup` and codegen the corresponding functions into the same module.

CUDA wants to get a function pointer and then wrap that in a `CuDeviceFunction` https://github.com/JuliaGPU/CUDA.jl/blob/e9928ca84509d7c686ea7ec413e1ad2d8176b987/src/compiler/execution.jl#L417

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by tracing deferred_codegen and the proposed gpuc_deferred/gpuc_lookup path, including how the session-only runtime dictionary is used. Read CUDA's linked compiler/execution.jl call site and examine the proposed LLVM IR scan. Done means the generated module contains the corresponding functions without relying on the session dictionary and still produces the function pointer CUDA wraps in CuDeviceFunction.

Written by the indexing model from the issue text.

Assessment

Tech stack
julia
Domain
compilers
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.