1 #ifndef HEFFTE_STOCK_ALLOCATOR_H
2 #define HEFFTE_STOCK_ALLOCATOR_H
7 #include "heffte_stock_complex.h"
23 typedef const F* const_pointer;
25 typedef const F& const_reference;
26 typedef size_t size_type;
27 typedef std::ptrdiff_t difference_type;
36 inline pointer
address(reference r) {
return &r; }
38 inline const_pointer
address(const_reference r)
const {
return &r; }
41 pointer
allocate(size_type n,
typename std::allocator<void>::const_pointer =
nullptr) {
42 #ifdef Heffte_ENABLE_AVX
43 return reinterpret_cast<pointer
>(aligned_alloc(
alignof(F), n*
sizeof(F)));
45 return reinterpret_cast<pointer
>(malloc(n*
sizeof(F)));
56 inline void destroy(pointer p) { p->~value_type(); }
59 inline size_type
max_size() const noexcept {
return size_type(-1) /
sizeof(F); }
68 template<
typename F,
int L>
69 using complex_allocator = complex_allocator_t<Complex<F, L>>;
72 template<
typename F,
int L>
73 using complex_vector = std::vector<Complex<F,L>, complex_allocator<F,L>>;
Allocator to use with heffte::stock::Complex types Class to properly allocate heffte::stock::Complex<...
Definition: heffte_stock_allocator.h:18
void construct(pointer p, const_reference value)
Copy into pointer.
Definition: heffte_stock_allocator.h:54
pointer allocate(size_type n, typename std::allocator< void >::const_pointer=nullptr)
Define allocation for complex type.
Definition: heffte_stock_allocator.h:41
bool operator!=(const complex_allocator_t &rhs)
Define != operator.
Definition: heffte_stock_allocator.h:64
void deallocate(pointer p, size_type)
Define deallocation for complex type.
Definition: heffte_stock_allocator.h:49
size_type max_size() const noexcept
Define maximum size of an array of this.
Definition: heffte_stock_allocator.h:59
void destroy(pointer p)
Destroy a pointer to this type.
Definition: heffte_stock_allocator.h:56
F value_type
Mandatory aliases.
Definition: heffte_stock_allocator.h:21
bool operator==(const complex_allocator_t &)
Define == operator.
Definition: heffte_stock_allocator.h:62
const_pointer address(const_reference r) const
Get address from a const reference.
Definition: heffte_stock_allocator.h:38
pointer address(reference r)
Get address from a reference.
Definition: heffte_stock_allocator.h:36
Namespace containing all HeFFTe methods and classes.
Definition: heffte_backend_cuda.h:38
Defining rebind for the allocator.
Definition: heffte_stock_allocator.h:31