Celeritas
0.5.0-56+6b053cd
|
Allocate raw uninitialized memory. More...
#include <DeviceAllocation.hh>
Public Types | |
Type aliases | |
using | size_type = std::size_t |
using | SpanBytes = Span< std::byte > |
using | SpanConstBytes = Span< std::byte const > |
Public Member Functions | |
DeviceAllocation (StreamId stream) | |
Construct in unallocated state. | |
DeviceAllocation (size_type num_bytes) | |
Allocate a buffer with the given number of bytes. | |
DeviceAllocation (size_type num_bytes, StreamId stream) | |
Allocate a buffer with the given number of bytes. | |
void | swap (DeviceAllocation &other) noexcept |
Swap with another allocation. | |
size_type | size () const |
Get the number of bytes allocated. | |
bool | empty () const |
Whether memory is allocated. | |
StreamId | stream_id () const |
Access the stream, set for asynchonous allocation/copy. | |
SpanBytes | device_ref () |
Get a view to the owned device memory. | |
SpanConstBytes | device_ref () const |
Get a view to the owned device memory. | |
void | copy_to_device (SpanConstBytes bytes) |
Copy data to device. | |
void | copy_to_host (SpanBytes bytes) const |
Copy data to host. | |
Allocate raw uninitialized memory.
This class is intended to be used by host-compiler .hh code as a bridge to device memory. It allows Storage classes to allocate and manage device memory without using
thrust
, which requires NVCC and propagates that requirement into all downstream code.
TODO: remove the stream constructor data members and rely on Copier
or thrust
to do streamed async operations?