mirror of
https://gitlab.kitware.com/vtk/vtk-m
synced 2024-10-08 03:18:58 +00:00
Expose the Variant helper class
For several versions, VTK-m has had a `Variant` templated class. This acts like a templated union where the object will store one of a list of types specified as the template arguments. (There are actually 2 versions for the control and execution environments, respectively.) Because this is a complex class that required several iterations to work through performance and compiler issues, `Variant` was placed in the `internal` namespace to avoid complications with backward compatibility. However, the class has been stable for a while, so let us expose this helpful tool for wider use.
This commit is contained in:
parent
ef3c4c65c9
commit
c029ac113d
12
docs/changelog/expose-variant.md
Normal file
12
docs/changelog/expose-variant.md
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
# Expose the Variant helper class
|
||||||
|
|
||||||
|
For several versions, VTK-m has had a `Variant` templated class. This acts
|
||||||
|
like a templated union where the object will store one of a list of types
|
||||||
|
specified as the template arguments. (There are actually 2 versions for the
|
||||||
|
control and execution environments, respectively.)
|
||||||
|
|
||||||
|
Because this is a complex class that required several iterations to work
|
||||||
|
through performance and compiler issues, `Variant` was placed in the
|
||||||
|
`internal` namespace to avoid complications with backward compatibility.
|
||||||
|
However, the class has been stable for a while, so let us expose this
|
||||||
|
helpful tool for wider use.
|
@ -15,7 +15,7 @@
|
|||||||
#include <vtkm/Math.h>
|
#include <vtkm/Math.h>
|
||||||
#include <vtkm/VectorAnalysis.h>
|
#include <vtkm/VectorAnalysis.h>
|
||||||
|
|
||||||
#include <vtkm/exec/internal/Variant.h>
|
#include <vtkm/exec/Variant.h>
|
||||||
|
|
||||||
// For interface class only.
|
// For interface class only.
|
||||||
#include <vtkm/cont/ExecutionAndControlObjectBase.h>
|
#include <vtkm/cont/ExecutionAndControlObjectBase.h>
|
||||||
@ -729,7 +729,7 @@ class ImplicitFunctionMultiplexer
|
|||||||
: public vtkm::internal::ImplicitFunctionBase<
|
: public vtkm::internal::ImplicitFunctionBase<
|
||||||
ImplicitFunctionMultiplexer<ImplicitFunctionTypes...>>
|
ImplicitFunctionMultiplexer<ImplicitFunctionTypes...>>
|
||||||
{
|
{
|
||||||
vtkm::exec::internal::Variant<ImplicitFunctionTypes...> Variant;
|
vtkm::exec::Variant<ImplicitFunctionTypes...> Variant;
|
||||||
|
|
||||||
using Superclass =
|
using Superclass =
|
||||||
vtkm::internal::ImplicitFunctionBase<ImplicitFunctionMultiplexer<ImplicitFunctionTypes...>>;
|
vtkm::internal::ImplicitFunctionBase<ImplicitFunctionMultiplexer<ImplicitFunctionTypes...>>;
|
||||||
|
@ -19,8 +19,8 @@
|
|||||||
#include <vtkm/cont/ArrayHandleCast.h>
|
#include <vtkm/cont/ArrayHandleCast.h>
|
||||||
#include <vtkm/cont/ArrayHandleUniformPointCoordinates.h>
|
#include <vtkm/cont/ArrayHandleUniformPointCoordinates.h>
|
||||||
|
|
||||||
#include <vtkm/cont/internal/Variant.h>
|
#include <vtkm/cont/Variant.h>
|
||||||
#include <vtkm/exec/internal/Variant.h>
|
#include <vtkm/exec/Variant.h>
|
||||||
|
|
||||||
namespace vtkm
|
namespace vtkm
|
||||||
{
|
{
|
||||||
@ -90,7 +90,7 @@ private:
|
|||||||
template <typename... PortalTypes>
|
template <typename... PortalTypes>
|
||||||
struct ArrayPortalMultiplexer
|
struct ArrayPortalMultiplexer
|
||||||
{
|
{
|
||||||
using PortalVariantType = vtkm::exec::internal::Variant<PortalTypes...>;
|
using PortalVariantType = vtkm::exec::Variant<PortalTypes...>;
|
||||||
PortalVariantType PortalVariant;
|
PortalVariantType PortalVariant;
|
||||||
|
|
||||||
using ValueType = typename PortalVariantType::template TypeAt<0>::ValueType;
|
using ValueType = typename PortalVariantType::template TypeAt<0>::ValueType;
|
||||||
@ -214,7 +214,7 @@ struct MultiplexerCreateWritePortalFunctor
|
|||||||
template <typename T, typename... Ss>
|
template <typename T, typename... Ss>
|
||||||
struct MultiplexerArrayHandleVariantFunctor
|
struct MultiplexerArrayHandleVariantFunctor
|
||||||
{
|
{
|
||||||
using VariantType = vtkm::cont::internal::Variant<vtkm::cont::ArrayHandle<T, Ss>...>;
|
using VariantType = vtkm::cont::Variant<vtkm::cont::ArrayHandle<T, Ss>...>;
|
||||||
|
|
||||||
template <typename StorageTag>
|
template <typename StorageTag>
|
||||||
VTKM_CONT VariantType operator()(vtkm::cont::internal::Storage<T, StorageTag>,
|
VTKM_CONT VariantType operator()(vtkm::cont::internal::Storage<T, StorageTag>,
|
||||||
@ -232,7 +232,7 @@ class Storage<ValueType, StorageTagMultiplexer<StorageTags...>>
|
|||||||
template <typename S>
|
template <typename S>
|
||||||
using StorageFor = vtkm::cont::internal::Storage<ValueType, S>;
|
using StorageFor = vtkm::cont::internal::Storage<ValueType, S>;
|
||||||
|
|
||||||
using StorageVariant = vtkm::cont::internal::Variant<StorageFor<StorageTags>...>;
|
using StorageVariant = vtkm::cont::Variant<StorageFor<StorageTags>...>;
|
||||||
|
|
||||||
VTKM_CONT static StorageVariant Variant(const std::vector<vtkm::cont::internal::Buffer>& buffers)
|
VTKM_CONT static StorageVariant Variant(const std::vector<vtkm::cont::internal::Buffer>& buffers)
|
||||||
{
|
{
|
||||||
|
@ -125,6 +125,7 @@ set(headers
|
|||||||
UncertainCellSet.h
|
UncertainCellSet.h
|
||||||
UnknownArrayHandle.h
|
UnknownArrayHandle.h
|
||||||
UnknownCellSet.h
|
UnknownCellSet.h
|
||||||
|
Variant.h
|
||||||
VariantArrayHandle.h # Deprecated, replaces with Unknown/UncertainArrayHandle.h
|
VariantArrayHandle.h # Deprecated, replaces with Unknown/UncertainArrayHandle.h
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
|
|
||||||
#include <vtkm/exec/CellLocatorMultiplexer.h>
|
#include <vtkm/exec/CellLocatorMultiplexer.h>
|
||||||
|
|
||||||
#include <vtkm/cont/internal/Variant.h>
|
#include <vtkm/cont/Variant.h>
|
||||||
|
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
@ -60,7 +60,7 @@ public:
|
|||||||
vtkm::cont::Token& token) const;
|
vtkm::cont::Token& token) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
vtkm::cont::internal::ListAsVariant<ContLocatorList> LocatorImpl;
|
vtkm::cont::ListAsVariant<ContLocatorList> LocatorImpl;
|
||||||
|
|
||||||
friend Superclass;
|
friend Superclass;
|
||||||
VTKM_CONT void Build();
|
VTKM_CONT void Build();
|
||||||
|
@ -41,7 +41,6 @@ set(headers
|
|||||||
RuntimeDeviceOption.h
|
RuntimeDeviceOption.h
|
||||||
StorageDeprecated.h
|
StorageDeprecated.h
|
||||||
StorageError.h
|
StorageError.h
|
||||||
Variant.h
|
|
||||||
)
|
)
|
||||||
|
|
||||||
vtkm_declare_headers(${headers})
|
vtkm_declare_headers(${headers})
|
||||||
|
@ -32,6 +32,7 @@ set(headers
|
|||||||
ParametricCoordinates.h
|
ParametricCoordinates.h
|
||||||
PointLocatorSparseGrid.h
|
PointLocatorSparseGrid.h
|
||||||
TaskBase.h
|
TaskBase.h
|
||||||
|
Variant.h
|
||||||
)
|
)
|
||||||
|
|
||||||
set(header_impls
|
set(header_impls
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
#include <vtkm/ErrorCode.h>
|
#include <vtkm/ErrorCode.h>
|
||||||
#include <vtkm/TypeList.h>
|
#include <vtkm/TypeList.h>
|
||||||
|
|
||||||
#include <vtkm/exec/internal/Variant.h>
|
#include <vtkm/exec/Variant.h>
|
||||||
|
|
||||||
namespace vtkm
|
namespace vtkm
|
||||||
{
|
{
|
||||||
@ -55,12 +55,12 @@ struct FindCellFunctor
|
|||||||
template <typename... LocatorTypes>
|
template <typename... LocatorTypes>
|
||||||
class VTKM_ALWAYS_EXPORT CellLocatorMultiplexer
|
class VTKM_ALWAYS_EXPORT CellLocatorMultiplexer
|
||||||
{
|
{
|
||||||
vtkm::exec::internal::Variant<LocatorTypes...> Locators;
|
vtkm::exec::Variant<LocatorTypes...> Locators;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CellLocatorMultiplexer() = default;
|
CellLocatorMultiplexer() = default;
|
||||||
|
|
||||||
using LastCell = vtkm::exec::internal::Variant<typename LocatorTypes::LastCell...>;
|
using LastCell = vtkm::exec::Variant<typename LocatorTypes::LastCell...>;
|
||||||
|
|
||||||
template <typename Locator>
|
template <typename Locator>
|
||||||
VTKM_CONT CellLocatorMultiplexer(const Locator& locator)
|
VTKM_CONT CellLocatorMultiplexer(const Locator& locator)
|
||||||
|
@ -14,7 +14,6 @@ set(headers
|
|||||||
ReduceByKeyLookup.h
|
ReduceByKeyLookup.h
|
||||||
TaskSingular.h
|
TaskSingular.h
|
||||||
TwoLevelUniformGridExecutionObject.h
|
TwoLevelUniformGridExecutionObject.h
|
||||||
Variant.h
|
|
||||||
WorkletInvokeFunctorDetail.h
|
WorkletInvokeFunctorDetail.h
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
// PURPOSE. See the above copyright notice for more information.
|
// PURPOSE. See the above copyright notice for more information.
|
||||||
//============================================================================
|
//============================================================================
|
||||||
|
|
||||||
#include <vtkm/exec/internal/Variant.h>
|
#include <vtkm/exec/Variant.h>
|
||||||
|
|
||||||
#include <vtkm/testing/Testing.h>
|
#include <vtkm/testing/Testing.h>
|
||||||
|
|
||||||
@ -93,7 +93,7 @@ void TestSize()
|
|||||||
{
|
{
|
||||||
std::cout << "Test size" << std::endl;
|
std::cout << "Test size" << std::endl;
|
||||||
|
|
||||||
using VariantType = vtkm::exec::internal::Variant<float, double, char, short, int, long>;
|
using VariantType = vtkm::exec::Variant<float, double, char, short, int, long>;
|
||||||
|
|
||||||
constexpr size_t variantSize = sizeof(VariantType);
|
constexpr size_t variantSize = sizeof(VariantType);
|
||||||
|
|
||||||
@ -106,36 +106,36 @@ void TestIndexing()
|
|||||||
{
|
{
|
||||||
std::cout << "Test indexing" << std::endl;
|
std::cout << "Test indexing" << std::endl;
|
||||||
|
|
||||||
using VariantType = vtkm::exec::internal::Variant<TypePlaceholder<0>,
|
using VariantType = vtkm::exec::Variant<TypePlaceholder<0>,
|
||||||
TypePlaceholder<1>,
|
TypePlaceholder<1>,
|
||||||
TypePlaceholder<2>,
|
TypePlaceholder<2>,
|
||||||
TypePlaceholder<3>,
|
TypePlaceholder<3>,
|
||||||
TypePlaceholder<4>,
|
TypePlaceholder<4>,
|
||||||
TypePlaceholder<5>,
|
TypePlaceholder<5>,
|
||||||
TypePlaceholder<6>,
|
TypePlaceholder<6>,
|
||||||
TypePlaceholder<7>,
|
TypePlaceholder<7>,
|
||||||
TypePlaceholder<8>,
|
TypePlaceholder<8>,
|
||||||
TypePlaceholder<9>,
|
TypePlaceholder<9>,
|
||||||
TypePlaceholder<10>,
|
TypePlaceholder<10>,
|
||||||
TypePlaceholder<11>,
|
TypePlaceholder<11>,
|
||||||
TypePlaceholder<12>,
|
TypePlaceholder<12>,
|
||||||
TypePlaceholder<13>,
|
TypePlaceholder<13>,
|
||||||
TypePlaceholder<14>,
|
TypePlaceholder<14>,
|
||||||
TypePlaceholder<15>,
|
TypePlaceholder<15>,
|
||||||
TypePlaceholder<16>,
|
TypePlaceholder<16>,
|
||||||
TypePlaceholder<17>,
|
TypePlaceholder<17>,
|
||||||
TypePlaceholder<18>,
|
TypePlaceholder<18>,
|
||||||
TypePlaceholder<19>,
|
TypePlaceholder<19>,
|
||||||
TypePlaceholder<20>,
|
TypePlaceholder<20>,
|
||||||
TypePlaceholder<21>,
|
TypePlaceholder<21>,
|
||||||
TypePlaceholder<22>,
|
TypePlaceholder<22>,
|
||||||
TypePlaceholder<23>,
|
TypePlaceholder<23>,
|
||||||
TypePlaceholder<24>,
|
TypePlaceholder<24>,
|
||||||
TypePlaceholder<25>,
|
TypePlaceholder<25>,
|
||||||
TypePlaceholder<26>,
|
TypePlaceholder<26>,
|
||||||
TypePlaceholder<27>,
|
TypePlaceholder<27>,
|
||||||
TypePlaceholder<28>,
|
TypePlaceholder<28>,
|
||||||
TypePlaceholder<29>>;
|
TypePlaceholder<29>>;
|
||||||
|
|
||||||
VariantType variant;
|
VariantType variant;
|
||||||
|
|
||||||
@ -256,51 +256,48 @@ void TestTriviallyCopyable()
|
|||||||
VTKM_STATIC_ASSERT(!vtkmstd::is_trivial<TrivialCopy>::value);
|
VTKM_STATIC_ASSERT(!vtkmstd::is_trivial<TrivialCopy>::value);
|
||||||
|
|
||||||
// A variant of trivially constructable things should be trivially constructable
|
// A variant of trivially constructable things should be trivially constructable
|
||||||
VTKM_STATIC_ASSERT((vtkmstd::is_trivially_constructible<
|
|
||||||
vtkm::exec::internal::detail::VariantUnion<float, int>>::value));
|
|
||||||
VTKM_STATIC_ASSERT(
|
VTKM_STATIC_ASSERT(
|
||||||
(vtkmstd::is_trivially_constructible<vtkm::exec::internal::Variant<float, int>>::value));
|
(vtkmstd::is_trivially_constructible<vtkm::exec::detail::VariantUnion<float, int>>::value));
|
||||||
|
VTKM_STATIC_ASSERT((vtkmstd::is_trivially_constructible<vtkm::exec::Variant<float, int>>::value));
|
||||||
|
|
||||||
// A variant of trivially copyable things should be trivially copyable
|
// A variant of trivially copyable things should be trivially copyable
|
||||||
VTKM_STATIC_ASSERT((vtkmstd::is_trivially_copyable<
|
VTKM_STATIC_ASSERT((vtkmstd::is_trivially_copyable<
|
||||||
vtkm::exec::internal::detail::VariantUnion<float, int, TrivialCopy>>::value));
|
vtkm::exec::detail::VariantUnion<float, int, TrivialCopy>>::value));
|
||||||
VTKM_STATIC_ASSERT((
|
VTKM_STATIC_ASSERT(
|
||||||
vtkmstd::is_trivially_copyable<vtkm::exec::internal::Variant<float, int, TrivialCopy>>::value));
|
(vtkmstd::is_trivially_copyable<vtkm::exec::Variant<float, int, TrivialCopy>>::value));
|
||||||
|
|
||||||
// A variant of any non-trivially constructable things is not trivially copyable
|
// A variant of any non-trivially constructable things is not trivially copyable
|
||||||
VTKM_STATIC_ASSERT((!vtkmstd::is_trivially_constructible<
|
VTKM_STATIC_ASSERT((!vtkmstd::is_trivially_constructible<
|
||||||
vtkm::exec::internal::detail::VariantUnion<NonTrivial, float, int>>::value));
|
vtkm::exec::detail::VariantUnion<NonTrivial, float, int>>::value));
|
||||||
VTKM_STATIC_ASSERT((!vtkmstd::is_trivially_constructible<
|
VTKM_STATIC_ASSERT((!vtkmstd::is_trivially_constructible<
|
||||||
vtkm::exec::internal::detail::VariantUnion<float, NonTrivial, int>>::value));
|
vtkm::exec::detail::VariantUnion<float, NonTrivial, int>>::value));
|
||||||
VTKM_STATIC_ASSERT((!vtkmstd::is_trivially_constructible<
|
VTKM_STATIC_ASSERT((!vtkmstd::is_trivially_constructible<
|
||||||
vtkm::exec::internal::detail::VariantUnion<float, int, NonTrivial>>::value));
|
vtkm::exec::detail::VariantUnion<float, int, NonTrivial>>::value));
|
||||||
VTKM_STATIC_ASSERT((!vtkmstd::is_trivially_constructible<
|
VTKM_STATIC_ASSERT(
|
||||||
vtkm::exec::internal::Variant<NonTrivial, float, int>>::value));
|
(!vtkmstd::is_trivially_constructible<vtkm::exec::Variant<NonTrivial, float, int>>::value));
|
||||||
VTKM_STATIC_ASSERT((!vtkmstd::is_trivially_constructible<
|
VTKM_STATIC_ASSERT(
|
||||||
vtkm::exec::internal::Variant<float, NonTrivial, int>>::value));
|
(!vtkmstd::is_trivially_constructible<vtkm::exec::Variant<float, NonTrivial, int>>::value));
|
||||||
VTKM_STATIC_ASSERT((!vtkmstd::is_trivially_constructible<
|
VTKM_STATIC_ASSERT(
|
||||||
vtkm::exec::internal::Variant<float, int, NonTrivial>>::value));
|
(!vtkmstd::is_trivially_constructible<vtkm::exec::Variant<float, int, NonTrivial>>::value));
|
||||||
|
|
||||||
// A variant of any non-trivially copyable things is not trivially copyable
|
// A variant of any non-trivially copyable things is not trivially copyable
|
||||||
VTKM_STATIC_ASSERT((!vtkmstd::is_trivially_copyable<
|
VTKM_STATIC_ASSERT((!vtkmstd::is_trivially_copyable<
|
||||||
vtkm::exec::internal::detail::VariantUnion<NonTrivial, float, int>>::value));
|
vtkm::exec::detail::VariantUnion<NonTrivial, float, int>>::value));
|
||||||
VTKM_STATIC_ASSERT((!vtkmstd::is_trivially_copyable<
|
VTKM_STATIC_ASSERT((!vtkmstd::is_trivially_copyable<
|
||||||
vtkm::exec::internal::detail::VariantUnion<float, NonTrivial, int>>::value));
|
vtkm::exec::detail::VariantUnion<float, NonTrivial, int>>::value));
|
||||||
VTKM_STATIC_ASSERT((!vtkmstd::is_trivially_copyable<
|
VTKM_STATIC_ASSERT((!vtkmstd::is_trivially_copyable<
|
||||||
vtkm::exec::internal::detail::VariantUnion<float, int, NonTrivial>>::value));
|
vtkm::exec::detail::VariantUnion<float, int, NonTrivial>>::value));
|
||||||
VTKM_STATIC_ASSERT((
|
VTKM_STATIC_ASSERT(
|
||||||
!vtkmstd::is_trivially_copyable<vtkm::exec::internal::Variant<NonTrivial, float, int>>::value));
|
(!vtkmstd::is_trivially_copyable<vtkm::exec::Variant<NonTrivial, float, int>>::value));
|
||||||
VTKM_STATIC_ASSERT((
|
VTKM_STATIC_ASSERT(
|
||||||
!vtkmstd::is_trivially_copyable<vtkm::exec::internal::Variant<float, NonTrivial, int>>::value));
|
(!vtkmstd::is_trivially_copyable<vtkm::exec::Variant<float, NonTrivial, int>>::value));
|
||||||
VTKM_STATIC_ASSERT((
|
VTKM_STATIC_ASSERT(
|
||||||
!vtkmstd::is_trivially_copyable<vtkm::exec::internal::Variant<float, int, NonTrivial>>::value));
|
(!vtkmstd::is_trivially_copyable<vtkm::exec::Variant<float, int, NonTrivial>>::value));
|
||||||
|
|
||||||
// A variant of trivial things should be trivial
|
// A variant of trivial things should be trivial
|
||||||
VTKM_STATIC_ASSERT((vtkmstd::is_trivial<vtkm::exec::internal::Variant<float, int>>::value));
|
VTKM_STATIC_ASSERT((vtkmstd::is_trivial<vtkm::exec::Variant<float, int>>::value));
|
||||||
VTKM_STATIC_ASSERT(
|
VTKM_STATIC_ASSERT((!vtkmstd::is_trivial<vtkm::exec::Variant<float, int, TrivialCopy>>::value));
|
||||||
(!vtkmstd::is_trivial<vtkm::exec::internal::Variant<float, int, TrivialCopy>>::value));
|
VTKM_STATIC_ASSERT((!vtkmstd::is_trivial<vtkm::exec::Variant<float, int, NonTrivial>>::value));
|
||||||
VTKM_STATIC_ASSERT(
|
|
||||||
(!vtkmstd::is_trivial<vtkm::exec::internal::Variant<float, int, NonTrivial>>::value));
|
|
||||||
#endif // VTKM_USE_STD_IS_TRIVIAL
|
#endif // VTKM_USE_STD_IS_TRIVIAL
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -329,36 +326,36 @@ void TestGet()
|
|||||||
{
|
{
|
||||||
std::cout << "Test Get" << std::endl;
|
std::cout << "Test Get" << std::endl;
|
||||||
|
|
||||||
using VariantType = vtkm::exec::internal::Variant<TypePlaceholder<0>,
|
using VariantType = vtkm::exec::Variant<TypePlaceholder<0>,
|
||||||
TypePlaceholder<1>,
|
TypePlaceholder<1>,
|
||||||
vtkm::Id,
|
vtkm::Id,
|
||||||
TypePlaceholder<3>,
|
TypePlaceholder<3>,
|
||||||
TypePlaceholder<4>,
|
TypePlaceholder<4>,
|
||||||
TypePlaceholder<5>,
|
TypePlaceholder<5>,
|
||||||
TypePlaceholder<6>,
|
TypePlaceholder<6>,
|
||||||
TypePlaceholder<7>,
|
TypePlaceholder<7>,
|
||||||
TypePlaceholder<8>,
|
TypePlaceholder<8>,
|
||||||
TypePlaceholder<9>,
|
TypePlaceholder<9>,
|
||||||
TypePlaceholder<10>,
|
TypePlaceholder<10>,
|
||||||
TypePlaceholder<11>,
|
TypePlaceholder<11>,
|
||||||
TypePlaceholder<12>,
|
TypePlaceholder<12>,
|
||||||
TypePlaceholder<13>,
|
TypePlaceholder<13>,
|
||||||
TypePlaceholder<14>,
|
TypePlaceholder<14>,
|
||||||
TypePlaceholder<15>,
|
TypePlaceholder<15>,
|
||||||
TypePlaceholder<16>,
|
TypePlaceholder<16>,
|
||||||
TypePlaceholder<17>,
|
TypePlaceholder<17>,
|
||||||
TypePlaceholder<18>,
|
TypePlaceholder<18>,
|
||||||
TypePlaceholder<19>,
|
TypePlaceholder<19>,
|
||||||
TypePlaceholder<20>,
|
TypePlaceholder<20>,
|
||||||
TypePlaceholder<21>,
|
TypePlaceholder<21>,
|
||||||
TypePlaceholder<22>,
|
TypePlaceholder<22>,
|
||||||
TypePlaceholder<23>,
|
TypePlaceholder<23>,
|
||||||
TypePlaceholder<24>,
|
TypePlaceholder<24>,
|
||||||
TypePlaceholder<25>,
|
TypePlaceholder<25>,
|
||||||
TypePlaceholder<26>,
|
TypePlaceholder<26>,
|
||||||
vtkm::Float32,
|
vtkm::Float32,
|
||||||
TypePlaceholder<28>,
|
TypePlaceholder<28>,
|
||||||
TypePlaceholder<29>>;
|
TypePlaceholder<29>>;
|
||||||
|
|
||||||
{
|
{
|
||||||
const vtkm::Id expectedValue = TestValue(3, vtkm::Id{});
|
const vtkm::Id expectedValue = TestValue(3, vtkm::Id{});
|
||||||
@ -392,36 +389,36 @@ void TestCastAndCall()
|
|||||||
{
|
{
|
||||||
std::cout << "Test CastAndCall" << std::endl;
|
std::cout << "Test CastAndCall" << std::endl;
|
||||||
|
|
||||||
using VariantType = vtkm::exec::internal::Variant<TypePlaceholder<0>,
|
using VariantType = vtkm::exec::Variant<TypePlaceholder<0>,
|
||||||
TypePlaceholder<1>,
|
TypePlaceholder<1>,
|
||||||
TypePlaceholder<2>,
|
TypePlaceholder<2>,
|
||||||
TypePlaceholder<3>,
|
TypePlaceholder<3>,
|
||||||
TypePlaceholder<4>,
|
TypePlaceholder<4>,
|
||||||
TypePlaceholder<5>,
|
TypePlaceholder<5>,
|
||||||
TypePlaceholder<6>,
|
TypePlaceholder<6>,
|
||||||
TypePlaceholder<7>,
|
TypePlaceholder<7>,
|
||||||
TypePlaceholder<8>,
|
TypePlaceholder<8>,
|
||||||
TypePlaceholder<9>,
|
TypePlaceholder<9>,
|
||||||
TypePlaceholder<10>,
|
TypePlaceholder<10>,
|
||||||
TypePlaceholder<11>,
|
TypePlaceholder<11>,
|
||||||
TypePlaceholder<12>,
|
TypePlaceholder<12>,
|
||||||
TypePlaceholder<13>,
|
TypePlaceholder<13>,
|
||||||
TypePlaceholder<14>,
|
TypePlaceholder<14>,
|
||||||
TypePlaceholder<15>,
|
TypePlaceholder<15>,
|
||||||
TypePlaceholder<16>,
|
TypePlaceholder<16>,
|
||||||
TypePlaceholder<17>,
|
TypePlaceholder<17>,
|
||||||
TypePlaceholder<18>,
|
TypePlaceholder<18>,
|
||||||
TypePlaceholder<19>,
|
TypePlaceholder<19>,
|
||||||
TypePlaceholder<20>,
|
TypePlaceholder<20>,
|
||||||
TypePlaceholder<21>,
|
TypePlaceholder<21>,
|
||||||
TypePlaceholder<22>,
|
TypePlaceholder<22>,
|
||||||
TypePlaceholder<23>,
|
TypePlaceholder<23>,
|
||||||
TypePlaceholder<24>,
|
TypePlaceholder<24>,
|
||||||
TypePlaceholder<25>,
|
TypePlaceholder<25>,
|
||||||
TypePlaceholder<26>,
|
TypePlaceholder<26>,
|
||||||
TypePlaceholder<27>,
|
TypePlaceholder<27>,
|
||||||
TypePlaceholder<28>,
|
TypePlaceholder<28>,
|
||||||
TypePlaceholder<29>>;
|
TypePlaceholder<29>>;
|
||||||
vtkm::FloatDefault result;
|
vtkm::FloatDefault result;
|
||||||
|
|
||||||
VariantType variant0{ TypePlaceholder<0>{} };
|
VariantType variant0{ TypePlaceholder<0>{} };
|
||||||
@ -454,7 +451,7 @@ void TestCopyInvalid()
|
|||||||
{
|
{
|
||||||
std::cout << "Test copy invalid variant" << std::endl;
|
std::cout << "Test copy invalid variant" << std::endl;
|
||||||
|
|
||||||
using VariantType = vtkm::exec::internal::Variant<TypePlaceholder<0>, NonTrivial>;
|
using VariantType = vtkm::exec::Variant<TypePlaceholder<0>, NonTrivial>;
|
||||||
|
|
||||||
VariantType source;
|
VariantType source;
|
||||||
source.Reset();
|
source.Reset();
|
||||||
@ -488,11 +485,11 @@ void TestCopyDestroy()
|
|||||||
{
|
{
|
||||||
std::cout << "Test copy destroy" << std::endl;
|
std::cout << "Test copy destroy" << std::endl;
|
||||||
|
|
||||||
using VariantType = vtkm::exec::internal::Variant<TypePlaceholder<0>,
|
using VariantType = vtkm::exec::Variant<TypePlaceholder<0>,
|
||||||
TypePlaceholder<1>,
|
TypePlaceholder<1>,
|
||||||
CountConstructDestruct,
|
CountConstructDestruct,
|
||||||
TypePlaceholder<3>,
|
TypePlaceholder<3>,
|
||||||
TypePlaceholder<4>>;
|
TypePlaceholder<4>>;
|
||||||
#ifdef VTKM_USE_STD_IS_TRIVIAL
|
#ifdef VTKM_USE_STD_IS_TRIVIAL
|
||||||
VTKM_STATIC_ASSERT(!vtkmstd::is_trivially_copyable<VariantType>::value);
|
VTKM_STATIC_ASSERT(!vtkmstd::is_trivially_copyable<VariantType>::value);
|
||||||
#endif // VTKM_USE_STD_IS_TRIVIAL
|
#endif // VTKM_USE_STD_IS_TRIVIAL
|
||||||
@ -545,7 +542,7 @@ void TestEmplace()
|
|||||||
{
|
{
|
||||||
std::cout << "Test Emplace" << std::endl;
|
std::cout << "Test Emplace" << std::endl;
|
||||||
|
|
||||||
using VariantType = vtkm::exec::internal::Variant<vtkm::Id, vtkm::Id3, std::vector<vtkm::Id>>;
|
using VariantType = vtkm::exec::Variant<vtkm::Id, vtkm::Id3, std::vector<vtkm::Id>>;
|
||||||
|
|
||||||
VariantType variant;
|
VariantType variant;
|
||||||
variant.Emplace<vtkm::Id>(TestValue(0, vtkm::Id{}));
|
variant.Emplace<vtkm::Id>(TestValue(0, vtkm::Id{}));
|
||||||
@ -577,7 +574,7 @@ void TestConstructDestruct()
|
|||||||
|
|
||||||
g_NonTrivialCount = 0;
|
g_NonTrivialCount = 0;
|
||||||
|
|
||||||
using VariantType = vtkm::exec::internal::Variant<NonTrivial, TrivialCopy>;
|
using VariantType = vtkm::exec::Variant<NonTrivial, TrivialCopy>;
|
||||||
|
|
||||||
{
|
{
|
||||||
VariantType variant1 = NonTrivial{};
|
VariantType variant1 = NonTrivial{};
|
||||||
@ -597,8 +594,7 @@ void TestCopySelf()
|
|||||||
{
|
{
|
||||||
std::cout << "Make sure copying a Variant to itself works" << std::endl;
|
std::cout << "Make sure copying a Variant to itself works" << std::endl;
|
||||||
|
|
||||||
using VariantType =
|
using VariantType = vtkm::exec::Variant<TypePlaceholder<0>, NonTrivial, TypePlaceholder<2>>;
|
||||||
vtkm::exec::internal::Variant<TypePlaceholder<0>, NonTrivial, TypePlaceholder<2>>;
|
|
||||||
|
|
||||||
VariantType variant{ NonTrivial{} };
|
VariantType variant{ NonTrivial{} };
|
||||||
VariantType& variantRef = variant;
|
VariantType& variantRef = variant;
|
||||||
|
@ -26,8 +26,7 @@ namespace
|
|||||||
VTKM_CONT std::vector<vtkm::filter::flow::internal::DataSetIntegratorSteadyState>
|
VTKM_CONT std::vector<vtkm::filter::flow::internal::DataSetIntegratorSteadyState>
|
||||||
CreateDataSetIntegrators(
|
CreateDataSetIntegrators(
|
||||||
const vtkm::cont::PartitionedDataSet& input,
|
const vtkm::cont::PartitionedDataSet& input,
|
||||||
const vtkm::cont::internal::Variant<std::string, std::pair<std::string, std::string>>&
|
const vtkm::cont::Variant<std::string, std::pair<std::string, std::string>>& activeField,
|
||||||
activeField,
|
|
||||||
const vtkm::filter::flow::internal::BoundsMap& boundsMap,
|
const vtkm::filter::flow::internal::BoundsMap& boundsMap,
|
||||||
const vtkm::filter::flow::IntegrationSolverType solverType,
|
const vtkm::filter::flow::IntegrationSolverType solverType,
|
||||||
const vtkm::filter::flow::VectorFieldType vecFieldType,
|
const vtkm::filter::flow::VectorFieldType vecFieldType,
|
||||||
@ -69,8 +68,7 @@ VTKM_CONT vtkm::cont::PartitionedDataSet NewFilterParticleAdvectionSteadyState::
|
|||||||
using DSIType = vtkm::filter::flow::internal::DataSetIntegratorSteadyState;
|
using DSIType = vtkm::filter::flow::internal::DataSetIntegratorSteadyState;
|
||||||
this->ValidateOptions();
|
this->ValidateOptions();
|
||||||
|
|
||||||
using VariantType =
|
using VariantType = vtkm::cont::Variant<std::string, std::pair<std::string, std::string>>;
|
||||||
vtkm::cont::internal::Variant<std::string, std::pair<std::string, std::string>>;
|
|
||||||
VariantType variant;
|
VariantType variant;
|
||||||
|
|
||||||
if (this->VecFieldType == vtkm::filter::flow::VectorFieldType::VELOCITY_FIELD_TYPE)
|
if (this->VecFieldType == vtkm::filter::flow::VectorFieldType::VELOCITY_FIELD_TYPE)
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
#include <vtkm/filter/flow/worklet/RK4Integrator.h>
|
#include <vtkm/filter/flow/worklet/RK4Integrator.h>
|
||||||
#include <vtkm/filter/flow/worklet/Stepper.h>
|
#include <vtkm/filter/flow/worklet/Stepper.h>
|
||||||
|
|
||||||
#include <vtkm/cont/internal/Variant.h>
|
#include <vtkm/cont/Variant.h>
|
||||||
|
|
||||||
namespace vtkm
|
namespace vtkm
|
||||||
{
|
{
|
||||||
@ -54,8 +54,8 @@ public:
|
|||||||
std::vector<vtkm::Id> TermIdx, TermID;
|
std::vector<vtkm::Id> TermIdx, TermID;
|
||||||
};
|
};
|
||||||
|
|
||||||
using DSIHelperInfoType = vtkm::cont::internal::Variant<DSIHelperInfo<vtkm::Particle>,
|
using DSIHelperInfoType =
|
||||||
DSIHelperInfo<vtkm::ChargedParticle>>;
|
vtkm::cont::Variant<DSIHelperInfo<vtkm::Particle>, DSIHelperInfo<vtkm::ChargedParticle>>;
|
||||||
|
|
||||||
template <typename Derived>
|
template <typename Derived>
|
||||||
class DataSetIntegrator
|
class DataSetIntegrator
|
||||||
@ -65,14 +65,13 @@ public:
|
|||||||
using ElectroMagneticFieldNameType = std::pair<std::string, std::string>;
|
using ElectroMagneticFieldNameType = std::pair<std::string, std::string>;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
using FieldNameType =
|
using FieldNameType = vtkm::cont::Variant<VelocityFieldNameType, ElectroMagneticFieldNameType>;
|
||||||
vtkm::cont::internal::Variant<VelocityFieldNameType, ElectroMagneticFieldNameType>;
|
|
||||||
|
|
||||||
using RType = vtkm::cont::internal::Variant<
|
using RType =
|
||||||
vtkm::worklet::flow::ParticleAdvectionResult<vtkm::Particle>,
|
vtkm::cont::Variant<vtkm::worklet::flow::ParticleAdvectionResult<vtkm::Particle>,
|
||||||
vtkm::worklet::flow::ParticleAdvectionResult<vtkm::ChargedParticle>,
|
vtkm::worklet::flow::ParticleAdvectionResult<vtkm::ChargedParticle>,
|
||||||
vtkm::worklet::flow::StreamlineResult<vtkm::Particle>,
|
vtkm::worklet::flow::StreamlineResult<vtkm::Particle>,
|
||||||
vtkm::worklet::flow::StreamlineResult<vtkm::ChargedParticle>>;
|
vtkm::worklet::flow::StreamlineResult<vtkm::ChargedParticle>>;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
DataSetIntegrator(vtkm::Id id,
|
DataSetIntegrator(vtkm::Id id,
|
||||||
@ -128,7 +127,7 @@ protected:
|
|||||||
DSIHelperInfo<ParticleType>& dsiInfo) const;
|
DSIHelperInfo<ParticleType>& dsiInfo) const;
|
||||||
|
|
||||||
//Data members.
|
//Data members.
|
||||||
vtkm::cont::internal::Variant<VelocityFieldNameType, ElectroMagneticFieldNameType> FieldName;
|
vtkm::cont::Variant<VelocityFieldNameType, ElectroMagneticFieldNameType> FieldName;
|
||||||
|
|
||||||
vtkm::Id Id;
|
vtkm::Id Id;
|
||||||
vtkm::filter::flow::IntegrationSolverType SolverType;
|
vtkm::filter::flow::IntegrationSolverType SolverType;
|
||||||
|
@ -26,8 +26,6 @@ namespace vtkm
|
|||||||
{
|
{
|
||||||
namespace VTK_M_NAMESPACE
|
namespace VTK_M_NAMESPACE
|
||||||
{
|
{
|
||||||
namespace internal
|
|
||||||
{
|
|
||||||
|
|
||||||
// Forward declaration
|
// Forward declaration
|
||||||
template <typename... Ts>
|
template <typename... Ts>
|
||||||
@ -126,8 +124,7 @@ template <typename VariantType>
|
|||||||
struct VariantTriviallyCopyable;
|
struct VariantTriviallyCopyable;
|
||||||
|
|
||||||
template <typename... Ts>
|
template <typename... Ts>
|
||||||
struct VariantTriviallyCopyable<vtkm::VTK_M_NAMESPACE::internal::Variant<Ts...>>
|
struct VariantTriviallyCopyable<vtkm::VTK_M_NAMESPACE::Variant<Ts...>> : AllTriviallyCopyable<Ts...>
|
||||||
: AllTriviallyCopyable<Ts...>
|
|
||||||
{
|
{
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -135,7 +132,7 @@ template <typename VariantType>
|
|||||||
struct VariantTriviallyConstructible;
|
struct VariantTriviallyConstructible;
|
||||||
|
|
||||||
template <typename... Ts>
|
template <typename... Ts>
|
||||||
struct VariantTriviallyConstructible<vtkm::VTK_M_NAMESPACE::internal::Variant<Ts...>>
|
struct VariantTriviallyConstructible<vtkm::VTK_M_NAMESPACE::Variant<Ts...>>
|
||||||
: AllTriviallyConstructible<Ts...>
|
: AllTriviallyConstructible<Ts...>
|
||||||
{
|
{
|
||||||
};
|
};
|
||||||
@ -205,9 +202,8 @@ struct VariantConstructorImpl;
|
|||||||
|
|
||||||
// Can trivially construct, deconstruct, and copy all data. (Probably all trivial classes.)
|
// Can trivially construct, deconstruct, and copy all data. (Probably all trivial classes.)
|
||||||
template <typename... Ts>
|
template <typename... Ts>
|
||||||
struct VariantConstructorImpl<vtkm::VTK_M_NAMESPACE::internal::Variant<Ts...>,
|
struct VariantConstructorImpl<vtkm::VTK_M_NAMESPACE::Variant<Ts...>, std::true_type, std::true_type>
|
||||||
std::true_type,
|
: VariantStorageImpl<Ts...>
|
||||||
std::true_type> : VariantStorageImpl<Ts...>
|
|
||||||
{
|
{
|
||||||
VariantConstructorImpl() = default;
|
VariantConstructorImpl() = default;
|
||||||
~VariantConstructorImpl() = default;
|
~VariantConstructorImpl() = default;
|
||||||
@ -221,7 +217,7 @@ struct VariantConstructorImpl<vtkm::VTK_M_NAMESPACE::internal::Variant<Ts...>,
|
|||||||
// Can trivially copy, but cannot trivially construct. Common if a class is simple but
|
// Can trivially copy, but cannot trivially construct. Common if a class is simple but
|
||||||
// initializes itself.
|
// initializes itself.
|
||||||
template <typename... Ts>
|
template <typename... Ts>
|
||||||
struct VariantConstructorImpl<vtkm::VTK_M_NAMESPACE::internal::Variant<Ts...>,
|
struct VariantConstructorImpl<vtkm::VTK_M_NAMESPACE::Variant<Ts...>,
|
||||||
std::false_type,
|
std::false_type,
|
||||||
std::true_type> : VariantStorageImpl<Ts...>
|
std::true_type> : VariantStorageImpl<Ts...>
|
||||||
{
|
{
|
||||||
@ -242,7 +238,7 @@ struct VariantConstructorImpl<vtkm::VTK_M_NAMESPACE::internal::Variant<Ts...>,
|
|||||||
|
|
||||||
// Cannot trivially copy. We assume we cannot trivially construct/destruct.
|
// Cannot trivially copy. We assume we cannot trivially construct/destruct.
|
||||||
template <typename construct_type, typename... Ts>
|
template <typename construct_type, typename... Ts>
|
||||||
struct VariantConstructorImpl<vtkm::VTK_M_NAMESPACE::internal::Variant<Ts...>,
|
struct VariantConstructorImpl<vtkm::VTK_M_NAMESPACE::Variant<Ts...>,
|
||||||
construct_type,
|
construct_type,
|
||||||
std::false_type> : VariantStorageImpl<Ts...>
|
std::false_type> : VariantStorageImpl<Ts...>
|
||||||
{
|
{
|
||||||
@ -555,15 +551,14 @@ template <typename ListTag>
|
|||||||
using ListTagAsVariant VTKM_DEPRECATED(
|
using ListTagAsVariant VTKM_DEPRECATED(
|
||||||
1.6,
|
1.6,
|
||||||
"vtkm::ListTag is no longer supported. Use vtkm::List instead.") =
|
"vtkm::ListTag is no longer supported. Use vtkm::List instead.") =
|
||||||
vtkm::ListApply<ListTag, vtkm::VTK_M_NAMESPACE::internal::Variant>;
|
vtkm::ListApply<ListTag, vtkm::VTK_M_NAMESPACE::Variant>;
|
||||||
|
|
||||||
/// \brief Convert a `List` to a `Variant`.
|
/// \brief Convert a `List` to a `Variant`.
|
||||||
///
|
///
|
||||||
template <typename List>
|
template <typename List>
|
||||||
using ListAsVariant = vtkm::ListApply<List, vtkm::VTK_M_NAMESPACE::internal::Variant>;
|
using ListAsVariant = vtkm::ListApply<List, vtkm::VTK_M_NAMESPACE::Variant>;
|
||||||
}
|
}
|
||||||
}
|
} // namespace vtkm::VTK_M_NAMESPACE
|
||||||
} // namespace vtkm::VTK_M_NAMESPACE::internal
|
|
||||||
|
|
||||||
#undef VTK_M_DEVICE
|
#undef VTK_M_DEVICE
|
||||||
#undef VTK_M_NAMESPACE
|
#undef VTK_M_NAMESPACE
|
||||||
|
@ -32,8 +32,6 @@ namespace vtkm
|
|||||||
{
|
{
|
||||||
namespace VTK_M_NAMESPACE
|
namespace VTK_M_NAMESPACE
|
||||||
{
|
{
|
||||||
namespace internal
|
|
||||||
{
|
|
||||||
namespace detail
|
namespace detail
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -1010,5 +1008,4 @@ VTK_M_DEVICE inline auto VariantCastAndCallImpl(
|
|||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} // vtkm::VTK_M_NAMESPACE::detail
|
||||||
} // vtkm::VTK_M_NAMESPACE::internal::detail
|
|
||||||
|
@ -65,8 +65,6 @@ namespace vtkm
|
|||||||
{
|
{
|
||||||
namespace VTK_M_NAMESPACE
|
namespace VTK_M_NAMESPACE
|
||||||
{
|
{
|
||||||
namespace internal
|
|
||||||
{
|
|
||||||
namespace detail
|
namespace detail
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -354,5 +352,4 @@ VTK_M_DEVICE inline auto VariantCastAndCallImpl(
|
|||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} // vtkm::VTK_M_NAMESPACE::detail
|
||||||
} // vtkm::VTK_M_NAMESPACE::internal::detail
|
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <vtkm/CellShape.h>
|
#include <vtkm/CellShape.h>
|
||||||
#include <vtkm/cont/ErrorBadValue.h>
|
#include <vtkm/cont/ErrorBadValue.h>
|
||||||
#include <vtkm/exec/internal/Variant.h>
|
#include <vtkm/exec/Variant.h>
|
||||||
#include <vtkm/rendering/raytracing/BoundingVolumeHierarchy.h>
|
#include <vtkm/rendering/raytracing/BoundingVolumeHierarchy.h>
|
||||||
#include <vtkm/rendering/raytracing/CellTables.h>
|
#include <vtkm/rendering/raytracing/CellTables.h>
|
||||||
#include <vtkm/rendering/raytracing/Logger.h>
|
#include <vtkm/rendering/raytracing/Logger.h>
|
||||||
@ -250,7 +250,7 @@ public:
|
|||||||
/// \brief General version of mesh connectivity that can be used for all supported mesh types.
|
/// \brief General version of mesh connectivity that can be used for all supported mesh types.
|
||||||
class VTKM_ALWAYS_EXPORT MeshConnectivity
|
class VTKM_ALWAYS_EXPORT MeshConnectivity
|
||||||
{
|
{
|
||||||
using ConnectivityType = vtkm::exec::internal::
|
using ConnectivityType = vtkm::exec::
|
||||||
Variant<MeshConnectivityStructured, MeshConnectivityUnstructured, MeshConnectivitySingleType>;
|
Variant<MeshConnectivityStructured, MeshConnectivityUnstructured, MeshConnectivitySingleType>;
|
||||||
ConnectivityType Connectivity;
|
ConnectivityType Connectivity;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user