ERF
Energy Research and Forecasting: An Atmospheric Modeling Code
erf_actuator::StagedBuffer< T > Struct Template Reference

#include <ERF_ActuatorDeviceBuffers.H>

Inheritance diagram for erf_actuator::StagedBuffer< T >:
Collaboration diagram for erf_actuator::StagedBuffer< T >:

Public Member Functions

void upload ()
 
void download_async (std::size_t n)
 
T * data ()
 

Public Attributes

std::vector< T > host
 what the next upload() sends More...
 
amrex::Gpu::PinnedVector< T > pinned
 staging, and the host side of download_async() More...
 
amrex::Gpu::DeviceVector< T > device
 

Detailed Description

template<class T>
struct erf_actuator::StagedBuffer< T >

An array filled on the host and read by the kernels: the host side is a std::vector (clear() keeps its capacity), copied through pinned memory to the device with one asynchronous copy. The pinned and device sides only grow. A call that uploads must synchronize the stream before it returns, so that the next call may refill the host side.

Member Function Documentation

◆ data()

template<class T >
T* erf_actuator::StagedBuffer< T >::data ( )
inline
52 { return device.data(); }
amrex::Gpu::DeviceVector< T > device
Definition: ERF_ActuatorDeviceBuffers.H:34

Referenced by erf_actuator::add_scaled_kernels(), erf_actuator::sample_velocity_local(), and erf_actuator::spread_partial_norms().

Here is the caller graph for this function:

◆ download_async()

template<class T >
void erf_actuator::StagedBuffer< T >::download_async ( std::size_t  n)
inline

Copy the first n device values to pinned, asynchronously: they are there after the next stream synchronization.

47  {
48  grow_buffer(pinned, n);
49  if (n == 0) { return; }
50  amrex::Gpu::copyAsync(amrex::Gpu::deviceToHost, device.begin(), device.begin() + n, pinned.begin());
51  }
void grow_buffer(V &v, std::size_t n)
Definition: ERF_ActuatorDeviceBuffers.H:18
amrex::Gpu::PinnedVector< T > pinned
staging, and the host side of download_async()
Definition: ERF_ActuatorDeviceBuffers.H:33

Referenced by erf_actuator::sample_velocity_local(), and erf_actuator::spread_partial_norms().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ upload()

template<class T >
void erf_actuator::StagedBuffer< T >::upload ( )
inline

Copy host to the device, asynchronously.

38  {
39  grow_buffer(pinned, host.size());
40  grow_buffer(device, host.size());
41  if (host.empty()) { return; }
42  std::copy(host.begin(), host.end(), pinned.begin());
43  amrex::Gpu::copyAsync(amrex::Gpu::hostToDevice, pinned.begin(), pinned.begin() + host.size(), device.begin());
44  }
std::vector< T > host
what the next upload() sends
Definition: ERF_ActuatorDeviceBuffers.H:32

Referenced by erf_actuator::add_scaled_kernels(), erf_actuator::sample_velocity_local(), and erf_actuator::spread_partial_norms().

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ device

◆ host

◆ pinned


The documentation for this struct was generated from the following file: