Gpu storage improvements - #712
Draft
ameligrana wants to merge 6 commits into
Draft
Conversation
- Allow pairing the back-end with a zero-based device ordinal
(Storage{GPUVector{(:CUDA, 1)}}) or passing a device object
(Storage(GPUVector{:CUDA}, CuDevice(1))) to pin a GPU storage
to a specific device. Allocations and growth happen on that device.
- Route wrapper-level unsafe_copyto! between GPUVectors through the
raw memory arrays (device-to-device) instead of the host.
- Check copyto! bounds against logical lengths, matching Base semantics.
- Use M(undef, 0) instead of M() in the empty GPUVector constructor.
GPU back-ends (CUDA, Metal, oneAPI, OpenCL) contribute their memory type
through a weak dependency extension. The World constructor is a generated
function, and generated bodies dispatch in the world in which Ark was
loaded, i.e. before any extension is available. Storage types that embed
the back-end memory type could therefore not be computed at
world-construction time, and constructing a world with a GPU storage
(e.g. World(P => Storage{GPUVector{:CUDA}})) failed for every GPU back-end.
Fix by not deriving the memory type at world-construction time at all:
- Storage types in the world schema now use the memory-type-erased
GPUVector{B,T} for GPU back-ends (the :CPU back-end keeps its concrete
type); GPUStructArray field vectors likewise.
- Concrete GPUVector{B,T,M} storages are constructed at runtime, where
extension dispatch works.
- GPUVectorView always carries the erased parent type GPUVector{B,T}, so
static and runtime view types are identical regardless of the back-end.
Also add a regression test using a back-end registered after Ark is
loaded, which reproduces the world-age failure without a GPU.
Storage modes are now specified with a function call, like
World(Position => Storage(StructArray)), instead of the type parameter
syntax Storage{StructArray}. Storage(x) returns the Storage{x} phantom
type, which remains an internal detail.
This unifies the API with device selection: Storage(GPUVector{:CUDA},
CuDevice(1)) and Storage(GPUStructArray{(:CUDA, 1)}) now compose with
World(...) exactly like every other storage mode.
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Contributor
boxed = false🚀 7 benchmark improvements detected! Click to expand benchmark resultsTime is per entity/N, allocations are totals. Allocations are only shown for current.
boxed = trueClick to expand benchmark resultsTime is per entity/N, allocations are totals. Allocations are only shown for current.
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
- ArkOpenCLInterop: implement _gpuvector_pinned_device, _gpuvector_ordinal and _gpuvector_withdev for OpenCL. OpenCL.jl provides per-device task-local state via cl.device!, so device selection works like for the other back-ends. - _new_gpuvector_storage now resolves the memory type inside the device switch, as OpenCL's unified-memory back-end is determined per device. - Simplify _gpuvector_ordinal for CUDA to just CUDA.deviceid, matching the other back-ends (CuDevice is validated at construction). - Update docs to list :OpenCL among the back-ends supporting device selection. - Guard the GPU test helper structs with @isdefined, as the suite is included once per world mode (hard error on Julia 1.10/LTS otherwise).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.