CliMA / CliMA/ClimaCore.jl

Use CUDA constant memory

Open
#1,514 0 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
Julia
Stars
118
Forks
19
Avg merge
3d 8h
Merged PRs (30d)
38

Description

See https://docs.nvidia.com/cuda/cuda-c-programming-guide/index.html#constant-memory
It probably only provides benefits with certain access patterns, see https://stackoverflow.com/a/18021374/392585.

This could be helpful for e.g. differentiation matrices. Unfortunately there is not yet an interfaces to use it in CUDA.jl

From Slack:

>
> Tim Besard
> [2 months ago](https://julialang.slack.com/archives/C689Y34LE/p1692774393019099?thread_ts=1692764665.843229&cid=C689Y34LE)
> const memory is special, and often isn’t required. it isn’t just for constant data, but requires a specific access pattern to be beneficial.
>
>
>
>
>
> Tim Besard
> [2 months ago](https://julialang.slack.com/archives/C689Y34LE/p1692774400285569?thread_ts=1692764665.843229&cid=C689Y34LE)
> we don’t have first class support. there’s a hacky way: https://github.com/JuliaGPU/CUDA.jl/blob/5cc0ff2edd97ed51b5d96c6e5c824510cb19c22d/src/device/random.jl#L159-L202
>
>
> Tim Besard
> [2 months ago](https://julialang.slack.com/archives/C689Y34LE/p1692774422391479?thread_ts=1692764665.843229&cid=C689Y34LE)
> there’s also a draft PR that would need to be reworked: https://github.com/JuliaGPU/CUDA.jl/pull/552
>
>
> Tim Besard
> [2 months ago](https://julialang.slack.com/archives/C689Y34LE/p1692774473944789?thread_ts=1692764665.843229&cid=C689Y34LE)
> the main problem is that there’s no good way to have constant globals that you can initialize from the host and use from the device, where the type/behavior differs on both ends.

Contributor guide

No contributing guide indexed for this repository

Research direction

Read the CUDA constant-memory guide, the existing workaround in CUDA.jl/src/device/random.jl (lines 159–202), and draft PR #552. Investigate how host initialization and device use could support differing types or behavior; done should provide first-class constant-memory support in CUDA.jl.

Written by the indexing model from the issue text.

Assessment

Tech stack
julia
Domain
hpc, performance
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.