[UR][HIP] Implement async device allocation#22672
Open
zjin-lcf wants to merge 1 commit into
Open
Conversation
Port the CUDA adapter's stream-ordered (async) allocation support to HIP. urEnqueueUSMDeviceAllocExp and urEnqueueUSMFreeExp are implemented using the HIP stream-ordered memory allocator (hipMallocAsync/hipFreeAsync) on the device's default memory pool, mirroring the CUDA implementation but using ScopedDevice instead of ScopedContext. Host and shared async allocations remain unsupported, matching CUDA. Register the four async-alloc entry points in the adapter's urGetEnqueueExpProcAddrTable; they were previously stubbed but never wired into the DDI table, so the loader returned UR_RESULT_ERROR_UNINITIALIZED. UR_DEVICE_INFO_ASYNC_USM_ALLOCATIONS_SUPPORT_EXP now queries hipDeviceAttributeMemoryPoolsSupported so the device advertises the ext_oneapi_async_memory_alloc aspect when supported. The default-pool async allocation e2e tests (async_alloc, ooo_queue_async_alloc) pass on an AMD Instinct MI300A (gfx942). Tests that construct a sycl memory_pool still require the USM memory pool experimental API (urUSMPool*Exp), which remains unimplemented on HIP. Co-authored-by: Cursor <cursoragent@cursor.com>
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.
Summary
urEnqueueUSMDeviceAllocExpandurEnqueueUSMFreeExpusing the HIP stream-ordered memory allocator (hipMallocAsync/hipFreeAsync) on the device's default memory pool, mirroring the CUDA implementation but usingScopedDevice. Host and shared async allocations remain unsupported, matching CUDA.urGetEnqueueExpProcAddrTable. They were previously stubbed but never wired into the DDI table, so the loader returnedUR_RESULT_ERROR_UNINITIALIZED.UR_DEVICE_INFO_ASYNC_USM_ALLOCATIONS_SUPPORT_EXPnow querieshipDeviceAttributeMemoryPoolsSupported, so the device advertises theext_oneapi_async_memory_allocaspect when supported.Test plan
AsyncAlloc/device/async_alloc,ooo_queue_async_alloc) pass on an AMD Instinct MI300A (gfx942).sycl::ext::oneapi::experimental::memory_poolstill require the USM memory pool experimental API (urUSMPool*Exp), which remains unimplemented on HIP and is out of scope for this PR.