Memory Resources

Memory Resources#

2026-10-23

2 min read time

Applies to Linux and Windows

This page covers the memory resource extended API, providing a standard C++ interface for heterogeneous, stream-ordered memory allocation in HIP.

The <cuda/memory_resource> header provides a standard C++ interface for heterogeneous, stream-ordered memory allocation tailored to the needs of HIP C++ developers.

<cuda/memory_resource> only defines the memory allocation interface; it does not provide allocator implementations. For HIP developers, hipMM provides implementations of the cuda::mr interfaces optimized for AMD GPUs.

At a high level, the header provides:

API

Description

Since

cuda::get_property

Infrastructure to tag a user defined type with a given property

libhipcxx 3.4

cuda::mr::{synchronous_}resource and cuda::mr::{synchronous_}resource_with

Concepts that provide proper constraints for arbitrary memory resources.

libhipcxx 3.4

cuda::mr::{synchronous_}resource_ref

A non-owning type-erased memory resource wrapper that enables consumers to specify properties of resources that they expect.

libhipcxx 3.4

cuda::mr::any_resource and cuda::mr::any_synchronous_resource

Owning type-erased wrappers for stream-ordered and synchronous resources.

libhipcxx 3.4

cuda::mr::shared_resource

Reference-counted wrapper to share a resource instance across objects.

libhipcxx 3.4

cuda::mr::synchronous_resource_adapter

Adapter that enables synchronous resources to work with streams.

libhipcxx 3.4

These features are an evolution of std::pmr::memory_resource that was introduced in C++17. While std::pmr::memory_resource provides a polymorphic memory resource that can be adopted through inheritance, it is not properly suited for heterogeneous systems.

With the current design it ranges from cumbersome to impossible to verify whether a memory resource provides allocations that are e.g. accessible on device, or whether it can utilize other allocation mechanisms.

To better support asynchronous HIP stream-ordered allocations libhipcxx provides cuda::stream_ref as a wrapper around hipStream_t. The definition of cuda::stream_ref can be found in the <cuda/stream> header.