OpenPFC  0.1.4
Phase Field Crystal simulation framework
Loading...
Searching...
No Matches
gpu_vector.hpp File Reference

Simple GPU memory container with RAII management. More...

#include <cstddef>
#include <stdexcept>
#include <vector>
Include dependency graph for gpu_vector.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  pfc::gpu::GPUVector< T >
 Simple GPU memory container (RAII) More...
 

Macros

#define PFC_GPU_CUDA_AVAILABLE   0
 

Detailed Description

Simple GPU memory container with RAII management.

GPUVector provides a simple, RAII-style container for GPU memory that automatically manages CUDA memory allocation and deallocation. It's designed to be similar to std::vector in interface, but memory lives on the GPU.

Key features:

  • Automatic memory management (RAII)
  • Fixed size (no resizing)
  • CPU-GPU transfer methods
  • Move semantics supported
  • Copy semantics disabled (would require deep copy)

This header must compile on systems without CUDA (e.g., AMD systems). CUDA-specific code is guarded with #ifdef OpenPFC_ENABLE_CUDA.

#ifdef OpenPFC_ENABLE_CUDA
std::vector<double> host_data(100, 1.0);
vec.copy_from_host(host_data);
// ... use GPU memory ...
std::vector<double> result = vec.to_host();
#endif
Simple GPU memory container (RAII)
Definition gpu_vector.hpp:73
See also
gpu/kernels_simple.hpp for GPU kernel operations
tungsten-gpu-implementation-plan.md for usage examples
Author
OpenPFC Development Team
Date
2025