|
| device_buffer (device_buffer const &other)=delete |
|
device_buffer & | operator= (device_buffer const &other)=delete |
|
| device_buffer () |
| Default constructor creates an empty device_buffer
|
|
| device_buffer (std::size_t size, cuda_stream_view stream, async_resource_ref mr=mr::get_current_device_resource()) |
| Constructs a new device buffer of size uninitialized bytes. More...
|
|
| device_buffer (void const *source_data, std::size_t size, cuda_stream_view stream, async_resource_ref mr=rmm::mr::get_current_device_resource()) |
| Construct a new device buffer by copying from a raw pointer to an existing host or device memory allocation. More...
|
|
| device_buffer (device_buffer const &other, cuda_stream_view stream, async_resource_ref mr=rmm::mr::get_current_device_resource()) |
| Construct a new device_buffer by deep copying the contents of another device_buffer , optionally using the specified stream and memory resource. More...
|
|
| device_buffer (device_buffer &&other) noexcept |
| Constructs a new device_buffer by moving the contents of another device_buffer into the newly constructed one. More...
|
|
device_buffer & | operator= (device_buffer &&other) noexcept |
| Move assignment operator moves the contents from other . More...
|
|
| ~device_buffer () noexcept |
| Destroy the device buffer object. More...
|
|
void | reserve (std::size_t new_capacity, cuda_stream_view stream) |
| Increase the capacity of the device memory allocation. More...
|
|
void | resize (std::size_t new_size, cuda_stream_view stream) |
| Resize the device memory allocation. More...
|
|
void | shrink_to_fit (cuda_stream_view stream) |
| Forces the deallocation of unused memory. More...
|
|
void const * | data () const noexcept |
| Const pointer to the device memory allocation. More...
|
|
void * | data () noexcept |
| Pointer to the device memory allocation. More...
|
|
std::size_t | size () const noexcept |
| The number of bytes. More...
|
|
std::int64_t | ssize () const noexcept |
| The signed number of bytes. More...
|
|
bool | is_empty () const noexcept |
| Whether or not the buffer currently holds any data. More...
|
|
std::size_t | capacity () const noexcept |
| Returns actual size in bytes of device memory allocation. More...
|
|
cuda_stream_view | stream () const noexcept |
| The stream most recently specified for allocation/deallocation. More...
|
|
void | set_stream (cuda_stream_view stream) noexcept |
| Sets the stream to be used for deallocation. More...
|
|
async_resource_ref | memory_resource () const noexcept |
| The async_resource_ref used to allocate and deallocate. More...
|
|
RAII construct for device memory allocation.
This class allocates untyped and uninitialized device memory using a device_memory_resource
. If not explicitly specified, the memory resource returned from get_current_device_resource()
is used.
- Note
- Unlike
std::vector
or thrust::device_vector
, the device memory allocated by a device_buffer
is uninitialized. Therefore, it is undefined behavior to read the contents of data()
before first initializing it.
Examples:
custom_memory_resource mr;
cuda_stream_view
stream = cuda_stream_view{};
buff_default.resize(100,
stream);
cuda_stream_view stream() const noexcept
The stream most recently specified for allocation/deallocation.
Definition: device_buffer.hpp:397
device_buffer()
Default constructor creates an empty device_buffer
Definition: device_buffer.hpp:100
void rmm::device_buffer::reserve |
( |
std::size_t |
new_capacity, |
|
|
cuda_stream_view |
stream |
|
) |
| |
|
inline |
Increase the capacity of the device memory allocation.
If the requested new_capacity
is less than or equal to capacity()
, no action is taken.
If new_capacity
is larger than capacity()
, a new allocation is made on stream
to satisfy new_capacity
, and the contents of the old allocation are copied on stream
to the new allocation. The old allocation is then freed. The bytes from [size(), new_capacity)
are uninitialized.
- Exceptions
-
- Parameters
-
new_capacity | The requested new capacity, in bytes |
stream | The stream to use for allocation and copy |
void rmm::device_buffer::resize |
( |
std::size_t |
new_size, |
|
|
cuda_stream_view |
stream |
|
) |
| |
|
inline |
Resize the device memory allocation.
If the requested new_size
is less than or equal to capacity()
, no action is taken other than updating the value that is returned from size()
. Specifically, no memory is allocated nor copied. The value capacity()
remains the actual size of the device memory allocation.
- Note
shrink_to_fit()
may be used to force the deallocation of unused capacity()
.
If new_size
is larger than capacity()
, a new allocation is made on stream
to satisfy new_size
, and the contents of the old allocation are copied on stream
to the new allocation. The old allocation is then freed. The bytes from [old_size, new_size)
are uninitialized.
The invariant size() <= capacity()
holds.
- Exceptions
-
- Parameters
-
new_size | The requested new size, in bytes |
stream | The stream to use for allocation and copy |