EBGeometry
Compact, header-only C++ library for fast evaluation of signed distance functions
Loading...
Searching...
No Matches
Public Member Functions | List of all members
EBGeometry::MappedMemoryResource Class Referencefinal

Mapped (zero-copy) pinned host memory resource: page-locked host memory also mapped into the device address space (GPU::memAllocHostMapped / GPU::memFreeHost). More...

#include <EBGeometry_MemoryResource.hpp>

Inheritance diagram for EBGeometry::MappedMemoryResource:
Inheritance graph
[legend]
Collaboration diagram for EBGeometry::MappedMemoryResource:
Collaboration graph
[legend]

Public Member Functions

 MappedMemoryResource ()=default
 Default constructor.
 
 ~MappedMemoryResource () override=default
 Destructor.
 
void * allocate (size_t a_bytes, size_t a_alignment) override
 Allocate a block of mapped (zero-copy) pinned host memory.
 
void deallocate (void *a_ptr, size_t a_bytes, size_t a_alignment) noexcept override
 Free a block previously returned by allocate.
 
bool isHostAccessible () const noexcept override
 Mapped blocks are host-accessible.
 
bool isDeviceAccessible () const noexcept override
 Mapped blocks are device-accessible.
 
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.
 
- Public Member Functions inherited from EBGeometry::MemoryResource
 MemoryResource ()=default
 Default constructor.
 
virtual ~MemoryResource ()=default
 Destructor.
 
 MemoryResource (const MemoryResource &)=delete
 Copy constructor. Deleted: a resource's identity is meaningful and non-copyable.
 
MemoryResource & operator= (const MemoryResource &)=delete
 Copy assignment. Deleted: a resource's identity is meaningful and non-copyable.
 

Detailed Description

Mapped (zero-copy) pinned host memory resource: page-locked host memory also mapped into the device address space (GPU::memAllocHostMapped / GPU::memFreeHost).

Compiled only under an offload backend (CUDA/HIP) or for documentation. Blocks are both host- and device-accessible: the same base pointer is dereferenced by the CPU and by a kernel, which reaches it over the host/device interconnect on each access. Unlike ManagedMemoryResource there is no page migration – the block stays in host RAM and the device reads it in place, which suits small or write-once/streamed data rather than hot, reused data. Requires unified virtual addressing (all 64-bit CUDA; HIP under HSA) so the host pointer is directly valid on the device.

Member Function Documentation

◆ allocate()

void * EBGeometry::MappedMemoryResource::allocate ( size_t  a_bytes,
size_t  a_alignment 
)
overridevirtual

Allocate a block of mapped (zero-copy) pinned host memory.

Parameters
[in]a_bytesNumber of bytes to allocate.
[in]a_alignmentRequired alignment (validated to be <= PoolBaseAlign).
Returns
Host pointer to the mapped block (never null on success; aborts on failure).

Implements EBGeometry::MemoryResource.

◆ copy()

void EBGeometry::MappedMemoryResource::copy ( void *  a_dst,
const MemoryResource &  a_dstResource,
const void *  a_src,
const MemoryResource &  a_srcResource,
size_t  a_bytes 
) const
overridevirtualnoexcept

Copy between host and device memory with the GPU runtime; see MemoryResource::copy.

Host-to-host is a plain copy; device-to-device aborts, in every build.

Parameters
[out]a_dstDestination block.
[in]a_dstResourceResource that allocated a_dst.
[in]a_srcSource block.
[in]a_srcResourceResource that allocated a_src.
[in]a_bytesNumber of bytes to copy.

Reimplemented from EBGeometry::MemoryResource.

◆ deallocate()

void EBGeometry::MappedMemoryResource::deallocate ( void *  a_ptr,
size_t  a_bytes,
size_t  a_alignment 
)
overridevirtualnoexcept

Free a block previously returned by allocate.

Parameters
[in]a_ptrHost pointer to free (null is a no-op).
[in]a_bytesUnused.
[in]a_alignmentUnused.

Implements EBGeometry::MemoryResource.

◆ isDeviceAccessible()

bool EBGeometry::MappedMemoryResource::isDeviceAccessible ( ) const
inlineoverridevirtualnoexcept

Mapped blocks are device-accessible.

Returns
Always true.

Implements EBGeometry::MemoryResource.

◆ isHostAccessible()

bool EBGeometry::MappedMemoryResource::isHostAccessible ( ) const
inlineoverridevirtualnoexcept

Mapped blocks are host-accessible.

Returns
Always true.

Implements EBGeometry::MemoryResource.


The documentation for this class was generated from the following file: