30#ifndef EBGEOMETRY_MEMORYRESOURCE_HPP
31#define EBGEOMETRY_MEMORYRESOURCE_HPP
113 deallocate(
void* a_ptr,
size_t a_bytes,
size_t a_alignment)
noexcept = 0;
150 size_t a_bytes) const noexcept;
179 allocate(
size_t a_bytes,
size_t a_alignment)
override;
189 deallocate(
void* a_ptr,
size_t a_bytes,
size_t a_alignment)
noexcept override;
254 allocate(
size_t a_bytes,
size_t a_alignment)
override;
264 deallocate(
void* a_ptr,
size_t a_bytes,
size_t a_alignment)
noexcept override;
296EmulatedDeviceMemoryResource&
299#if defined(EBGEOMETRY_CUDA) || defined(EBGEOMETRY_HIP) || defined(EBGEOMETRY_DOXYGEN)
330 allocate(
size_t a_bytes,
size_t a_alignment)
override;
340 deallocate(
void* a_ptr,
size_t a_bytes,
size_t a_alignment)
noexcept override;
379 size_t a_bytes)
const noexcept override;
410 allocate(
size_t a_bytes,
size_t a_alignment)
override;
420 deallocate(
void* a_ptr,
size_t a_bytes,
size_t a_alignment)
noexcept override;
459 size_t a_bytes)
const noexcept override;
490 allocate(
size_t a_bytes,
size_t a_alignment)
override;
500 deallocate(
void* a_ptr,
size_t a_bytes,
size_t a_alignment)
noexcept override;
539 size_t a_bytes)
const noexcept override;
574 allocate(
size_t a_bytes,
size_t a_alignment)
override;
584 deallocate(
void* a_ptr,
size_t a_bytes,
size_t a_alignment)
noexcept override;
623 size_t a_bytes)
const noexcept override;
674#include "EBGeometry_MemoryResourceImplem.hpp"
Backend-neutral GPU runtime API layer (CUDA or HIP) plus the EBGEOMETRY_GPU_CHECK macro.
GPU portability layer: host/device decoration macros and backend detection.
#define EBGEOMETRY_HOST
Mark a function as callable from host code only (no-op on host compilers).
Definition EBGeometry_GPU.hpp:83
Utility macros for EBGeometry.
Device memory resource: raw device allocation (GPU::memAlloc / GPU::memFree).
Definition EBGeometry_MemoryResource.hpp:309
void deallocate(void *a_ptr, size_t a_bytes, size_t a_alignment) noexcept override
Free a block previously returned by allocate.
bool isDeviceAccessible() const noexcept override
Device blocks are device-accessible.
Definition EBGeometry_MemoryResource.hpp:359
~DeviceMemoryResource() override=default
Destructor.
void copy(void *a_dst, const MemoryResource &a_dstResource, const void *a_src, const MemoryResource &a_srcResource, size_t a_bytes) const noexcept override
Copy between host and device memory with the GPU runtime; see MemoryResource::copy.
bool isHostAccessible() const noexcept override
Device blocks are not host-accessible.
Definition EBGeometry_MemoryResource.hpp:348
void * allocate(size_t a_bytes, size_t a_alignment) override
Allocate a block of device memory.
DeviceMemoryResource()=default
Default constructor.
Host memory that stands in for device memory: host RAM that reports itself device-accessible.
Definition EBGeometry_MemoryResource.hpp:234
~EmulatedDeviceMemoryResource() override=default
Destructor.
bool isDeviceAccessible() const noexcept override
The blocks report themselves device-accessible, which is what makes them stand in for device memory.
Definition EBGeometry_MemoryResource.hpp:284
EmulatedDeviceMemoryResource()=default
Default constructor.
bool isHostAccessible() const noexcept override
The blocks are host memory.
Definition EBGeometry_MemoryResource.hpp:272
void deallocate(void *a_ptr, size_t a_bytes, size_t a_alignment) noexcept override
Free a block previously returned by allocate.
void * allocate(size_t a_bytes, size_t a_alignment) override
Allocate an aligned block of host memory.
Host memory resource: plain aligned allocation in host RAM (std::aligned_alloc / free family).
Definition EBGeometry_MemoryResource.hpp:159
void * allocate(size_t a_bytes, size_t a_alignment) override
Allocate an aligned block of host memory.
HostMemoryResource()=default
Default constructor.
void deallocate(void *a_ptr, size_t a_bytes, size_t a_alignment) noexcept override
Free a block previously returned by allocate.
~HostMemoryResource() override=default
Destructor.
bool isDeviceAccessible() const noexcept override
Host blocks are not device-accessible.
Definition EBGeometry_MemoryResource.hpp:208
bool isHostAccessible() const noexcept override
Host blocks are host-accessible.
Definition EBGeometry_MemoryResource.hpp:197
Managed (unified) memory resource: one allocation reachable from host and device (GPU::memAllocManage...
Definition EBGeometry_MemoryResource.hpp:390
~ManagedMemoryResource() override=default
Destructor.
void * allocate(size_t a_bytes, size_t a_alignment) override
Allocate a block of managed (unified) memory.
void copy(void *a_dst, const MemoryResource &a_dstResource, const void *a_src, const MemoryResource &a_srcResource, size_t a_bytes) const noexcept override
Copy between host and device memory with the GPU runtime; see MemoryResource::copy.
bool isHostAccessible() const noexcept override
Managed blocks are host-accessible.
Definition EBGeometry_MemoryResource.hpp:428
void deallocate(void *a_ptr, size_t a_bytes, size_t a_alignment) noexcept override
Free a block previously returned by allocate.
ManagedMemoryResource()=default
Default constructor.
bool isDeviceAccessible() const noexcept override
Managed blocks are device-accessible.
Definition EBGeometry_MemoryResource.hpp:439
Mapped (zero-copy) pinned host memory resource: page-locked host memory also mapped into the device a...
Definition EBGeometry_MemoryResource.hpp:554
void deallocate(void *a_ptr, size_t a_bytes, size_t a_alignment) noexcept override
Free a block previously returned by allocate.
~MappedMemoryResource() override=default
Destructor.
bool isDeviceAccessible() const noexcept override
Mapped blocks are device-accessible.
Definition EBGeometry_MemoryResource.hpp:603
MappedMemoryResource()=default
Default constructor.
bool isHostAccessible() const noexcept override
Mapped blocks are host-accessible.
Definition EBGeometry_MemoryResource.hpp:592
void copy(void *a_dst, const MemoryResource &a_dstResource, const void *a_src, const MemoryResource &a_srcResource, size_t a_bytes) const noexcept override
Copy between host and device memory with the GPU runtime; see MemoryResource::copy.
void * allocate(size_t a_bytes, size_t a_alignment) override
Allocate a block of mapped (zero-copy) pinned host memory.
Abstract placement policy: allocates and frees raw, correctly-aligned byte blocks.
Definition EBGeometry_MemoryResource.hpp:69
MemoryResource(const MemoryResource &)=delete
Copy constructor. Deleted: a resource's identity is meaningful and non-copyable.
virtual void copy(void *a_dst, const MemoryResource &a_dstResource, const void *a_src, const MemoryResource &a_srcResource, size_t a_bytes) const noexcept
Copy a block between memory from two resources, one of which is this one.
MemoryResource()=default
Default constructor.
virtual ~MemoryResource()=default
Destructor.
virtual void deallocate(void *a_ptr, size_t a_bytes, size_t a_alignment) noexcept=0
Release a block previously returned by allocate.
virtual bool isHostAccessible() const noexcept=0
Whether a plain host pointer dereference / std::memcpy is valid on returned blocks.
MemoryResource & operator=(const MemoryResource &)=delete
Copy assignment. Deleted: a resource's identity is meaningful and non-copyable.
virtual void * allocate(size_t a_bytes, size_t a_alignment)=0
Obtain a block of at least a_bytes bytes, aligned to a_alignment.
virtual bool isDeviceAccessible() const noexcept=0
Whether a device kernel may dereference returned blocks.
Pinned (page-locked) host memory resource: fast host-to-device staging (GPU::memAllocHost / GPU::memF...
Definition EBGeometry_MemoryResource.hpp:470
bool isDeviceAccessible() const noexcept override
Pinned blocks are not device-accessible.
Definition EBGeometry_MemoryResource.hpp:519
void * allocate(size_t a_bytes, size_t a_alignment) override
Allocate a block of page-locked host memory.
void deallocate(void *a_ptr, size_t a_bytes, size_t a_alignment) noexcept override
Free a block previously returned by allocate.
~PinnedMemoryResource() override=default
Destructor.
PinnedMemoryResource()=default
Default constructor.
bool isHostAccessible() const noexcept override
Pinned blocks are host-accessible.
Definition EBGeometry_MemoryResource.hpp:508
void copy(void *a_dst, const MemoryResource &a_dstResource, const void *a_src, const MemoryResource &a_srcResource, size_t a_bytes) const noexcept override
Copy between host and device memory with the GPU runtime; see MemoryResource::copy.
Namespace containing all of EBGeometry's functionality.
Definition EBGeometry_Affine.hpp:26
constexpr size_t PoolBaseAlign
Block-base alignment for every Pool, in bytes.
Definition EBGeometry_MemoryResource.hpp:52
ManagedMemoryResource & managedMemoryResource() noexcept
Process-wide default managed (unified) memory resource.
DeviceMemoryResource & deviceMemoryResource() noexcept
Process-wide default device memory resource.
MappedMemoryResource & mappedMemoryResource() noexcept
Process-wide default mapped (zero-copy) pinned host memory resource.
PinnedMemoryResource & pinnedMemoryResource() noexcept
Process-wide default pinned (page-locked) host memory resource.
HostMemoryResource & hostMemoryResource() noexcept
Process-wide default host memory resource.
EmulatedDeviceMemoryResource & emulatedDeviceMemoryResource() noexcept
Process-wide emulated device memory resource.