QMCPACK
qmc_allocator_traits< DualAllocator< T, DeviceAllocator, HostAllocator > > Struct Template Reference
+ Collaboration diagram for qmc_allocator_traits< DualAllocator< T, DeviceAllocator, HostAllocator > >:

Public Types

using DualAlloc = DualAllocator< T, DeviceAllocator, HostAllocator >
 

Static Public Member Functions

static void fill_n (T *ptr, size_t n, const T &value)
 
static void attachReference (const DualAlloc &from, DualAlloc &to, std::ptrdiff_t ptr_offset)
 
static void updateTo (DualAlloc &alloc, T *host_ptr, size_t n, size_t offset=0)
 update to the device, assumes you are copying starting with the implicit host_ptr. More...
 
static void updateFrom (DualAlloc &alloc, T *host_ptr, size_t n, size_t offset=0)
 update from the device, assumes you are copying starting with the device_ptr to the implicit host_ptr. More...
 
static void deviceSideCopyN (DualAlloc &alloc, size_t to, size_t n, size_t from)
 

Static Public Attributes

static constexpr bool is_host_accessible = true
 
static constexpr bool is_dual_space = true
 

Detailed Description

template<typename T, class DeviceAllocator, class HostAllocator>
struct qmcplusplus::qmc_allocator_traits< DualAllocator< T, DeviceAllocator, HostAllocator > >

Definition at line 108 of file DualAllocator.hpp.

Member Typedef Documentation

◆ DualAlloc

using DualAlloc = DualAllocator<T, DeviceAllocator, HostAllocator>

Definition at line 110 of file DualAllocator.hpp.

Member Function Documentation

◆ attachReference()

static void attachReference ( const DualAlloc from,
DualAlloc to,
std::ptrdiff_t  ptr_offset 
)
inlinestatic

Definition at line 116 of file DualAllocator.hpp.

References DualAllocator< T, DeviceAllocator, HostAllocator >::attachReference().

117  {
118  to.attachReference(from, ptr_offset);
119  }

◆ deviceSideCopyN()

static void deviceSideCopyN ( DualAlloc alloc,
size_t  to,
size_t  n,
size_t  from 
)
inlinestatic

Definition at line 144 of file DualAllocator.hpp.

References DualAllocator< T, DeviceAllocator, HostAllocator >::get_device_allocator(), DualAllocator< T, DeviceAllocator, HostAllocator >::get_device_ptr(), and qmcplusplus::n.

145  {
146  T* device_ptr = alloc.get_device_ptr();
147  T* to_ptr = device_ptr + to;
148  T* from_ptr = device_ptr + from;
149  alloc.get_device_allocator().copyDeviceToDevice(to_ptr, n, from_ptr);
150  }

◆ fill_n()

static void fill_n ( T *  ptr,
size_t  n,
const T &  value 
)
inlinestatic

Definition at line 114 of file DualAllocator.hpp.

References qmc_allocator_traits< Allocator >::fill_n(), and qmcplusplus::n.

static void fill_n(value_type *ptr, size_t n, const value_type &value)

◆ updateFrom()

static void updateFrom ( DualAlloc alloc,
T *  host_ptr,
size_t  n,
size_t  offset = 0 
)
inlinestatic

update from the device, assumes you are copying starting with the device_ptr to the implicit host_ptr.

Definition at line 139 of file DualAllocator.hpp.

References DualAllocator< T, DeviceAllocator, HostAllocator >::get_device_allocator(), DualAllocator< T, DeviceAllocator, HostAllocator >::get_device_ptr(), and qmcplusplus::n.

140  {
141  alloc.get_device_allocator().copyFromDevice(host_ptr + offset, alloc.get_device_ptr() + offset, n);
142  }

◆ updateTo()

static void updateTo ( DualAlloc alloc,
T *  host_ptr,
size_t  n,
size_t  offset = 0 
)
inlinestatic

update to the device, assumes you are copying starting with the implicit host_ptr.

These follow the openmp target semantics where you only provide the host side of a host_ptr device_ptr pair but the verb relates to what happens on the device.

This is primarily for testing to reduce ifdef code and single "flavor" testing

This a generic API and unlikely to be the best way to handle performance critical transfers, but if you have to use it or ifdef at a level above a xxxCUDA.cu or xxxOMPTarget.hpp file thats an issue.

Definition at line 132 of file DualAllocator.hpp.

References DualAllocator< T, DeviceAllocator, HostAllocator >::get_device_allocator(), DualAllocator< T, DeviceAllocator, HostAllocator >::get_device_ptr(), and qmcplusplus::n.

133  {
134  alloc.get_device_allocator().copyToDevice(alloc.get_device_ptr() + offset, host_ptr + offset, n);
135  }

Member Data Documentation

◆ is_dual_space

constexpr bool is_dual_space = true
static

Definition at line 112 of file DualAllocator.hpp.

◆ is_host_accessible

constexpr bool is_host_accessible = true
static

Definition at line 111 of file DualAllocator.hpp.


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