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::EmulatedDeviceMemoryResource Class Referencefinal

Host memory that stands in for device memory: host RAM that reports itself device-accessible. More...

#include <EBGeometry_MemoryResource.hpp>

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

Public Member Functions

 EmulatedDeviceMemoryResource ()=default
 Default constructor.
 
 ~EmulatedDeviceMemoryResource () override=default
 Destructor.
 
void * allocate (size_t a_bytes, size_t a_alignment) override
 Allocate an aligned block of 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
 The blocks are host memory.
 
bool isDeviceAccessible () const noexcept override
 The blocks report themselves device-accessible, which is what makes them stand in for device memory.
 
- 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.
 
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.
 

Detailed Description

Host memory that stands in for device memory: host RAM that reports itself device-accessible.

Always compiled, on every backend. A pool mirrored into it is a host copy, but a rebasedView() onto that copy takes the device-view path (a snapshot of the location, no control block), exactly as it would onto a mirror in device memory. Code that mirrors, rebases and runs a query through GPU::transform() therefore runs unchanged in a plain C++ build, where GPU::transform() is a host loop. Use it through GPU::memoryResource(), which picks device memory in a CUDA or HIP build and this resource otherwise. Never hand memory from it to a real kernel: it is host memory.

Member Function Documentation

◆ allocate()

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

Allocate an aligned block of host memory.

Parameters
[in]a_bytesNumber of bytes to allocate.
[in]a_alignmentRequired alignment in bytes (power of two).
Returns
Pointer to the allocated host block (never null on success).

Implements EBGeometry::MemoryResource.

◆ deallocate()

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

Free a block previously returned by allocate.

Parameters
[in]a_ptrPointer to free (null is a no-op).
[in]a_bytesSize passed to allocate.
[in]a_alignmentAlignment passed to allocate.

Implements EBGeometry::MemoryResource.

◆ isDeviceAccessible()

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

The blocks report themselves device-accessible, which is what makes them stand in for device memory.

Returns
Always true.

Implements EBGeometry::MemoryResource.

◆ isHostAccessible()

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

The blocks are host memory.

Returns
Always true.

Implements EBGeometry::MemoryResource.


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