19 #include <rmm/detail/aligned.hpp>
20 #include <rmm/detail/cccl_adaptors.hpp>
21 #include <rmm/detail/cuda_memory_resource.hpp>
22 #include <rmm/detail/error.hpp>
23 #include <rmm/detail/export.hpp>
24 #include <rmm/detail/nvtx/ranges.hpp>
28 namespace RMM_NAMESPACE {
127 return do_allocate(bytes, stream);
151 do_deallocate(ptr, bytes, stream);
169 return do_is_equal(other);
187 void*
allocate(std::size_t bytes, std::size_t alignment)
206 void deallocate(
void* ptr, std::size_t bytes, std::size_t alignment) noexcept
252 return do_allocate(bytes, stream);
271 std::size_t alignment,
294 do_deallocate(ptr, bytes, stream);
297 #if CCCL_MAJOR_VERSION > 3 || (CCCL_MAJOR_VERSION == 3 && CCCL_MINOR_VERSION >= 1)
315 "Alignment must be less than or equal to 256 and a power of two");
327 void deallocate_sync(
void* ptr,
331 do_deallocate(ptr,
rmm::align_up(bytes, alignment), cuda_stream_view{});
347 void* allocate(cuda_stream_view stream,
352 "Alignment must be less than or equal to 256 and a power of two");
365 void deallocate(cuda_stream_view stream,
383 return do_is_equal(other);
395 return !do_is_equal(other);
431 virtual void do_deallocate(
void* ptr, std::size_t bytes,
cuda_stream_view stream) noexcept = 0;
449 return this == &other;
454 static_assert(rmm::detail::polyfill::resource<device_memory_resource>);
455 static_assert(rmm::detail::polyfill::async_resource<device_memory_resource>);
457 rmm::detail::polyfill::resource_with<device_memory_resource, cuda::mr::device_accessible>);
459 rmm::detail::polyfill::async_resource_with<device_memory_resource, cuda::mr::device_accessible>);
Strongly-typed non-owning wrapper for CUDA streams with default constructor.
Definition: cuda_stream_view.hpp:39
Base class for all librmm device memory allocation.
Definition: device_memory_resource.hpp:94
void deallocate(void *ptr, std::size_t bytes, std::size_t alignment) noexcept
Deallocate memory pointed to by p.
Definition: device_memory_resource.hpp:206
friend void get_property(device_memory_resource const &, cuda::mr::device_accessible) noexcept
Enables the cuda::mr::device_accessible property.
Definition: device_memory_resource.hpp:403
device_memory_resource(device_memory_resource &&) noexcept=default
Default move constructor.
void deallocate_async(void *ptr, std::size_t bytes, cuda_stream_view stream) noexcept
Deallocate memory pointed to by p.
Definition: device_memory_resource.hpp:291
void deallocate_async(void *ptr, std::size_t bytes, std::size_t alignment, cuda_stream_view stream) noexcept
Deallocate memory pointed to by p.
Definition: device_memory_resource.hpp:269
void * allocate(std::size_t bytes, std::size_t alignment)
Allocates memory of size at least bytes.
Definition: device_memory_resource.hpp:187
void * allocate_async(std::size_t bytes, cuda_stream_view stream)
Allocates memory of size at least bytes.
Definition: device_memory_resource.hpp:249
void deallocate(void *ptr, std::size_t bytes, cuda_stream_view stream=cuda_stream_view{}) noexcept
Deallocate memory pointed to by p.
Definition: device_memory_resource.hpp:146
bool operator==(device_memory_resource const &other) const noexcept
Comparison operator with another device_memory_resource.
Definition: device_memory_resource.hpp:381
bool operator!=(device_memory_resource const &other) const noexcept
Comparison operator with another device_memory_resource.
Definition: device_memory_resource.hpp:393
device_memory_resource(device_memory_resource const &)=default
Default copy constructor.
void * allocate_async(std::size_t bytes, std::size_t alignment, cuda_stream_view stream)
Allocates memory of size at least bytes.
Definition: device_memory_resource.hpp:228
bool is_equal(device_memory_resource const &other) const noexcept
Compare this resource to another.
Definition: device_memory_resource.hpp:167
static constexpr std::size_t CUDA_ALLOCATION_ALIGNMENT
Default alignment used for CUDA memory allocation.
Definition: aligned.hpp:43
bool is_supported_alignment(std::size_t alignment) noexcept
Returns whether or not alignment is a valid memory alignment.
std::size_t align_up(std::size_t value, std::size_t alignment) noexcept
Align up to nearest multiple of specified power of 2.