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

Growable bump arena for the GPU memory foundation. More...

#include <atomic>
#include <cstddef>
#include <cstdint>
#include <memory>
#include <type_traits>
#include "EBGeometry_GPU.hpp"
#include "EBGeometry_Macros.hpp"
#include "EBGeometry_MemoryResource.hpp"
#include "EBGeometry_PoolImplem.hpp"
Include dependency graph for EBGeometry_Pool.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  EBGeometry::PoolControl
 Stable, heap-resident handle to a Pool's current base address and identity. More...
 
struct  EBGeometry::PoolLocation
 Where a pool-resident descriptor resolves its offsets, and the rules for moving it. More...
 
class  EBGeometry::Pool
 Growable bump arena over a MemoryResource. More...
 
class  EBGeometry::PoolHandle
 Base of every pool-resident handle: the one PoolLocation its arrays resolve against. More...
 

Namespaces

namespace  EBGeometry
 Namespace containing all of EBGeometry's functionality.
 

Variables

template<class P >
constexpr bool EBGeometry::isPoolHandle = std::is_base_of_v<PoolHandle, P>
 Whether P is a pool-resident handle (derives from PoolHandle).
 

Detailed Description

Growable bump arena for the GPU memory foundation.

A EBGeometry::Pool is a single contiguous byte block obtained from a EBGeometry::MemoryResource, into which many sub-regions are bump-reserved and from which nothing is individually freed.

Building and querying are not separate phases. EBGeometry::Pool::reserve hands out byte offsets and may grow (reallocate and move) the block at any time. Because every EBGeometry::PODVector stores a byte offset rather than a pointer, and pool-resident objects re-read the base through the pool's EBGeometry::PoolControl on every access, a grow invalidates no EBGeometry::PODVector and no such object: an object is queryable as soon as it is built, while the same pool keeps being built into. What a grow does invalidate is any address already resolved against the old base (a pointer, reference or EBGeometry::PODSpan), hence the rule resolve, use, discard – see EBGeometry::Pool::reserve.

EBGeometry::Pool::freeze seals the pool (a further reserve aborts, in every build) and is the precondition for EBGeometry::Pool::mirror, which copies the whole block (one memcpy) into another resource – the host-to-device upload. The same offsets resolve against the new base with zero pointer patching. Freezing is not required to query anything.

The EBGeometry::Pool is the one owning, move-only, RAII (hence non-trivial) type of the foundation; everything stored inside it is trivially copyable POD.

Author
Robert Marskar