Block-Structured AMR Software Framework
Loading...
Searching...
No Matches
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
12namespace amrex {
13
18class PArena
19 :
20 public Arena
21{
22public:
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 void streamOrderedFree (void* p, gpuStream_t stream) override;
44#endif
45
46#ifdef AMREX_GPU_STREAM_ALLOC_SUPPORT
47private:
49 hipMemPool_t m_pool;,
50 cudaMemPool_t m_pool;
51 )
53 uint64_t m_old_release_threshold;,
54 cuuint64_t m_old_release_threshold;
55 )
56#endif
57};
58
59}
60#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:127
This arena uses CUDA stream-ordered memory allocator if available. If not, use The_Arena().
Definition AMReX_PArena.H:21
PArena & operator=(const PArena &rhs)=delete
void * alloc(std::size_t nbytes) final
Definition AMReX_PArena.cpp:54
void streamOrderedFree(void *p, gpuStream_t stream) override
Definition AMReX_PArena.cpp:125
~PArena() override
Definition AMReX_PArena.cpp:39
bool isManaged() const final
Check whether it is managed GPU memory.
Definition AMReX_PArena.cpp:179
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
bool isPinned() const final
Check whether it is pinned host memory.
Definition AMReX_PArena.cpp:213
bool isDeviceAccessible() const final
Definition AMReX_PArena.cpp:145
PArena(PArena &&rhs)=delete
bool isHostAccessible() const final
Definition AMReX_PArena.cpp:162
PArena(const PArena &rhs)=delete
bool isDevice() const final
Check whether it is non-managed GPU device memory.
Definition AMReX_PArena.cpp:196
amrex_long Long
Definition AMReX_INT.H:30
Definition AMReX_Amr.cpp:49
cudaStream_t gpuStream_t
Definition AMReX_GpuControl.H:83