Celeritas
0.5.0-56+6b053cd
|
Host vector for managing uninitialized device-storage data. More...
#include <DeviceVector.hh>
Public Types | |
Type aliases | |
using | value_type = T |
using | SpanT = Span< T > |
using | SpanConstT = Span< T const > |
Public Member Functions | |
DeviceVector (StreamId stream) | |
Construct with a stream. | |
DeviceVector (size_type count) | |
Construct with a number of allocated elements. | |
DeviceVector (size_type count, StreamId stream) | |
Construct with a number of allocated elements and a stream. | |
void | swap (DeviceVector &other) noexcept |
Get the device data pointer. | |
void | assign (T const *first, T const *last) |
Allocate and copy from host pointers. More... | |
size_type | size () const |
Get the number of elements. | |
bool | empty () const |
Whether any elements are stored. | |
void | copy_to_device (SpanConstT host_data) |
Copy data to device. | |
void | copy_to_host (SpanT host_data) const |
Copy data to host. | |
SpanT | device_ref () |
SpanConstT | device_ref () const |
T * | data () |
Get a device data pointer. | |
T const * | data () const |
Get a device data pointer. | |
Host vector for managing uninitialized device-storage data.
This is a class used only in host memory (not passed to kernels) to manage device allocation and host/device copies. It does not perform initialization on the data: the host code must define and copy over suitable data.
For more complex data usage (dynamic size increases, std vector-like access, object initialization), use thrust::device_vector
inside a .cu file.
When a StreamId
is passed as the last constructor argument, all memory operations are asynchronous and ordered within that stream.
void celeritas::DeviceVector< T >::assign | ( | T const * | first, |
T const * | last | ||
) |
Allocate and copy from host pointers.
Not exception safe: if the copy fails, the original contents are lost.