mirror of
https://gitlab.kitware.com/vtk/vtk-m
synced 2024-09-16 17:22:55 +00:00
c9bcdd0195
Create a `VaraintUnion` that is an actual C++ `union` to store the data in a `Variant`. You may be asking yourself, why not just use an `std::aligned_union` rather than a real union type? That was our first implementation, but the problem is that the `std::aligned_union` reference needs to be recast to the actual type. Typically you would do that with `reinterpret_cast`. However, doing that leads to undefined behavior. The C++ compiler assumes that 2 pointers of different types point to different memory (even if it is clear that they are set to the same address). That means optimizers can remove code because it "knows" that data in one type cannot affect data in another type. To safely change the type of an `std::aligned_union`, you really have to do an `std::memcpy`. This is problematic for types that cannot be trivially copied. Another problem is that we found that device compilers do not optimize the memcpy as well as most CPU compilers. Likely, memcpy is used much less frequently on GPU devices. |
||
---|---|---|
.. | ||
arg | ||
cuda | ||
internal | ||
kokkos | ||
openmp | ||
serial | ||
tbb | ||
testing | ||
AtomicArrayExecutionObject.h | ||
BoundaryState.h | ||
CellDerivative.h | ||
CellEdge.h | ||
CellFace.h | ||
CellInside.h | ||
CellInterpolate.h | ||
CellLocator.h | ||
CellLocatorBoundingIntervalHierarchy.h | ||
CellLocatorMultiplexer.h | ||
CellLocatorRectilinearGrid.h | ||
CellLocatorTwoLevel.h | ||
CellLocatorUniformGrid.h | ||
CellMeasure.h | ||
CMakeLists.txt | ||
ColorTable.h | ||
ColorTable.hxx | ||
ConnectivityExplicit.h | ||
ConnectivityExtrude.h | ||
ConnectivityPermuted.h | ||
ConnectivityStructured.h | ||
ExecutionWholeArray.h | ||
FieldNeighborhood.h | ||
FunctorBase.h | ||
ParametricCoordinates.h | ||
PointLocator.h | ||
PointLocatorSparseGrid.h | ||
TaskBase.h |