EBGeometry
Compact, header-only C++ library for fast evaluation of signed distance functions
Loading...
Searching...
No Matches
Functions
EBGeometry::TriangleSoA Namespace Reference

Namespace for TriangleSoAT-related compile-time utilities. More...

Functions

template<typename T >
constexpr size_t HostWidth () noexcept
 The SoA width W (triangles per TriangleSoAT group) that fills one SIMD register for type T under the compiler's SIMD flags.
 
template<typename T >
constexpr size_t DefaultWidth () noexcept
 The default SoA width W (triangles per TriangleSoAT group): 4, or HostWidth<T>() in a build that defines EBGEOMETRY_HOST_TUNED_DEFAULTS.
 

Detailed Description

Namespace for TriangleSoAT-related compile-time utilities.

Function Documentation

◆ DefaultWidth()

template<typename T >
constexpr size_t EBGeometry::TriangleSoA::DefaultWidth ( )
constexprnoexcept

The default SoA width W (triangles per TriangleSoAT group): 4, or HostWidth<T>() in a build that defines EBGEOMETRY_HOST_TUNED_DEFAULTS.

This is the value the library's class templates default to.

By default it is 4 for both float and double and never depends on compiler flags, so a type spelled with it has the same layout in a host-only file, in a file compiled with AVX, and in both passes of a CUDA or HIP compile – which is what lets an object be built on the host and used on a device.

A host-only build can define EBGEOMETRY_HOST_TUNED_DEFAULTS to make it return HostWidth<T>() instead, the width that fills one SIMD register under the compiler's flags (8 for float under AVX, for example): a wider group evaluates more triangles per instruction, which measured up to about 20% faster TriMeshSDF queries in float. The macro changes this width only; the branching factor and the point-group width stay 4, since widening them measured no faster, and slower under AVX-512. The macro must be defined for every translation unit of the build, all compiled with the same SIMD flags, or the same spelled type has different layouts in different files. It is a compile error in a CUDA or HIP translation unit. EBGeometry's own CMake build defines it when EBGeometry is the top-level project and no GPU backend is enabled.

Measured (200,000 queries, best of three; TriMeshSDF on the 100k-triangle armadillo, PointCloudBVH on a 200,000-point random cloud): on AVX2 in float, W = 8 took TriMeshSDF from 0.531 s to 0.438 s, K = 8 changed nothing, and PointCloudBVH was unchanged. On an AVX-512 machine (runs varied by up to 15%): float TriMeshSDF 1.81 s, 1.85 s at W = 16, 3.51 s at K = 16; float PointCloudBVH 0.175 s, 0.220 s at W = 16, 0.386 s at K = 16; double TriMeshSDF 3.06 s, 2.62 s at W = 8, 3.95 s at K = 8; double PointCloudBVH 0.354 s, 0.352 s at W = 8, 0.380 s at K = 8. On one AVX2 core, host vectorization is worth about 3.4 times for float TriMeshSDF.

Usage: size_t W = TriangleSoA::DefaultWidth<T>() as a template-parameter default.

Template Parameters
TFloating-point precision type (float or double).
Returns
4, or HostWidth<T>() under EBGEOMETRY_HOST_TUNED_DEFAULTS.

◆ HostWidth()

template<typename T >
constexpr size_t EBGeometry::TriangleSoA::HostWidth ( )
constexprnoexcept

The SoA width W (triangles per TriangleSoAT group) that fills one SIMD register for type T under the compiler's SIMD flags.

Opt-in, for host-only code:

ISA T=float T=double
AVX-512F 16 8
AVX 8 4
otherwise 4 4

The value depends on the flags each translation unit is compiled with, so a type spelled with it can mean different types in different files, and different layouts in the host and device passes of one CUDA or HIP compile. Never use it for a type that is shared with device code or with another translation unit built with different flags; use DefaultWidth<T>() there.

Template Parameters
TFloating-point precision type (float or double).
Returns
W for T under the current ISA.