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);
149 do_deallocate(ptr, bytes, stream);
167 return do_is_equal(other);
185 void*
allocate(std::size_t bytes, std::size_t alignment)
204 void deallocate(
void* ptr, std::size_t bytes, std::size_t alignment)
250 return do_allocate(bytes, stream);
269 std::size_t alignment,
292 do_deallocate(ptr, bytes, stream);
295 #if CCCL_MAJOR_VERSION > 3 || (CCCL_MAJOR_VERSION == 3 && CCCL_MINOR_VERSION >= 1)
313 "Alignment must be less than or equal to 256 and a power of two");
325 void deallocate_sync(
void* ptr,
329 do_deallocate(ptr,
rmm::align_up(bytes, alignment), cuda_stream_view{});
345 void* allocate(cuda_stream_view stream,
350 "Alignment must be less than or equal to 256 and a power of two");
363 void deallocate(cuda_stream_view stream,
381 return do_is_equal(other);
393 return !do_is_equal(other);
429 virtual void do_deallocate(
void* ptr, std::size_t bytes,
cuda_stream_view stream) = 0;
447 return this == &other;
452 static_assert(rmm::detail::polyfill::resource<device_memory_resource>);
453 static_assert(rmm::detail::polyfill::async_resource<device_memory_resource>);
455 rmm::detail::polyfill::resource_with<device_memory_resource, cuda::mr::device_accessible>);
457 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_async(void *ptr, std::size_t bytes, cuda_stream_view stream)
Deallocate memory pointed to by p.
Definition: device_memory_resource.hpp:289
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:401
device_memory_resource(device_memory_resource &&) noexcept=default
Default move constructor.
void deallocate(void *ptr, std::size_t bytes, std::size_t alignment)
Deallocate memory pointed to by p.
Definition: device_memory_resource.hpp:204
void * allocate(std::size_t bytes, std::size_t alignment)
Allocates memory of size at least bytes.
Definition: device_memory_resource.hpp:185
void * allocate_async(std::size_t bytes, cuda_stream_view stream)
Allocates memory of size at least bytes.
Definition: device_memory_resource.hpp:247
bool operator==(device_memory_resource const &other) const noexcept
Comparison operator with another device_memory_resource.
Definition: device_memory_resource.hpp:379
void deallocate(void *ptr, std::size_t bytes, cuda_stream_view stream=cuda_stream_view{})
Deallocate memory pointed to by p.
Definition: device_memory_resource.hpp:146
void deallocate_async(void *ptr, std::size_t bytes, std::size_t alignment, cuda_stream_view stream)
Deallocate memory pointed to by p.
Definition: device_memory_resource.hpp:267
bool operator!=(device_memory_resource const &other) const noexcept
Comparison operator with another device_memory_resource.
Definition: device_memory_resource.hpp:391
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:226
bool is_equal(device_memory_resource const &other) const noexcept
Compare this resource to another.
Definition: device_memory_resource.hpp:165
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.