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

Building blocks for builds that run with GPU::parallelFor(): a bounding-box reduction, a bitonic sort and an exclusive scan. More...

#include <cmath>
#include <cstddef>
#include <cstdint>
#include <type_traits>
#include "EBGeometry_BoundingVolumes.hpp"
#include "EBGeometry_GPU.hpp"
#include "EBGeometry_GPURuntime.hpp"
#include "EBGeometry_GPUTransform.hpp"
#include "EBGeometry_Macros.hpp"
#include "EBGeometry_Math.hpp"
#include "EBGeometry_Vec.hpp"
Include dependency graph for EBGeometry_GPUAlgorithms.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  EBGeometry::GPU::AlgorithmsDetail::FromPointer< T >
 boundingBox()'s source for an array of points. More...
 
struct  EBGeometry::GPU::AlgorithmsDetail::ChunkBox< T, Source >
 boundingBox(), pass 1: the box of each chunk of points. More...
 
struct  EBGeometry::GPU::AlgorithmsDetail::MergeChunks< T >
 boundingBox(), pass 2: one thread merges the chunk boxes into chunk 0's. One thread is enough at the sizes the builds see (a few thousand chunks); a cloud near the 2^31-point limit would want a tree of merges. More...
 
struct  EBGeometry::GPU::AlgorithmsDetail::BitonicPass< Key, Less >
 bitonicSort(): one compare-exchange pass, one thread per pair. More...
 
struct  EBGeometry::GPU::AlgorithmsDetail::ChunkSums
 exclusiveScan(), pass 1: the sum of each chunk of values. More...
 
struct  EBGeometry::GPU::AlgorithmsDetail::ScanSums
 exclusiveScan(), pass 2: one thread turns the chunk sums into each chunk's offset, and the total after them. More...
 
struct  EBGeometry::GPU::AlgorithmsDetail::ScanChunks
 exclusiveScan(), pass 3: each chunk's values replaced by their exclusive prefix sums. More...
 
struct  EBGeometry::GPU::Ascending
 The order operator< gives, as a trivially copyable functor callable on a device. More...
 

Namespaces

namespace  EBGeometry
 Namespace containing all of EBGeometry's functionality.
 
namespace  EBGeometry::GPU
 Backend-neutral GPU runtime API surface (CUDA or HIP).
 
namespace  EBGeometry::GPU::AlgorithmsDetail
 The functors behind boundingBox() and bitonicSort().
 

Functions

uint32_t EBGeometry::GPU::exclusiveScanScratchSize (const uint32_t a_count) noexcept
 Scratch elements exclusiveScan() needs for a_count values: one per chunk, and one for the total.
 
uint32_t EBGeometry::GPU::boundingBoxScratchSize (const uint32_t a_count) noexcept
 Scratch elements boundingBox() needs for a_count points: two corners per chunk.
 
template<class T , class Source >
BoundingVolumes::AABBT< T > EBGeometry::GPU::boundingBoxOf (const Source &a_points, const uint32_t a_count, Vec3T< T > *a_scratch)
 The smallest box holding every point, from a source of points: one box per chunk of BoundingBoxChunk points, then one thread merging them.
 
template<class T >
BoundingVolumes::AABBT< T > EBGeometry::GPU::boundingBox (const Vec3T< T > *a_points, const uint32_t a_count, Vec3T< T > *a_scratch)
 The smallest box holding an array of points; see boundingBoxOf().
 
template<class Key , class Less = Ascending>
void EBGeometry::GPU::bitonicSort (Key *a_keys, const uint32_t a_count, const Less &a_less=Less())
 Sort a_count keys in place with a bitonic network: log2(n) (log2(n) + 1) / 2 passes of n / 2 compare-exchanges each.
 
uint32_t EBGeometry::GPU::exclusiveScan (uint32_t *a_values, const uint32_t a_count, uint32_t *a_scratch)
 Replace a_count values by their exclusive prefix sums, in place, and return their total: one sum per chunk of ScanChunk values, one thread scanning the sums, then each chunk scanned from its offset.
 

Variables

constexpr uint32_t EBGeometry::GPU::ScanChunk = 256
 Values per chunk in exclusiveScan()'s passes.
 
constexpr uint32_t EBGeometry::GPU::BoundingBoxChunk = 256
 Points per chunk in boundingBox()'s first pass.
 

Detailed Description

Building blocks for builds that run with GPU::parallelFor(): a bounding-box reduction, a bitonic sort and an exclusive scan.

Each runs one or more GPU::parallelFor() launches, so it runs on the device in a CUDA or HIP translation unit and as host loops otherwise, and returns once the work is done. The arrays they read and write must be memory the launch can reach: device-accessible in a CUDA or HIP build (device memory will do), and host memory otherwise. They use no atomics, so their results do not depend on thread scheduling.

Author
Robert Marskar