Commit eed321aa authored by Robert Maynard's avatar Robert Maynard

Update vtkm/worklet to work with ArrayHandleVariant

parent 09383ceb
......@@ -32,10 +32,10 @@
#include <vtkm/cont/Algorithm.h>
#include <vtkm/cont/ArrayCopy.h>
#include <vtkm/cont/ArrayHandlePermutation.h>
#include <vtkm/cont/ArrayHandleVariant.h>
#include <vtkm/cont/ArrayHandleView.h>
#include <vtkm/cont/CellSetExplicit.h>
#include <vtkm/cont/CoordinateSystem.h>
#include <vtkm/cont/DynamicArrayHandle.h>
#include <vtkm/cont/DynamicCellSet.h>
#include <vtkm/cont/ImplicitFunctionHandle.h>
#include <vtkm/cont/Timer.h>
......
......@@ -71,7 +71,7 @@ public:
const InputDomainType& inputDomain = invocation.GetInputDomain();
// For a DispatcherMapField, the inputDomain must be an ArrayHandle (or
// a DynamicArrayHandle that gets cast to one). The size of the domain
// an ArrayHandleVariant that gets cast to one). The size of the domain
// (number of threads/worklet instances) is equal to the size of the
// array.
auto numInstances = internal::scheduling_range(inputDomain);
......
......@@ -244,7 +244,7 @@ public:
const InputDomainType& inputDomain = invocation.GetInputDomain();
// For a DispatcherStreamingMapField, the inputDomain must be an ArrayHandle (or
// a DynamicArrayHandle that gets cast to one). The size of the domain
// an ArrayHandleVariant that gets cast to one). The size of the domain
// (number of threads/worklet instances) is equal to the size of the
// array.
vtkm::Id fullSize = internal::scheduling_range(inputDomain);
......
......@@ -29,7 +29,6 @@
#include <vtkm/cont/ArrayHandleUniformPointCoordinates.h>
#include <vtkm/cont/DataSet.h>
#include <vtkm/cont/DeviceAdapterAlgorithm.h>
#include <vtkm/cont/DynamicArrayHandle.h>
#include <vtkm/cont/Timer.h>
#include <vtkm/cont/internal/ArrayPortalFromIterators.h>
......
......@@ -37,7 +37,6 @@
#include <vtkm/cont/ArrayHandleZip.h>
#include <vtkm/cont/CellSetPermutation.h>
#include <vtkm/cont/DataSet.h>
#include <vtkm/cont/DynamicArrayHandle.h>
#include <vtkm/cont/Field.h>
#include <vtkm/worklet/DispatcherMapTopology.h>
......
......@@ -71,7 +71,7 @@ public:
else
{
CastAndCall(
fieldArray.ResetTypeList(vtkm::TypeListTagScalarAll()),
fieldArray.ResetTypes(vtkm::TypeListTagScalarAll()),
vtkm::worklet::histogram::ComputeBins(Bin1DIndex, numberOfBins, rangeOfValues, binDelta));
}
}
......
......@@ -32,7 +32,7 @@
#include <vtkm/VectorAnalysis.h>
#include <vtkm/cont/Algorithm.h>
#include <vtkm/cont/ArrayCopy.h>
#include <vtkm/cont/testing/Testing.h>
#include <vtkm/cont/ArrayHandlePermutation.h>
#include <vtkm/exec/CellEdge.h>
namespace vtkm
......
......@@ -20,12 +20,14 @@
#ifndef vtk_m_worklet_SurfaceNormals_h
#define vtk_m_worklet_SurfaceNormals_h
#include <vtkm/worklet/DispatcherMapTopology.h>
#include <vtkm/worklet/WorkletMapTopology.h>
#include <vtkm/CellTraits.h>
#include <vtkm/TypeTraits.h>
#include <vtkm/VectorAnalysis.h>
#include <vtkm/cont/ArrayHandleVariant.h>
namespace vtkm
{
......@@ -141,11 +143,10 @@ public:
}
}
template <typename CellSetType, typename CoordsStorageList, typename NormalCompType>
void Run(
const CellSetType& cellset,
const vtkm::cont::DynamicArrayHandleBase<vtkm::TypeListTagFieldVec3, CoordsStorageList>& points,
vtkm::cont::ArrayHandle<vtkm::Vec<NormalCompType, 3>>& normals)
template <typename CellSetType, typename NormalCompType>
void Run(const CellSetType& cellset,
const vtkm::cont::ArrayHandleVariantBase<vtkm::TypeListTagFieldVec3>& points,
vtkm::cont::ArrayHandle<vtkm::Vec<NormalCompType, 3>>& normals)
{
if (this->Normalize)
{
......@@ -205,13 +206,9 @@ public:
vtkm::worklet::DispatcherMapTopology<Worklet>().Invoke(cellset, faceNormals, pointNormals);
}
template <typename CellSetType,
typename FaceNormalTypeList,
typename FaceNormalStorageList,
typename NormalCompType>
template <typename CellSetType, typename FaceNormalTypeList, typename NormalCompType>
void Run(const CellSetType& cellset,
const vtkm::cont::DynamicArrayHandleBase<FaceNormalTypeList, FaceNormalStorageList>&
faceNormals,
const vtkm::cont::ArrayHandleVariantBase<FaceNormalTypeList>& faceNormals,
vtkm::cont::ArrayHandle<vtkm::Vec<NormalCompType, 3>>& pointNormals)
{
vtkm::worklet::DispatcherMapTopology<Worklet>().Invoke(cellset, faceNormals, pointNormals);
......
......@@ -29,7 +29,6 @@
#include <vtkm/cont/ArrayHandleCounting.h>
#include <vtkm/cont/ArrayHandlePermutation.h>
#include <vtkm/cont/CellSetPermutation.h>
#include <vtkm/cont/DynamicArrayHandle.h>
#include <vtkm/cont/DynamicCellSet.h>
#include <vtkm/cont/Field.h>
......
......@@ -32,7 +32,6 @@
#include <vtkm/cont/ArrayHandleIndex.h>
#include <vtkm/cont/ArrayHandlePermutation.h>
#include <vtkm/cont/DataSet.h>
#include <vtkm/cont/DynamicArrayHandle.h>
#include <vtkm/cont/Logging.h>
#include <vtkm/worklet/DispatcherMapField.h>
......@@ -84,7 +83,7 @@ struct SelectRepresentativePoint : public vtkm::worklet::WorkletReduceByKey
template <typename InputPointsArrayType, typename KeyType>
VTKM_CONT void operator()(const InputPointsArrayType& points,
const vtkm::worklet::Keys<KeyType>& keys,
vtkm::cont::DynamicArrayHandle& output) const
vtkm::cont::ArrayHandleVariant& output) const
{
vtkm::cont::ArrayHandle<typename InputPointsArrayType::ValueType> out;
......@@ -96,11 +95,11 @@ struct SelectRepresentativePoint : public vtkm::worklet::WorkletReduceByKey
};
template <typename KeyType, typename InputDynamicPointsArrayType>
VTKM_CONT static vtkm::cont::DynamicArrayHandle Run(
VTKM_CONT static vtkm::cont::ArrayHandleVariant Run(
const vtkm::worklet::Keys<KeyType>& keys,
const InputDynamicPointsArrayType& inputPoints)
{
vtkm::cont::DynamicArrayHandle output;
vtkm::cont::ArrayHandleVariant output;
RunTrampoline trampoline;
vtkm::cont::CastAndCall(inputPoints, trampoline, keys, output);
return output;
......@@ -380,7 +379,7 @@ public:
#endif
/// pass 2 : Choose a representative point from each cluster for the output:
vtkm::cont::DynamicArrayHandle repPointArray;
vtkm::cont::ArrayHandleVariant repPointArray;
{
vtkm::worklet::Keys<vtkm::Id> keys;
keys.BuildArrays(pointCidArray, vtkm::worklet::Keys<vtkm::Id>::SortType::Stable);
......
......@@ -142,13 +142,13 @@ public:
}
};
template <typename T, typename S, typename OutputPortalType>
template <typename T, typename OutputPortalType>
void Run(const vtkm::cont::CellSetStructured<2>& input,
const vtkm::cont::DynamicArrayHandleBase<T, S>& pixels,
const vtkm::cont::ArrayHandleVariantBase<T>& pixels,
OutputPortalType& componentsOut) const
{
using Types = vtkm::ListTagBase<vtkm::UInt8>;
vtkm::cont::CastAndCall(pixels.ResetTypeList(Types{}), RunImpl(), input, componentsOut);
vtkm::cont::CastAndCall(pixels.ResetTypes(Types{}), RunImpl(), input, componentsOut);
}
template <typename T, typename S, typename OutputPortalType>
......
......@@ -27,7 +27,6 @@
#include <vtkm/cont/CellSetStructured.h>
#include <vtkm/cont/DataSet.h>
#include <vtkm/cont/DeviceAdapter.h>
#include <vtkm/cont/DynamicArrayHandle.h>
#include <vtkm/worklet/particleadvection/Integrators.h>
......
......@@ -24,7 +24,10 @@
#include <vtkm/TypeTraits.h>
#include <vtkm/Types.h>
#include <vtkm/VectorAnalysis.h>
#include <vtkm/cont/DataSet.h>
#include <vtkm/cont/VirtualObjectHandle.h>
#include <vtkm/worklet/particleadvection/Particles.h>
namespace vtkm
......
......@@ -26,7 +26,6 @@
#include <vtkm/cont/CellSetStructured.h>
#include <vtkm/cont/DataSet.h>
#include <vtkm/cont/DeviceAdapter.h>
#include <vtkm/cont/DynamicArrayHandle.h>
#include <vtkm/worklet/particleadvection/Particles.h>
namespace vtkm
......
......@@ -23,7 +23,6 @@
#include <vtkm/cont/ArrayHandleUniformPointCoordinates.h>
#include <vtkm/cont/CellSetSingleType.h>
#include <vtkm/cont/DataSet.h>
#include <vtkm/cont/DynamicArrayHandle.h>
#include <vtkm/cont/testing/Testing.h>
#include <vtkm/worklet/DispatcherMapField.h>
......@@ -266,12 +265,11 @@ inline vtkm::cont::DataSet MakeRadiantDataSet::Make3DRadiantDataSet(vtkm::IdComp
dataSet.AddCoordinateSystem(vtkm::cont::CoordinateSystem("coordinates", coordinates));
//Set point scalar
dataSet.AddField(vtkm::cont::Field("distanceToOrigin",
vtkm::cont::Field::Association::POINTS,
vtkm::cont::DynamicArrayHandle(distanceToOrigin)));
dataSet.AddField(vtkm::cont::Field(
"distanceToOrigin", vtkm::cont::Field::Association::POINTS, distanceToOrigin));
dataSet.AddField(vtkm::cont::Field("distanceToOther",
vtkm::cont::Field::Association::POINTS,
vtkm::cont::DynamicArrayHandle(distanceToOther)));
vtkm::cont::ArrayHandleVariant(distanceToOther)));
CellSet cellSet("cells");
cellSet.Fill((dim + 1) * (dim + 1) * (dim + 1), HexTag::Id, HexTraits::NUM_POINTS, connectivity);
......
......@@ -78,7 +78,7 @@ void TestWarpScalar()
vtkm::cont::ArrayHandle<vtkm::FloatDefault> scaleFactorArray;
auto scaleFactor =
ds.GetField("scalefactor").GetData().ResetTypeList(vtkm::TypeListTagFieldScalar());
ds.GetField("scalefactor").GetData().ResetTypes(vtkm::TypeListTagFieldScalar());
scaleFactor.CopyTo(scaleFactorArray);
auto sFAPortal = scaleFactorArray.GetPortalControl();
......
......@@ -19,7 +19,8 @@
//============================================================================
#include <vtkm/cont/ArrayCopy.h>
#include <vtkm/cont/ArrayHandle.h>
#include <vtkm/cont/DynamicArrayHandle.h>
#include <vtkm/cont/ArrayHandleVariant.h>
#include <vtkm/cont/internal/DeviceAdapterTag.h>
#include <vtkm/worklet/DispatcherMapField.h>
......@@ -136,7 +137,7 @@ struct DoStaticTestWorklet
};
template <typename WorkletType>
struct DoDynamicTestWorklet
struct DoVariantTestWorklet
{
template <typename T>
VTKM_CONT void operator()(T) const
......@@ -154,25 +155,25 @@ struct DoDynamicTestWorklet
vtkm::cont::ArrayHandle<T> inoutHandle;
std::cout << "Create and run dispatcher with dynamic arrays." << std::endl;
std::cout << "Create and run dispatcher with variant arrays." << std::endl;
vtkm::worklet::DispatcherMapField<WorkletType> dispatcher;
vtkm::cont::DynamicArrayHandle inputDynamic(inputHandle);
vtkm::cont::ArrayHandleVariant inputVariant(inputHandle);
{ //Verify we can pass by value
vtkm::cont::ArrayCopy(inputHandle, inoutHandle);
vtkm::cont::DynamicArrayHandle outputDynamic(outputHandle);
vtkm::cont::DynamicArrayHandle inoutDynamic(inoutHandle);
dispatcher.Invoke(inputDynamic, outputDynamic, inoutDynamic);
vtkm::cont::ArrayHandleVariant outputVariant(outputHandle);
vtkm::cont::ArrayHandleVariant inoutVariant(inoutHandle);
dispatcher.Invoke(inputVariant, outputVariant, inoutVariant);
CheckPortal(outputHandle.GetPortalConstControl());
CheckPortal(inoutHandle.GetPortalConstControl());
}
{ //Verify we can pass by pointer
vtkm::cont::ArrayCopy(inputHandle, inoutHandle);
vtkm::cont::DynamicArrayHandle outputDynamic(outputHandle);
vtkm::cont::DynamicArrayHandle inoutDynamic(inoutHandle);
dispatcher.Invoke(&inputDynamic, &outputDynamic, &inoutDynamic);
vtkm::cont::ArrayHandleVariant outputVariant(outputHandle);
vtkm::cont::ArrayHandleVariant inoutVariant(inoutHandle);
dispatcher.Invoke(&inputVariant, &outputVariant, &inoutVariant);
CheckPortal(outputHandle.GetPortalConstControl());
CheckPortal(inoutHandle.GetPortalConstControl());
}
......@@ -187,7 +188,7 @@ struct DoTestWorklet
{
DoStaticTestWorklet<WorkletType> sw;
sw(t);
DoDynamicTestWorklet<WorkletType> dw;
DoVariantTestWorklet<WorkletType> dw;
dw(t);
}
};
......@@ -207,8 +208,8 @@ void TestWorkletMapField(vtkm::cont::DeviceAdapterId id)
std::cout << "--- Sending bad type to worklet." << std::endl;
try
{
//can only test with dynamic arrays, as static arrays will fail to compile
DoDynamicTestWorklet<TestMapFieldWorkletLimitedTypes> badWorkletTest;
//can only test with variant arrays, as static arrays will fail to compile
DoVariantTestWorklet<TestMapFieldWorkletLimitedTypes> badWorkletTest;
badWorkletTest(vtkm::Vec<vtkm::Float32, 3>());
VTKM_TEST_FAIL("Did not throw expected error.");
}
......
......@@ -19,7 +19,7 @@
//============================================================================
#include <vtkm/cont/ArrayHandle.h>
#include <vtkm/cont/ArrayHandleIndex.h>
#include <vtkm/cont/DynamicArrayHandle.h>
#include <vtkm/cont/ArrayHandleVariant.h>
#include <vtkm/cont/internal/DeviceAdapterTag.h>
#include <vtkm/worklet/DispatcherMapField.h>
......@@ -94,7 +94,7 @@ struct DoTestWorklet
outputHandle = vtkm::cont::ArrayHandle<T>();
outputHandle.Allocate(ARRAY_SIZE);
vtkm::cont::DynamicArrayHandle outputFieldDynamic(outputFieldArray);
vtkm::cont::ArrayHandleVariant outputFieldDynamic(outputFieldArray);
dispatcher.Invoke(counting, inputHandle, outputHandle, outputFieldDynamic);
std::cout << "Check dynamic array result." << std::endl;
......
......@@ -19,7 +19,7 @@
//============================================================================
#include <vtkm/cont/ArrayHandle.h>
#include <vtkm/cont/ArrayHandleIndex.h>
#include <vtkm/cont/DynamicArrayHandle.h>
#include <vtkm/cont/ArrayHandleVariant.h>
#include <vtkm/cont/internal/DeviceAdapterTag.h>
#include <vtkm/worklet/DispatcherMapField.h>
......@@ -83,9 +83,9 @@ struct DoTestWholeArrayWorklet
// This just demonstrates that the WholeArray tags support dynamic arrays.
VTKM_CONT
void CallWorklet(const vtkm::cont::DynamicArrayHandle& inArray,
const vtkm::cont::DynamicArrayHandle& inOutArray,
const vtkm::cont::DynamicArrayHandle& outArray) const
void CallWorklet(const vtkm::cont::ArrayHandleVariant& inArray,
const vtkm::cont::ArrayHandleVariant& inOutArray,
const vtkm::cont::ArrayHandleVariant& outArray) const
{
std::cout << "Create and run dispatcher." << std::endl;
vtkm::worklet::DispatcherMapField<WorkletType> dispatcher;
......@@ -111,9 +111,9 @@ struct DoTestWholeArrayWorklet
// Output arrays must be preallocated.
outHandle.Allocate(ARRAY_SIZE);
this->CallWorklet(vtkm::cont::DynamicArrayHandle(inHandle),
vtkm::cont::DynamicArrayHandle(inOutHandle),
vtkm::cont::DynamicArrayHandle(outHandle));
this->CallWorklet(vtkm::cont::ArrayHandleVariant(inHandle),
vtkm::cont::ArrayHandleVariant(inOutHandle),
vtkm::cont::ArrayHandleVariant(outHandle));
std::cout << "Check result." << std::endl;
CheckPortal(inOutHandle.GetPortalConstControl());
......@@ -127,7 +127,7 @@ struct DoTestAtomicArrayWorklet
// This just demonstrates that the WholeArray tags support dynamic arrays.
VTKM_CONT
void CallWorklet(const vtkm::cont::DynamicArrayHandle& inOutArray) const
void CallWorklet(const vtkm::cont::ArrayHandleVariant& inOutArray) const
{
std::cout << "Create and run dispatcher." << std::endl;
vtkm::worklet::DispatcherMapField<WorkletType> dispatcher;
......@@ -142,7 +142,7 @@ struct DoTestAtomicArrayWorklet
vtkm::cont::ArrayHandle<T> inOutHandle = vtkm::cont::make_ArrayHandle(&inOutValue, 1);
this->CallWorklet(vtkm::cont::DynamicArrayHandle(inOutHandle));
this->CallWorklet(vtkm::cont::ArrayHandleVariant(inOutHandle));
std::cout << "Check result." << std::endl;
T result = inOutHandle.GetPortalConstControl().Get(0);
......
......@@ -26,7 +26,6 @@
#include <vtkm/cont/CellSetExplicit.h>
#include <vtkm/cont/DataSet.h>
#include <vtkm/cont/DeviceAdapter.h>
#include <vtkm/cont/DynamicArrayHandle.h>
#include <vtkm/cont/Field.h>
#include <vtkm/worklet/DispatcherMapField.h>
......
......@@ -28,7 +28,6 @@
#include <vtkm/cont/CellSetStructured.h>
#include <vtkm/cont/DataSet.h>
#include <vtkm/cont/DeviceAdapter.h>
#include <vtkm/cont/DynamicArrayHandle.h>
#include <vtkm/cont/ErrorBadValue.h>
#include <vtkm/cont/Field.h>
......
......@@ -25,7 +25,6 @@
#include <vtkm/cont/ArrayHandleGroupVec.h>
#include <vtkm/cont/CellSetExplicit.h>
#include <vtkm/cont/DataSet.h>
#include <vtkm/cont/DynamicArrayHandle.h>
#include <vtkm/cont/Field.h>
#include <vtkm/worklet/DispatcherMapField.h>
......
......@@ -27,7 +27,6 @@
#include <vtkm/cont/CellSetSingleType.h>
#include <vtkm/cont/CellSetStructured.h>
#include <vtkm/cont/DataSet.h>
#include <vtkm/cont/DynamicArrayHandle.h>
#include <vtkm/cont/ErrorBadValue.h>
#include <vtkm/cont/Field.h>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment