![]() |
QMCPACK
|
OMPallocator is an allocator with fused device and dualspace allocator functionality. More...
Classes | |
struct | rebind |
Public Types | |
using | value_type = typename HostAllocator::value_type |
using | size_type = typename HostAllocator::size_type |
using | pointer = typename HostAllocator::pointer |
using | const_pointer = typename HostAllocator::const_pointer |
Public Member Functions | |
OMPallocator ()=default | |
OMPallocator (const OMPallocator &) | |
Gives you a OMPallocator with no state. More... | |
template<class U , class V > | |
OMPallocator (const OMPallocator< U, V > &) | |
value_type * | allocate (std::size_t n) |
void | deallocate (value_type *pt, std::size_t n) |
void | attachReference (const OMPallocator &from, std::ptrdiff_t ptr_offset) |
T * | get_device_ptr () |
const T * | get_device_ptr () const |
Private Attributes | |
T * | device_ptr_ = nullptr |
OMPallocator is an allocator with fused device and dualspace allocator functionality.
it is mostly c++03 style but is stateful with respect to the bond between the returned pt on the host and the device_ptr_. While many containers may need a copy only one can own the memory it returns and it can only service one owner. i.e. only one object should call the allocate and deallocate methods.
Note: in the style of openmp portability this class always thinks its dual space even when its not, this happens through the magic of openmp ignoring target pragmas when target isn't enabled. i.e. -fopenmp-targets=... isn't passed at compile time. This makes the code "simpler" and more "portable" since its the same code you would write for openmp CPU implementation exploding head and that is the same implementation + pragmas as the serial implementation. This definitely isn't true for all QMCPACK code using offload but it is true for OMPAllocator so we do test it that way.
Definition at line 60 of file OMPallocator.hpp.
struct qmcplusplus::OMPallocator::rebind |
Definition at line 79 of file OMPallocator.hpp.
Class Members | ||
---|---|---|
typedef OMPallocator< U, V > | other |
using const_pointer = typename HostAllocator::const_pointer |
Definition at line 65 of file OMPallocator.hpp.
using pointer = typename HostAllocator::pointer |
Definition at line 64 of file OMPallocator.hpp.
using size_type = typename HostAllocator::size_type |
Definition at line 63 of file OMPallocator.hpp.
using value_type = typename HostAllocator::value_type |
Definition at line 62 of file OMPallocator.hpp.
|
default |
|
inline |
Gives you a OMPallocator with no state.
But OMPallocoator is stateful so this copy constructor is a lie. However until allocators are correct > c++11 this is retained since our < c++11 compliant containers may expect it.
Definition at line 73 of file OMPallocator.hpp.
|
inline |
Definition at line 75 of file OMPallocator.hpp.
|
inline |
Definition at line 84 of file OMPallocator.hpp.
Referenced by qmcplusplus::TEST_CASE().
|
inline |
Definition at line 116 of file OMPallocator.hpp.
Referenced by qmc_allocator_traits< OMPallocator< T, HostAllocator > >::attachReference().
|
inline |
Definition at line 101 of file OMPallocator.hpp.
Referenced by qmcplusplus::TEST_CASE().
|
inline |
Definition at line 121 of file OMPallocator.hpp.
Referenced by OMPallocator< Value >::attachReference(), and qmc_allocator_traits< OMPallocator< T, HostAllocator > >::deviceSideCopyN().
|
inline |
Definition at line 122 of file OMPallocator.hpp.
|
private |
Definition at line 126 of file OMPallocator.hpp.
Referenced by OMPallocator< Value >::allocate(), OMPallocator< Value >::attachReference(), and OMPallocator< Value >::get_device_ptr().