EBGeometry
Compact, header-only C++ library for fast evaluation of signed distance functions
Loading...
Searching...
No Matches
Classes | Namespaces | Functions | Variables
EBGeometry_MemoryResource.hpp File Reference

Placement-policy layer for the GPU memory foundation: the abstract MemoryResource and its concrete host, emulated device, device, managed, pinned and mapped implementations. More...

#include <cstddef>
#include "EBGeometry_GPU.hpp"
#include "EBGeometry_GPURuntime.hpp"
#include "EBGeometry_Macros.hpp"
#include "EBGeometry_MemoryResourceImplem.hpp"
Include dependency graph for EBGeometry_MemoryResource.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  EBGeometry::MemoryResource
 Abstract placement policy: allocates and frees raw, correctly-aligned byte blocks. More...
 
class  EBGeometry::HostMemoryResource
 Host memory resource: plain aligned allocation in host RAM (std::aligned_alloc / free family). More...
 
class  EBGeometry::EmulatedDeviceMemoryResource
 Host memory that stands in for device memory: host RAM that reports itself device-accessible. More...
 
class  EBGeometry::DeviceMemoryResource
 Device memory resource: raw device allocation (GPU::memAlloc / GPU::memFree). More...
 
class  EBGeometry::ManagedMemoryResource
 Managed (unified) memory resource: one allocation reachable from host and device (GPU::memAllocManaged / GPU::memFree). More...
 
class  EBGeometry::PinnedMemoryResource
 Pinned (page-locked) host memory resource: fast host-to-device staging (GPU::memAllocHost / GPU::memFreeHost). More...
 
class  EBGeometry::MappedMemoryResource
 Mapped (zero-copy) pinned host memory resource: page-locked host memory also mapped into the device address space (GPU::memAllocHostMapped / GPU::memFreeHost). More...
 

Namespaces

namespace  EBGeometry
 Namespace containing all of EBGeometry's functionality.
 

Functions

HostMemoryResource & EBGeometry::hostMemoryResource () noexcept
 Process-wide default host memory resource.
 
EmulatedDeviceMemoryResource & EBGeometry::emulatedDeviceMemoryResource () noexcept
 Process-wide emulated device memory resource.
 
DeviceMemoryResource & EBGeometry::deviceMemoryResource () noexcept
 Process-wide default device memory resource.
 
ManagedMemoryResource & EBGeometry::managedMemoryResource () noexcept
 Process-wide default managed (unified) memory resource.
 
PinnedMemoryResource & EBGeometry::pinnedMemoryResource () noexcept
 Process-wide default pinned (page-locked) host memory resource.
 
MappedMemoryResource & EBGeometry::mappedMemoryResource () noexcept
 Process-wide default mapped (zero-copy) pinned host memory resource.
 

Variables

constexpr size_t EBGeometry::PoolBaseAlign = 256
 Block-base alignment for every Pool, in bytes.
 

Detailed Description

Placement-policy layer for the GPU memory foundation: the abstract MemoryResource and its concrete host, emulated device, device, managed, pinned and mapped implementations.

A EBGeometry::MemoryResource is a thin, runtime-virtual allocation policy: it decides where a block of bytes physically lives (host RAM, device memory, unified/managed memory, or page-locked host memory) without the caller knowing which. Allocation is a cold, once-per-build operation, so the virtual dispatch cost is irrelevant and the runtime-swappable placement is the whole point: the same POD scene structure (see EBGeometry::Pool and EBGeometry::PODVector) can be built into a host resource for a CPU query, or mirrored into a device resource for a kernel. Managed and mapped blocks are reachable from both sides: an object built directly in a managed pool reaches a kernel through rebasedView() onto that same pool once it is frozen, and a view of a managed or mapped pool also answers queries on the host (see EBGeometry::PoolLocation).

EBGeometry::HostMemoryResource (plain aligned host allocation) and EBGeometry::EmulatedDeviceMemoryResource (host memory standing in for device memory in a plain C++ build) are always compiled. The device-backed resources – EBGeometry::DeviceMemoryResource, EBGeometry::ManagedMemoryResource, EBGeometry::PinnedMemoryResource, EBGeometry::MappedMemoryResource – are compiled only when an offload backend is active (CUDA/HIP) or for documentation, behind the same guard as EBGeometry_GPURuntime.hpp, and reach the backend exclusively through the backend-neutral EBGeometry::GPU alias layer.

Author
Robert Marskar