Conversation
Wire `ROCArray` and `JLArray` into the storage-generic `BufferAllocator` from #293, through `AMDBufferAllocator` and `JLBufferAllocator`. Unlike the CUDA extension, neither can serve temporaries via `unsafe_wrap`: `AMDGPU.unsafe_wrap` queries `hipPointerGetAttributes` on every call and would re-register host buffers, and `JLArrays` has no `unsafe_wrap` at all. Both instead share the buffer's refcounted `DataRef` at an offset, the way their own `reshape` does, which needs no API call and keeps the buffer alive by refcount. `JLArray` offsets are in elements rather than bytes, so element types whose size does not divide the alignment fall back on a regular allocation instead of landing on a truncated offset. The `JLArray` backing also makes the foreign-storage paths testable without GPU hardware, which they previously were not. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
Not sure about the name |
|
I was having this exact debate with myself, but it's inconsistent no matter what: we have ( TensorOperations.jl/src/implementation/allocator.jl Lines 13 to 38 in 58c6e03 |
|
ah ok then I don't feel strongly enough to break stuff, AMDBufferAllocator it is |
|
great, will merge once the AMD tests turn green then. (Can you approve the PR so it automerges?) |
Codecov Report❌ Patch coverage is
... and 5 files with indirect coverage changes 🚀 New features to boost your workflow:
|
Follow-up to #293: wires
ROCArrayandJLArrayinto the storage-genericBufferAllocator, viaAMDBufferAllocatorandJLBufferAllocator.The
JLArraybacking is half the point — it makes the foreign-storage paths testable without GPU hardware, which they previously weren't.Note on the implementation
Neither package can serve temporaries the way the CUDA extension does.
AMDGPU.unsafe_wrapquerieshipPointerGetAttributeson every call — the per-temporary host round-trip the buffer exists to avoid — and would re-hipHostRegistera sub-range of already-pinned memory for host buffers;JLArrayshas nounsafe_wrapat all.Both instead share the buffer's refcounted
DataRefat an offset, as their ownreshapedoes. No API call, and the buffer stays alive by refcount.One wrinkle:
JLArrayoffsets are in elements, not bytes, so an element type larger than the padding alignment would land on a truncated offset and alias a previous temporary.buffer_arraytypereturnsnothingfor those, falling back to a regular allocation.Testing
JLArraytestset intest/allocator.jl(134 tests) runs in ordinary CI.BufferAllocator ($AT)testset intest/gpu.jlcoversJLArray,CuArrayandROCArray, so buildkite'srocmqueue exercises the AMD path.rocmqueue is the real check.🤖 Generated with Claude Code