Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
#include <cuda/std/__concepts/concept_macros.h>
#include <cuda/std/__cuda/api_wrapper.h>

#include <cuda/experimental/__memory_resource/device_memory_pool.cuh>
#include <cuda/experimental/__memory_resource/memory_resource_base.cuh>

#include <cuda/std/__cccl/prologue.h>
Expand All @@ -48,9 +47,10 @@ namespace cuda::experimental
//! Stream ordered memory resource
//! ------------------------------
//!
//! ``device_memory_resource`` uses `cudaMallocFromPoolAsync / cudaFreeAsync
//! ``device_memory_resource`` allocates device memory using `cudaMallocFromPoolAsync / cudaFreeAsync
//! <https://docs.nvidia.com/cuda/cuda-runtime-api/group__CUDART__MEMORY__POOLS.html>`__ for allocation/deallocation. A
//! ``device_memory_resource`` is a thin wrapper around a \c cudaMemPool_t.
//! ``device_memory_resource`` is a thin wrapper around a \c cudaMemPool_t with the location type set to \c
//! cudaMemLocationTypeDevice.
//!
//! .. warning::
//!
Expand Down Expand Up @@ -90,19 +90,65 @@ public:
: __memory_resource_base(__pool)
{}

//! @brief Constructs the device_memory_resource from a \c device_memory_pool by calling get().
//! @param __pool The \c device_memory_pool used to allocate memory.
_CCCL_HOST_API explicit device_memory_resource(device_memory_pool& __pool) noexcept
: __memory_resource_base(__pool.get())
{}

//! @brief Enables the \c device_accessible property for \c device_memory_resource.
//! @relates device_memory_resource
_CCCL_HOST_API friend constexpr void get_property(device_memory_resource const&, device_accessible) noexcept {}

using default_queries = properties_list<device_accessible>;
};

//! @rst
//! .. _cudax-memory-resource-async:
//!
//! Stream ordered memory resource
//! ------------------------------
//!
//! ``device_memory_pool`` allocates device memory using `cudaMallocFromPoolAsync / cudaFreeAsync
//! <https://docs.nvidia.com/cuda/cuda-runtime-api/group__CUDART__MEMORY__POOLS.html>`__ for allocation/deallocation. A
//! When constructed it creates an underlying \c cudaMemPool_t with the location type set to \c
//! cudaMemLocationTypeDevice and owns it.
//!
//! @endrst
struct device_memory_pool : device_memory_resource
{
using reference_type = device_memory_resource;

//! @brief Constructs a \c device_memory_pool with the optionally specified initial pool size and release
//! threshold. If the pool size grows beyond the release threshold, unused memory held by the pool will be released at
//! the next synchronization event.
//! @throws cuda_error if the CUDA version does not support ``cudaMallocAsync``.
//! @param __device_id The device id of the device the stream pool is constructed on.
//! @param __pool_properties Optional, additional properties of the pool to be created.
_CCCL_HOST_API device_memory_pool(::cuda::device_ref __device_id, memory_pool_properties __properties = {})
: device_memory_resource(__create_cuda_mempool(
__properties,
::CUmemLocation{::CU_MEM_LOCATION_TYPE_DEVICE, __device_id.get()},
::CU_MEM_ALLOCATION_TYPE_PINNED))
{}

~device_memory_pool() noexcept
{
::cuda::__driver::__mempoolDestroy(__pool_);
}

_CCCL_HOST_API static device_memory_pool from_native_handle(::cudaMemPool_t __pool) noexcept
{
return device_memory_pool(__pool);
}

device_memory_pool(const device_memory_pool&) = delete;
device_memory_pool& operator=(const device_memory_pool&) = delete;

private:
device_memory_pool(::cudaMemPool_t __pool) noexcept
: device_memory_resource(__pool)
{}
};

static_assert(::cuda::mr::synchronous_resource_with<device_memory_resource, device_accessible>, "");

static_assert(::cuda::mr::resource_with<device_memory_pool, device_accessible>, "");

} // namespace cuda::experimental

#include <cuda/std/__cccl/epilogue.h>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
#include <cuda/std/detail/libcxx/include/stdexcept>

#include <cuda/experimental/__memory_resource/memory_resource_base.cuh>
#include <cuda/experimental/__memory_resource/pinned_memory_pool.cuh>
#include <cuda/experimental/__stream/internal_streams.cuh>

#include <cuda/std/__cccl/prologue.h>
Expand Down

This file was deleted.

Loading