include/pops/core/foundation/allocator.hpp File ReferenceΒΆ

adc_cpp: include/pops/core/foundation/allocator.hpp File Reference
adc_cpp 0.3.0
Model-free C++23 core for coupled hyperbolic-elliptic systems on adaptive (AMR) meshes, with MPI and GPU (Kokkos) backends
allocator.hpp File Reference

Fab2D storage allocator, selectable at compile time. More...

#include <cstddef>
#include <memory>
+ Include dependency graph for allocator.hpp:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  pops::ArenaStats
 ManagedArena pool statistics: hits/misses/fences and retained bytes. More...
 

Namespaces

namespace  pops
 

Typedefs

template<class T >
using pops::fab_allocator = std::allocator< T >
 
template<class T >
using pops::comm_allocator = std::allocator< T >
 

Functions

ArenaStats pops::arena_stats ()
 

Detailed Description

Fab2D storage allocator, selectable at compile time.

Two strategies depending on the build:

  • Kokkos (POPS_HAS_KOKKOS): ManagedAllocator<T> backed by ManagedArena (a pool of blocks in Kokkos::SharedSpace unified memory). std::vector<T, ManagedAllocator<T>> keeps value semantics (deep copy into a new managed allocation).
  • Pure CPU: std::allocator<T> – byte-identical to the old behavior.

fab_allocator<T> is the canonical alias to use; do not instantiate ManagedAllocator directly in numerical code.

Async safety INVARIANT: a freed block goes into pending_ (ManagedArena) and is only reused after the next batched Kokkos::fence. This reproduces the implicit barrier of cudaFree in a portable way. See ManagedArena::deallocate and ManagedArena::allocate.