![]() |
OpenPFC
0.1.4
Phase Field Crystal simulation framework
|
Simple GPU memory container (RAII) More...
#include <gpu_vector.hpp>
Public Member Functions | |
| GPUVector (size_t size) | |
| Construct a GPUVector with the specified size. | |
| ~GPUVector () | |
| Destructor - automatically frees GPU memory. | |
| GPUVector (const GPUVector &)=delete | |
| GPUVector & | operator= (const GPUVector &)=delete |
| GPUVector (GPUVector &&other) noexcept | |
| Move constructor. | |
| GPUVector & | operator= (GPUVector &&other) noexcept |
| Move assignment operator. | |
| T * | data () |
| Get pointer to GPU memory. | |
| const T * | data () const |
| Get const pointer to GPU memory. | |
| size_t | size () const |
| Get the number of elements. | |
| bool | empty () const |
| Check if the vector is empty. | |
| void | copy_from_host (const std::vector< T > &host_data) |
| Copy data from host (CPU) to device (GPU) | |
| void | copy_to_host (std::vector< T > &host_data) const |
| Copy data from device (GPU) to host (CPU) | |
| std::vector< T > | to_host () const |
| Copy data from device to host and return as vector. | |
Simple GPU memory container (RAII)
Similar to std::vector but memory lives on GPU. Fixed size (no resizing).
| T | Element type (must be trivially copyable) |
|
inlineexplicit |
Construct a GPUVector with the specified size.
Allocates GPU memory for size elements of type T.
| size | Number of elements to allocate |
| std::runtime_error | if GPU memory allocation fails |

|
inline |
Copy data from host (CPU) to device (GPU)
| host_data | Source data on CPU |
| std::runtime_error | if sizes don't match or copy fails |
|
inline |
Copy data from device (GPU) to host (CPU)
| host_data | Destination vector (will be resized if needed) |

|
inline |
Get pointer to GPU memory.
|
inline |
Copy data from device to host and return as vector.
