Skip to content

[UR][HIP] Implement USM memory pool experimental API#22673

Open
zjin-lcf wants to merge 2 commits into
intel:syclfrom
zjin-lcf:hip-usm-memory-pools
Open

[UR][HIP] Implement USM memory pool experimental API#22673
zjin-lcf wants to merge 2 commits into
intel:syclfrom
zjin-lcf:hip-usm-memory-pools

Conversation

@zjin-lcf

Copy link
Copy Markdown
Contributor

Summary

Ports the CUDA adapter's native USM memory pool experimental API to the HIP adapter, backed by the HIP stream-ordered memory allocator (hipMemPool_t).

  • A ur_usm_pool_handle_t can now wrap either a UMF pool (existing behaviour) or a native hipMemPool_t.
  • Implements urUSMPoolCreateExp, urUSMPoolDestroyExp, urUSMPoolGetDefaultDevicePoolExp, urUSMPoolGetInfoExp, urUSMPoolSetInfoExp and urUSMPoolTrimToExp using hipMemPoolCreate/hipMemPoolDestroy, hipDeviceGetDefaultMemPool, hipMemPoolGet/SetAttribute and hipMemPoolTrimTo. urUSMPoolGetDevicePoolExp/urUSMPoolSetDevicePoolExp remain unsupported, matching CUDA.
  • urEnqueueUSMDeviceAllocExp now allocates from the supplied native pool via hipMallocFromPoolAsync, falling back to the device's default pool otherwise.

Dependency

This PR is stacked on #22672 ([UR][HIP] Implement async device allocation). Until that PR merges, the diff here also contains its commit; the only commit for review in this PR is [UR][HIP] Implement USM memory pool experimental API. Please merge #22672 first; this branch will be rebased onto sycl afterwards.

Test plan

The USM memory pool e2e tests pass on an AMD Instinct MI300A (gfx942):

  • AsyncAlloc/device/memory_pool.cpp
  • AsyncAlloc/device/async_alloc_from_pool.cpp
  • AsyncAlloc/device/async_alloc_from_default_pool.cpp
  • AsyncAlloc/device/ooo_queue_async_alloc_from_pool.cpp

zjin-lcf and others added 2 commits July 18, 2026 14:06
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>
Port the CUDA adapter's native USM memory pool support to HIP, backed by
the HIP stream-ordered memory allocator (hipMemPool_t). A
ur_usm_pool_handle_t may now wrap either a UMF pool (existing behaviour) or
a native hipMemPool_t.

Implement the experimental pool entry points:
urUSMPoolCreateExp, urUSMPoolDestroyExp, urUSMPoolGetDefaultDevicePoolExp,
urUSMPoolGetInfoExp, urUSMPoolSetInfoExp and urUSMPoolTrimToExp using
hipMemPoolCreate/Destroy, hipDeviceGetDefaultMemPool,
hipMemPoolGet/SetAttribute and hipMemPoolTrimTo. urUSMPoolGetDevicePoolExp
and urUSMPoolSetDevicePoolExp remain unsupported, matching CUDA.

urEnqueueUSMDeviceAllocExp now allocates from the supplied native pool via
hipMallocFromPoolAsync when a pool is provided, falling back to the
device's default pool otherwise.

The USM memory pool e2e tests (memory_pool, async_alloc_from_pool,
async_alloc_from_default_pool, ooo_queue_async_alloc_from_pool) pass on an
AMD Instinct MI300A (gfx942).

Co-authored-by: Cursor <cursoragent@cursor.com>
@zjin-lcf
zjin-lcf requested a review from a team as a code owner July 18, 2026 21:35
@zjin-lcf
zjin-lcf requested a review from bratpiorka July 18, 2026 21:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant