|
FEAT 3
Finite Element Analysis Toolbox
|
Owns the device-resident cubature (points + weights) of a voxel assembler. More...
#include <voxel_assembly_common.hpp>
Public Member Functions | |
| DeviceCubature (const DeviceCubature &)=delete | |
| DeviceCubature (DeviceCubature &&)=default | |
| AssemblyCubatureData< DT_ > | device_data () const |
| Returns the device-side view of the cached cubature. More... | |
| DeviceCubature & | operator= (const DeviceCubature &)=delete |
| DeviceCubature & | operator= (DeviceCubature &&)=default |
| void | update (const PointType_ *pts, const DT_ *wgs, int num_cubs) |
| Uploads the cubature into the cached host buffers if it changed. More... | |
Private Attributes | |
| int | _num_cubs = 0 |
| number of cubature points currently cached (0 = nothing uploaded yet) More... | |
| Memory::Arbiter | _points |
| device/host buffer for the cubature points More... | |
| Memory::Arbiter | _weights |
| device/host buffer for the cubature weights More... | |
Owns the device-resident cubature (points + weights) of a voxel assembler.
The cubature points and weights are held in two Memory::Arbiter buffers, which manage the host/device (main/cuda) synchronization for us. The cubature data is written into the arbiters' host memory (see update()) and pulled to the device on demand by acquiring a cuda read view (see device_data()). Because the arbiter sources the host->device copy from its own persistent host buffer - rather than from the transient stack-local Cubature::Rule the assemble entry points build - the upload stays valid even when the batched assembly runs asynchronously (no end-of-kernel synchronization, stream-ordered frees). Reusing the buffers across assembly calls also avoids the per-call device alloc/free churn.
| DT_ | The data type of the cubature weights. |
| PointType_ | The cubature point type (e.g. Tiny::Vector<DT_, dim>). |
Definition at line 110 of file voxel_assembly_common.hpp.
|
inline |
Returns the device-side view of the cached cubature.
Acquiring the cuda read views performs the host->device copy (from the arbiters' persistent host memory) when the device copy is not yet up to date, and is a no-op otherwise. The returned raw device pointers remain valid after the temporary views are released, for as long as this object (and thus the arbiters) is alive and not re-uploaded (and reuploading requires a stream synchronization, so this should be save).
Definition at line 165 of file voxel_assembly_common.hpp.
References FEAT::VoxelAssembly::DeviceCubature< DT_, PointType_ >::_num_cubs, FEAT::VoxelAssembly::DeviceCubature< DT_, PointType_ >::_points, FEAT::VoxelAssembly::DeviceCubature< DT_, PointType_ >::_weights, FEAT::Memory::cuda, and FEAT::Memory::read.
|
inline |
Uploads the cubature into the cached host buffers if it changed.
Reuses the cached upload when the cubature is unchanged (keyed on the point count, which is constant for a given assembler instance in practice). On a change, fresh arbiters are allocated - releasing the previous ones through the blocking device free, which drains any still-pending asynchronous copy - and the new cubature is written synchronously into the arbiters' own (persistent) host memory. The device copy is (re)synchronized lazily by device_data(). The unchanged path performs no host write, so it can never race an in-flight asynchronous host->device copy of the same buffer.
| [in] | pts | A transient pointer to the num_cubs cubature points. |
| [in] | wgs | A transient pointer to the num_cubs cubature weights. |
| [in] | num_cubs | The number of cubature points. |
Definition at line 144 of file voxel_assembly_common.hpp.
References FEAT::VoxelAssembly::DeviceCubature< DT_, PointType_ >::_num_cubs, FEAT::VoxelAssembly::DeviceCubature< DT_, PointType_ >::_points, FEAT::VoxelAssembly::DeviceCubature< DT_, PointType_ >::_weights, FEAT::Memory::Arbiter::copy(), and FEAT::Memory::main.
|
private |
number of cubature points currently cached (0 = nothing uploaded yet)
Definition at line 118 of file voxel_assembly_common.hpp.
Referenced by FEAT::VoxelAssembly::DeviceCubature< DT_, PointType_ >::device_data(), and FEAT::VoxelAssembly::DeviceCubature< DT_, PointType_ >::update().
|
private |
device/host buffer for the cubature points
Definition at line 114 of file voxel_assembly_common.hpp.
Referenced by FEAT::VoxelAssembly::DeviceCubature< DT_, PointType_ >::device_data(), and FEAT::VoxelAssembly::DeviceCubature< DT_, PointType_ >::update().
|
private |
device/host buffer for the cubature weights
Definition at line 116 of file voxel_assembly_common.hpp.
Referenced by FEAT::VoxelAssembly::DeviceCubature< DT_, PointType_ >::device_data(), and FEAT::VoxelAssembly::DeviceCubature< DT_, PointType_ >::update().