mirror of
https://gitlab.kitware.com/vtk/vtk-m
synced 2024-09-08 13:23:51 +00:00
Merge topic 'soa-array-default'
cecd81d5d Add types appropriate for Ascent 865855ea0 Add changelog for making ArrayHandleSOA a default array 50ff9c22a Add support of `ArrayHandleSOA` as a default storage type bc09a9cd1 Add precompiled versions of `ArrayRangeCompute` for `ArrayHandleSOA` 77f9ae653 Support `ArrayHandleSOA` only for `Vec` value types Acked-by: Kitware Robot <kwrobot@kitware.com> Acked-by: Robert Maynard <robert.maynard@kitware.com> Merge-request: !2349
This commit is contained in:
commit
a6edc832da
@ -29,6 +29,10 @@ foreach(option IN LISTS options)
|
||||
elseif(vtk_types STREQUAL option)
|
||||
set(VTKm_USE_DEFAULT_TYPES_FOR_VTK "ON" CACHE STRING "")
|
||||
|
||||
elseif(ascent_types STREQUAL option)
|
||||
# Note: ascent_types also requires 32bit_ids and 64bit_floats
|
||||
set(VTKm_USE_DEFAULT_TYPES_FOR_ASCENT "ON" CACHE STRING "")
|
||||
|
||||
elseif(32bit_ids STREQUAL option)
|
||||
set(VTKm_USE_64BIT_IDS "OFF" CACHE STRING "")
|
||||
|
||||
|
@ -17,7 +17,7 @@ build:ubuntu1604_gcc5:
|
||||
CC: "gcc-5"
|
||||
CXX: "g++-5"
|
||||
CMAKE_BUILD_TYPE: RelWithDebInfo
|
||||
VTKM_SETTINGS: "cuda+pascal+no_virtual"
|
||||
VTKM_SETTINGS: "cuda+pascal+no_virtual+ascent_types+32bit_ids+64bit_floats"
|
||||
|
||||
test:ubuntu1604_gcc5:
|
||||
tags:
|
||||
|
22
docs/changelog/soa-array-default.md
Normal file
22
docs/changelog/soa-array-default.md
Normal file
@ -0,0 +1,22 @@
|
||||
Support `ArrayHandleSOA` as a "default" array
|
||||
|
||||
Many programs, particularly simulations, store fields of vectors in
|
||||
separate arrays for each component. This maps to the storage of
|
||||
`ArrayHandleSOA`. The VTK-m code tends to prefer the AOS storage (which is
|
||||
what is implemented in `ArrayHandleBasic`, and the behavior of which is
|
||||
inherited from VTK). VTK-m should better support adding `ArrayHandleSOA` as
|
||||
one of the types.
|
||||
|
||||
We now have a set of default types for Ascent that uses SOA as one of the
|
||||
basic types.
|
||||
|
||||
Part of this change includes an intentional feature regression of
|
||||
`ArrayHandleSOA` to only support value types of `Vec`. Previously, scalar
|
||||
types were supported. However, the behavior of `ArrayHandleSOA` is exactly
|
||||
the same as `ArrayHandleBasic`, except a lot more template code has to be
|
||||
generated. That itself is not a huge deal, but because you have 2 types
|
||||
that essentially do the same thing, a lot of template code in VTK-m would
|
||||
unwind to create two separate code paths that do the same thing with the
|
||||
same data. To avoid creating those code paths, we simply make any use of
|
||||
`ArrayHandleSOA` without a `Vec` value invalid. This will prevent VTK-m
|
||||
from creating those code paths.
|
@ -288,6 +288,10 @@ VTKM_CONT_EXPORT VTKM_CONT vtkm::cont::DeviceAdapterId ArrayHandleGetDeviceAdapt
|
||||
template <typename T, typename StorageTag_ = VTKM_DEFAULT_STORAGE_TAG>
|
||||
class VTKM_ALWAYS_EXPORT ArrayHandle : public internal::ArrayHandleBase
|
||||
{
|
||||
VTKM_STATIC_ASSERT_MSG(
|
||||
(internal::IsValidArrayHandle<T, StorageTag_>::value),
|
||||
"Attempted to create an ArrayHandle with an invalid type/storage combination.");
|
||||
|
||||
public:
|
||||
using ValueType = T;
|
||||
using StorageTag = StorageTag_;
|
||||
|
@ -17,7 +17,6 @@ namespace cont
|
||||
{
|
||||
|
||||
#define VTKM_ARRAYHANDLE_SOA_INSTANTIATE(Type) \
|
||||
template class VTKM_CONT_EXPORT ArrayHandle<Type, StorageTagSOA>; \
|
||||
template class VTKM_CONT_EXPORT ArrayHandle<vtkm::Vec<Type, 2>, StorageTagSOA>; \
|
||||
template class VTKM_CONT_EXPORT ArrayHandle<vtkm::Vec<Type, 3>, StorageTagSOA>; \
|
||||
template class VTKM_CONT_EXPORT ArrayHandle<vtkm::Vec<Type, 4>, StorageTagSOA>;
|
||||
|
@ -128,20 +128,17 @@ struct VTKM_ALWAYS_EXPORT StorageTagSOA
|
||||
namespace internal
|
||||
{
|
||||
|
||||
template <typename T>
|
||||
class VTKM_ALWAYS_EXPORT Storage<T, vtkm::cont::StorageTagSOA>
|
||||
template <typename ComponentType, vtkm::IdComponent NUM_COMPONENTS>
|
||||
class VTKM_ALWAYS_EXPORT
|
||||
Storage<vtkm::Vec<ComponentType, NUM_COMPONENTS>, vtkm::cont::StorageTagSOA>
|
||||
{
|
||||
VTKM_STATIC_ASSERT(vtkm::HasVecTraits<T>::value);
|
||||
using VTraits = vtkm::VecTraits<T>;
|
||||
|
||||
using ComponentType = typename VTraits::ComponentType;
|
||||
static constexpr vtkm::IdComponent NUM_COMPONENTS = VTraits::NUM_COMPONENTS;
|
||||
using ValueType = vtkm::Vec<ComponentType, NUM_COMPONENTS>;
|
||||
|
||||
public:
|
||||
using ReadPortalType =
|
||||
vtkm::internal::ArrayPortalSOA<T, vtkm::internal::ArrayPortalBasicRead<ComponentType>>;
|
||||
vtkm::internal::ArrayPortalSOA<ValueType, vtkm::internal::ArrayPortalBasicRead<ComponentType>>;
|
||||
using WritePortalType =
|
||||
vtkm::internal::ArrayPortalSOA<T, vtkm::internal::ArrayPortalBasicWrite<ComponentType>>;
|
||||
vtkm::internal::ArrayPortalSOA<ValueType, vtkm::internal::ArrayPortalBasicWrite<ComponentType>>;
|
||||
|
||||
VTKM_CONT constexpr static vtkm::IdComponent GetNumberOfBuffers() { return NUM_COMPONENTS; }
|
||||
|
||||
@ -629,7 +626,6 @@ namespace cont
|
||||
{
|
||||
|
||||
#define VTKM_ARRAYHANDLE_SOA_EXPORT(Type) \
|
||||
extern template class VTKM_CONT_TEMPLATE_EXPORT ArrayHandle<Type, StorageTagSOA>; \
|
||||
extern template class VTKM_CONT_TEMPLATE_EXPORT ArrayHandle<vtkm::Vec<Type, 2>, StorageTagSOA>; \
|
||||
extern template class VTKM_CONT_TEMPLATE_EXPORT ArrayHandle<vtkm::Vec<Type, 3>, StorageTagSOA>; \
|
||||
extern template class VTKM_CONT_TEMPLATE_EXPORT ArrayHandle<vtkm::Vec<Type, 4>, StorageTagSOA>;
|
||||
|
@ -74,6 +74,10 @@ VTKM_ARRAY_RANGE_COMPUTE_IMPL_ALL_VEC(2, vtkm::cont::StorageTagBasic);
|
||||
VTKM_ARRAY_RANGE_COMPUTE_IMPL_ALL_VEC(3, vtkm::cont::StorageTagBasic);
|
||||
VTKM_ARRAY_RANGE_COMPUTE_IMPL_ALL_VEC(4, vtkm::cont::StorageTagBasic);
|
||||
|
||||
VTKM_ARRAY_RANGE_COMPUTE_IMPL_ALL_VEC(2, vtkm::cont::StorageTagSOA);
|
||||
VTKM_ARRAY_RANGE_COMPUTE_IMPL_ALL_VEC(3, vtkm::cont::StorageTagSOA);
|
||||
VTKM_ARRAY_RANGE_COMPUTE_IMPL_ALL_VEC(4, vtkm::cont::StorageTagSOA);
|
||||
|
||||
#undef VTKM_ARRAY_RANGE_COMPUTE_IMPL_T
|
||||
#undef VTKM_ARRAY_RANGE_COMPUTE_IMPL_VEC
|
||||
#undef VTKM_ARRAY_RANGE_COMPUTE_IMPL_ALL_SCALAR_T
|
||||
|
@ -15,6 +15,7 @@
|
||||
#include <vtkm/cont/ArrayHandle.h>
|
||||
#include <vtkm/cont/ArrayHandleCartesianProduct.h>
|
||||
#include <vtkm/cont/ArrayHandleCompositeVector.h>
|
||||
#include <vtkm/cont/ArrayHandleSOA.h>
|
||||
#include <vtkm/cont/ArrayHandleUniformPointCoordinates.h>
|
||||
#include <vtkm/cont/DeviceAdapterTag.h>
|
||||
|
||||
@ -94,6 +95,10 @@ VTK_M_ARRAY_RANGE_COMPUTE_EXPORT_ALL_VEC(2, vtkm::cont::StorageTagBasic);
|
||||
VTK_M_ARRAY_RANGE_COMPUTE_EXPORT_ALL_VEC(3, vtkm::cont::StorageTagBasic);
|
||||
VTK_M_ARRAY_RANGE_COMPUTE_EXPORT_ALL_VEC(4, vtkm::cont::StorageTagBasic);
|
||||
|
||||
VTK_M_ARRAY_RANGE_COMPUTE_EXPORT_ALL_VEC(2, vtkm::cont::StorageTagSOA);
|
||||
VTK_M_ARRAY_RANGE_COMPUTE_EXPORT_ALL_VEC(3, vtkm::cont::StorageTagSOA);
|
||||
VTK_M_ARRAY_RANGE_COMPUTE_EXPORT_ALL_VEC(4, vtkm::cont::StorageTagSOA);
|
||||
|
||||
#undef VTK_M_ARRAY_RANGE_COMPUTE_EXPORT_T
|
||||
#undef VTK_M_ARRAY_RANGE_COMPUTE_EXPORT_VEC
|
||||
#undef VTK_M_ARRAY_RANGE_COMPUTE_EXPORT_ALL_SCALAR_T
|
||||
|
@ -217,12 +217,36 @@ endif()
|
||||
vtkm_get_kit_name(kit_name kit_dir)
|
||||
|
||||
# Some custom types included with VTK-m
|
||||
vtkm_option(VTKm_USE_DEFAULT_TYPES_FOR_VTK "Compile VTK-m algorithms for use with types from VTK." OFF)
|
||||
vtkm_option(VTKm_USE_DEFAULT_TYPES_FOR_VTK
|
||||
"Compile VTK-m algorithms for use with types from VTK."
|
||||
OFF
|
||||
)
|
||||
if (VTKm_USE_DEFAULT_TYPES_FOR_VTK)
|
||||
set(VTKm_DEFAULT_TYPES_HEADER "internal/DefaultTypesVTK.h.in")
|
||||
endif()
|
||||
|
||||
mark_as_advanced(VTKm_USE_DEFAULT_TYPES_FOR_VTK)
|
||||
vtkm_option(VTKm_USE_DEFAULT_TYPES_FOR_ASCENT
|
||||
"Compile VTK-m algorithms for use with types from Ascent."
|
||||
OFF
|
||||
)
|
||||
if (VTKm_USE_DEFAULT_TYPES_FOR_ASCENT)
|
||||
set(VTKm_DEFAULT_TYPES_HEADER "internal/DefaultTypesAscent.h.in")
|
||||
if (VTKm_USE_64BIT_IDS)
|
||||
message(SEND_ERROR
|
||||
"When VTKm_USE_DEFAULT_TYPES_FOR_ASCENT is ON, VTKm_USE_64BIT_IDS must be set to OFF"
|
||||
)
|
||||
endif()
|
||||
if (NOT VTKm_USE_DOUBLE_PRECISION)
|
||||
message(SEND_ERROR
|
||||
"When VTKm_USE_DEFAULT_TYPES_FOR_ASCENT is ON, VTKm_USE_DOUBLE_PRECISION must be set to ON"
|
||||
)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
mark_as_advanced(
|
||||
VTKm_USE_DEFAULT_TYPES_FOR_VTK
|
||||
VTKm_USE_DEFAULT_TYPES_FOR_ASCENT
|
||||
)
|
||||
|
||||
if (VTKm_DEFAULT_TYPES_HEADER)
|
||||
set(VTK_M_HAS_DEFAULT_TYPES_HEADER TRUE)
|
||||
|
@ -59,13 +59,10 @@ namespace internal
|
||||
using StorageListField = vtkm::ListAppend<
|
||||
vtkm::cont::StorageListBasic,
|
||||
vtkm::List<
|
||||
vtkm::cont::ArrayHandleUniformPointCoordinates::StorageTag,
|
||||
vtkm::cont::ArrayHandleCartesianProduct<vtkm::cont::ArrayHandle<vtkm::Float32>,
|
||||
vtkm::cont::ArrayHandle<vtkm::Float32>,
|
||||
vtkm::cont::ArrayHandle<vtkm::Float32>>::StorageTag,
|
||||
vtkm::cont::ArrayHandleCartesianProduct<vtkm::cont::ArrayHandle<vtkm::Float64>,
|
||||
vtkm::cont::ArrayHandle<vtkm::Float64>,
|
||||
vtkm::cont::ArrayHandle<vtkm::Float64>>::StorageTag>>;
|
||||
vtkm::cont::StorageTagUniformPoints,
|
||||
vtkm::cont::StorageTagCartesianProduct<vtkm::cont::StorageTagBasic,
|
||||
vtkm::cont::StorageTagBasic,
|
||||
vtkm::cont::StorageTagBasic>>>;
|
||||
|
||||
}
|
||||
}
|
||||
|
69
vtkm/cont/internal/DefaultTypesAscent.h.in
Normal file
69
vtkm/cont/internal/DefaultTypesAscent.h.in
Normal file
@ -0,0 +1,69 @@
|
||||
//============================================================================
|
||||
// Copyright (c) Kitware, Inc.
|
||||
// All rights reserved.
|
||||
// See LICENSE.txt for details.
|
||||
//
|
||||
// This software is distributed WITHOUT ANY WARRANTY; without even
|
||||
// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
// PURPOSE. See the above copyright notice for more information.
|
||||
//============================================================================
|
||||
#ifndef vtk_m_cont_internal_DefaultTypesAscent_h
|
||||
#define vtk_m_cont_internal_DefaultTypesAscent_h
|
||||
|
||||
#include <vtkm/TypeList.h>
|
||||
#include <vtkm/Types.h>
|
||||
|
||||
#include <vtkm/cont/ArrayHandleCartesianProduct.h>
|
||||
#include <vtkm/cont/ArrayHandleSOA.h>
|
||||
#include <vtkm/cont/ArrayHandleUniformPointCoordinates.h>
|
||||
#include <vtkm/cont/StorageList.h>
|
||||
|
||||
#ifdef VTKM_USE_64BIT_IDS
|
||||
#error "VTK-m must be compiled with VTKM_USE_64BITS_IDS set to OFF for Ascent."
|
||||
#endif
|
||||
|
||||
#ifndef VTKM_USE_DOUBLE_PRECISION
|
||||
#error "VTK-m must be compiled with VTKM_USE_DOUBLE_PRECISION to ON for Ascent."
|
||||
#endif
|
||||
|
||||
namespace vtkm
|
||||
{
|
||||
namespace internal
|
||||
{
|
||||
|
||||
// Default value types for fields in Ascent.
|
||||
using TypeListAscent = vtkm::List<vtkm::FloatDefault,
|
||||
vtkm::Vec3f,
|
||||
// We should not need Float32 types, but currently the tests need
|
||||
// them. We should remove these types once we are able to "fix"
|
||||
// the tests by converting to supported default types.
|
||||
vtkm::Float32,
|
||||
vtkm::Vec3f_32>;
|
||||
|
||||
}
|
||||
} // namespace vtkm::internal
|
||||
|
||||
#define VTKM_DEFAULT_TYPE_LIST ::vtkm::internal::TypeListAscent
|
||||
|
||||
namespace vtkm
|
||||
{
|
||||
namespace cont
|
||||
{
|
||||
namespace internal
|
||||
{
|
||||
|
||||
using StorageListAscent = vtkm::List<
|
||||
vtkm::cont::StorageTagBasic, // Basic storage should always be included
|
||||
vtkm::cont::StorageTagSOA, // Support separate arrays for each component
|
||||
vtkm::cont::StorageTagUniformPoints, // Support uniform structured grids
|
||||
vtkm::cont::StorageTagCartesianProduct<vtkm::cont::StorageTagBasic, // Support rectilinear grids
|
||||
vtkm::cont::StorageTagBasic,
|
||||
vtkm::cont::StorageTagBasic>>;
|
||||
|
||||
}
|
||||
}
|
||||
} // namespace vtkm::cont::internal
|
||||
|
||||
#define VTKM_DEFAULT_STORAGE_LIST ::vtkm::cont::internal::StorageListAscent
|
||||
|
||||
#endif //vtk_m_cont_internal_DefaultTypesAscent_h
|
@ -7,8 +7,8 @@
|
||||
// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
// PURPOSE. See the above copyright notice for more information.
|
||||
//============================================================================
|
||||
#ifndef vtkmDefaultTypes_h
|
||||
#define vtkmDefaultTypes_h
|
||||
#ifndef vtk_m_cont_internal_DefaultTypesVTK_h
|
||||
#define vtk_m_cont_internal_DefaultTypesVTK_h
|
||||
|
||||
// This configures the default types to use when compiling VTK-m for use as an
|
||||
// accelerator in VTK.
|
||||
@ -105,4 +105,4 @@ using CellListAllOutVTK = vtkm::ListAppend<CellListStructuredOutVTK, CellListUns
|
||||
#define VTKM_DEFAULT_CELL_SET_LIST_STRUCTURED ::tovtkm::CellListStructuredInVTK
|
||||
#define VTKM_DEFAULT_CELL_SET_LIST_UNSTRUCTURED ::tovtkm::CellListUnstructuredInVTK
|
||||
|
||||
#endif //vtkmDefaultTypes_h
|
||||
#endif //vtk_m_cont_internal_DefaultTypesVTK_h
|
||||
|
@ -1482,6 +1482,8 @@ private:
|
||||
|
||||
using ScalarTypesToTest = vtkm::List<vtkm::UInt8, vtkm::FloatDefault>;
|
||||
|
||||
using VectorTypesToTest = vtkm::List<vtkm::Vec2i_8, vtkm::Vec3f_32>;
|
||||
|
||||
using ZipTypesToTest = vtkm::List<vtkm::Pair<vtkm::UInt8, vtkm::Id>,
|
||||
vtkm::Pair<vtkm::Float64, vtkm::Vec4ui_8>,
|
||||
vtkm::Pair<vtkm::Vec3f_32, vtkm::Vec4i_8>>;
|
||||
@ -1505,12 +1507,12 @@ private:
|
||||
std::cout << "-------------------------------------------" << std::endl;
|
||||
std::cout << "Testing ArrayHandleSOA as Input" << std::endl;
|
||||
vtkm::testing::Testing::TryTypes(TestingFancyArrayHandles<DeviceAdapterTag>::TestSOAAsInput(),
|
||||
HandleTypesToTest());
|
||||
VectorTypesToTest());
|
||||
|
||||
std::cout << "-------------------------------------------" << std::endl;
|
||||
std::cout << "Testing ArrayHandleSOA as Output" << std::endl;
|
||||
vtkm::testing::Testing::TryTypes(
|
||||
TestingFancyArrayHandles<DeviceAdapterTag>::TestSOAAsOutput(), HandleTypesToTest());
|
||||
TestingFancyArrayHandles<DeviceAdapterTag>::TestSOAAsOutput(), VectorTypesToTest());
|
||||
|
||||
std::cout << "-------------------------------------------" << std::endl;
|
||||
std::cout << "Testing ArrayHandleCompositeVector as Input" << std::endl;
|
||||
|
@ -378,7 +378,7 @@ void TestArrayHandleSerialization()
|
||||
TestArrayHandleBasic(), vtkm::List<char, long, long long, unsigned long, unsigned long long>());
|
||||
|
||||
std::cout << "Testing ArrayHandleSOA\n";
|
||||
vtkm::testing::Testing::TryTypes(TestArrayHandleSOA(), TestTypesList());
|
||||
vtkm::testing::Testing::TryTypes(TestArrayHandleSOA(), TestTypesListVec());
|
||||
|
||||
std::cout << "Testing ArrayHandleCartesianProduct\n";
|
||||
vtkm::testing::Testing::TryTypes(TestArrayHandleCartesianProduct(), TestTypesListScalar());
|
||||
|
@ -416,17 +416,20 @@ void TryAsMultiplexer(T, ArrayVariantType sourceArray)
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void TryDefaultType(T)
|
||||
struct TryDefaultType
|
||||
{
|
||||
vtkm::cont::VariantArrayHandle array = CreateArrayVariant(T());
|
||||
template <typename T>
|
||||
void operator()(T) const
|
||||
{
|
||||
vtkm::cont::VariantArrayHandle array = CreateArrayVariant(T());
|
||||
|
||||
CheckArrayVariant(array, vtkm::VecTraits<T>::NUM_COMPONENTS, true);
|
||||
CheckArrayVariant(array, vtkm::VecTraits<T>::NUM_COMPONENTS, true);
|
||||
|
||||
TryNewInstance(T(), array);
|
||||
TryNewInstance(T(), array);
|
||||
|
||||
TryAsMultiplexer(T(), array);
|
||||
}
|
||||
TryAsMultiplexer(T(), array);
|
||||
}
|
||||
};
|
||||
|
||||
struct TryBasicVTKmType
|
||||
{
|
||||
@ -471,18 +474,18 @@ void TryCastToArrayHandle(const ArrayHandleType& array)
|
||||
void TryCastToArrayHandle()
|
||||
{
|
||||
std::cout << " Normal array handle." << std::endl;
|
||||
vtkm::Id buffer[ARRAY_SIZE];
|
||||
vtkm::FloatDefault buffer[ARRAY_SIZE];
|
||||
for (vtkm::Id index = 0; index < ARRAY_SIZE; index++)
|
||||
{
|
||||
buffer[index] = TestValue(index, vtkm::Id());
|
||||
buffer[index] = TestValue(index, vtkm::FloatDefault());
|
||||
}
|
||||
|
||||
vtkm::cont::ArrayHandle<vtkm::Id> array =
|
||||
vtkm::cont::ArrayHandle<vtkm::FloatDefault> array =
|
||||
vtkm::cont::make_ArrayHandle(buffer, ARRAY_SIZE, vtkm::CopyFlag::On);
|
||||
TryCastToArrayHandle(array);
|
||||
|
||||
std::cout << " Cast array handle." << std::endl;
|
||||
TryCastToArrayHandle(vtkm::cont::make_ArrayHandleCast(array, vtkm::FloatDefault()));
|
||||
TryCastToArrayHandle(vtkm::cont::make_ArrayHandleCast<vtkm::Id>(array));
|
||||
|
||||
std::cout << " Composite vector array handle." << std::endl;
|
||||
TryCastToArrayHandle(vtkm::cont::make_ArrayHandleCompositeVector(array, array));
|
||||
@ -495,7 +498,8 @@ void TryCastToArrayHandle()
|
||||
TryCastToArrayHandle(countingArray);
|
||||
|
||||
std::cout << " Group vec array handle" << std::endl;
|
||||
vtkm::cont::ArrayHandleGroupVec<vtkm::cont::ArrayHandle<vtkm::Id>, 2> groupVecArray(array);
|
||||
vtkm::cont::ArrayHandleGroupVec<vtkm::cont::ArrayHandle<vtkm::FloatDefault>, 2> groupVecArray(
|
||||
array);
|
||||
TryCastToArrayHandle(groupVecArray);
|
||||
|
||||
std::cout << " Implicit array handle." << std::endl;
|
||||
@ -522,18 +526,7 @@ void TryCastToArrayHandle()
|
||||
void TestVariantArrayHandle()
|
||||
{
|
||||
std::cout << "Try common types with default type lists." << std::endl;
|
||||
std::cout << "*** vtkm::Id **********************" << std::endl;
|
||||
TryDefaultType(vtkm::Id());
|
||||
std::cout << "*** vtkm::FloatDefault ************" << std::endl;
|
||||
TryDefaultType(vtkm::FloatDefault());
|
||||
std::cout << "*** vtkm::Float32 *****************" << std::endl;
|
||||
TryDefaultType(vtkm::Float32());
|
||||
std::cout << "*** vtkm::Float64 *****************" << std::endl;
|
||||
TryDefaultType(vtkm::Float64());
|
||||
std::cout << "*** vtkm::Vec<Float32,3> **********" << std::endl;
|
||||
TryDefaultType(vtkm::Vec3f_32());
|
||||
std::cout << "*** vtkm::Vec<Float64,3> **********" << std::endl;
|
||||
TryDefaultType(vtkm::Vec3f_64());
|
||||
vtkm::testing::Testing::TryTypes(TryDefaultType{}, VTKM_DEFAULT_TYPE_LIST{});
|
||||
|
||||
std::cout << "Try exemplar VTK-m types." << std::endl;
|
||||
vtkm::testing::Testing::TryTypes(TryBasicVTKmType());
|
||||
|
@ -149,6 +149,12 @@ extern template VTKM_FILTER_GRADIENT_TEMPLATE_EXPORT vtkm::cont::DataSet Gradien
|
||||
const vtkm::filter::FieldMetadata&,
|
||||
vtkm::filter::PolicyBase<vtkm::filter::PolicyDefault>);
|
||||
|
||||
extern template VTKM_FILTER_GRADIENT_TEMPLATE_EXPORT vtkm::cont::DataSet Gradient::DoExecute(
|
||||
const vtkm::cont::DataSet&,
|
||||
const vtkm::cont::ArrayHandle<vtkm::Vec3f_32, vtkm::cont::StorageTagSOA>&,
|
||||
const vtkm::filter::FieldMetadata&,
|
||||
vtkm::filter::PolicyBase<vtkm::filter::PolicyDefault>);
|
||||
|
||||
#ifndef VTKM_NO_DEPRECATED_VIRTUAL
|
||||
VTKM_DEPRECATED_SUPPRESS_BEGIN
|
||||
extern template VTKM_FILTER_GRADIENT_TEMPLATE_EXPORT vtkm::cont::DataSet Gradient::DoExecute(
|
||||
@ -165,6 +171,12 @@ extern template VTKM_FILTER_GRADIENT_TEMPLATE_EXPORT vtkm::cont::DataSet Gradien
|
||||
const vtkm::filter::FieldMetadata&,
|
||||
vtkm::filter::PolicyBase<vtkm::filter::PolicyDefault>);
|
||||
|
||||
extern template VTKM_FILTER_GRADIENT_TEMPLATE_EXPORT vtkm::cont::DataSet Gradient::DoExecute(
|
||||
const vtkm::cont::DataSet&,
|
||||
const vtkm::cont::ArrayHandle<vtkm::Vec3f_64, vtkm::cont::StorageTagSOA>&,
|
||||
const vtkm::filter::FieldMetadata&,
|
||||
vtkm::filter::PolicyBase<vtkm::filter::PolicyDefault>);
|
||||
|
||||
#ifndef VTKM_NO_DEPRECATED_VIRTUAL
|
||||
VTKM_DEPRECATED_SUPPRESS_BEGIN
|
||||
extern template VTKM_FILTER_GRADIENT_TEMPLATE_EXPORT vtkm::cont::DataSet Gradient::DoExecute(
|
||||
|
@ -24,6 +24,12 @@ template VTKM_FILTER_GRADIENT_EXPORT vtkm::cont::DataSet Gradient::DoExecute(
|
||||
const vtkm::filter::FieldMetadata&,
|
||||
vtkm::filter::PolicyBase<vtkm::filter::PolicyDefault>);
|
||||
|
||||
template VTKM_FILTER_GRADIENT_EXPORT vtkm::cont::DataSet Gradient::DoExecute(
|
||||
const vtkm::cont::DataSet&,
|
||||
const vtkm::cont::ArrayHandle<vtkm::Vec3f_32, vtkm::cont::StorageTagSOA>&,
|
||||
const vtkm::filter::FieldMetadata&,
|
||||
vtkm::filter::PolicyBase<vtkm::filter::PolicyDefault>);
|
||||
|
||||
#ifndef VTKM_NO_DEPRECATED_VIRTUAL
|
||||
VTKM_DEPRECATED_SUPPRESS_BEGIN
|
||||
template VTKM_FILTER_GRADIENT_EXPORT vtkm::cont::DataSet Gradient::DoExecute(
|
||||
@ -40,6 +46,12 @@ template VTKM_FILTER_GRADIENT_EXPORT vtkm::cont::DataSet Gradient::DoExecute(
|
||||
const vtkm::filter::FieldMetadata&,
|
||||
vtkm::filter::PolicyBase<vtkm::filter::PolicyDefault>);
|
||||
|
||||
template VTKM_FILTER_GRADIENT_EXPORT vtkm::cont::DataSet Gradient::DoExecute(
|
||||
const vtkm::cont::DataSet&,
|
||||
const vtkm::cont::ArrayHandle<vtkm::Vec3f_64, vtkm::cont::StorageTagSOA>&,
|
||||
const vtkm::filter::FieldMetadata&,
|
||||
vtkm::filter::PolicyBase<vtkm::filter::PolicyDefault>);
|
||||
|
||||
#ifndef VTKM_NO_DEPRECATED_VIRTUAL
|
||||
VTKM_DEPRECATED_SUPPRESS_BEGIN
|
||||
template VTKM_FILTER_GRADIENT_EXPORT vtkm::cont::DataSet Gradient::DoExecute(
|
||||
|
@ -75,7 +75,7 @@ inline VTKM_CONT vtkm::cont::DataSet ImageDifference::DoExecute(
|
||||
vtkm::cont::ArrayHandle<T, StorageType> diffOutput;
|
||||
vtkm::cont::ArrayHandle<T, StorageType> primaryOutput;
|
||||
vtkm::cont::ArrayHandle<T, StorageType> secondaryOutput;
|
||||
vtkm::cont::ArrayHandle<vtkm::FloatDefault, StorageType> thresholdOutput;
|
||||
vtkm::cont::ArrayHandle<vtkm::FloatDefault> thresholdOutput;
|
||||
|
||||
if (this->AverageRadius > 0)
|
||||
{
|
||||
|
@ -18,7 +18,7 @@ void TestFieldToColors()
|
||||
{
|
||||
//faux input field
|
||||
constexpr vtkm::Id nvals = 8;
|
||||
constexpr int data[nvals] = { -1, 0, 10, 20, 30, 40, 50, 60 };
|
||||
constexpr vtkm::FloatDefault data[nvals] = { -1, 0, 10, 20, 30, 40, 50, 60 };
|
||||
|
||||
//build a color table with clamping off and verify that sampling works
|
||||
vtkm::Range range{ 0.0, 50.0 };
|
||||
|
@ -70,7 +70,7 @@ vtkm::cont::PartitionedDataSet PartitionedDataSetBuilder(std::size_t partitionNu
|
||||
}
|
||||
return partitions;
|
||||
}
|
||||
template <typename D>
|
||||
template <typename T, typename D>
|
||||
void Result_Verify(const vtkm::cont::PartitionedDataSet& result,
|
||||
D& filter,
|
||||
const vtkm::cont::PartitionedDataSet& partitions,
|
||||
@ -88,9 +88,9 @@ void Result_Verify(const vtkm::cont::PartitionedDataSet& result,
|
||||
partitionResult.GetField(outputFieldName).GetNumberOfValues(),
|
||||
"result vectors' size incorrect");
|
||||
|
||||
vtkm::cont::ArrayHandle<vtkm::Id> partitionArray;
|
||||
vtkm::cont::ArrayHandle<T> partitionArray;
|
||||
result.GetPartition(j).GetField(outputFieldName).GetData().CopyTo(partitionArray);
|
||||
vtkm::cont::ArrayHandle<vtkm::Id> sDataSetArray;
|
||||
vtkm::cont::ArrayHandle<T> sDataSetArray;
|
||||
partitionResult.GetField(outputFieldName).GetData().CopyTo(sDataSetArray);
|
||||
|
||||
const vtkm::Id numValues = result.GetPartition(j).GetField(outputFieldName).GetNumberOfValues();
|
||||
@ -109,12 +109,12 @@ void TestPartitionedDataSetFilters()
|
||||
vtkm::cont::PartitionedDataSet result;
|
||||
vtkm::cont::PartitionedDataSet partitions;
|
||||
|
||||
partitions = PartitionedDataSetBuilder<vtkm::Id>(partitionNum, "pointvar");
|
||||
partitions = PartitionedDataSetBuilder<vtkm::FloatDefault>(partitionNum, "pointvar");
|
||||
vtkm::filter::CellAverage cellAverage;
|
||||
cellAverage.SetOutputFieldName("average");
|
||||
cellAverage.SetActiveField("pointvar");
|
||||
result = cellAverage.Execute(partitions);
|
||||
Result_Verify(result, cellAverage, partitions, std::string("pointvar"));
|
||||
Result_Verify<vtkm::FloatDefault>(result, cellAverage, partitions, std::string("pointvar"));
|
||||
}
|
||||
|
||||
int UnitTestPartitionedDataSetFilters(int argc, char* argv[])
|
||||
|
@ -44,6 +44,13 @@ struct CheckSameCoordinateSystem
|
||||
CheckSameField{}(originalArray, fileCoords);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void operator()(const vtkm::cont::ArrayHandle<T, vtkm::cont::StorageTagSOA>& originalArray,
|
||||
const vtkm::cont::CoordinateSystem& fileCoords) const
|
||||
{
|
||||
CheckSameField{}(originalArray, fileCoords);
|
||||
}
|
||||
|
||||
#ifndef VTKM_NO_DEPRECATED_VIRTUAL
|
||||
VTKM_DEPRECATED_SUPPRESS_BEGIN
|
||||
template <typename T>
|
||||
|
@ -126,14 +126,16 @@ struct DoVariantTestWorklet
|
||||
std::cout << "Create and run dispatcher with unknown arrays." << std::endl;
|
||||
vtkm::worklet::DispatcherMapField<WorkletType> dispatcher;
|
||||
|
||||
vtkm::cont::UnknownArrayHandle inputVariant(inputHandle);
|
||||
using UncertainArrayType =
|
||||
vtkm::cont::UncertainArrayHandle<vtkm::List<T>, VTKM_DEFAULT_STORAGE_LIST>;
|
||||
UncertainArrayType inputVariant(inputHandle);
|
||||
|
||||
{ //Verify we can pass by value
|
||||
vtkm::cont::ArrayCopy(inputHandle, inoutHandle);
|
||||
vtkm::cont::UnknownArrayHandle outputVariant(outputHandle);
|
||||
vtkm::cont::UnknownArrayHandle inoutVariant(inoutHandle);
|
||||
dispatcher.Invoke(
|
||||
inputVariant.ResetTypes<vtkm::List<T>, vtkm::List<VTKM_DEFAULT_STORAGE_TAG>>(),
|
||||
inputVariant.template ResetTypes<vtkm::List<T>, vtkm::List<VTKM_DEFAULT_STORAGE_TAG>>(),
|
||||
outputVariant.ResetTypes<vtkm::List<T>, vtkm::List<VTKM_DEFAULT_STORAGE_TAG>>(),
|
||||
inoutVariant.ResetTypes<vtkm::List<T>, vtkm::List<VTKM_DEFAULT_STORAGE_TAG>>());
|
||||
CheckPortal(outputHandle.ReadPortal());
|
||||
@ -141,8 +143,8 @@ struct DoVariantTestWorklet
|
||||
}
|
||||
|
||||
{ //Verify we can pass by pointer
|
||||
vtkm::cont::UnknownArrayHandle outputVariant(outputHandle);
|
||||
vtkm::cont::UnknownArrayHandle inoutVariant(inoutHandle);
|
||||
UncertainArrayType outputVariant(outputHandle);
|
||||
UncertainArrayType inoutVariant(inoutHandle);
|
||||
|
||||
vtkm::cont::ArrayCopy(inputHandle, inoutHandle);
|
||||
dispatcher.Invoke(&inputVariant, outputHandle, inoutHandle);
|
||||
|
Loading…
Reference in New Issue
Block a user