1 #ifndef AMREX_GPUALLOCATORS_H_
2 #define AMREX_GPUALLOCATORS_H_
3 #include <AMReX_Config.H>
11 #include <driver_types.h>
12 #include <cuda_runtime.h>
18 #include <type_traits>
27 [[nodiscard]] constexpr T*
ptr () const noexcept {
return m_ptr; }
28 [[nodiscard]] constexpr std::size_t
size () const noexcept {
return m_size; }
31 template <
class T,
class AR>
49 return FatPtr<T>{(T*)pn.first, pn.second/
sizeof(T)};
60 if (ptr !=
nullptr) {
arena()->
free(ptr); }
157 template <
typename T>
160 template <
class T,
class Enable =
void>
165 <T,std::enable_if_t<std::is_base_of_v
166 <ArenaAllocatorBase<typename T::value_type,
167 typename T::arena_wrapper_type>,
171 template <
typename T>
175 template <
typename T>
178 template <
typename T>
181 template <
typename T>
184 template <
typename T>
187 template <
typename T>
200 template <
typename A1,
typename A2,
201 std::enable_if_t<IsArenaAllocator<A1>::value &&
205 return a1.arena() == a2.arena();
208 template <
typename A1,
typename A2,
209 std::enable_if_t<IsArenaAllocator<A1>::value &&
210 IsArenaAllocator<A2>::value,
int> = 0>
213 return a1.arena() != a2.arena();
Definition: AMReX_GpuAllocators.H:114
A virtual base class for objects that manage their own dynamic memory allocation.
Definition: AMReX_Arena.H:100
virtual void free(void *pt)=0
A pure virtual function for deleting the arena pointed to by pt.
virtual void * shrink_in_place(void *, std::size_t sz)
Definition: AMReX_Arena.H:132
virtual void * alloc(std::size_t sz)=0
virtual std::pair< void *, std::size_t > alloc_in_place(void *, std::size_t, std::size_t szmax)
Definition: AMReX_Arena.H:122
Definition: AMReX_GpuAllocators.H:138
Definition: AMReX_GpuAllocators.H:120
Definition: AMReX_GpuAllocators.H:132
Definition: AMReX_GpuAllocators.H:126
Definition: AMReX_GpuAllocators.H:144
void setArena(Arena *a_ar) noexcept
Definition: AMReX_GpuAllocators.H:151
constexpr PolymorphicArenaAllocator(Arena *a_arena)
Definition: AMReX_GpuAllocators.H:147
constexpr PolymorphicArenaAllocator()=default
Definition: AMReX_Amr.cpp:49
Arena * The_Managed_Arena()
Definition: AMReX_Arena.cpp:639
bool operator!=(A1 const &a1, A2 const &a2)
Definition: AMReX_GpuAllocators.H:211
Arena * The_Device_Arena()
Definition: AMReX_Arena.cpp:629
bool operator==(A1 const &a1, A2 const &a2)
Definition: AMReX_GpuAllocators.H:203
Arena * The_Pinned_Arena()
Definition: AMReX_Arena.cpp:649
Arena * The_Async_Arena()
Definition: AMReX_Arena.cpp:619
Arena * The_Arena()
Definition: AMReX_Arena.cpp:609
Definition: AMReX_GpuAllocators.H:33
FatPtr< T > allocate_in_place(T *p, std::size_t nmin, std::size_t nmax)
Definition: AMReX_GpuAllocators.H:46
T value_type
Definition: AMReX_GpuAllocators.H:34
constexpr ArenaAllocatorBase()=default
AR arena_wrapper_type
Definition: AMReX_GpuAllocators.H:35
AR m_ar
Definition: AMReX_GpuAllocators.H:68
T * allocate(std::size_t n)
Definition: AMReX_GpuAllocators.H:40
constexpr ArenaAllocatorBase(AR a_ar)
Definition: AMReX_GpuAllocators.H:38
Arena * arena() const noexcept
Definition: AMReX_GpuAllocators.H:63
T * shrink_in_place(T *p, std::size_t n)
Definition: AMReX_GpuAllocators.H:53
void deallocate(T *ptr, std::size_t)
Definition: AMReX_GpuAllocators.H:58
Definition: AMReX_GpuAllocators.H:71
static Arena * arena() noexcept
Definition: AMReX_GpuAllocators.H:72
Definition: AMReX_GpuAllocators.H:95
static Arena * arena() noexcept
Definition: AMReX_GpuAllocators.H:96
Definition: AMReX_GpuAllocators.H:77
static Arena * arena() noexcept
Definition: AMReX_GpuAllocators.H:78
Definition: AMReX_GpuAllocators.H:24
constexpr T * ptr() const noexcept
Definition: AMReX_GpuAllocators.H:27
std::size_t m_size
Definition: AMReX_GpuAllocators.H:26
T * m_ptr
Definition: AMReX_GpuAllocators.H:25
constexpr std::size_t size() const noexcept
Definition: AMReX_GpuAllocators.H:28
Definition: AMReX_GpuAllocators.H:161
Definition: AMReX_GpuAllocators.H:172
Definition: AMReX_GpuAllocators.H:89
static Arena * arena() noexcept
Definition: AMReX_GpuAllocators.H:90
Definition: AMReX_GpuAllocators.H:83
static Arena * arena() noexcept
Definition: AMReX_GpuAllocators.H:84
Definition: AMReX_GpuAllocators.H:101
constexpr PolymorphicArenaWrapper()=default
Arena * arena() const noexcept
Definition: AMReX_GpuAllocators.H:105
constexpr PolymorphicArenaWrapper(Arena *a_arena)
Definition: AMReX_GpuAllocators.H:103
Arena * m_arena
Definition: AMReX_GpuAllocators.H:108
Definition: AMReX_GpuAllocators.H:158