QMCPACK
CUDALockedPageAllocator< T, ULPHA > Struct Template Reference

allocator locks memory pages allocated by ULPHA More...

+ Inheritance diagram for CUDALockedPageAllocator< T, ULPHA >:
+ Collaboration diagram for CUDALockedPageAllocator< T, ULPHA >:

Classes

struct  rebind
 

Public Types

using value_type = typename ULPHA::value_type
 
using size_type = typename ULPHA::size_type
 
using pointer = typename ULPHA::pointer
 
using const_pointer = typename ULPHA::const_pointer
 

Public Member Functions

 CUDALockedPageAllocator ()=default
 
template<class U , class V >
 CUDALockedPageAllocator (const CUDALockedPageAllocator< U, V > &)
 
value_typeallocate (std::size_t n)
 
void deallocate (value_type *pt, std::size_t n)
 

Detailed Description

template<typename T, class ULPHA = std::allocator<T>>
struct qmcplusplus::CUDALockedPageAllocator< T, ULPHA >

allocator locks memory pages allocated by ULPHA

Template Parameters
Tdata type
ULPHAhost memory allocator using unlocked page

ULPHA cannot be CUDAHostAllocator

Definition at line 242 of file CUDAallocator.hpp.


Class Documentation

◆ qmcplusplus::CUDALockedPageAllocator::rebind

struct qmcplusplus::CUDALockedPageAllocator::rebind

template<typename T, class ULPHA = std::allocator<T>>
template<class U, class V>
struct qmcplusplus::CUDALockedPageAllocator< T, ULPHA >::rebind< U, V >

Definition at line 255 of file CUDAallocator.hpp.

+ Collaboration diagram for CUDALockedPageAllocator< T, ULPHA >::rebind< U, V >:
Class Members
typedef CUDALockedPageAllocator< U, V > other

Member Typedef Documentation

◆ const_pointer

using const_pointer = typename ULPHA::const_pointer

Definition at line 247 of file CUDAallocator.hpp.

◆ pointer

using pointer = typename ULPHA::pointer

Definition at line 246 of file CUDAallocator.hpp.

◆ size_type

using size_type = typename ULPHA::size_type

Definition at line 245 of file CUDAallocator.hpp.

◆ value_type

using value_type = typename ULPHA::value_type

Definition at line 244 of file CUDAallocator.hpp.

Constructor & Destructor Documentation

◆ CUDALockedPageAllocator() [1/2]

◆ CUDALockedPageAllocator() [2/2]

CUDALockedPageAllocator ( const CUDALockedPageAllocator< U, V > &  )
inline

Definition at line 251 of file CUDAallocator.hpp.

252  {}

Member Function Documentation

◆ allocate()

value_type* allocate ( std::size_t  n)
inline

Definition at line 260 of file CUDAallocator.hpp.

References qmcplusplus::cudaErrorCheck(), cudaHostRegister, cudaHostRegisterDefault, and qmcplusplus::n.

261  {
262  static_assert(std::is_same<T, value_type>::value, "CUDALockedPageAllocator and ULPHA data types must agree!");
263  value_type* pt = ULPHA::allocate(n);
265  "cudaHostRegister failed in CUDALockedPageAllocator!");
266  return pt;
267  }
#define cudaHostRegister
Definition: cuda2hip.h:126
#define cudaHostRegisterDefault
Definition: cuda2hip.h:129
typename ULPHA::value_type value_type
cudaErrorCheck(cudaMemcpyAsync(dev_lu.data(), lu.data(), sizeof(decltype(lu)::value_type) *lu.size(), cudaMemcpyHostToDevice, hstream), "cudaMemcpyAsync failed copying log_values to device")

◆ deallocate()

void deallocate ( value_type pt,
std::size_t  n 
)
inline

Definition at line 269 of file CUDAallocator.hpp.

References qmcplusplus::cudaErrorCheck(), cudaHostUnregister, and qmcplusplus::n.

270  {
271  cudaErrorCheck(cudaHostUnregister(pt), "cudaHostUnregister failed in CUDALockedPageAllocator!");
272  ULPHA::deallocate(pt, n);
273  }
cudaErrorCheck(cudaMemcpyAsync(dev_lu.data(), lu.data(), sizeof(decltype(lu)::value_type) *lu.size(), cudaMemcpyHostToDevice, hstream), "cudaMemcpyAsync failed copying log_values to device")
#define cudaHostUnregister
Definition: cuda2hip.h:127

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