QMCPACK
CUDAHostAllocator< T > Struct Template Reference

allocator for CUDA host pinned memory More...

+ Inheritance diagram for CUDAHostAllocator< T >:
+ Collaboration diagram for CUDAHostAllocator< T >:

Classes

struct  rebind
 

Public Types

using value_type = T
 
using size_type = size_t
 
using pointer = T *
 
using const_pointer = const T *
 

Public Member Functions

 CUDAHostAllocator ()=default
 
template<class U >
 CUDAHostAllocator (const CUDAHostAllocator< U > &)
 
T * allocate (std::size_t n)
 
void deallocate (T *p, std::size_t)
 

Detailed Description

template<typename T>
struct qmcplusplus::CUDAHostAllocator< T >

allocator for CUDA host pinned memory

Template Parameters
Tdata type

Definition at line 197 of file CUDAallocator.hpp.


Class Documentation

◆ qmcplusplus::CUDAHostAllocator::rebind

struct qmcplusplus::CUDAHostAllocator::rebind

template<typename T>
template<class U>
struct qmcplusplus::CUDAHostAllocator< T >::rebind< U >

Definition at line 210 of file CUDAallocator.hpp.

+ Collaboration diagram for CUDAHostAllocator< T >::rebind< U >:
Class Members
typedef CUDAHostAllocator< U > other

Member Typedef Documentation

◆ const_pointer

using const_pointer = const T*

Definition at line 202 of file CUDAallocator.hpp.

◆ pointer

using pointer = T*

Definition at line 201 of file CUDAallocator.hpp.

◆ size_type

using size_type = size_t

Definition at line 200 of file CUDAallocator.hpp.

◆ value_type

using value_type = T

Definition at line 199 of file CUDAallocator.hpp.

Constructor & Destructor Documentation

◆ CUDAHostAllocator() [1/2]

CUDAHostAllocator ( )
default

◆ CUDAHostAllocator() [2/2]

CUDAHostAllocator ( const CUDAHostAllocator< U > &  )
inline

Definition at line 206 of file CUDAallocator.hpp.

207  {}

Member Function Documentation

◆ allocate()

T* allocate ( std::size_t  n)
inline

Definition at line 215 of file CUDAallocator.hpp.

216  {
217  void* pt;
218  cudaErrorCheck(cudaMallocHost(&pt, n * sizeof(T)), "Allocation failed in CUDAHostAllocator!");
219  return static_cast<T*>(pt);
220  }
#define cudaMallocHost
Definition: cuda2hip.h:121
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 ( T *  p,
std::size_t   
)
inline

Definition at line 221 of file CUDAallocator.hpp.

221 { cudaErrorCheck(cudaFreeHost(p), "Deallocation failed in CUDAHostAllocator!"); }
cudaErrorCheck(cudaMemcpyAsync(dev_lu.data(), lu.data(), sizeof(decltype(lu)::value_type) *lu.size(), cudaMemcpyHostToDevice, hstream), "cudaMemcpyAsync failed copying log_values to device")
#define cudaFreeHost
Definition: cuda2hip.h:100

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