File MemoryManager.hpp¶
↰ Parent directory (core/include
)
Singleton RAII owner of all solver buffers (host and device).
Definition (core/include/MemoryManager.hpp
)¶
Detailed Description¶
The Class MemoryManager owns every allocated block and tracks it in an internal registry. It supports two back‑ends:
Unified Memory (UM) – single pointer via
cudaMallocManaged
with optionalcudaMemPrefetchAsync
.Explicit mirrors – separate host/device buffers with async H2D/D2H.
Thread‑safety
All public methods are thread‑safe. The registry is protected by a mutex.
Typical use
auto& mm = MemoryManager::instance();
// Allocate SoA arrays with ghosts
double* rho = mm.allocate<double>(nx_tot*ny_tot*nz_tot);
// Transfer before a GPU kernel when not using UM
mm.to_device(rho, bytes, stream);
// On shutdown or scope end, release once
mm.release(rho);
Non‑owning views (Field<T>) should wrap the returned pointer for safer access.
Includes¶
AlignedAlloc.hpp
(File AlignedAlloc.hpp)cstddef
cstdint
mutex
unordered_map