Block-Structured AMR Software Framework
AMReX_PArena.H
Go to the documentation of this file.
1 #ifndef AMREX_PARENA_H_
2 #define AMREX_PARENA_H_
3 #include <AMReX_Config.H>
4 
5 #include <AMReX_Arena.H>
6 #include <AMReX_GpuControl.H>
7 
8 #ifdef AMREX_USE_CUDA
9 #include <cuda.h>
10 #endif
11 
12 namespace amrex {
13 
18 class PArena
19  :
20  public Arena
21 {
22 public:
23  PArena (Long release_threshold);
24  PArena (const PArena& rhs) = delete;
25  PArena (PArena&& rhs) = delete;
26  PArena& operator= (const PArena& rhs) = delete;
27  PArena& operator= (PArena&& rhs) = delete;
28  ~PArena () override;
29 
30  [[nodiscard]] void* alloc (std::size_t nbytes) final;
31  void free (void* p) final;
32 
33  [[nodiscard]] bool isDeviceAccessible () const final;
34  [[nodiscard]] bool isHostAccessible () const final;
35 
36  [[nodiscard]] bool isManaged () const final;
37  [[nodiscard]] bool isDevice () const final;
38  [[nodiscard]] bool isPinned () const final;
39 
40 #ifdef AMREX_USE_GPU
42  [[nodiscard]] bool isStreamOrderedArena () const final { return true; }
43 #endif
44 
45 #ifdef AMREX_GPU_STREAM_ALLOC_SUPPORT
46 private:
48  hipMemPool_t m_pool;,
49  cudaMemPool_t m_pool;
50  )
52  uint64_t m_old_release_threshold;,
53  cuuint64_t m_old_release_threshold;
54  )
55 #endif
56 };
57 
58 }
59 #endif
#define AMREX_HIP_OR_CUDA(a, b)
Definition: AMReX_GpuControl.H:21
A virtual base class for objects that manage their own dynamic memory allocation.
Definition: AMReX_Arena.H:100
This arena uses CUDA stream-ordered memory allocator if available. If not, use The_Arena().
Definition: AMReX_PArena.H:21
void * alloc(std::size_t nbytes) final
Definition: AMReX_PArena.cpp:54
PArena(Long release_threshold)
Definition: AMReX_PArena.cpp:12
~PArena() override
Definition: AMReX_PArena.cpp:39
bool isManaged() const final
Definition: AMReX_PArena.cpp:158
bool isStreamOrderedArena() const final
Is this CUDA stream ordered memory allocator?
Definition: AMReX_PArena.H:42
void free(void *p) final
A pure virtual function for deleting the arena pointed to by pt.
Definition: AMReX_PArena.cpp:89
PArena & operator=(const PArena &rhs)=delete
bool isPinned() const final
Definition: AMReX_PArena.cpp:192
bool isDeviceAccessible() const final
Definition: AMReX_PArena.cpp:124
PArena(PArena &&rhs)=delete
bool isHostAccessible() const final
Definition: AMReX_PArena.cpp:141
PArena(const PArena &rhs)=delete
bool isDevice() const final
Definition: AMReX_PArena.cpp:175
Definition: AMReX_Amr.cpp:49