mirror of
https://gitlab.kitware.com/vtk/vtk-m
synced 2024-10-05 01:49:02 +00:00
Support ArrayHandleSOA
only for Vec
value types
Previously, `ArrayHandleSOA` worked with any value type that supported `VecTraits`. That means that `ArrayHandleSOA` worked with scalar types like `Float32`. However, for scalar types, the behavior is essentially the same as `ArrayHandleBasic`, but with lots of extra templating and code generation. Although there is nothing _wrong_ with allowing `ArrayHandleSOA` holding a scalar, there is no real reason to either (other than likely template convenience). Generally, there is nothing wrong with supporting it, but if you want to support `ArrayHandleSOA` in places where types are not known (e.g. `Field`), then templating tends to iterate over the cross of all supported types with all supported storage. That means such code will automatically generate a bunch of code for `ArrayHandleSOA` with scalars even if there is no reason for those code paths. So, we can just disable the use of `ArrayHandleSOA` with scalars to allow us to use `ArrayHandleSOA` as a default storage without creating all these useless code paths.
This commit is contained in:
parent
142a538d32
commit
77f9ae653d
@ -1002,6 +1002,10 @@ VTKM_CONT_EXPORT VTKM_CONT vtkm::cont::DeviceAdapterId ArrayHandleGetDeviceAdapt
|
||||
template <typename T, typename StorageTag_ = VTKM_DEFAULT_STORAGE_TAG>
|
||||
class VTKM_ALWAYS_EXPORT ArrayHandleNewStyle : 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; }
|
||||
|
||||
@ -632,7 +629,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>;
|
||||
|
@ -1426,6 +1426,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>>;
|
||||
@ -1449,12 +1451,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());
|
||||
|
Loading…
Reference in New Issue
Block a user