2019-04-15 23:24:21 +00:00
|
|
|
//============================================================================
|
2015-05-05 18:25:48 +00:00
|
|
|
// 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.
|
2019-04-15 23:24:21 +00:00
|
|
|
//============================================================================
|
2015-05-05 18:25:48 +00:00
|
|
|
#ifndef vtk_m_cont_testing_TestingFancyArrayHandles_h
|
|
|
|
#define vtk_m_cont_testing_TestingFancyArrayHandles_h
|
|
|
|
|
2017-05-18 14:51:24 +00:00
|
|
|
#include <vtkm/VecTraits.h>
|
2015-07-13 17:01:41 +00:00
|
|
|
#include <vtkm/cont/ArrayHandle.h>
|
2015-09-01 21:42:45 +00:00
|
|
|
#include <vtkm/cont/ArrayHandleCast.h>
|
2015-07-13 17:01:41 +00:00
|
|
|
#include <vtkm/cont/ArrayHandleCompositeVector.h>
|
2016-10-28 03:14:29 +00:00
|
|
|
#include <vtkm/cont/ArrayHandleConcatenate.h>
|
2015-05-13 20:24:51 +00:00
|
|
|
#include <vtkm/cont/ArrayHandleConstant.h>
|
2015-05-05 18:25:48 +00:00
|
|
|
#include <vtkm/cont/ArrayHandleCounting.h>
|
2017-02-07 17:53:53 +00:00
|
|
|
#include <vtkm/cont/ArrayHandleDiscard.h>
|
2015-09-28 23:19:38 +00:00
|
|
|
#include <vtkm/cont/ArrayHandleGroupVec.h>
|
2016-10-28 03:14:29 +00:00
|
|
|
#include <vtkm/cont/ArrayHandleGroupVecVariable.h>
|
2015-05-05 18:25:48 +00:00
|
|
|
#include <vtkm/cont/ArrayHandleImplicit.h>
|
2015-09-15 04:55:44 +00:00
|
|
|
#include <vtkm/cont/ArrayHandleIndex.h>
|
2015-05-05 18:25:48 +00:00
|
|
|
#include <vtkm/cont/ArrayHandlePermutation.h>
|
|
|
|
#include <vtkm/cont/ArrayHandleTransform.h>
|
2018-08-29 20:54:31 +00:00
|
|
|
#include <vtkm/cont/ArrayHandleView.h>
|
2015-05-05 18:25:48 +00:00
|
|
|
#include <vtkm/cont/ArrayHandleZip.h>
|
2018-09-05 16:07:23 +00:00
|
|
|
#include <vtkm/cont/VirtualObjectHandle.h>
|
2015-05-05 18:25:48 +00:00
|
|
|
|
|
|
|
#include <vtkm/worklet/DispatcherMapField.h>
|
|
|
|
#include <vtkm/worklet/WorkletMapField.h>
|
|
|
|
|
|
|
|
#include <vtkm/cont/testing/Testing.h>
|
|
|
|
|
2015-07-13 17:01:41 +00:00
|
|
|
#include <vector>
|
|
|
|
|
2015-05-05 18:25:48 +00:00
|
|
|
namespace fancy_array_detail
|
|
|
|
{
|
|
|
|
|
2017-05-18 14:29:41 +00:00
|
|
|
template <typename ValueType>
|
2015-05-05 18:25:48 +00:00
|
|
|
struct IndexSquared
|
|
|
|
{
|
2016-10-19 22:42:58 +00:00
|
|
|
VTKM_EXEC_CONT
|
2015-05-07 22:34:06 +00:00
|
|
|
ValueType operator()(vtkm::Id index) const
|
|
|
|
{
|
2017-08-16 15:34:21 +00:00
|
|
|
using ComponentType = typename vtkm::VecTraits<ValueType>::ComponentType;
|
2017-05-18 14:29:41 +00:00
|
|
|
return ValueType(static_cast<ComponentType>(index * index));
|
2015-05-07 22:34:06 +00:00
|
|
|
}
|
2015-05-05 18:25:48 +00:00
|
|
|
};
|
|
|
|
|
2017-05-18 14:29:41 +00:00
|
|
|
template <typename ValueType>
|
2015-05-05 18:25:48 +00:00
|
|
|
struct ValueSquared
|
|
|
|
{
|
2017-05-18 14:29:41 +00:00
|
|
|
template <typename U>
|
|
|
|
VTKM_EXEC_CONT ValueType operator()(U u) const
|
|
|
|
{
|
2018-05-14 18:25:46 +00:00
|
|
|
return vtkm::Dot(u, u);
|
2017-05-18 14:29:41 +00:00
|
|
|
}
|
2015-05-05 18:25:48 +00:00
|
|
|
};
|
|
|
|
|
2015-09-29 14:36:11 +00:00
|
|
|
struct ValueScale
|
|
|
|
{
|
2017-05-18 14:29:41 +00:00
|
|
|
ValueScale()
|
2018-09-05 16:07:23 +00:00
|
|
|
: Factor(1.0)
|
2017-05-18 14:29:41 +00:00
|
|
|
{
|
|
|
|
}
|
2015-09-29 14:36:11 +00:00
|
|
|
|
2017-05-18 14:29:41 +00:00
|
|
|
ValueScale(vtkm::Float64 factor)
|
|
|
|
: Factor(factor)
|
|
|
|
{
|
|
|
|
}
|
2015-09-29 14:36:11 +00:00
|
|
|
|
2017-05-18 14:29:41 +00:00
|
|
|
template <typename ValueType>
|
|
|
|
VTKM_EXEC_CONT ValueType operator()(const ValueType& v) const
|
2015-09-29 14:36:11 +00:00
|
|
|
{
|
2017-08-16 15:34:21 +00:00
|
|
|
using Traits = vtkm::VecTraits<ValueType>;
|
2017-09-21 14:33:17 +00:00
|
|
|
using TTraits = vtkm::TypeTraits<ValueType>;
|
2017-08-16 15:34:21 +00:00
|
|
|
using ComponentType = typename Traits::ComponentType;
|
2015-09-29 14:36:11 +00:00
|
|
|
|
2017-09-21 14:33:17 +00:00
|
|
|
ValueType result = TTraits::ZeroInitialization();
|
2015-09-29 14:36:11 +00:00
|
|
|
for (vtkm::IdComponent i = 0; i < Traits::GetNumberOfComponents(v); ++i)
|
|
|
|
{
|
|
|
|
vtkm::Float64 vi = static_cast<vtkm::Float64>(Traits::GetComponent(v, i));
|
|
|
|
vtkm::Float64 ri = vi * this->Factor;
|
|
|
|
Traits::SetComponent(result, i, static_cast<ComponentType>(ri));
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
vtkm::Float64 Factor;
|
|
|
|
};
|
2018-09-05 16:07:23 +00:00
|
|
|
|
|
|
|
struct InverseValueScale
|
|
|
|
{
|
|
|
|
InverseValueScale()
|
|
|
|
: InverseFactor(1.0)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
InverseValueScale(vtkm::Float64 factor)
|
|
|
|
: InverseFactor(1.0 / factor)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
template <typename ValueType>
|
|
|
|
VTKM_EXEC_CONT ValueType operator()(const ValueType& v) const
|
|
|
|
{
|
|
|
|
using Traits = vtkm::VecTraits<ValueType>;
|
|
|
|
using TTraits = vtkm::TypeTraits<ValueType>;
|
|
|
|
using ComponentType = typename Traits::ComponentType;
|
|
|
|
|
|
|
|
ValueType result = TTraits::ZeroInitialization();
|
|
|
|
for (vtkm::IdComponent i = 0; i < Traits::GetNumberOfComponents(v); ++i)
|
|
|
|
{
|
|
|
|
vtkm::Float64 vi = static_cast<vtkm::Float64>(Traits::GetComponent(v, i));
|
|
|
|
vtkm::Float64 ri = vi * this->InverseFactor;
|
|
|
|
Traits::SetComponent(result, i, static_cast<ComponentType>(ri));
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
vtkm::Float64 InverseFactor;
|
|
|
|
};
|
|
|
|
|
|
|
|
template <typename ValueType>
|
|
|
|
struct VirtualTransformFunctorBase : public vtkm::VirtualObjectBase
|
|
|
|
{
|
|
|
|
VirtualTransformFunctorBase() = default;
|
|
|
|
|
|
|
|
VTKM_EXEC_CONT
|
|
|
|
virtual ValueType operator()(const ValueType& v) const = 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
template <typename ValueType, typename FunctorType>
|
|
|
|
struct VirtualTransformFunctor : VirtualTransformFunctorBase<ValueType>
|
|
|
|
{
|
|
|
|
FunctorType Functor;
|
|
|
|
|
|
|
|
VTKM_CONT
|
|
|
|
VirtualTransformFunctor(const FunctorType& functor)
|
|
|
|
: Functor(functor)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
VTKM_EXEC_CONT
|
|
|
|
ValueType operator()(const ValueType& v) const override { return this->Functor(v); }
|
|
|
|
};
|
|
|
|
|
|
|
|
template <typename ValueType>
|
2018-09-08 17:07:06 +00:00
|
|
|
struct TransformExecObject : public vtkm::cont::ExecutionAndControlObjectBase
|
2018-09-05 16:07:23 +00:00
|
|
|
{
|
|
|
|
vtkm::cont::VirtualObjectHandle<VirtualTransformFunctorBase<ValueType>> VirtualFunctor;
|
|
|
|
|
|
|
|
VTKM_CONT TransformExecObject() = default;
|
|
|
|
|
|
|
|
template <typename FunctorType>
|
|
|
|
VTKM_CONT TransformExecObject(const FunctorType& functor)
|
|
|
|
{
|
|
|
|
// Need to make sure the serial device is supported, since that is what is used on the
|
2019-05-20 19:04:09 +00:00
|
|
|
// control side. Therefore we reset to all supported devices.
|
2019-05-21 19:32:10 +00:00
|
|
|
vtkm::cont::ScopedRuntimeDeviceTracker scopedTracker(
|
|
|
|
vtkm::cont::DeviceAdapterTagSerial{}, vtkm::cont::RuntimeDeviceTrackerMode::Enable);
|
2018-09-05 16:07:23 +00:00
|
|
|
this->VirtualFunctor.Reset(new VirtualTransformFunctor<ValueType, FunctorType>(functor));
|
|
|
|
}
|
|
|
|
|
2018-09-08 17:07:06 +00:00
|
|
|
struct FunctorWrapper
|
2018-09-05 16:07:23 +00:00
|
|
|
{
|
|
|
|
const VirtualTransformFunctorBase<ValueType>* FunctorPointer;
|
|
|
|
|
2018-09-08 17:07:06 +00:00
|
|
|
FunctorWrapper() = default;
|
2018-09-05 16:07:23 +00:00
|
|
|
|
|
|
|
VTKM_CONT
|
2018-09-08 17:07:06 +00:00
|
|
|
FunctorWrapper(const VirtualTransformFunctorBase<ValueType>* functorPointer)
|
2018-09-05 16:07:23 +00:00
|
|
|
: FunctorPointer(functorPointer)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
template <typename InValueType>
|
|
|
|
VTKM_EXEC ValueType operator()(const InValueType& value) const
|
|
|
|
{
|
|
|
|
return (*this->FunctorPointer)(value);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
template <typename DeviceAdapterTag>
|
2018-09-08 17:07:06 +00:00
|
|
|
VTKM_CONT FunctorWrapper PrepareForExecution(DeviceAdapterTag device) const
|
|
|
|
{
|
|
|
|
return FunctorWrapper(this->VirtualFunctor.PrepareForExecution(device));
|
|
|
|
}
|
|
|
|
|
|
|
|
VTKM_CONT FunctorWrapper PrepareForControl() const
|
2018-09-05 16:07:23 +00:00
|
|
|
{
|
2018-09-08 17:07:06 +00:00
|
|
|
return FunctorWrapper(this->VirtualFunctor.Get());
|
2018-09-05 16:07:23 +00:00
|
|
|
}
|
|
|
|
};
|
2015-05-05 18:25:48 +00:00
|
|
|
}
|
|
|
|
|
2017-05-18 14:29:41 +00:00
|
|
|
namespace vtkm
|
|
|
|
{
|
|
|
|
namespace cont
|
|
|
|
{
|
|
|
|
namespace testing
|
|
|
|
{
|
2015-05-05 18:25:48 +00:00
|
|
|
|
|
|
|
/// This class has a single static member, Run, that tests that all Fancy Array
|
|
|
|
/// Handles work with the given DeviceAdapter
|
|
|
|
///
|
2017-05-18 14:29:41 +00:00
|
|
|
template <class DeviceAdapterTag>
|
2015-05-05 18:25:48 +00:00
|
|
|
struct TestingFancyArrayHandles
|
|
|
|
{
|
|
|
|
|
|
|
|
private:
|
|
|
|
static const int ARRAY_SIZE = 10;
|
|
|
|
|
|
|
|
public:
|
|
|
|
struct PassThrough : public vtkm::worklet::WorkletMapField
|
2016-10-28 03:14:29 +00:00
|
|
|
{
|
2019-01-10 18:59:25 +00:00
|
|
|
using ControlSignature = void(FieldIn, FieldOut);
|
2018-05-25 21:18:41 +00:00
|
|
|
using ExecutionSignature = _2(_1);
|
2015-05-05 18:25:48 +00:00
|
|
|
|
2017-05-18 14:29:41 +00:00
|
|
|
template <class ValueType>
|
|
|
|
VTKM_EXEC ValueType operator()(const ValueType& inValue) const
|
|
|
|
{
|
|
|
|
return inValue;
|
|
|
|
}
|
2016-10-28 03:14:29 +00:00
|
|
|
};
|
2015-05-05 18:25:48 +00:00
|
|
|
|
2017-01-17 22:33:18 +00:00
|
|
|
struct InplaceFunctorPair : public vtkm::worklet::WorkletMapField
|
|
|
|
{
|
2019-01-10 18:59:25 +00:00
|
|
|
using ControlSignature = void(FieldInOut);
|
2018-05-25 21:18:41 +00:00
|
|
|
using ExecutionSignature = void(_1);
|
2017-01-17 22:33:18 +00:00
|
|
|
|
2017-05-18 14:29:41 +00:00
|
|
|
template <typename T>
|
|
|
|
VTKM_EXEC void operator()(vtkm::Pair<T, T>& value) const
|
2017-01-17 22:33:18 +00:00
|
|
|
{
|
|
|
|
value.second = value.first;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2016-11-23 00:31:50 +00:00
|
|
|
#ifndef VTKM_CUDA
|
2015-05-05 18:25:48 +00:00
|
|
|
private:
|
2016-11-23 00:31:50 +00:00
|
|
|
#endif
|
2015-07-13 17:01:41 +00:00
|
|
|
|
|
|
|
struct TestCompositeAsInput
|
2015-05-05 18:25:48 +00:00
|
|
|
{
|
2017-05-18 14:29:41 +00:00
|
|
|
template <typename ValueType>
|
2016-10-19 22:42:58 +00:00
|
|
|
VTKM_CONT void operator()(const ValueType vtkmNotUsed(v)) const
|
2015-05-05 18:25:48 +00:00
|
|
|
{
|
2015-07-13 17:01:41 +00:00
|
|
|
const ValueType value = TestValue(13, ValueType());
|
2017-05-18 14:29:41 +00:00
|
|
|
std::vector<ValueType> compositeData(ARRAY_SIZE, value);
|
|
|
|
vtkm::cont::ArrayHandle<ValueType> compositeInput =
|
|
|
|
vtkm::cont::make_ArrayHandle(compositeData);
|
2015-05-05 18:25:48 +00:00
|
|
|
|
2018-05-10 17:06:08 +00:00
|
|
|
auto composite =
|
|
|
|
vtkm::cont::make_ArrayHandleCompositeVector(compositeInput, compositeInput, compositeInput);
|
2015-05-05 18:25:48 +00:00
|
|
|
|
2017-02-15 00:14:29 +00:00
|
|
|
vtkm::cont::printSummary_ArrayHandle(composite, std::cout);
|
|
|
|
std::cout << std::endl;
|
|
|
|
|
2017-05-18 14:29:41 +00:00
|
|
|
vtkm::cont::ArrayHandle<vtkm::Vec<ValueType, 3>> result;
|
2015-05-05 18:25:48 +00:00
|
|
|
|
2018-08-28 20:36:50 +00:00
|
|
|
vtkm::worklet::DispatcherMapField<PassThrough> dispatcher;
|
2015-07-13 17:01:41 +00:00
|
|
|
dispatcher.Invoke(composite, result);
|
2015-05-05 18:25:48 +00:00
|
|
|
|
|
|
|
//verify that the control portal works
|
2017-05-18 14:29:41 +00:00
|
|
|
for (vtkm::Id i = 0; i < ARRAY_SIZE; ++i)
|
|
|
|
{
|
|
|
|
const vtkm::Vec<ValueType, 3> result_v = result.GetPortalConstControl().Get(i);
|
2015-07-13 17:01:41 +00:00
|
|
|
VTKM_TEST_ASSERT(test_equal(result_v, vtkm::Vec<ValueType, 3>(value)),
|
2017-05-18 14:29:41 +00:00
|
|
|
"CompositeVector Handle Failed");
|
2016-01-04 19:53:56 +00:00
|
|
|
|
2017-05-18 14:29:41 +00:00
|
|
|
const vtkm::Vec<ValueType, 3> result_c = composite.GetPortalConstControl().Get(i);
|
2016-01-04 19:53:56 +00:00
|
|
|
VTKM_TEST_ASSERT(test_equal(result_c, vtkm::Vec<ValueType, 3>(value)),
|
2017-05-18 14:29:41 +00:00
|
|
|
"CompositeVector Handle Failed");
|
|
|
|
}
|
2015-05-05 18:25:48 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2015-05-13 20:24:51 +00:00
|
|
|
struct TestConstantAsInput
|
|
|
|
{
|
2017-05-18 14:29:41 +00:00
|
|
|
template <typename ValueType>
|
2016-10-19 22:42:58 +00:00
|
|
|
VTKM_CONT void operator()(const ValueType vtkmNotUsed(v)) const
|
2015-05-13 20:24:51 +00:00
|
|
|
{
|
|
|
|
const ValueType value = TestValue(43, ValueType());
|
|
|
|
|
|
|
|
vtkm::cont::ArrayHandleConstant<ValueType> constant =
|
2017-05-18 14:29:41 +00:00
|
|
|
vtkm::cont::make_ArrayHandleConstant(value, ARRAY_SIZE);
|
2015-05-13 20:24:51 +00:00
|
|
|
vtkm::cont::ArrayHandle<ValueType> result;
|
|
|
|
|
2018-08-28 20:36:50 +00:00
|
|
|
vtkm::worklet::DispatcherMapField<PassThrough> dispatcher;
|
2015-05-13 20:24:51 +00:00
|
|
|
dispatcher.Invoke(constant, result);
|
|
|
|
|
2017-02-15 00:14:29 +00:00
|
|
|
vtkm::cont::printSummary_ArrayHandle(constant, std::cout);
|
|
|
|
std::cout << std::endl;
|
|
|
|
|
2015-05-13 20:24:51 +00:00
|
|
|
//verify that the control portal works
|
2017-05-18 14:29:41 +00:00
|
|
|
for (vtkm::Id i = 0; i < ARRAY_SIZE; ++i)
|
|
|
|
{
|
2015-05-13 20:24:51 +00:00
|
|
|
const ValueType result_v = result.GetPortalConstControl().Get(i);
|
|
|
|
const ValueType control_value = constant.GetPortalConstControl().Get(i);
|
2017-05-18 14:29:41 +00:00
|
|
|
VTKM_TEST_ASSERT(test_equal(result_v, value), "Counting Handle Failed");
|
|
|
|
VTKM_TEST_ASSERT(test_equal(result_v, control_value), "Counting Handle Control Failed");
|
|
|
|
}
|
2015-05-13 20:24:51 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2015-05-05 18:25:48 +00:00
|
|
|
struct TestCountingAsInput
|
|
|
|
{
|
2017-05-18 14:29:41 +00:00
|
|
|
template <typename ValueType>
|
2016-10-19 22:42:58 +00:00
|
|
|
VTKM_CONT void operator()(const ValueType vtkmNotUsed(v)) const
|
2015-05-05 18:25:48 +00:00
|
|
|
{
|
2017-08-16 15:34:21 +00:00
|
|
|
using ComponentType = typename vtkm::VecTraits<ValueType>::ComponentType;
|
2015-05-07 22:34:06 +00:00
|
|
|
|
2015-05-05 18:25:48 +00:00
|
|
|
const vtkm::Id length = ARRAY_SIZE;
|
|
|
|
|
|
|
|
//need to initialize the start value or else vectors will have
|
|
|
|
//random values to start
|
2015-05-07 22:34:06 +00:00
|
|
|
ComponentType component_value(0);
|
|
|
|
const ValueType start = ValueType(component_value);
|
2015-05-05 18:25:48 +00:00
|
|
|
|
2017-05-18 14:29:41 +00:00
|
|
|
vtkm::cont::ArrayHandleCounting<ValueType> counting =
|
|
|
|
vtkm::cont::make_ArrayHandleCounting(start, ValueType(1), length);
|
|
|
|
vtkm::cont::ArrayHandle<ValueType> result;
|
2015-05-05 18:25:48 +00:00
|
|
|
|
2018-08-28 20:36:50 +00:00
|
|
|
vtkm::worklet::DispatcherMapField<PassThrough> dispatcher;
|
2015-05-05 18:25:48 +00:00
|
|
|
dispatcher.Invoke(counting, result);
|
|
|
|
|
2017-02-15 00:14:29 +00:00
|
|
|
vtkm::cont::printSummary_ArrayHandle(counting, std::cout);
|
|
|
|
std::cout << std::endl;
|
|
|
|
|
2015-05-05 18:25:48 +00:00
|
|
|
//verify that the control portal works
|
2017-05-18 14:29:41 +00:00
|
|
|
for (vtkm::Id i = 0; i < length; ++i)
|
|
|
|
{
|
2015-05-05 18:25:48 +00:00
|
|
|
const ValueType result_v = result.GetPortalConstControl().Get(i);
|
2015-05-07 22:34:06 +00:00
|
|
|
const ValueType correct_value = ValueType(component_value);
|
2015-05-05 18:25:48 +00:00
|
|
|
const ValueType control_value = counting.GetPortalConstControl().Get(i);
|
2017-05-18 14:29:41 +00:00
|
|
|
VTKM_TEST_ASSERT(test_equal(result_v, correct_value), "Counting Handle Failed");
|
|
|
|
VTKM_TEST_ASSERT(test_equal(result_v, control_value), "Counting Handle Control Failed");
|
2015-07-30 22:43:19 +00:00
|
|
|
component_value = ComponentType(component_value + ComponentType(1));
|
2017-05-18 14:29:41 +00:00
|
|
|
}
|
2015-05-05 18:25:48 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
struct TestImplicitAsInput
|
|
|
|
{
|
2017-05-18 14:29:41 +00:00
|
|
|
template <typename ValueType>
|
2016-10-19 22:42:58 +00:00
|
|
|
VTKM_CONT void operator()(const ValueType vtkmNotUsed(v)) const
|
2015-05-05 18:25:48 +00:00
|
|
|
{
|
|
|
|
const vtkm::Id length = ARRAY_SIZE;
|
2017-08-16 15:34:21 +00:00
|
|
|
using FunctorType = ::fancy_array_detail::IndexSquared<ValueType>;
|
2015-05-05 18:25:48 +00:00
|
|
|
FunctorType functor;
|
|
|
|
|
2017-05-30 15:13:18 +00:00
|
|
|
vtkm::cont::ArrayHandleImplicit<FunctorType> implicit =
|
|
|
|
vtkm::cont::make_ArrayHandleImplicit(functor, length);
|
2015-05-05 18:25:48 +00:00
|
|
|
|
2017-02-15 00:14:29 +00:00
|
|
|
vtkm::cont::printSummary_ArrayHandle(implicit, std::cout);
|
|
|
|
std::cout << std::endl;
|
|
|
|
|
2017-05-18 14:29:41 +00:00
|
|
|
vtkm::cont::ArrayHandle<ValueType> result;
|
2015-05-05 18:25:48 +00:00
|
|
|
|
2018-08-28 20:36:50 +00:00
|
|
|
vtkm::worklet::DispatcherMapField<PassThrough> dispatcher;
|
2015-05-05 18:25:48 +00:00
|
|
|
dispatcher.Invoke(implicit, result);
|
|
|
|
|
|
|
|
//verify that the control portal works
|
2017-05-18 14:29:41 +00:00
|
|
|
for (vtkm::Id i = 0; i < length; ++i)
|
|
|
|
{
|
2015-05-05 18:25:48 +00:00
|
|
|
const ValueType result_v = result.GetPortalConstControl().Get(i);
|
2017-05-18 14:29:41 +00:00
|
|
|
const ValueType correct_value = functor(i);
|
2015-05-05 18:25:48 +00:00
|
|
|
const ValueType control_value = implicit.GetPortalConstControl().Get(i);
|
2017-05-18 14:29:41 +00:00
|
|
|
VTKM_TEST_ASSERT(test_equal(result_v, correct_value), "Implicit Handle Failed");
|
|
|
|
VTKM_TEST_ASSERT(test_equal(result_v, control_value), "Implicit Handle Failed");
|
|
|
|
}
|
2015-05-05 18:25:48 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2016-08-08 22:38:41 +00:00
|
|
|
struct TestConcatenateAsInput
|
|
|
|
{
|
2017-05-18 14:29:41 +00:00
|
|
|
template <typename ValueType>
|
2016-10-19 22:42:58 +00:00
|
|
|
VTKM_CONT void operator()(const ValueType vtkmNotUsed(v)) const
|
2016-08-08 22:38:41 +00:00
|
|
|
{
|
|
|
|
const vtkm::Id length = ARRAY_SIZE;
|
|
|
|
|
2017-08-16 15:34:21 +00:00
|
|
|
using FunctorType = ::fancy_array_detail::IndexSquared<ValueType>;
|
|
|
|
using ComponentType = typename vtkm::VecTraits<ValueType>::ComponentType;
|
2016-08-08 22:38:41 +00:00
|
|
|
|
2017-08-16 15:34:21 +00:00
|
|
|
using ValueHandleType = vtkm::cont::ArrayHandleImplicit<FunctorType>;
|
|
|
|
using BasicArrayType = vtkm::cont::ArrayHandle<ValueType>;
|
|
|
|
using ConcatenateType = vtkm::cont::ArrayHandleConcatenate<ValueHandleType, BasicArrayType>;
|
2016-08-08 22:38:41 +00:00
|
|
|
|
|
|
|
FunctorType functor;
|
2017-05-18 14:29:41 +00:00
|
|
|
for (vtkm::Id start_pos = 0; start_pos < length; start_pos += length / 4)
|
2016-08-08 22:38:41 +00:00
|
|
|
{
|
|
|
|
vtkm::Id implicitLen = length - start_pos;
|
2017-05-18 14:29:41 +00:00
|
|
|
vtkm::Id basicLen = start_pos;
|
2017-01-31 19:13:45 +00:00
|
|
|
|
2016-08-08 22:38:41 +00:00
|
|
|
// make an implicit array
|
2017-05-30 15:13:18 +00:00
|
|
|
ValueHandleType implicit = vtkm::cont::make_ArrayHandleImplicit(functor, implicitLen);
|
2016-08-08 22:38:41 +00:00
|
|
|
// make a basic array
|
2017-05-18 14:29:41 +00:00
|
|
|
std::vector<ValueType> basicVec;
|
|
|
|
for (vtkm::Id i = 0; i < basicLen; i++)
|
2016-08-08 22:38:41 +00:00
|
|
|
{
|
2017-05-18 14:29:41 +00:00
|
|
|
basicVec.push_back(ValueType(static_cast<ComponentType>(i)));
|
|
|
|
basicVec.push_back(ValueType(ComponentType(i)));
|
2016-08-08 22:38:41 +00:00
|
|
|
}
|
2017-05-18 14:29:41 +00:00
|
|
|
BasicArrayType basic = vtkm::cont::make_ArrayHandle(basicVec);
|
2016-08-08 22:38:41 +00:00
|
|
|
|
|
|
|
// concatenate two arrays together
|
2017-05-18 14:29:41 +00:00
|
|
|
ConcatenateType concatenate = vtkm::cont::make_ArrayHandleConcatenate(implicit, basic);
|
2017-02-15 00:14:29 +00:00
|
|
|
vtkm::cont::printSummary_ArrayHandle(concatenate, std::cout);
|
|
|
|
std::cout << std::endl;
|
2016-08-08 22:38:41 +00:00
|
|
|
|
2017-05-18 14:29:41 +00:00
|
|
|
vtkm::cont::ArrayHandle<ValueType> result;
|
2016-08-08 22:38:41 +00:00
|
|
|
|
2018-08-28 20:36:50 +00:00
|
|
|
vtkm::worklet::DispatcherMapField<PassThrough> dispatcher;
|
2016-08-08 22:38:41 +00:00
|
|
|
dispatcher.Invoke(concatenate, result);
|
|
|
|
|
|
|
|
//verify that the control portal works
|
2017-05-18 14:29:41 +00:00
|
|
|
for (vtkm::Id i = 0; i < length; ++i)
|
2016-08-08 22:38:41 +00:00
|
|
|
{
|
2017-05-18 14:29:41 +00:00
|
|
|
const ValueType result_v = result.GetPortalConstControl().Get(i);
|
2016-08-08 22:38:41 +00:00
|
|
|
ValueType correct_value;
|
2017-05-18 14:29:41 +00:00
|
|
|
if (i < implicitLen)
|
|
|
|
correct_value = implicit.GetPortalConstControl().Get(i);
|
2016-08-08 22:38:41 +00:00
|
|
|
else
|
2017-05-18 14:29:41 +00:00
|
|
|
correct_value = basic.GetPortalConstControl().Get(i - implicitLen);
|
|
|
|
const ValueType control_value = concatenate.GetPortalConstControl().Get(i);
|
2016-08-08 22:38:41 +00:00
|
|
|
VTKM_TEST_ASSERT(test_equal(result_v, correct_value),
|
|
|
|
"ArrayHandleConcatenate as Input Failed");
|
|
|
|
VTKM_TEST_ASSERT(test_equal(result_v, control_value),
|
|
|
|
"ArrayHandleConcatenate as Input Failed");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2015-05-05 18:25:48 +00:00
|
|
|
struct TestPermutationAsInput
|
|
|
|
{
|
2017-05-18 14:29:41 +00:00
|
|
|
template <typename ValueType>
|
2016-10-19 22:42:58 +00:00
|
|
|
VTKM_CONT void operator()(const ValueType vtkmNotUsed(v)) const
|
2015-05-05 18:25:48 +00:00
|
|
|
{
|
|
|
|
const vtkm::Id length = ARRAY_SIZE;
|
|
|
|
|
2017-08-16 15:34:21 +00:00
|
|
|
using FunctorType = ::fancy_array_detail::IndexSquared<ValueType>;
|
2015-05-05 18:25:48 +00:00
|
|
|
|
2017-08-16 15:34:21 +00:00
|
|
|
using KeyHandleType = vtkm::cont::ArrayHandleCounting<vtkm::Id>;
|
|
|
|
using ValueHandleType = vtkm::cont::ArrayHandleImplicit<FunctorType>;
|
|
|
|
using PermutationHandleType =
|
|
|
|
vtkm::cont::ArrayHandlePermutation<KeyHandleType, ValueHandleType>;
|
2015-05-05 18:25:48 +00:00
|
|
|
|
|
|
|
FunctorType functor;
|
2017-05-18 14:29:41 +00:00
|
|
|
for (vtkm::Id start_pos = 0; start_pos < length; start_pos += length / 4)
|
|
|
|
{
|
2015-05-05 18:25:48 +00:00
|
|
|
const vtkm::Id counting_length = length - start_pos;
|
|
|
|
|
|
|
|
KeyHandleType counting =
|
2017-05-18 14:29:41 +00:00
|
|
|
vtkm::cont::make_ArrayHandleCounting<vtkm::Id>(start_pos, 1, counting_length);
|
2015-05-05 18:25:48 +00:00
|
|
|
|
2017-05-30 15:13:18 +00:00
|
|
|
ValueHandleType implicit = vtkm::cont::make_ArrayHandleImplicit(functor, length);
|
2015-05-05 18:25:48 +00:00
|
|
|
|
|
|
|
PermutationHandleType permutation =
|
2017-05-18 14:29:41 +00:00
|
|
|
vtkm::cont::make_ArrayHandlePermutation(counting, implicit);
|
2015-05-05 18:25:48 +00:00
|
|
|
|
2017-02-15 00:14:29 +00:00
|
|
|
vtkm::cont::printSummary_ArrayHandle(permutation, std::cout);
|
|
|
|
std::cout << std::endl;
|
|
|
|
|
2017-05-18 14:29:41 +00:00
|
|
|
vtkm::cont::ArrayHandle<ValueType> result;
|
2015-05-05 18:25:48 +00:00
|
|
|
|
2018-08-28 20:36:50 +00:00
|
|
|
vtkm::worklet::DispatcherMapField<PassThrough> dispatcher;
|
2015-05-05 18:25:48 +00:00
|
|
|
dispatcher.Invoke(permutation, result);
|
|
|
|
|
|
|
|
//verify that the control portal works
|
2017-05-18 14:29:41 +00:00
|
|
|
for (vtkm::Id i = 0; i < counting_length; ++i)
|
|
|
|
{
|
2015-05-05 18:25:48 +00:00
|
|
|
const vtkm::Id value_index = i;
|
|
|
|
const vtkm::Id key_index = start_pos + i;
|
|
|
|
|
2017-05-18 14:29:41 +00:00
|
|
|
const ValueType result_v = result.GetPortalConstControl().Get(value_index);
|
|
|
|
const ValueType correct_value = implicit.GetPortalConstControl().Get(key_index);
|
|
|
|
const ValueType control_value = permutation.GetPortalConstControl().Get(value_index);
|
|
|
|
VTKM_TEST_ASSERT(test_equal(result_v, correct_value), "Implicit Handle Failed");
|
|
|
|
VTKM_TEST_ASSERT(test_equal(result_v, control_value), "Implicit Handle Failed");
|
2015-05-05 18:25:48 +00:00
|
|
|
}
|
2017-05-18 14:29:41 +00:00
|
|
|
}
|
2015-05-05 18:25:48 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2018-08-29 20:54:31 +00:00
|
|
|
struct TestViewAsInput
|
|
|
|
{
|
|
|
|
template <typename ValueType>
|
|
|
|
VTKM_CONT void operator()(const ValueType vtkmNotUsed(v)) const
|
|
|
|
{
|
|
|
|
const vtkm::Id length = ARRAY_SIZE;
|
|
|
|
|
|
|
|
using FunctorType = ::fancy_array_detail::IndexSquared<ValueType>;
|
|
|
|
|
|
|
|
using ValueHandleType = vtkm::cont::ArrayHandleImplicit<FunctorType>;
|
|
|
|
using ViewHandleType = vtkm::cont::ArrayHandleView<ValueHandleType>;
|
|
|
|
|
|
|
|
FunctorType functor;
|
|
|
|
for (vtkm::Id start_pos = 0; start_pos < length; start_pos += length / 4)
|
|
|
|
{
|
|
|
|
const vtkm::Id counting_length = length - start_pos;
|
|
|
|
|
|
|
|
ValueHandleType implicit = vtkm::cont::make_ArrayHandleImplicit(functor, length);
|
|
|
|
|
|
|
|
ViewHandleType view =
|
|
|
|
vtkm::cont::make_ArrayHandleView(implicit, start_pos, counting_length);
|
|
|
|
|
|
|
|
vtkm::cont::printSummary_ArrayHandle(view, std::cout);
|
|
|
|
std::cout << std::endl;
|
|
|
|
|
|
|
|
vtkm::cont::ArrayHandle<ValueType> result;
|
|
|
|
|
2018-08-28 20:36:50 +00:00
|
|
|
vtkm::worklet::DispatcherMapField<PassThrough> dispatcher;
|
2018-08-29 20:54:31 +00:00
|
|
|
dispatcher.Invoke(view, result);
|
|
|
|
|
|
|
|
//verify that the control portal works
|
|
|
|
for (vtkm::Id i = 0; i < counting_length; ++i)
|
|
|
|
{
|
|
|
|
const vtkm::Id value_index = i;
|
|
|
|
const vtkm::Id key_index = start_pos + i;
|
|
|
|
|
|
|
|
const ValueType result_v = result.GetPortalConstControl().Get(value_index);
|
|
|
|
const ValueType correct_value = implicit.GetPortalConstControl().Get(key_index);
|
|
|
|
const ValueType control_value = view.GetPortalConstControl().Get(value_index);
|
|
|
|
VTKM_TEST_ASSERT(test_equal(result_v, correct_value), "Implicit Handle Failed");
|
|
|
|
VTKM_TEST_ASSERT(test_equal(result_v, control_value), "Implicit Handle Failed");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2015-05-05 18:25:48 +00:00
|
|
|
struct TestTransformAsInput
|
|
|
|
{
|
2017-05-18 14:29:41 +00:00
|
|
|
template <typename ValueType>
|
2016-10-19 22:42:58 +00:00
|
|
|
VTKM_CONT void operator()(const ValueType vtkmNotUsed(v)) const
|
2015-05-05 18:25:48 +00:00
|
|
|
{
|
2017-08-16 15:34:21 +00:00
|
|
|
using FunctorType = fancy_array_detail::ValueScale;
|
2015-05-05 18:25:48 +00:00
|
|
|
|
|
|
|
const vtkm::Id length = ARRAY_SIZE;
|
2015-09-29 14:36:11 +00:00
|
|
|
FunctorType functor(2.0);
|
2015-05-05 18:25:48 +00:00
|
|
|
|
|
|
|
vtkm::cont::ArrayHandle<ValueType> input;
|
2017-05-30 14:00:01 +00:00
|
|
|
vtkm::cont::ArrayHandleTransform<vtkm::cont::ArrayHandle<ValueType>, FunctorType>
|
|
|
|
transformed = vtkm::cont::make_ArrayHandleTransform(input, functor);
|
2015-05-05 18:25:48 +00:00
|
|
|
|
|
|
|
input.Allocate(length);
|
2017-02-15 00:14:29 +00:00
|
|
|
SetPortal(input.GetPortalControl());
|
|
|
|
|
|
|
|
vtkm::cont::printSummary_ArrayHandle(transformed, std::cout);
|
|
|
|
std::cout << std::endl;
|
2015-05-05 18:25:48 +00:00
|
|
|
|
2017-05-18 14:29:41 +00:00
|
|
|
vtkm::cont::ArrayHandle<ValueType> result;
|
2015-05-05 18:25:48 +00:00
|
|
|
|
2018-08-28 20:36:50 +00:00
|
|
|
vtkm::worklet::DispatcherMapField<PassThrough> dispatcher;
|
2015-05-05 18:25:48 +00:00
|
|
|
dispatcher.Invoke(transformed, result);
|
|
|
|
|
2017-02-15 00:14:29 +00:00
|
|
|
//verify that the control portal works
|
2017-05-18 14:29:41 +00:00
|
|
|
for (vtkm::Id i = 0; i < length; ++i)
|
2015-05-05 18:25:48 +00:00
|
|
|
{
|
2017-02-15 00:14:29 +00:00
|
|
|
const ValueType result_v = result.GetPortalConstControl().Get(i);
|
|
|
|
const ValueType correct_value = functor(TestValue(i, ValueType()));
|
|
|
|
const ValueType control_value = transformed.GetPortalConstControl().Get(i);
|
2017-05-18 14:29:41 +00:00
|
|
|
VTKM_TEST_ASSERT(test_equal(result_v, correct_value), "Transform Handle Failed");
|
|
|
|
VTKM_TEST_ASSERT(test_equal(result_v, control_value), "Transform Handle Control Failed");
|
2015-05-05 18:25:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2018-09-05 16:07:23 +00:00
|
|
|
struct TestTransformVirtualAsInput
|
|
|
|
{
|
|
|
|
template <typename ValueType>
|
|
|
|
VTKM_CONT void operator()(const ValueType vtkmNotUsed(v)) const
|
|
|
|
{
|
|
|
|
using FunctorType = fancy_array_detail::ValueScale;
|
|
|
|
using VirtualFunctorType = fancy_array_detail::TransformExecObject<ValueType>;
|
|
|
|
|
|
|
|
const vtkm::Id length = ARRAY_SIZE;
|
|
|
|
FunctorType functor(2.0);
|
|
|
|
VirtualFunctorType virtualFunctor(functor);
|
|
|
|
|
|
|
|
vtkm::cont::ArrayHandle<ValueType> input;
|
|
|
|
auto transformed = vtkm::cont::make_ArrayHandleTransform(input, virtualFunctor);
|
|
|
|
|
|
|
|
input.Allocate(length);
|
|
|
|
SetPortal(input.GetPortalControl());
|
|
|
|
|
|
|
|
vtkm::cont::printSummary_ArrayHandle(transformed, std::cout);
|
|
|
|
std::cout << std::endl;
|
|
|
|
|
|
|
|
vtkm::cont::ArrayHandle<ValueType> result;
|
|
|
|
|
|
|
|
vtkm::worklet::DispatcherMapField<PassThrough> dispatcher;
|
|
|
|
dispatcher.Invoke(transformed, result);
|
|
|
|
|
|
|
|
//verify that the control portal works
|
|
|
|
for (vtkm::Id i = 0; i < length; ++i)
|
|
|
|
{
|
|
|
|
const ValueType result_v = result.GetPortalConstControl().Get(i);
|
|
|
|
const ValueType correct_value = functor(TestValue(i, ValueType()));
|
|
|
|
const ValueType control_value = transformed.GetPortalConstControl().Get(i);
|
|
|
|
VTKM_TEST_ASSERT(test_equal(result_v, correct_value), "Transform Handle Failed");
|
|
|
|
VTKM_TEST_ASSERT(test_equal(result_v, control_value), "Transform Handle Control Failed");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2015-05-05 18:25:48 +00:00
|
|
|
struct TestCountingTransformAsInput
|
|
|
|
{
|
2017-05-18 14:29:41 +00:00
|
|
|
template <typename ValueType>
|
2016-10-19 22:42:58 +00:00
|
|
|
VTKM_CONT void operator()(const ValueType vtkmNotUsed(v)) const
|
2015-05-05 18:25:48 +00:00
|
|
|
{
|
2017-08-16 15:34:21 +00:00
|
|
|
using ComponentType = typename vtkm::VecTraits<ValueType>::ComponentType;
|
|
|
|
using OutputValueType = ComponentType;
|
|
|
|
using FunctorType = fancy_array_detail::ValueSquared<OutputValueType>;
|
2015-05-05 18:25:48 +00:00
|
|
|
|
|
|
|
vtkm::Id length = ARRAY_SIZE;
|
|
|
|
FunctorType functor;
|
|
|
|
|
|
|
|
//need to initialize the start value or else vectors will have
|
|
|
|
//random values to start
|
2015-05-07 22:34:06 +00:00
|
|
|
ComponentType component_value(0);
|
|
|
|
const ValueType start = ValueType(component_value);
|
2015-05-05 18:25:48 +00:00
|
|
|
|
2017-05-18 14:29:41 +00:00
|
|
|
vtkm::cont::ArrayHandleCounting<ValueType> counting(start, ValueType(1), length);
|
2015-05-05 18:25:48 +00:00
|
|
|
|
2017-05-30 14:00:01 +00:00
|
|
|
vtkm::cont::ArrayHandleTransform<vtkm::cont::ArrayHandleCounting<ValueType>, FunctorType>
|
|
|
|
countingTransformed = vtkm::cont::make_ArrayHandleTransform(counting, functor);
|
2015-05-05 18:25:48 +00:00
|
|
|
|
2017-02-15 00:14:29 +00:00
|
|
|
vtkm::cont::printSummary_ArrayHandle(countingTransformed, std::cout);
|
|
|
|
std::cout << std::endl;
|
|
|
|
|
2017-05-18 14:29:41 +00:00
|
|
|
vtkm::cont::ArrayHandle<OutputValueType> result;
|
2015-05-05 18:25:48 +00:00
|
|
|
|
2018-08-28 20:36:50 +00:00
|
|
|
vtkm::worklet::DispatcherMapField<PassThrough> dispatcher;
|
2015-05-05 18:25:48 +00:00
|
|
|
dispatcher.Invoke(countingTransformed, result);
|
|
|
|
|
|
|
|
//verify that the control portal works
|
2017-05-18 14:29:41 +00:00
|
|
|
for (vtkm::Id i = 0; i < length; ++i)
|
|
|
|
{
|
2015-05-05 18:25:48 +00:00
|
|
|
const OutputValueType result_v = result.GetPortalConstControl().Get(i);
|
2017-05-18 14:29:41 +00:00
|
|
|
const OutputValueType correct_value = functor(ValueType(component_value));
|
|
|
|
const OutputValueType control_value = countingTransformed.GetPortalConstControl().Get(i);
|
|
|
|
VTKM_TEST_ASSERT(test_equal(result_v, correct_value), "Transform Counting Handle Failed");
|
2015-05-07 22:34:06 +00:00
|
|
|
VTKM_TEST_ASSERT(test_equal(result_v, control_value),
|
|
|
|
"Transform Counting Handle Control Failed");
|
2015-07-30 22:43:19 +00:00
|
|
|
component_value = ComponentType(component_value + ComponentType(1));
|
2017-05-18 14:29:41 +00:00
|
|
|
}
|
2015-05-05 18:25:48 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2015-09-01 21:42:45 +00:00
|
|
|
struct TestCastAsInput
|
|
|
|
{
|
2017-05-18 14:29:41 +00:00
|
|
|
template <typename CastToType>
|
|
|
|
VTKM_CONT void operator()(CastToType vtkmNotUsed(type)) const
|
2015-09-01 21:42:45 +00:00
|
|
|
{
|
2017-08-16 15:34:21 +00:00
|
|
|
using InputArrayType = vtkm::cont::ArrayHandleIndex;
|
2015-09-01 21:42:45 +00:00
|
|
|
|
2015-09-15 04:55:44 +00:00
|
|
|
InputArrayType input(ARRAY_SIZE);
|
2017-05-18 14:29:41 +00:00
|
|
|
vtkm::cont::ArrayHandleCast<CastToType, InputArrayType> castArray =
|
|
|
|
vtkm::cont::make_ArrayHandleCast(input, CastToType());
|
2015-09-01 21:42:45 +00:00
|
|
|
vtkm::cont::ArrayHandle<CastToType> result;
|
|
|
|
|
2018-08-28 20:36:50 +00:00
|
|
|
vtkm::worklet::DispatcherMapField<PassThrough> dispatcher;
|
2015-09-01 21:42:45 +00:00
|
|
|
dispatcher.Invoke(castArray, result);
|
|
|
|
|
2017-02-15 00:14:29 +00:00
|
|
|
vtkm::cont::printSummary_ArrayHandle(castArray, std::cout);
|
|
|
|
std::cout << std::endl;
|
|
|
|
|
2015-09-01 21:42:45 +00:00
|
|
|
// verify results
|
|
|
|
vtkm::Id length = ARRAY_SIZE;
|
|
|
|
for (vtkm::Id i = 0; i < length; ++i)
|
|
|
|
{
|
2017-05-18 14:29:41 +00:00
|
|
|
VTKM_TEST_ASSERT(result.GetPortalConstControl().Get(i) ==
|
|
|
|
static_cast<CastToType>(input.GetPortalConstControl().Get(i)),
|
|
|
|
"Casting ArrayHandle Failed");
|
2015-09-01 21:42:45 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2019-07-18 00:40:45 +00:00
|
|
|
struct TestCastAsOutput
|
|
|
|
{
|
|
|
|
template <typename CastFromType>
|
|
|
|
VTKM_CONT void operator()(CastFromType vtkmNotUsed(type)) const
|
|
|
|
{
|
|
|
|
using InputArrayType = vtkm::cont::ArrayHandleIndex;
|
|
|
|
using ResultArrayType = vtkm::cont::ArrayHandle<CastFromType>;
|
|
|
|
|
|
|
|
InputArrayType input(ARRAY_SIZE);
|
|
|
|
|
|
|
|
ResultArrayType result;
|
|
|
|
vtkm::cont::ArrayHandleCast<vtkm::Id, ResultArrayType> castArray =
|
|
|
|
vtkm::cont::make_ArrayHandleCast<CastFromType>(result);
|
|
|
|
|
|
|
|
vtkm::worklet::DispatcherMapField<PassThrough> dispatcher;
|
|
|
|
dispatcher.Invoke(input, castArray);
|
|
|
|
|
|
|
|
vtkm::cont::printSummary_ArrayHandle(castArray, std::cout);
|
|
|
|
std::cout << std::endl;
|
|
|
|
|
|
|
|
// verify results
|
|
|
|
vtkm::Id length = ARRAY_SIZE;
|
|
|
|
for (vtkm::Id i = 0; i < length; ++i)
|
|
|
|
{
|
|
|
|
VTKM_TEST_ASSERT(input.GetPortalConstControl().Get(i) ==
|
|
|
|
static_cast<vtkm::Id>(result.GetPortalConstControl().Get(i)),
|
|
|
|
"Casting ArrayHandle Failed");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2017-05-18 14:29:41 +00:00
|
|
|
template <vtkm::IdComponent NUM_COMPONENTS>
|
2015-09-28 23:19:38 +00:00
|
|
|
struct TestGroupVecAsInput
|
|
|
|
{
|
2017-05-18 14:29:41 +00:00
|
|
|
template <typename ComponentType>
|
|
|
|
VTKM_CONT void operator()(ComponentType) const
|
2015-09-28 23:19:38 +00:00
|
|
|
{
|
2017-08-16 15:34:21 +00:00
|
|
|
using ValueType = vtkm::Vec<ComponentType, NUM_COMPONENTS>;
|
2015-09-28 23:19:38 +00:00
|
|
|
|
2017-05-18 14:29:41 +00:00
|
|
|
ComponentType testValues[ARRAY_SIZE * NUM_COMPONENTS];
|
2015-09-28 23:19:38 +00:00
|
|
|
|
2017-05-18 14:29:41 +00:00
|
|
|
for (vtkm::Id index = 0; index < ARRAY_SIZE * NUM_COMPONENTS; ++index)
|
|
|
|
{
|
2015-09-28 23:19:38 +00:00
|
|
|
testValues[index] = TestValue(index, ComponentType());
|
2017-05-18 14:29:41 +00:00
|
|
|
}
|
2015-09-28 23:19:38 +00:00
|
|
|
vtkm::cont::ArrayHandle<ComponentType> baseArray =
|
2017-05-18 14:29:41 +00:00
|
|
|
vtkm::cont::make_ArrayHandle(testValues, ARRAY_SIZE * NUM_COMPONENTS);
|
2015-09-28 23:19:38 +00:00
|
|
|
|
2017-05-18 14:29:41 +00:00
|
|
|
vtkm::cont::ArrayHandleGroupVec<vtkm::cont::ArrayHandle<ComponentType>, NUM_COMPONENTS>
|
|
|
|
groupArray(baseArray);
|
2015-09-28 23:19:38 +00:00
|
|
|
VTKM_TEST_ASSERT(groupArray.GetNumberOfValues() == ARRAY_SIZE,
|
|
|
|
"Group array reporting wrong array size.");
|
|
|
|
|
2017-02-15 00:14:29 +00:00
|
|
|
vtkm::cont::printSummary_ArrayHandle(groupArray, std::cout);
|
|
|
|
std::cout << std::endl;
|
|
|
|
|
2015-09-28 23:19:38 +00:00
|
|
|
vtkm::cont::ArrayHandle<ValueType> resultArray;
|
|
|
|
|
2018-08-28 20:36:50 +00:00
|
|
|
vtkm::worklet::DispatcherMapField<PassThrough> dispatcher;
|
2015-09-28 23:19:38 +00:00
|
|
|
dispatcher.Invoke(groupArray, resultArray);
|
|
|
|
|
2017-05-18 14:29:41 +00:00
|
|
|
VTKM_TEST_ASSERT(resultArray.GetNumberOfValues() == ARRAY_SIZE, "Got bad result array size.");
|
2015-09-28 23:19:38 +00:00
|
|
|
|
|
|
|
//verify that the control portal works
|
|
|
|
vtkm::Id totalIndex = 0;
|
2017-05-18 14:29:41 +00:00
|
|
|
for (vtkm::Id index = 0; index < ARRAY_SIZE; ++index)
|
2015-09-28 23:19:38 +00:00
|
|
|
{
|
|
|
|
const ValueType result = resultArray.GetPortalConstControl().Get(index);
|
2017-05-18 14:29:41 +00:00
|
|
|
for (vtkm::IdComponent componentIndex = 0; componentIndex < NUM_COMPONENTS;
|
2015-09-28 23:19:38 +00:00
|
|
|
componentIndex++)
|
|
|
|
{
|
2017-05-18 14:29:41 +00:00
|
|
|
const ComponentType expectedValue = TestValue(totalIndex, ComponentType());
|
2015-09-29 14:21:03 +00:00
|
|
|
VTKM_TEST_ASSERT(test_equal(result[componentIndex], expectedValue),
|
2015-09-28 23:19:38 +00:00
|
|
|
"Result array got wrong value.");
|
|
|
|
totalIndex++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2017-05-18 14:29:41 +00:00
|
|
|
template <vtkm::IdComponent NUM_COMPONENTS>
|
2015-09-28 23:19:38 +00:00
|
|
|
struct TestGroupVecAsOutput
|
|
|
|
{
|
2017-05-18 14:29:41 +00:00
|
|
|
template <typename ComponentType>
|
|
|
|
VTKM_CONT void operator()(ComponentType) const
|
2015-09-28 23:19:38 +00:00
|
|
|
{
|
2017-08-16 15:34:21 +00:00
|
|
|
using ValueType = vtkm::Vec<ComponentType, NUM_COMPONENTS>;
|
2015-09-28 23:19:38 +00:00
|
|
|
|
2017-02-15 00:14:29 +00:00
|
|
|
vtkm::cont::ArrayHandle<ValueType> baseArray;
|
|
|
|
baseArray.Allocate(ARRAY_SIZE);
|
|
|
|
SetPortal(baseArray.GetPortalControl());
|
2015-09-28 23:19:38 +00:00
|
|
|
|
|
|
|
vtkm::cont::ArrayHandle<ComponentType> resultArray;
|
|
|
|
|
2017-05-18 14:29:41 +00:00
|
|
|
vtkm::cont::ArrayHandleGroupVec<vtkm::cont::ArrayHandle<ComponentType>, NUM_COMPONENTS>
|
|
|
|
groupArray(resultArray);
|
2015-09-28 23:19:38 +00:00
|
|
|
|
2018-08-28 20:36:50 +00:00
|
|
|
vtkm::worklet::DispatcherMapField<PassThrough> dispatcher;
|
2015-09-28 23:19:38 +00:00
|
|
|
dispatcher.Invoke(baseArray, groupArray);
|
|
|
|
|
2017-02-15 00:14:29 +00:00
|
|
|
vtkm::cont::printSummary_ArrayHandle(groupArray, std::cout);
|
|
|
|
std::cout << std::endl;
|
|
|
|
vtkm::cont::printSummary_ArrayHandle(resultArray, std::cout);
|
|
|
|
std::cout << std::endl;
|
|
|
|
|
2015-09-28 23:19:38 +00:00
|
|
|
VTKM_TEST_ASSERT(groupArray.GetNumberOfValues() == ARRAY_SIZE,
|
|
|
|
"Group array reporting wrong array size.");
|
|
|
|
|
2017-05-18 14:29:41 +00:00
|
|
|
VTKM_TEST_ASSERT(resultArray.GetNumberOfValues() == ARRAY_SIZE * NUM_COMPONENTS,
|
|
|
|
"Got bad result array size.");
|
2015-09-28 23:19:38 +00:00
|
|
|
|
|
|
|
//verify that the control portal works
|
|
|
|
vtkm::Id totalIndex = 0;
|
2017-05-18 14:29:41 +00:00
|
|
|
for (vtkm::Id index = 0; index < ARRAY_SIZE; ++index)
|
2015-09-28 23:19:38 +00:00
|
|
|
{
|
|
|
|
const ValueType expectedValue = TestValue(index, ValueType());
|
2017-05-18 14:29:41 +00:00
|
|
|
for (vtkm::IdComponent componentIndex = 0; componentIndex < NUM_COMPONENTS;
|
2015-09-28 23:19:38 +00:00
|
|
|
componentIndex++)
|
|
|
|
{
|
2017-05-18 14:29:41 +00:00
|
|
|
const ComponentType result = resultArray.GetPortalConstControl().Get(totalIndex);
|
2015-09-29 14:21:03 +00:00
|
|
|
VTKM_TEST_ASSERT(test_equal(result, expectedValue[componentIndex]),
|
2015-09-28 23:19:38 +00:00
|
|
|
"Result array got wrong value.");
|
|
|
|
totalIndex++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
2015-07-13 17:01:41 +00:00
|
|
|
|
2016-10-28 03:14:29 +00:00
|
|
|
// GroupVecVariable is a bit strange because it supports values of different
|
|
|
|
// lengths, so a simple pass through worklet will not work. Use custom
|
|
|
|
// worklets.
|
|
|
|
struct GroupVariableInputWorklet : public vtkm::worklet::WorkletMapField
|
|
|
|
{
|
2019-05-30 20:37:21 +00:00
|
|
|
using ControlSignature = void(FieldIn, FieldOut);
|
|
|
|
using ExecutionSignature = void(_1, WorkIndex, _2);
|
2016-10-28 03:14:29 +00:00
|
|
|
|
2017-05-18 14:29:41 +00:00
|
|
|
template <typename InputType>
|
2019-05-30 20:37:21 +00:00
|
|
|
VTKM_EXEC void operator()(const InputType& input, vtkm::Id workIndex, vtkm::Id& dummyOut) const
|
2016-10-28 03:14:29 +00:00
|
|
|
{
|
|
|
|
using ComponentType = typename InputType::ComponentType;
|
2017-05-18 14:29:41 +00:00
|
|
|
vtkm::IdComponent expectedSize = static_cast<vtkm::IdComponent>(workIndex + 1);
|
2016-10-28 03:14:29 +00:00
|
|
|
if (expectedSize != input.GetNumberOfComponents())
|
|
|
|
{
|
|
|
|
this->RaiseError("Got unexpected number of components.");
|
|
|
|
}
|
|
|
|
|
2017-05-18 14:29:41 +00:00
|
|
|
vtkm::Id valueIndex = workIndex * (workIndex + 1) / 2;
|
2019-05-30 20:37:21 +00:00
|
|
|
dummyOut = valueIndex;
|
2017-05-18 14:29:41 +00:00
|
|
|
for (vtkm::IdComponent componentIndex = 0; componentIndex < expectedSize; componentIndex++)
|
2016-10-28 03:14:29 +00:00
|
|
|
{
|
|
|
|
ComponentType expectedValue = TestValue(valueIndex, ComponentType());
|
2019-05-30 20:37:21 +00:00
|
|
|
if (vtkm::Abs(expectedValue - input[componentIndex]) > 0.000001)
|
2016-10-28 03:14:29 +00:00
|
|
|
{
|
|
|
|
this->RaiseError("Got bad value in GroupVariableInputWorklet.");
|
|
|
|
}
|
|
|
|
valueIndex++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
struct TestGroupVecVariableAsInput
|
|
|
|
{
|
2017-05-18 14:29:41 +00:00
|
|
|
template <typename ComponentType>
|
|
|
|
VTKM_CONT void operator()(ComponentType) const
|
2016-10-28 03:14:29 +00:00
|
|
|
{
|
|
|
|
vtkm::Id sourceArraySize;
|
|
|
|
|
2017-05-18 14:29:41 +00:00
|
|
|
vtkm::cont::ArrayHandleCounting<vtkm::IdComponent> numComponentsArray(1, 1, ARRAY_SIZE);
|
2016-10-28 03:14:29 +00:00
|
|
|
vtkm::cont::ArrayHandle<vtkm::Id> offsetsArray =
|
2017-05-18 14:29:41 +00:00
|
|
|
vtkm::cont::ConvertNumComponentsToOffsets(numComponentsArray, sourceArraySize);
|
2016-10-28 03:14:29 +00:00
|
|
|
|
|
|
|
vtkm::cont::ArrayHandle<ComponentType> sourceArray;
|
|
|
|
sourceArray.Allocate(sourceArraySize);
|
|
|
|
SetPortal(sourceArray.GetPortalControl());
|
|
|
|
|
2017-02-15 00:14:29 +00:00
|
|
|
vtkm::cont::printSummary_ArrayHandle(
|
2017-05-18 14:29:41 +00:00
|
|
|
vtkm::cont::make_ArrayHandleGroupVecVariable(sourceArray, offsetsArray), std::cout);
|
2017-02-15 00:14:29 +00:00
|
|
|
std::cout << std::endl;
|
|
|
|
|
2019-05-30 20:37:21 +00:00
|
|
|
vtkm::cont::ArrayHandle<vtkm::Id> dummyArray;
|
|
|
|
|
2018-08-28 20:36:50 +00:00
|
|
|
vtkm::worklet::DispatcherMapField<GroupVariableInputWorklet> dispatcher;
|
2019-05-30 20:37:21 +00:00
|
|
|
dispatcher.Invoke(vtkm::cont::make_ArrayHandleGroupVecVariable(sourceArray, offsetsArray),
|
|
|
|
dummyArray);
|
|
|
|
|
|
|
|
dummyArray.GetPortalConstControl();
|
2016-10-28 03:14:29 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
// GroupVecVariable is a bit strange because it supports values of different
|
|
|
|
// lengths, so a simple pass through worklet will not work. Use custom
|
|
|
|
// worklets.
|
|
|
|
struct GroupVariableOutputWorklet : public vtkm::worklet::WorkletMapField
|
|
|
|
{
|
2019-01-10 18:59:25 +00:00
|
|
|
using ControlSignature = void(FieldIn, FieldOut);
|
2018-05-25 21:18:41 +00:00
|
|
|
using ExecutionSignature = void(_2, WorkIndex);
|
2016-10-28 03:14:29 +00:00
|
|
|
|
2017-05-18 14:29:41 +00:00
|
|
|
template <typename OutputType>
|
|
|
|
VTKM_EXEC void operator()(OutputType& output, vtkm::Id workIndex) const
|
2016-10-28 03:14:29 +00:00
|
|
|
{
|
|
|
|
using ComponentType = typename OutputType::ComponentType;
|
2017-05-18 14:29:41 +00:00
|
|
|
vtkm::IdComponent expectedSize = static_cast<vtkm::IdComponent>(workIndex + 1);
|
2016-10-28 03:14:29 +00:00
|
|
|
if (expectedSize != output.GetNumberOfComponents())
|
|
|
|
{
|
|
|
|
this->RaiseError("Got unexpected number of components.");
|
|
|
|
}
|
|
|
|
|
2017-05-18 14:29:41 +00:00
|
|
|
vtkm::Id valueIndex = workIndex * (workIndex + 1) / 2;
|
|
|
|
for (vtkm::IdComponent componentIndex = 0; componentIndex < expectedSize; componentIndex++)
|
2016-10-28 03:14:29 +00:00
|
|
|
{
|
|
|
|
output[componentIndex] = TestValue(valueIndex, ComponentType());
|
|
|
|
valueIndex++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
struct TestGroupVecVariableAsOutput
|
|
|
|
{
|
2017-05-18 14:29:41 +00:00
|
|
|
template <typename ComponentType>
|
|
|
|
VTKM_CONT void operator()(ComponentType) const
|
2016-10-28 03:14:29 +00:00
|
|
|
{
|
|
|
|
vtkm::Id sourceArraySize;
|
|
|
|
|
2017-05-18 14:29:41 +00:00
|
|
|
vtkm::cont::ArrayHandleCounting<vtkm::IdComponent> numComponentsArray(1, 1, ARRAY_SIZE);
|
2017-09-07 21:08:55 +00:00
|
|
|
vtkm::cont::ArrayHandle<vtkm::Id> offsetsArray = vtkm::cont::ConvertNumComponentsToOffsets(
|
|
|
|
numComponentsArray, sourceArraySize, DeviceAdapterTag());
|
2016-10-28 03:14:29 +00:00
|
|
|
|
|
|
|
vtkm::cont::ArrayHandle<ComponentType> sourceArray;
|
|
|
|
sourceArray.Allocate(sourceArraySize);
|
|
|
|
|
2018-08-28 20:36:50 +00:00
|
|
|
vtkm::worklet::DispatcherMapField<GroupVariableOutputWorklet> dispatcher;
|
2017-05-18 14:29:41 +00:00
|
|
|
dispatcher.Invoke(vtkm::cont::ArrayHandleIndex(ARRAY_SIZE),
|
|
|
|
vtkm::cont::make_ArrayHandleGroupVecVariable(sourceArray, offsetsArray));
|
2016-10-28 03:14:29 +00:00
|
|
|
|
2017-02-15 00:14:29 +00:00
|
|
|
vtkm::cont::printSummary_ArrayHandle(
|
2017-05-18 14:29:41 +00:00
|
|
|
vtkm::cont::make_ArrayHandleGroupVecVariable(sourceArray, offsetsArray), std::cout);
|
2017-02-15 00:14:29 +00:00
|
|
|
std::cout << std::endl;
|
|
|
|
vtkm::cont::printSummary_ArrayHandle(sourceArray, std::cout);
|
|
|
|
std::cout << std::endl;
|
|
|
|
|
2016-10-28 03:14:29 +00:00
|
|
|
CheckPortal(sourceArray.GetPortalConstControl());
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2015-07-13 17:01:41 +00:00
|
|
|
struct TestZipAsInput
|
|
|
|
{
|
2017-05-18 14:29:41 +00:00
|
|
|
template <typename KeyType, typename ValueType>
|
|
|
|
VTKM_CONT void operator()(vtkm::Pair<KeyType, ValueType> vtkmNotUsed(pair)) const
|
2015-07-13 17:01:41 +00:00
|
|
|
{
|
2017-08-16 15:34:21 +00:00
|
|
|
using PairType = vtkm::Pair<KeyType, ValueType>;
|
|
|
|
using KeyComponentType = typename vtkm::VecTraits<KeyType>::ComponentType;
|
|
|
|
using ValueComponentType = typename vtkm::VecTraits<ValueType>::ComponentType;
|
2015-07-13 17:01:41 +00:00
|
|
|
|
|
|
|
KeyType testKeys[ARRAY_SIZE];
|
|
|
|
ValueType testValues[ARRAY_SIZE];
|
|
|
|
|
2017-05-18 14:29:41 +00:00
|
|
|
for (vtkm::Id i = 0; i < ARRAY_SIZE; ++i)
|
|
|
|
{
|
2015-07-13 17:01:41 +00:00
|
|
|
testKeys[i] = KeyType(static_cast<KeyComponentType>(ARRAY_SIZE - i));
|
|
|
|
testValues[i] = ValueType(static_cast<ValueComponentType>(i));
|
2017-05-18 14:29:41 +00:00
|
|
|
}
|
|
|
|
vtkm::cont::ArrayHandle<KeyType> keys = vtkm::cont::make_ArrayHandle(testKeys, ARRAY_SIZE);
|
|
|
|
vtkm::cont::ArrayHandle<ValueType> values =
|
|
|
|
vtkm::cont::make_ArrayHandle(testValues, ARRAY_SIZE);
|
2015-07-13 17:01:41 +00:00
|
|
|
|
2017-05-18 14:29:41 +00:00
|
|
|
vtkm::cont::ArrayHandleZip<vtkm::cont::ArrayHandle<KeyType>,
|
|
|
|
vtkm::cont::ArrayHandle<ValueType>>
|
|
|
|
zip = vtkm::cont::make_ArrayHandleZip(keys, values);
|
2015-07-13 17:01:41 +00:00
|
|
|
|
2017-02-15 00:14:29 +00:00
|
|
|
vtkm::cont::printSummary_ArrayHandle(zip, std::cout);
|
|
|
|
std::cout << std::endl;
|
|
|
|
|
2017-05-18 14:29:41 +00:00
|
|
|
vtkm::cont::ArrayHandle<PairType> result;
|
2015-07-13 17:01:41 +00:00
|
|
|
|
2018-08-28 20:36:50 +00:00
|
|
|
vtkm::worklet::DispatcherMapField<PassThrough> dispatcher;
|
2015-07-13 17:01:41 +00:00
|
|
|
dispatcher.Invoke(zip, result);
|
|
|
|
|
|
|
|
//verify that the control portal works
|
2017-05-18 14:29:41 +00:00
|
|
|
for (int i = 0; i < ARRAY_SIZE; ++i)
|
|
|
|
{
|
2015-07-13 17:01:41 +00:00
|
|
|
const PairType result_v = result.GetPortalConstControl().Get(i);
|
2017-05-18 14:29:41 +00:00
|
|
|
const PairType correct_value(KeyType(static_cast<KeyComponentType>(ARRAY_SIZE - i)),
|
|
|
|
ValueType(static_cast<ValueComponentType>(i)));
|
|
|
|
VTKM_TEST_ASSERT(test_equal(result_v, correct_value), "ArrayHandleZip Failed as input");
|
|
|
|
}
|
2015-07-13 17:01:41 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2017-02-07 17:53:53 +00:00
|
|
|
struct TestDiscardAsOutput
|
|
|
|
{
|
2017-05-18 14:29:41 +00:00
|
|
|
template <typename ValueType>
|
2017-02-07 17:53:53 +00:00
|
|
|
VTKM_CONT void operator()(const ValueType vtkmNotUsed(v)) const
|
|
|
|
{
|
|
|
|
using DiscardHandleType = vtkm::cont::ArrayHandleDiscard<ValueType>;
|
|
|
|
using ComponentType = typename vtkm::VecTraits<ValueType>::ComponentType;
|
|
|
|
|
2017-08-16 15:34:21 +00:00
|
|
|
using Portal = typename vtkm::cont::ArrayHandle<ValueType>::PortalControl;
|
2017-02-07 17:53:53 +00:00
|
|
|
|
|
|
|
const vtkm::Id length = ARRAY_SIZE;
|
|
|
|
|
|
|
|
vtkm::cont::ArrayHandle<ValueType> input;
|
|
|
|
input.Allocate(length);
|
|
|
|
Portal inputPortal = input.GetPortalControl();
|
2017-05-18 14:29:41 +00:00
|
|
|
for (vtkm::Id i = 0; i < length; ++i)
|
|
|
|
{
|
|
|
|
inputPortal.Set(i, ValueType(ComponentType(i)));
|
|
|
|
}
|
2017-02-07 17:53:53 +00:00
|
|
|
|
|
|
|
DiscardHandleType discard;
|
|
|
|
discard.Allocate(length);
|
|
|
|
|
2018-08-28 20:36:50 +00:00
|
|
|
vtkm::worklet::DispatcherMapField<PassThrough> dispatcher;
|
2017-02-07 17:53:53 +00:00
|
|
|
dispatcher.Invoke(input, discard);
|
|
|
|
|
|
|
|
// No output to verify since none is stored in memory. Just checking that
|
|
|
|
// this compiles/runs without errors.
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2015-07-13 17:01:41 +00:00
|
|
|
struct TestPermutationAsOutput
|
|
|
|
{
|
2017-05-18 14:29:41 +00:00
|
|
|
template <typename ValueType>
|
2016-10-19 22:42:58 +00:00
|
|
|
VTKM_CONT void operator()(const ValueType vtkmNotUsed(v)) const
|
2015-07-13 17:01:41 +00:00
|
|
|
{
|
|
|
|
const vtkm::Id length = ARRAY_SIZE;
|
|
|
|
|
2017-08-16 15:34:21 +00:00
|
|
|
using KeyHandleType = vtkm::cont::ArrayHandleCounting<vtkm::Id>;
|
|
|
|
using ValueHandleType = vtkm::cont::ArrayHandle<ValueType>;
|
|
|
|
using PermutationHandleType =
|
|
|
|
vtkm::cont::ArrayHandlePermutation<KeyHandleType, ValueHandleType>;
|
2015-07-13 17:01:41 +00:00
|
|
|
|
2017-08-16 15:34:21 +00:00
|
|
|
using ComponentType = typename vtkm::VecTraits<ValueType>::ComponentType;
|
2015-07-13 17:01:41 +00:00
|
|
|
vtkm::cont::ArrayHandle<ValueType> input;
|
2017-08-16 15:34:21 +00:00
|
|
|
using Portal = typename vtkm::cont::ArrayHandle<ValueType>::PortalControl;
|
2015-07-13 17:01:41 +00:00
|
|
|
input.Allocate(length);
|
|
|
|
Portal inputPortal = input.GetPortalControl();
|
2017-05-18 14:29:41 +00:00
|
|
|
for (vtkm::Id i = 0; i < length; ++i)
|
|
|
|
{
|
|
|
|
inputPortal.Set(i, ValueType(ComponentType(i)));
|
|
|
|
}
|
2015-07-13 17:01:41 +00:00
|
|
|
|
|
|
|
ValueHandleType values;
|
2017-05-18 14:29:41 +00:00
|
|
|
values.Allocate(length * 2);
|
2015-07-13 17:01:41 +00:00
|
|
|
|
2017-05-18 14:29:41 +00:00
|
|
|
KeyHandleType counting = vtkm::cont::make_ArrayHandleCounting<vtkm::Id>(length, 1, length);
|
2015-07-13 17:01:41 +00:00
|
|
|
|
2017-05-18 14:29:41 +00:00
|
|
|
PermutationHandleType permutation = vtkm::cont::make_ArrayHandlePermutation(counting, values);
|
2018-08-28 20:36:50 +00:00
|
|
|
vtkm::worklet::DispatcherMapField<PassThrough> dispatcher;
|
2015-07-13 17:01:41 +00:00
|
|
|
dispatcher.Invoke(input, permutation);
|
|
|
|
|
2017-02-15 00:14:29 +00:00
|
|
|
vtkm::cont::printSummary_ArrayHandle(permutation, std::cout);
|
|
|
|
std::cout << std::endl;
|
|
|
|
|
2015-07-13 17:01:41 +00:00
|
|
|
//verify that the control portal works
|
2017-05-18 14:29:41 +00:00
|
|
|
for (vtkm::Id i = 0; i < length; ++i)
|
|
|
|
{
|
|
|
|
const ValueType result_v = permutation.GetPortalConstControl().Get(i);
|
2015-07-13 17:01:41 +00:00
|
|
|
const ValueType correct_value = ValueType(ComponentType(i));
|
|
|
|
VTKM_TEST_ASSERT(test_equal(result_v, correct_value),
|
|
|
|
"Permutation Handle Failed As Output");
|
2017-05-18 14:29:41 +00:00
|
|
|
}
|
2015-07-13 17:01:41 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2018-08-29 20:54:31 +00:00
|
|
|
struct TestViewAsOutput
|
|
|
|
{
|
|
|
|
template <typename ValueType>
|
|
|
|
VTKM_CONT void operator()(const ValueType vtkmNotUsed(v)) const
|
|
|
|
{
|
|
|
|
const vtkm::Id length = ARRAY_SIZE;
|
|
|
|
|
|
|
|
using ValueHandleType = vtkm::cont::ArrayHandle<ValueType>;
|
|
|
|
using ViewHandleType = vtkm::cont::ArrayHandleView<ValueHandleType>;
|
|
|
|
|
|
|
|
using ComponentType = typename vtkm::VecTraits<ValueType>::ComponentType;
|
|
|
|
vtkm::cont::ArrayHandle<ValueType> input;
|
|
|
|
using Portal = typename vtkm::cont::ArrayHandle<ValueType>::PortalControl;
|
|
|
|
input.Allocate(length);
|
|
|
|
Portal inputPortal = input.GetPortalControl();
|
|
|
|
for (vtkm::Id i = 0; i < length; ++i)
|
|
|
|
{
|
|
|
|
inputPortal.Set(i, ValueType(ComponentType(i)));
|
|
|
|
}
|
|
|
|
|
|
|
|
ValueHandleType values;
|
|
|
|
values.Allocate(length * 2);
|
|
|
|
|
|
|
|
ViewHandleType view = vtkm::cont::make_ArrayHandleView(values, length, length);
|
2018-08-28 20:36:50 +00:00
|
|
|
vtkm::worklet::DispatcherMapField<PassThrough> dispatcher;
|
2018-08-29 20:54:31 +00:00
|
|
|
dispatcher.Invoke(input, view);
|
|
|
|
|
|
|
|
vtkm::cont::printSummary_ArrayHandle(view, std::cout);
|
|
|
|
std::cout << std::endl;
|
|
|
|
|
|
|
|
//verify that the control portal works
|
|
|
|
for (vtkm::Id i = 0; i < length; ++i)
|
|
|
|
{
|
|
|
|
const ValueType result_v = view.GetPortalConstControl().Get(i);
|
|
|
|
const ValueType correct_value = ValueType(ComponentType(i));
|
|
|
|
VTKM_TEST_ASSERT(test_equal(result_v, correct_value),
|
|
|
|
"Permutation Handle Failed As Output");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2018-09-05 16:07:23 +00:00
|
|
|
struct TestTransformAsOutput
|
|
|
|
{
|
|
|
|
template <typename ValueType>
|
|
|
|
VTKM_CONT void operator()(const ValueType vtkmNotUsed(v)) const
|
|
|
|
{
|
|
|
|
using FunctorType = fancy_array_detail::ValueScale;
|
|
|
|
using InverseFunctorType = fancy_array_detail::InverseValueScale;
|
|
|
|
|
|
|
|
const vtkm::Id length = ARRAY_SIZE;
|
|
|
|
FunctorType functor(2.0);
|
|
|
|
InverseFunctorType inverseFunctor(2.0);
|
|
|
|
|
|
|
|
vtkm::cont::ArrayHandle<ValueType> input;
|
|
|
|
input.Allocate(length);
|
|
|
|
SetPortal(input.GetPortalControl());
|
|
|
|
|
|
|
|
vtkm::cont::ArrayHandle<ValueType> output;
|
|
|
|
auto transformed = vtkm::cont::make_ArrayHandleTransform(output, functor, inverseFunctor);
|
|
|
|
|
|
|
|
vtkm::worklet::DispatcherMapField<PassThrough> dispatcher;
|
|
|
|
dispatcher.Invoke(input, transformed);
|
|
|
|
|
|
|
|
vtkm::cont::printSummary_ArrayHandle(transformed, std::cout);
|
|
|
|
std::cout << std::endl;
|
|
|
|
|
|
|
|
//verify that the control portal works
|
|
|
|
for (vtkm::Id i = 0; i < length; ++i)
|
|
|
|
{
|
|
|
|
const ValueType result_v = output.GetPortalConstControl().Get(i);
|
|
|
|
const ValueType correct_value = inverseFunctor(TestValue(i, ValueType()));
|
|
|
|
const ValueType control_value = transformed.GetPortalConstControl().Get(i);
|
|
|
|
VTKM_TEST_ASSERT(test_equal(result_v, correct_value), "Transform Handle Failed");
|
|
|
|
VTKM_TEST_ASSERT(test_equal(functor(result_v), control_value),
|
|
|
|
"Transform Handle Control Failed");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
struct TestTransformVirtualAsOutput
|
|
|
|
{
|
|
|
|
template <typename ValueType>
|
|
|
|
VTKM_CONT void operator()(const ValueType vtkmNotUsed(v)) const
|
|
|
|
{
|
|
|
|
using FunctorType = fancy_array_detail::ValueScale;
|
|
|
|
using InverseFunctorType = fancy_array_detail::InverseValueScale;
|
|
|
|
|
|
|
|
using VirtualFunctorType = fancy_array_detail::TransformExecObject<ValueType>;
|
|
|
|
|
|
|
|
const vtkm::Id length = ARRAY_SIZE;
|
|
|
|
FunctorType functor(2.0);
|
|
|
|
InverseFunctorType inverseFunctor(2.0);
|
|
|
|
|
|
|
|
VirtualFunctorType virtualFunctor(functor);
|
|
|
|
VirtualFunctorType virtualInverseFunctor(inverseFunctor);
|
|
|
|
|
|
|
|
vtkm::cont::ArrayHandle<ValueType> input;
|
|
|
|
input.Allocate(length);
|
|
|
|
SetPortal(input.GetPortalControl());
|
|
|
|
|
|
|
|
vtkm::cont::ArrayHandle<ValueType> output;
|
|
|
|
auto transformed =
|
|
|
|
vtkm::cont::make_ArrayHandleTransform(output, virtualFunctor, virtualInverseFunctor);
|
|
|
|
|
|
|
|
vtkm::worklet::DispatcherMapField<PassThrough> dispatcher;
|
|
|
|
dispatcher.Invoke(input, transformed);
|
|
|
|
|
|
|
|
vtkm::cont::printSummary_ArrayHandle(transformed, std::cout);
|
|
|
|
std::cout << std::endl;
|
|
|
|
|
|
|
|
//verify that the control portal works
|
|
|
|
for (vtkm::Id i = 0; i < length; ++i)
|
|
|
|
{
|
|
|
|
const ValueType result_v = output.GetPortalConstControl().Get(i);
|
|
|
|
const ValueType correct_value = inverseFunctor(TestValue(i, ValueType()));
|
|
|
|
const ValueType control_value = transformed.GetPortalConstControl().Get(i);
|
|
|
|
VTKM_TEST_ASSERT(test_equal(result_v, correct_value), "Transform Handle Failed");
|
|
|
|
VTKM_TEST_ASSERT(test_equal(functor(result_v), control_value),
|
|
|
|
"Transform Handle Control Failed");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2015-07-13 17:01:41 +00:00
|
|
|
struct TestZipAsOutput
|
|
|
|
{
|
2017-05-18 14:29:41 +00:00
|
|
|
template <typename KeyType, typename ValueType>
|
|
|
|
VTKM_CONT void operator()(vtkm::Pair<KeyType, ValueType> vtkmNotUsed(pair)) const
|
2015-07-13 17:01:41 +00:00
|
|
|
{
|
2017-08-16 15:34:21 +00:00
|
|
|
using PairType = vtkm::Pair<KeyType, ValueType>;
|
|
|
|
using KeyComponentType = typename vtkm::VecTraits<KeyType>::ComponentType;
|
|
|
|
using ValueComponentType = typename vtkm::VecTraits<ValueType>::ComponentType;
|
2015-07-13 17:01:41 +00:00
|
|
|
|
|
|
|
PairType testKeysAndValues[ARRAY_SIZE];
|
2017-05-18 14:29:41 +00:00
|
|
|
for (vtkm::Id i = 0; i < ARRAY_SIZE; ++i)
|
|
|
|
{
|
|
|
|
testKeysAndValues[i] = PairType(KeyType(static_cast<KeyComponentType>(ARRAY_SIZE - i)),
|
|
|
|
ValueType(static_cast<ValueComponentType>(i)));
|
|
|
|
}
|
|
|
|
vtkm::cont::ArrayHandle<PairType> input =
|
|
|
|
vtkm::cont::make_ArrayHandle(testKeysAndValues, ARRAY_SIZE);
|
2015-07-13 17:01:41 +00:00
|
|
|
|
2017-05-18 14:29:41 +00:00
|
|
|
vtkm::cont::ArrayHandle<KeyType> result_keys;
|
|
|
|
vtkm::cont::ArrayHandle<ValueType> result_values;
|
|
|
|
vtkm::cont::ArrayHandleZip<vtkm::cont::ArrayHandle<KeyType>,
|
|
|
|
vtkm::cont::ArrayHandle<ValueType>>
|
|
|
|
result_zip = vtkm::cont::make_ArrayHandleZip(result_keys, result_values);
|
2015-07-13 17:01:41 +00:00
|
|
|
|
2018-08-28 20:36:50 +00:00
|
|
|
vtkm::worklet::DispatcherMapField<PassThrough> dispatcher;
|
2015-07-13 17:01:41 +00:00
|
|
|
dispatcher.Invoke(input, result_zip);
|
|
|
|
|
2017-02-15 00:14:29 +00:00
|
|
|
vtkm::cont::printSummary_ArrayHandle(result_zip, std::cout);
|
|
|
|
std::cout << std::endl;
|
|
|
|
|
2015-07-13 17:01:41 +00:00
|
|
|
//now the two arrays we have zipped should have data inside them
|
2017-05-18 14:29:41 +00:00
|
|
|
for (int i = 0; i < ARRAY_SIZE; ++i)
|
|
|
|
{
|
2015-07-13 17:01:41 +00:00
|
|
|
const KeyType result_key = result_keys.GetPortalConstControl().Get(i);
|
|
|
|
const ValueType result_value = result_values.GetPortalConstControl().Get(i);
|
|
|
|
|
|
|
|
VTKM_TEST_ASSERT(
|
2017-05-18 14:29:41 +00:00
|
|
|
test_equal(result_key, KeyType(static_cast<KeyComponentType>(ARRAY_SIZE - i))),
|
|
|
|
"ArrayHandleZip Failed as input for key");
|
|
|
|
VTKM_TEST_ASSERT(test_equal(result_value, ValueType(static_cast<ValueComponentType>(i))),
|
|
|
|
"ArrayHandleZip Failed as input for value");
|
|
|
|
}
|
2015-07-13 17:01:41 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2017-01-17 22:33:18 +00:00
|
|
|
struct TestZipAsInPlace
|
|
|
|
{
|
2017-05-18 14:29:41 +00:00
|
|
|
template <typename ValueType>
|
|
|
|
VTKM_CONT void operator()(ValueType) const
|
2017-01-17 22:33:18 +00:00
|
|
|
{
|
|
|
|
vtkm::cont::ArrayHandle<ValueType> inputValues;
|
|
|
|
inputValues.Allocate(ARRAY_SIZE);
|
|
|
|
SetPortal(inputValues.GetPortalControl());
|
|
|
|
|
|
|
|
vtkm::cont::ArrayHandle<ValueType> outputValues;
|
|
|
|
outputValues.Allocate(ARRAY_SIZE);
|
|
|
|
|
2018-08-28 20:36:50 +00:00
|
|
|
vtkm::worklet::DispatcherMapField<InplaceFunctorPair> dispatcher;
|
2017-05-18 14:29:41 +00:00
|
|
|
dispatcher.Invoke(vtkm::cont::make_ArrayHandleZip(inputValues, outputValues));
|
2017-01-17 22:33:18 +00:00
|
|
|
|
2017-02-15 00:14:29 +00:00
|
|
|
vtkm::cont::printSummary_ArrayHandle(outputValues, std::cout);
|
|
|
|
std::cout << std::endl;
|
|
|
|
|
2017-01-17 22:33:18 +00:00
|
|
|
CheckPortal(outputValues.GetPortalConstControl());
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2017-05-18 14:29:41 +00:00
|
|
|
struct ScalarTypesToTest : vtkm::ListTagBase<vtkm::UInt8, vtkm::FloatDefault>
|
|
|
|
{
|
|
|
|
};
|
2015-07-13 17:01:41 +00:00
|
|
|
|
2019-07-31 16:20:38 +00:00
|
|
|
struct ZipTypesToTest : vtkm::ListTagBase<vtkm::Pair<vtkm::UInt8, vtkm::Id>,
|
|
|
|
vtkm::Pair<vtkm::Float64, vtkm::Vec4ui_8>,
|
|
|
|
vtkm::Pair<vtkm::Vec3f_32, vtkm::Vec4i_8>>
|
2017-05-18 14:29:41 +00:00
|
|
|
{
|
|
|
|
};
|
2015-09-01 21:42:45 +00:00
|
|
|
|
2019-07-31 16:20:38 +00:00
|
|
|
struct HandleTypesToTest
|
|
|
|
: vtkm::ListTagBase<vtkm::Id, vtkm::Vec2i_32, vtkm::FloatDefault, vtkm::Vec3f_64>
|
2017-05-18 14:29:41 +00:00
|
|
|
{
|
|
|
|
};
|
|
|
|
|
|
|
|
struct CastTypesToTest : vtkm::ListTagBase<vtkm::Int32, vtkm::UInt32>
|
|
|
|
{
|
|
|
|
};
|
2015-05-05 18:25:48 +00:00
|
|
|
|
|
|
|
struct TestAll
|
|
|
|
{
|
2016-10-19 22:42:58 +00:00
|
|
|
VTKM_CONT void operator()() const
|
2015-05-05 18:25:48 +00:00
|
|
|
{
|
|
|
|
std::cout << "Doing FancyArrayHandle tests" << std::endl;
|
|
|
|
|
|
|
|
std::cout << "-------------------------------------------" << std::endl;
|
2015-07-13 17:01:41 +00:00
|
|
|
std::cout << "Testing ArrayHandleCompositeVector as Input" << std::endl;
|
2015-05-05 18:25:48 +00:00
|
|
|
vtkm::testing::Testing::TryTypes(
|
2017-05-18 14:29:41 +00:00
|
|
|
TestingFancyArrayHandles<DeviceAdapterTag>::TestCompositeAsInput(), ScalarTypesToTest());
|
2015-05-05 18:25:48 +00:00
|
|
|
|
2015-05-13 20:24:51 +00:00
|
|
|
std::cout << "-------------------------------------------" << std::endl;
|
|
|
|
std::cout << "Testing ArrayHandleConstant as Input" << std::endl;
|
|
|
|
vtkm::testing::Testing::TryTypes(
|
2017-05-18 14:29:41 +00:00
|
|
|
TestingFancyArrayHandles<DeviceAdapterTag>::TestConstantAsInput(), HandleTypesToTest());
|
2015-05-13 20:24:51 +00:00
|
|
|
|
2015-05-05 18:25:48 +00:00
|
|
|
std::cout << "-------------------------------------------" << std::endl;
|
|
|
|
std::cout << "Testing ArrayHandleCounting as Input" << std::endl;
|
|
|
|
vtkm::testing::Testing::TryTypes(
|
2017-05-18 14:29:41 +00:00
|
|
|
TestingFancyArrayHandles<DeviceAdapterTag>::TestCountingAsInput(), HandleTypesToTest());
|
2015-05-05 18:25:48 +00:00
|
|
|
|
|
|
|
std::cout << "-------------------------------------------" << std::endl;
|
|
|
|
std::cout << "Testing ArrayHandleImplicit as Input" << std::endl;
|
|
|
|
vtkm::testing::Testing::TryTypes(
|
2017-05-18 14:29:41 +00:00
|
|
|
TestingFancyArrayHandles<DeviceAdapterTag>::TestImplicitAsInput(), HandleTypesToTest());
|
2015-05-05 18:25:48 +00:00
|
|
|
|
|
|
|
std::cout << "-------------------------------------------" << std::endl;
|
|
|
|
std::cout << "Testing ArrayHandlePermutation as Input" << std::endl;
|
|
|
|
vtkm::testing::Testing::TryTypes(
|
2017-05-18 14:29:41 +00:00
|
|
|
TestingFancyArrayHandles<DeviceAdapterTag>::TestPermutationAsInput(), HandleTypesToTest());
|
2015-05-05 18:25:48 +00:00
|
|
|
|
2018-08-29 20:54:31 +00:00
|
|
|
std::cout << "-------------------------------------------" << std::endl;
|
|
|
|
std::cout << "Testing ArrayHandleView as Input" << std::endl;
|
|
|
|
vtkm::testing::Testing::TryTypes(
|
|
|
|
TestingFancyArrayHandles<DeviceAdapterTag>::TestViewAsInput(), HandleTypesToTest());
|
|
|
|
|
2015-05-05 18:25:48 +00:00
|
|
|
std::cout << "-------------------------------------------" << std::endl;
|
|
|
|
std::cout << "Testing ArrayHandleTransform as Input" << std::endl;
|
|
|
|
vtkm::testing::Testing::TryTypes(
|
2017-05-18 14:29:41 +00:00
|
|
|
TestingFancyArrayHandles<DeviceAdapterTag>::TestTransformAsInput(), HandleTypesToTest());
|
2015-05-05 18:25:48 +00:00
|
|
|
|
2018-09-05 16:07:23 +00:00
|
|
|
std::cout << "-------------------------------------------" << std::endl;
|
|
|
|
std::cout << "Testing ArrayHandleTransform with virtual as Input" << std::endl;
|
|
|
|
vtkm::testing::Testing::TryTypes(
|
|
|
|
TestingFancyArrayHandles<DeviceAdapterTag>::TestTransformVirtualAsInput(),
|
|
|
|
HandleTypesToTest());
|
|
|
|
|
2015-05-05 18:25:48 +00:00
|
|
|
std::cout << "-------------------------------------------" << std::endl;
|
|
|
|
std::cout << "Testing ArrayHandleTransform with Counting as Input" << std::endl;
|
|
|
|
vtkm::testing::Testing::TryTypes(
|
2017-05-18 14:29:41 +00:00
|
|
|
TestingFancyArrayHandles<DeviceAdapterTag>::TestCountingTransformAsInput(),
|
|
|
|
HandleTypesToTest());
|
2015-05-05 18:25:48 +00:00
|
|
|
|
2015-09-01 21:42:45 +00:00
|
|
|
std::cout << "-------------------------------------------" << std::endl;
|
|
|
|
std::cout << "Testing ArrayHandleCast as Input" << std::endl;
|
|
|
|
vtkm::testing::Testing::TryTypes(
|
2017-05-18 14:29:41 +00:00
|
|
|
TestingFancyArrayHandles<DeviceAdapterTag>::TestCastAsInput(), CastTypesToTest());
|
2015-09-01 21:42:45 +00:00
|
|
|
|
2019-07-18 00:40:45 +00:00
|
|
|
std::cout << "-------------------------------------------" << std::endl;
|
|
|
|
std::cout << "Testing ArrayHandleCast as Output" << std::endl;
|
|
|
|
vtkm::testing::Testing::TryTypes(
|
|
|
|
TestingFancyArrayHandles<DeviceAdapterTag>::TestCastAsOutput(), CastTypesToTest());
|
|
|
|
|
2015-09-28 23:19:38 +00:00
|
|
|
std::cout << "-------------------------------------------" << std::endl;
|
|
|
|
std::cout << "Testing ArrayHandleGroupVec<3> as Input" << std::endl;
|
|
|
|
vtkm::testing::Testing::TryTypes(
|
2017-05-18 14:29:41 +00:00
|
|
|
TestingFancyArrayHandles<DeviceAdapterTag>::TestGroupVecAsInput<3>(), HandleTypesToTest());
|
2015-09-28 23:19:38 +00:00
|
|
|
|
|
|
|
std::cout << "-------------------------------------------" << std::endl;
|
|
|
|
std::cout << "Testing ArrayHandleGroupVec<4> as Input" << std::endl;
|
|
|
|
vtkm::testing::Testing::TryTypes(
|
2017-05-18 14:29:41 +00:00
|
|
|
TestingFancyArrayHandles<DeviceAdapterTag>::TestGroupVecAsInput<4>(), HandleTypesToTest());
|
2015-09-28 23:19:38 +00:00
|
|
|
|
|
|
|
std::cout << "-------------------------------------------" << std::endl;
|
|
|
|
std::cout << "Testing ArrayHandleGroupVec<2> as Output" << std::endl;
|
|
|
|
vtkm::testing::Testing::TryTypes(
|
2017-05-18 14:29:41 +00:00
|
|
|
TestingFancyArrayHandles<DeviceAdapterTag>::TestGroupVecAsOutput<2>(), ScalarTypesToTest());
|
2015-09-28 23:19:38 +00:00
|
|
|
|
|
|
|
std::cout << "-------------------------------------------" << std::endl;
|
|
|
|
std::cout << "Testing ArrayHandleGroupVec<3> as Output" << std::endl;
|
|
|
|
vtkm::testing::Testing::TryTypes(
|
2017-05-18 14:29:41 +00:00
|
|
|
TestingFancyArrayHandles<DeviceAdapterTag>::TestGroupVecAsOutput<3>(), ScalarTypesToTest());
|
2015-09-28 23:19:38 +00:00
|
|
|
|
2016-10-28 03:14:29 +00:00
|
|
|
std::cout << "-------------------------------------------" << std::endl;
|
|
|
|
std::cout << "Testing ArrayHandleGroupVecVariable as Input" << std::endl;
|
|
|
|
vtkm::testing::Testing::TryTypes(
|
2017-05-18 14:29:41 +00:00
|
|
|
TestingFancyArrayHandles<DeviceAdapterTag>::TestGroupVecVariableAsInput(),
|
|
|
|
ScalarTypesToTest());
|
2016-10-28 03:14:29 +00:00
|
|
|
|
|
|
|
std::cout << "-------------------------------------------" << std::endl;
|
|
|
|
std::cout << "Testing ArrayHandleGroupVecVariable as Output" << std::endl;
|
|
|
|
vtkm::testing::Testing::TryTypes(
|
2017-05-18 14:29:41 +00:00
|
|
|
TestingFancyArrayHandles<DeviceAdapterTag>::TestGroupVecVariableAsOutput(),
|
|
|
|
ScalarTypesToTest());
|
2016-10-28 03:14:29 +00:00
|
|
|
|
2015-05-08 19:32:06 +00:00
|
|
|
std::cout << "-------------------------------------------" << std::endl;
|
2015-07-13 17:01:41 +00:00
|
|
|
std::cout << "Testing ArrayHandleZip as Input" << std::endl;
|
2017-05-18 14:29:41 +00:00
|
|
|
vtkm::testing::Testing::TryTypes(TestingFancyArrayHandles<DeviceAdapterTag>::TestZipAsInput(),
|
|
|
|
ZipTypesToTest());
|
2015-05-08 19:32:06 +00:00
|
|
|
|
|
|
|
std::cout << "-------------------------------------------" << std::endl;
|
|
|
|
std::cout << "Testing ArrayHandlePermutation as Output" << std::endl;
|
|
|
|
vtkm::testing::Testing::TryTypes(
|
2017-05-18 14:29:41 +00:00
|
|
|
TestingFancyArrayHandles<DeviceAdapterTag>::TestPermutationAsOutput(), HandleTypesToTest());
|
2015-07-13 17:01:41 +00:00
|
|
|
|
2018-08-29 20:54:31 +00:00
|
|
|
std::cout << "-------------------------------------------" << std::endl;
|
|
|
|
std::cout << "Testing ArrayHandleView as Output" << std::endl;
|
|
|
|
vtkm::testing::Testing::TryTypes(
|
|
|
|
TestingFancyArrayHandles<DeviceAdapterTag>::TestViewAsOutput(), HandleTypesToTest());
|
|
|
|
|
2018-09-05 16:07:23 +00:00
|
|
|
std::cout << "-------------------------------------------" << std::endl;
|
|
|
|
std::cout << "Testing ArrayHandleTransform as Output" << std::endl;
|
|
|
|
vtkm::testing::Testing::TryTypes(
|
|
|
|
TestingFancyArrayHandles<DeviceAdapterTag>::TestTransformAsOutput(), HandleTypesToTest());
|
|
|
|
|
|
|
|
std::cout << "-------------------------------------------" << std::endl;
|
|
|
|
std::cout << "Testing ArrayHandleTransform with virtual as Output" << std::endl;
|
|
|
|
vtkm::testing::Testing::TryTypes(
|
|
|
|
TestingFancyArrayHandles<DeviceAdapterTag>::TestTransformVirtualAsOutput(),
|
|
|
|
HandleTypesToTest());
|
|
|
|
|
2017-02-07 17:53:53 +00:00
|
|
|
std::cout << "-------------------------------------------" << std::endl;
|
|
|
|
std::cout << "Testing ArrayHandleDiscard as Output" << std::endl;
|
|
|
|
vtkm::testing::Testing::TryTypes(
|
2017-05-18 14:29:41 +00:00
|
|
|
TestingFancyArrayHandles<DeviceAdapterTag>::TestDiscardAsOutput(), HandleTypesToTest());
|
2017-02-07 17:53:53 +00:00
|
|
|
|
2015-07-13 17:01:41 +00:00
|
|
|
std::cout << "-------------------------------------------" << std::endl;
|
|
|
|
std::cout << "Testing ArrayHandleZip as Output" << std::endl;
|
|
|
|
vtkm::testing::Testing::TryTypes(
|
2017-05-18 14:29:41 +00:00
|
|
|
TestingFancyArrayHandles<DeviceAdapterTag>::TestZipAsOutput(), ZipTypesToTest());
|
2016-08-08 22:38:41 +00:00
|
|
|
|
2017-01-17 22:33:18 +00:00
|
|
|
std::cout << "-------------------------------------------" << std::endl;
|
|
|
|
std::cout << "Testing ArrayHandleZip as In Place" << std::endl;
|
|
|
|
vtkm::testing::Testing::TryTypes(
|
2017-05-18 14:29:41 +00:00
|
|
|
TestingFancyArrayHandles<DeviceAdapterTag>::TestZipAsInPlace(), HandleTypesToTest());
|
2017-01-17 22:33:18 +00:00
|
|
|
|
2016-08-08 22:38:41 +00:00
|
|
|
std::cout << "-------------------------------------------" << std::endl;
|
|
|
|
std::cout << "Testing ArrayHandleConcatenate as Input" << std::endl;
|
|
|
|
vtkm::testing::Testing::TryTypes(
|
2017-05-18 14:29:41 +00:00
|
|
|
TestingFancyArrayHandles<DeviceAdapterTag>::TestConcatenateAsInput(), HandleTypesToTest());
|
2015-05-05 18:25:48 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2017-05-18 14:29:41 +00:00
|
|
|
public:
|
2015-05-05 18:25:48 +00:00
|
|
|
/// Run a suite of tests to check to see if a DeviceAdapter properly supports
|
|
|
|
/// all the fancy array handles that vtkm supports. Returns an
|
|
|
|
/// error code that can be returned from the main function of a test.
|
|
|
|
///
|
2019-01-01 22:19:02 +00:00
|
|
|
static VTKM_CONT int Run(int argc, char* argv[])
|
2018-08-28 20:36:50 +00:00
|
|
|
{
|
2019-03-15 19:59:02 +00:00
|
|
|
vtkm::cont::GetRuntimeDeviceTracker().ForceDevice(DeviceAdapterTag());
|
2019-01-01 22:19:02 +00:00
|
|
|
return vtkm::cont::testing::Testing::Run(TestAll(), argc, argv);
|
2018-08-28 20:36:50 +00:00
|
|
|
}
|
2015-05-05 18:25:48 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} // namespace vtkm::cont::testing
|
|
|
|
|
|
|
|
#endif //vtk_m_cont_testing_TestingFancyArrayHandles_h
|