![]() |
QMCPACK
|
allocator for SYCL device memory T data type ALIGN alignment in bytes More...
Classes | |
struct | rebind |
Public Types | |
typedef T | value_type |
typedef size_t | size_type |
typedef T * | pointer |
typedef const T * | const_pointer |
Public Member Functions | |
SYCLAllocator ()=default | |
template<class U > | |
SYCLAllocator (const SYCLAllocator< U > &) | |
T * | allocate (std::size_t n) |
void | deallocate (T *p, std::size_t n) |
void | copyToDevice (T *device_ptr, T *host_ptr, size_t n) |
void | copyFromDevice (T *host_ptr, T *device_ptr, size_t n) |
void | copyDeviceToDevice (T *to_ptr, size_t n, T *from_ptr) |
Static Public Member Functions | |
template<class U , class... Args> | |
static void | construct (U *p, Args &&... args) |
Provide a construct for std::allocator_traits::contruct to call. More... | |
template<class U > | |
static void | destroy (U *p) |
Give std::allocator_traits something to call. More... | |
Static Public Attributes | |
static constexpr size_t | alignment = ALIGN |
allocator for SYCL device memory T data type ALIGN alignment in bytes
using this with something other than Ohmms containers? – use caution, write unit tests! – It's not tested beyond use in some unit tests using std::vector with constant size. SYCLAllocator appears to meet all the nonoptional requirements of a c++ Allocator.
Some of the default implementations in std::allocator_traits of optional Allocator requirements may cause runtime or compilation failures. They assume there is only one memory space and that the host has access to it.
Definition at line 97 of file SYCLallocator.hpp.
struct qmcplusplus::SYCLAllocator::rebind |
Definition at line 113 of file SYCLallocator.hpp.
Class Members | ||
---|---|---|
typedef SYCLAllocator< U > | other |
typedef const T* const_pointer |
Definition at line 103 of file SYCLallocator.hpp.
typedef T* pointer |
Definition at line 102 of file SYCLallocator.hpp.
typedef size_t size_type |
Definition at line 101 of file SYCLallocator.hpp.
typedef T value_type |
Definition at line 100 of file SYCLallocator.hpp.
|
default |
|
inline |
Definition at line 109 of file SYCLallocator.hpp.
|
inline |
Definition at line 118 of file SYCLallocator.hpp.
|
inlinestatic |
Provide a construct for std::allocator_traits::contruct to call.
Don't do anything on construct, pointer p is on the device!
For example std::vector calls this to default initialize each element. You'll segfault if std::allocator_traits::construct tries doing that at p.
The standard is a bit confusing on this point. Implementing this is an optional requirement of Allocator from C++11 on, its not slated to be removed.
Its deprecated for the std::allocator in c++17 and will be removed in c++20. But we are not implementing std::allocator.
STL containers only use Allocators through allocator_traits and std::allocator_traits handles the case where no construct method is present in the Allocator. But std::allocator_traits will call the Allocators construct method if present.
Definition at line 148 of file SYCLallocator.hpp.
|
inline |
Definition at line 169 of file SYCLallocator.hpp.
|
inline |
Definition at line 164 of file SYCLallocator.hpp.
Referenced by qmc_allocator_traits< qmcplusplus::SYCLAllocator< T > >::updateFrom().
|
inline |
Definition at line 159 of file SYCLallocator.hpp.
Referenced by qmc_allocator_traits< qmcplusplus::SYCLAllocator< T > >::updateTo().
|
inline |
Definition at line 125 of file SYCLallocator.hpp.
|
inlinestatic |
Give std::allocator_traits something to call.
The default if this isn't present is to call p->~T() which we can't do on device memory.
Definition at line 156 of file SYCLallocator.hpp.
|
static |
Definition at line 105 of file SYCLallocator.hpp.