.. _file_core_include_MemoryManager.hpp: File MemoryManager.hpp ====================== |exhale_lsh| :ref:`Parent directory ` (``core/include``) .. |exhale_lsh| unicode:: U+021B0 .. UPWARDS ARROW WITH TIP LEFTWARDS Singleton RAII owner of all solver buffers (host and device). .. contents:: Contents :local: :backlinks: none Definition (``core/include/MemoryManager.hpp``) ----------------------------------------------- .. toctree:: :maxdepth: 1 program_listing_file_core_include_MemoryManager.hpp.rst Detailed Description -------------------- The :ref:`exhale_class_classMemoryManager` owns every allocated block and tracks it in an internal registry. It supports two back‑ends: 1. **Unified Memory (UM)** – single pointer via ``cudaMallocManaged`` with optional ``cudaMemPrefetchAsync``. 2. **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 .. code-block:: cpp auto& mm = MemoryManager::instance(); // Allocate SoA arrays with ghosts double* rho = mm.allocate(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) should wrap the returned pointer for safer access. Includes -------- - ``AlignedAlloc.hpp`` (:ref:`file_core_include_AlignedAlloc.hpp`) - ``cstddef`` - ``cstdint`` - ``mutex`` - ``unordered_map`` Included By ----------- - :ref:`file_core_memory_MemoryManager.cpp` Namespaces ---------- - :ref:`namespace_core` Classes ------- - :ref:`exhale_struct_structcore_1_1Block` - :ref:`exhale_class_classcore_1_1MemoryManager` - :ref:`exhale_class_classMemoryManager` Enums ----- - :ref:`exhale_enum_namespacecore_1aea9906baff2f9d3cc87bc0294a604e5b`