Make DispatcherBase invoke using a TryExecute

Rather than force all dispatchers to be templated on a device adapter,
instead use a TryExecute internally within the invoke to select a device
adapter.

Because this removes the need to declare a device when invoking a
worklet, this commit also removes the need to declare a device in
several other areas of the code.
This commit is contained in:
Kenneth Moreland 2018-08-28 13:36:50 -07:00
parent 4e0e829b81
commit d879188de0
112 changed files with 1915 additions and 1910 deletions

@ -631,8 +631,9 @@ private:
vtkm::cont::ArrayHandle<Value> result;
Timer timer;
vtkm::worklet::DispatcherMapField<InterpolateField, DeviceAdapterTag>().Invoke(
this->EdgePairHandle, this->WeightHandle, this->FieldHandle, result);
vtkm::worklet::DispatcherMapField<InterpolateField> dispatcher;
dispatcher.SetDevice(DeviceAdapterTag());
dispatcher.Invoke(this->EdgePairHandle, this->WeightHandle, this->FieldHandle, result);
return timer.GetElapsedTime();
}
@ -663,8 +664,9 @@ private:
vtkm::cont::ArrayHandle<Value> result;
Timer timer;
vtkm::worklet::DispatcherMapField<InterpolateField, DeviceAdapterTag>().Invoke(
dedges, dweight, dfield, result);
vtkm::worklet::DispatcherMapField<InterpolateField> dispatcher;
dispatcher.SetDevice(DeviceAdapterTag());
dispatcher.Invoke(dedges, dweight, dfield, result);
return timer.GetElapsedTime();
}
@ -719,7 +721,7 @@ private:
vtkm::Float64 operator()()
{
using EvalWorklet = EvaluateImplicitFunction<vtkm::Sphere>;
using EvalDispatcher = vtkm::worklet::DispatcherMapField<EvalWorklet, DeviceAdapterTag>;
using EvalDispatcher = vtkm::worklet::DispatcherMapField<EvalWorklet>;
auto handle = vtkm::cont::make_ImplicitFunctionHandle(Internal.Sphere1);
auto function =
@ -727,7 +729,9 @@ private:
EvalWorklet eval(function);
vtkm::cont::Timer<DeviceAdapterTag> timer;
EvalDispatcher(eval).Invoke(this->Internal.Points, this->Internal.Result);
EvalDispatcher dispatcher(eval);
dispatcher.SetDevice(DeviceAdapterTag());
dispatcher.Invoke(this->Internal.Points, this->Internal.Result);
return timer.GetElapsedTime();
}
@ -755,13 +759,15 @@ private:
vtkm::Float64 operator()()
{
using EvalWorklet = EvaluateImplicitFunction<vtkm::ImplicitFunction>;
using EvalDispatcher = vtkm::worklet::DispatcherMapField<EvalWorklet, DeviceAdapterTag>;
using EvalDispatcher = vtkm::worklet::DispatcherMapField<EvalWorklet>;
auto sphere = vtkm::cont::make_ImplicitFunctionHandle(Internal.Sphere1);
EvalWorklet eval(sphere.PrepareForExecution(DeviceAdapterTag()));
vtkm::cont::Timer<DeviceAdapterTag> timer;
EvalDispatcher(eval).Invoke(this->Internal.Points, this->Internal.Result);
EvalDispatcher dispatcher(eval);
dispatcher.SetDevice(DeviceAdapterTag());
dispatcher.Invoke(this->Internal.Points, this->Internal.Result);
return timer.GetElapsedTime();
}
@ -789,7 +795,7 @@ private:
vtkm::Float64 operator()()
{
using EvalWorklet = Evaluate2ImplicitFunctions<vtkm::Sphere, vtkm::Sphere>;
using EvalDispatcher = vtkm::worklet::DispatcherMapField<EvalWorklet, DeviceAdapterTag>;
using EvalDispatcher = vtkm::worklet::DispatcherMapField<EvalWorklet>;
auto h1 = vtkm::cont::make_ImplicitFunctionHandle(Internal.Sphere1);
auto h2 = vtkm::cont::make_ImplicitFunctionHandle(Internal.Sphere2);
@ -798,7 +804,9 @@ private:
EvalWorklet eval(f1, f2);
vtkm::cont::Timer<DeviceAdapterTag> timer;
EvalDispatcher(eval).Invoke(this->Internal.Points, this->Internal.Result);
EvalDispatcher dispatcher(eval);
dispatcher.SetDevice(DeviceAdapterTag());
dispatcher.Invoke(this->Internal.Points, this->Internal.Result);
return timer.GetElapsedTime();
}
@ -827,7 +835,7 @@ private:
{
using EvalWorklet =
Evaluate2ImplicitFunctions<vtkm::ImplicitFunction, vtkm::ImplicitFunction>;
using EvalDispatcher = vtkm::worklet::DispatcherMapField<EvalWorklet, DeviceAdapterTag>;
using EvalDispatcher = vtkm::worklet::DispatcherMapField<EvalWorklet>;
auto s1 = vtkm::cont::make_ImplicitFunctionHandle(Internal.Sphere1);
auto s2 = vtkm::cont::make_ImplicitFunctionHandle(Internal.Sphere2);
@ -835,7 +843,9 @@ private:
s2.PrepareForExecution(DeviceAdapterTag()));
vtkm::cont::Timer<DeviceAdapterTag> timer;
EvalDispatcher(eval).Invoke(this->Internal.Points, this->Internal.Result);
EvalDispatcher dispatcher(eval);
dispatcher.SetDevice(DeviceAdapterTag());
dispatcher.Invoke(this->Internal.Points, this->Internal.Result);
return timer.GetElapsedTime();
}

@ -934,7 +934,8 @@ void CreateFields(bool needPointScalars, bool needCellScalars, bool needPointVec
vtkm::cont::ArrayHandle<vtkm::Vec<vtkm::FloatDefault, 3>> pvecs;
PointVectorGenerator worklet(bounds);
vtkm::worklet::DispatcherMapField<PointVectorGenerator, Device> dispatch(worklet);
vtkm::worklet::DispatcherMapField<PointVectorGenerator> dispatch(worklet);
dispatch.SetDevice(Device());
dispatch.Invoke(points, pvecs);
InputDataSet.AddField(
vtkm::cont::Field("GeneratedPointVectors", vtkm::cont::Field::Association::POINTS, pvecs));

@ -0,0 +1,15 @@
# Make DispatcherBase invoke using a TryExecute
Rather than force all dispatchers to be templated on a device adapter,
instead use a TryExecute internally within the invoke to select a device
adapter.
Because this removes the need to declare a device when invoking a worklet,
this commit also removes the need to declare a device in several other
areas of the code.
This changes touches quite a bit a code. The first pass of the change
usually does the minimum amount of work, which is to change the
compile-time specification of the device to a run-time call to `SetDevice`
on the dispatcher. Although functionally equivalent, it might mean calling
`TryExecute` within itself.

@ -139,7 +139,7 @@ public:
this->PrintedDeviceMsg = true;
}
using DispatcherType = vtkm::worklet::DispatcherPointNeighborhood<UpdateLifeState, Device>;
using DispatcherType = vtkm::worklet::DispatcherPointNeighborhood<UpdateLifeState>;
vtkm::cont::ArrayHandle<vtkm::UInt8> state;
@ -153,7 +153,9 @@ public:
input.GetField("state", vtkm::cont::Field::Association::POINTS).GetData().CopyTo(prevstate);
//Update the game state
DispatcherType().Invoke(vtkm::filter::ApplyPolicy(cells, policy), prevstate, state, colors);
DispatcherType dispatcher;
dispatcher.SetDevice(Device());
dispatcher.Invoke(vtkm::filter::ApplyPolicy(cells, policy), prevstate, state, colors);
//save the results
vtkm::cont::DataSet output;

@ -53,7 +53,7 @@ vtkm::cont::DataSet make_test3DImageData(vtkm::Id3 dims)
vtkm::cont::DataSet ds = Builder::Create(dims);
vtkm::cont::ArrayHandle<vtkm::Vec<vtkm::FloatDefault, 3>> field;
vtkm::worklet::DispatcherMapField<WaveField, vtkm::cont::DeviceAdapterTagSerial> dispatcher;
vtkm::worklet::DispatcherMapField<WaveField> dispatcher;
dispatcher.Invoke(ds.GetCoordinateSystem(), field);
FieldAdd::AddPointField(ds, "vec_field", field);

@ -135,15 +135,16 @@ VTKM_CONT void BoundingIntervalHierarchy::CalculatePlaneSplitCost(
vtkm::cont::ArrayHandle<vtkm::FloatDefault> splitPlanes;
vtkm::worklet::spatialstructure::SplitPlaneCalculatorWorklet splitPlaneCalcWorklet(planeIndex,
numPlanes);
vtkm::worklet::DispatcherMapField<vtkm::worklet::spatialstructure::SplitPlaneCalculatorWorklet,
DeviceAdapter>
vtkm::worklet::DispatcherMapField<vtkm::worklet::spatialstructure::SplitPlaneCalculatorWorklet>
splitDispatcher(splitPlaneCalcWorklet);
splitDispatcher.SetDevice(DeviceAdapter());
splitDispatcher.Invoke(segmentRanges, splitPlanes);
// Check if a point is to the left of the split plane or right
vtkm::cont::ArrayHandle<vtkm::Id> isLEQOfSplitPlane, isROfSplitPlane;
vtkm::worklet::DispatcherMapField<vtkm::worklet::spatialstructure::LEQWorklet, DeviceAdapter>()
.Invoke(coords, splitPlanes, isLEQOfSplitPlane, isROfSplitPlane);
vtkm::worklet::DispatcherMapField<vtkm::worklet::spatialstructure::LEQWorklet> LEQDispatcher;
LEQDispatcher.SetDevice(DeviceAdapter());
LEQDispatcher.Invoke(coords, splitPlanes, isLEQOfSplitPlane, isROfSplitPlane);
// Count of points to the left
vtkm::cont::ArrayHandle<vtkm::Id> pointsToLeft;
@ -270,9 +271,11 @@ public:
//START_TIMER(s12);
CoordsArrayHandle centerXs, centerYs, centerZs;
RangeArrayHandle xRanges, yRanges, zRanges;
vtkm::worklet::DispatcherMapTopology<vtkm::worklet::spatialstructure::CellRangesExtracter,
DeviceAdapter>()
.Invoke(cellSet, points, xRanges, yRanges, zRanges, centerXs, centerYs, centerZs);
vtkm::worklet::DispatcherMapTopology<vtkm::worklet::spatialstructure::CellRangesExtracter>
cellRangesExtracterDispatcher;
cellRangesExtracterDispatcher.SetDevice(DeviceAdapter());
cellRangesExtracterDispatcher.Invoke(
cellSet, points, xRanges, yRanges, zRanges, centerXs, centerYs, centerZs);
//PRINT_TIMER("1.2", s12);
bool done = false;

@ -138,8 +138,9 @@ public:
auto coordinates =
this->Coordinates.GetData().Cast<vtkm::cont::ArrayHandleUniformPointCoordinates>();
auto cellset = this->CellSet.ResetCellSetList(StructuredCellSetList());
vtkm::worklet::DispatcherMapField<FindCellWorklet, DeviceAdapter>().Invoke(
points, cellset, coordinates, cellIds, parametricCoords);
vtkm::worklet::DispatcherMapField<FindCellWorklet> dispatcher;
dispatcher.SetDevice(DeviceAdapter());
dispatcher.Invoke(points, cellset, coordinates, cellIds, parametricCoords);
}
else
{

@ -513,8 +513,9 @@ public:
// 2: For each cell, find the number of top level bins they intersect
vtkm::cont::ArrayHandle<vtkm::Id> binCounts;
CountBinsL1 countL1(ls.TopLevel);
vtkm::worklet::DispatcherMapTopology<CountBinsL1, DeviceAdapter>(countL1).Invoke(
cellset, coords, binCounts);
vtkm::worklet::DispatcherMapTopology<CountBinsL1> countL1Dispatcher(countL1);
countL1Dispatcher.SetDevice(DeviceAdapter());
countL1Dispatcher.Invoke(cellset, coords, binCounts);
// 3: Total number of unique (cell, bin) pairs (for pre-allocating arrays)
vtkm::Id numPairsL1 = Algorithm::ScanExclusive(binCounts, binCounts);
@ -523,8 +524,9 @@ public:
vtkm::cont::ArrayHandle<vtkm::Id> binIds;
binIds.Allocate(numPairsL1);
FindBinsL1 findL1(ls.TopLevel);
vtkm::worklet::DispatcherMapTopology<FindBinsL1, DeviceAdapter>(findL1).Invoke(
cellset, coords, binCounts, binIds);
vtkm::worklet::DispatcherMapTopology<FindBinsL1> findL1Dispatcher(findL1);
findL1Dispatcher.SetDevice(DeviceAdapter());
findL1Dispatcher.Invoke(cellset, coords, binCounts, binIds);
binCounts.ReleaseResources();
// 5: From above, find the number of cells that intersect each top level bin
@ -544,8 +546,9 @@ public:
Algorithm::Copy(vtkm::cont::make_ArrayHandleConstant(DimVec3(0), numberOfBins),
ls.LeafDimensions);
GenerateBinsL1 generateL1(ls.TopLevel.BinSize, this->DensityL2);
vtkm::worklet::DispatcherMapField<GenerateBinsL1, DeviceAdapter>(generateL1)
.Invoke(bins, cellsPerBin, ls.LeafDimensions);
vtkm::worklet::DispatcherMapField<GenerateBinsL1> generateL1Dispatcher(generateL1);
generateL1Dispatcher.SetDevice(DeviceAdapter());
generateL1Dispatcher.Invoke(bins, cellsPerBin, ls.LeafDimensions);
bins.ReleaseResources();
cellsPerBin.ReleaseResources();
@ -557,8 +560,9 @@ public:
// 8: For each cell, find the number of l2 bins they intersect
CountBinsL2 countL2(ls.TopLevel);
vtkm::worklet::DispatcherMapTopology<CountBinsL2, DeviceAdapter>(countL2).Invoke(
cellset, coords, ls.LeafDimensions, binCounts);
vtkm::worklet::DispatcherMapTopology<CountBinsL2> countL2Dispatcher(countL2);
countL2Dispatcher.SetDevice(DeviceAdapter());
countL2Dispatcher.Invoke(cellset, coords, ls.LeafDimensions, binCounts);
// 9: Total number of unique (cell, bin) pairs (for pre-allocating arrays)
vtkm::Id numPairsL2 = Algorithm::ScanExclusive(binCounts, binCounts);
@ -567,7 +571,9 @@ public:
binIds.Allocate(numPairsL2);
ls.CellIds.Allocate(numPairsL2);
FindBinsL2 findL2(ls.TopLevel);
vtkm::worklet::DispatcherMapTopology<FindBinsL2, DeviceAdapter>(findL2).Invoke(
vtkm::worklet::DispatcherMapTopology<FindBinsL2> findL2Dispatcher(findL2);
findL2Dispatcher.SetDevice(DeviceAdapter());
findL2Dispatcher.Invoke(
cellset, coords, ls.LeafDimensions, ls.LeafStartIndex, binCounts, binIds, ls.CellIds);
binCounts.ReleaseResources();
@ -587,8 +593,9 @@ public:
Algorithm::Copy(vtkm::cont::ArrayHandleConstant<vtkm::Id>(0, numberOfLeaves),
ls.CellStartIndex);
Algorithm::Copy(vtkm::cont::ArrayHandleConstant<vtkm::Id>(0, numberOfLeaves), ls.CellCount);
vtkm::worklet::DispatcherMapField<GenerateBinsL2, DeviceAdapter>().Invoke(
bins, cellsStart, cellsPerBin, ls.CellStartIndex, ls.CellCount);
vtkm::worklet::DispatcherMapField<GenerateBinsL2> dispatchGenerateBinsL2;
dispatchGenerateBinsL2.SetDevice(DeviceAdapter());
dispatchGenerateBinsL2.Invoke(bins, cellsStart, cellsPerBin, ls.CellStartIndex, ls.CellCount);
std::swap(this->LookupStructure, ls);
}
@ -708,13 +715,14 @@ public:
DeviceAdapter,
CellSetList cellSetTypes = CellSetList()) const
{
vtkm::worklet::DispatcherMapField<FindCellWorklet, DeviceAdapter>().Invoke(
points,
this->CellSet.ResetCellSetList(cellSetTypes),
this->Coordinates,
this->LookupStructure,
cellIds,
parametricCoords);
vtkm::worklet::DispatcherMapField<FindCellWorklet> dispatcher;
dispatcher.SetDevice(DeviceAdapter());
dispatcher.Invoke(points,
this->CellSet.ResetCellSetList(cellSetTypes),
this->Coordinates,
this->LookupStructure,
cellIds,
parametricCoords);
}
private:

@ -92,8 +92,9 @@ public:
vtkm::Id connectivityLength = vtkm::cont::DeviceAdapterAlgorithm<Device>::ScanExclusive(
vtkm::cont::make_ArrayHandleCast(conn.NumIndices, vtkm::Id()), conn.IndexOffsets);
conn.Connectivity.Allocate(connectivityLength);
vtkm::worklet::DispatcherMapTopology<WriteConnectivity, Device>().Invoke(
cellset, conn.IndexOffsets, conn.Connectivity);
vtkm::worklet::DispatcherMapTopology<WriteConnectivity> dispatcher;
dispatcher.SetDevice(Device());
dispatcher.Invoke(cellset, conn.IndexOffsets, conn.Connectivity);
return conn;
}
@ -126,8 +127,9 @@ public:
conn.NumIndices = make_ArrayHandleConstant(numPointsInCell, numberOfCells);
conn.IndexOffsets = ArrayHandleCounting<vtkm::Id>(0, numPointsInCell, numberOfCells);
conn.Connectivity.Allocate(connectivityLength);
vtkm::worklet::DispatcherMapTopology<WriteConnectivity, Device>().Invoke(
cellset, conn.IndexOffsets, conn.Connectivity);
vtkm::worklet::DispatcherMapTopology<WriteConnectivity> dispatcher;
dispatcher.SetDevice(Device());
dispatcher.Invoke(cellset, conn.IndexOffsets, conn.Connectivity);
return conn;
}

@ -57,7 +57,8 @@ struct map_color_table
{
using namespace vtkm::worklet::colorconversion;
TransferFunction transfer(colors->PrepareForExecution(device));
vtkm::worklet::DispatcherMapField<TransferFunction, DeviceAdapter> dispatcher(transfer);
vtkm::worklet::DispatcherMapField<TransferFunction> dispatcher(transfer);
dispatcher.SetDevice(DeviceAdapter());
dispatcher.Invoke(std::forward<Args>(args)...);
return true;
}
@ -71,7 +72,8 @@ struct map_color_table_with_samples
Args&&... args) const
{
using namespace vtkm::worklet::colorconversion;
vtkm::worklet::DispatcherMapField<LookupTable, DeviceAdapter> dispatcher(lookupTable);
vtkm::worklet::DispatcherMapField<LookupTable> dispatcher(lookupTable);
dispatcher.SetDevice(DeviceAdapter());
dispatcher.Invoke(std::forward<Args>(args)...);
return true;
}

@ -20,6 +20,7 @@
#ifndef vtk_m_cont_DataSetBuilderRectilinear_h
#define vtk_m_cont_DataSetBuilderRectilinear_h
#include <vtkm/cont/ArrayCopy.h>
#include <vtkm/cont/ArrayHandleCartesianProduct.h>
#include <vtkm/cont/ArrayPortalToIterators.h>
#include <vtkm/cont/CoordinateSystem.h>
@ -43,8 +44,7 @@ class VTKM_CONT_EXPORT DataSetBuilderRectilinear
VTKM_CONT static void CopyInto(const vtkm::cont::ArrayHandle<T>& input,
vtkm::cont::ArrayHandle<U>& output)
{
using Algorithm = vtkm::cont::DeviceAdapterAlgorithm<vtkm::cont::DeviceAdapterTagSerial>;
Algorithm::Copy(input, output);
vtkm::cont::ArrayCopy(input, output);
}
template <typename T, typename U>

@ -36,7 +36,7 @@ class VTKM_ALWAYS_EXPORT ErrorBadValue : public Error
{
public:
ErrorBadValue(const std::string& message)
: Error(message)
: Error(message, true)
{
}
};

@ -36,7 +36,7 @@ class VTKM_ALWAYS_EXPORT ErrorExecution : public vtkm::cont::Error
{
public:
ErrorExecution(const std::string& message)
: Error(message)
: Error(message, true)
{
}
};

@ -20,10 +20,9 @@
#ifndef vtk_m_cont_PointLocatorUniformGrid_h
#define vtk_m_cont_PointLocatorUniformGrid_h
#include <vtkm/cont/Algorithm.h>
#include <vtkm/cont/ArrayCopy.h>
#include <vtkm/cont/ArrayHandleCounting.h>
#include <vtkm/cont/DeviceAdapter.h>
#include <vtkm/cont/DeviceAdapterAlgorithm.h>
#include <vtkm/cont/TryExecute.h>
#include <vtkm/worklet/DispatcherMapField.h>
#include <vtkm/worklet/WorkletMapField.h>
@ -77,62 +76,29 @@ public:
vtkm::Vec<vtkm::FloatDefault, 3> Dxdydz;
};
/// \brief Construct a 3D uniform grid for nearest neighbor search.
///
/// \param coords An ArrayHandle of x, y, z coordinates of input points.
/// \param device Tag for selecting device adapter
struct BuildFunctor
{
BuildFunctor(vtkm::cont::PointLocatorUniformGrid* self)
: Self(self)
{
}
template <typename Device>
bool operator()(Device)
{
using Algorithm = vtkm::cont::DeviceAdapterAlgorithm<Device>;
// Save training data points.
Algorithm::Copy(this->Self->GetCoords().GetData(), this->Self->coords);
// generate unique id for each input point
vtkm::cont::ArrayHandleCounting<vtkm::Id> pointCounting(
0, 1, this->Self->coords.GetNumberOfValues());
Algorithm::Copy(pointCounting, this->Self->pointIds);
// bin points into cells and give each of them the cell id.
BinPointsWorklet cellIdWorklet(this->Self->Min, this->Self->Max, this->Self->Dims);
vtkm::worklet::DispatcherMapField<BinPointsWorklet, Device> dispatchCellId(cellIdWorklet);
dispatchCellId.Invoke(this->Self->coords, this->Self->cellIds);
// Group points of the same cell together by sorting them according to the cell ids
Algorithm::SortByKey(this->Self->cellIds, this->Self->pointIds);
// for each cell, find the lower and upper bound of indices to the sorted point ids.
vtkm::cont::ArrayHandleCounting<vtkm::Id> cell_ids_counting(
0, 1, this->Self->Dims[0] * this->Self->Dims[1] * this->Self->Dims[2]);
Algorithm::UpperBounds(this->Self->cellIds, cell_ids_counting, this->Self->cellUpper);
Algorithm::LowerBounds(this->Self->cellIds, cell_ids_counting, this->Self->cellLower);
return true;
}
private:
vtkm::cont::PointLocatorUniformGrid* Self;
};
void Build() override
{
BuildFunctor functor(this);
// Save training data points.
vtkm::cont::ArrayCopy(this->GetCoords().GetData(), this->coords);
bool success = vtkm::cont::TryExecute(functor);
if (!success)
{
throw vtkm::cont::ErrorExecution("Could not build point locator structure");
}
};
// generate unique id for each input point
vtkm::cont::ArrayHandleCounting<vtkm::Id> pointCounting(0, 1, this->coords.GetNumberOfValues());
vtkm::cont::ArrayCopy(pointCounting, this->pointIds);
// bin points into cells and give each of them the cell id.
BinPointsWorklet cellIdWorklet(this->Min, this->Max, this->Dims);
vtkm::worklet::DispatcherMapField<BinPointsWorklet> dispatchCellId(cellIdWorklet);
dispatchCellId.Invoke(this->coords, this->cellIds);
// Group points of the same cell together by sorting them according to the cell ids
vtkm::cont::Algorithm::SortByKey(this->cellIds, this->pointIds);
// for each cell, find the lower and upper bound of indices to the sorted point ids.
vtkm::cont::ArrayHandleCounting<vtkm::Id> cell_ids_counting(
0, 1, this->Dims[0] * this->Dims[1] * this->Dims[2]);
vtkm::cont::Algorithm::UpperBounds(this->cellIds, cell_ids_counting, this->cellUpper);
vtkm::cont::Algorithm::LowerBounds(this->cellIds, cell_ids_counting, this->cellLower);
}
using HandleType = vtkm::cont::VirtualObjectHandle<vtkm::exec::PointLocator>;

@ -58,11 +58,11 @@ void HandleTryExecuteException(vtkm::cont::DeviceAdapterId deviceId,
//deferring to another device adapter?
std::cerr << "caught ErrorBadType : " << e.GetMessage() << std::endl;
}
catch (vtkm::cont::ErrorBadValue& e)
catch (vtkm::cont::ErrorBadValue&)
{
//should bad value errors should stop the filter, instead of deferring
//to another device adapter?
std::cerr << "caught ErrorBadValue : " << e.GetMessage() << std::endl;
// Should bad values be deferred to another device? Seems unlikely they will succeed.
// Re-throw instead.
throw;
}
catch (vtkm::cont::Error& e)
{

@ -65,6 +65,10 @@ public:
T* lockedValue = ::thrust::raw_pointer_cast(this->Portal.GetIteratorBegin() + index);
return this->vtkmAtomicAdd(lockedValue, value);
#else
// Shut up, compiler
(void)index;
(void)value;
throw vtkm::cont::ErrorExecution("AtomicArray used in control environment, "
"or incorrect array implementation used "
"for device.");
@ -85,6 +89,11 @@ public:
T* lockedValue = ::thrust::raw_pointer_cast(this->Portal.GetIteratorBegin() + index);
return this->vtkmCompareAndSwap(lockedValue, newValue, oldValue);
#else
// Shut up, compiler.
(void)index;
(void)newValue;
(void)oldValue;
throw vtkm::cont::ErrorExecution("AtomicArray used in control environment, "
"or incorrect array implementation used "
"for device.");

@ -92,7 +92,7 @@ struct TriggerICE : public vtkm::worklet::WorkletMapField
template <class ValueType>
ValueType operator()(const ValueType& bad, const ValueType& sane, const vtkm::Id sequenceId) const
{
return bad + sane * sequenceId;
return bad + sane * static_cast<ValueType>(sequenceId);
}
#endif
};
@ -156,7 +156,8 @@ void RunEdgeCases()
auto bad = vtkm::cont::make_ArrayHandle(badvalues);
auto sane = vtkm::cont::make_ArrayHandle(sanevalues);
decltype(sane) result;
vtkm::worklet::DispatcherMapField<TriggerICE, Device> dispatcher;
vtkm::worklet::DispatcherMapField<TriggerICE> dispatcher;
dispatcher.SetDevice(Device());
dispatcher.Invoke(bad, sane, result);
auto portal = result.GetPortalConstControl();

@ -63,12 +63,11 @@ struct DoubleWorklet : public vtkm::worklet::WorkletMapField
}
};
template <typename T, typename S, typename DeviceAdapter>
template <typename T, typename S>
inline void TestVirtualAccess(const vtkm::cont::ArrayHandle<T, S>& in,
vtkm::cont::ArrayHandle<T>& out,
DeviceAdapter)
vtkm::cont::ArrayHandle<T>& out)
{
vtkm::worklet::DispatcherMapField<CopyWorklet, DeviceAdapter>().Invoke(
vtkm::worklet::DispatcherMapField<CopyWorklet>().Invoke(
vtkm::cont::ArrayHandleVirtualCoordinates(in), vtkm::cont::ArrayHandleVirtualCoordinates(out));
VTKM_TEST_ASSERT(test_equal_portals(in.GetPortalConstControl(), out.GetPortalConstControl()),
@ -103,11 +102,11 @@ private:
{
a1.GetPortalControl().Set(i, TestValue(i, PointType()));
}
TestVirtualAccess(a1, out, DeviceAdapter{});
TestVirtualAccess(a1, out);
std::cout << "Testing ArrayHandleUniformPointCoordinates as input\n";
auto t = vtkm::cont::ArrayHandleUniformPointCoordinates(vtkm::Id3(4, 4, 4));
TestVirtualAccess(t, out, DeviceAdapter{});
TestVirtualAccess(t, out);
std::cout << "Testing ArrayHandleCartesianProduct as input\n";
vtkm::cont::ArrayHandle<vtkm::FloatDefault> c1, c2, c3;
@ -121,13 +120,12 @@ private:
c2.GetPortalControl().Set(i, p[1]);
c3.GetPortalControl().Set(i, p[2]);
}
TestVirtualAccess(
vtkm::cont::make_ArrayHandleCartesianProduct(c1, c2, c3), out, DeviceAdapter{});
TestVirtualAccess(vtkm::cont::make_ArrayHandleCartesianProduct(c1, c2, c3), out);
std::cout << "Testing resources releasing on ArrayHandleVirtualCoordinates\n";
vtkm::cont::ArrayHandleVirtualCoordinates virtualC =
vtkm::cont::ArrayHandleVirtualCoordinates(a1);
vtkm::worklet::DispatcherMapField<DoubleWorklet, DeviceAdapter>().Invoke(a1);
vtkm::worklet::DispatcherMapField<DoubleWorklet>().Invoke(a1);
virtualC.ReleaseResourcesExecution();
VTKM_TEST_ASSERT(a1.GetNumberOfValues() == length,
"ReleaseResourcesExecution"
@ -143,7 +141,11 @@ private:
}
public:
static int Run() { return vtkm::cont::testing::Testing::Run(TestAll); }
static int Run()
{
vtkm::cont::GetGlobalRuntimeDeviceTracker().ForceDevice(DeviceAdapter());
return vtkm::cont::testing::Testing::Run(TestAll);
}
};
}
}

@ -22,6 +22,7 @@
#include <vtkm/TypeTraits.h>
#include <vtkm/cont/ArrayHandle.h>
#include <vtkm/cont/RuntimeDeviceTracker.h>
#include <vtkm/worklet/DispatcherMapField.h>
#include <vtkm/worklet/WorkletMapField.h>
@ -135,7 +136,7 @@ private:
using Algorithm = vtkm::cont::DeviceAdapterAlgorithm<DeviceAdapterTag>;
using DispatcherPassThrough = vtkm::worklet::DispatcherMapField<PassThrough, DeviceAdapterTag>;
using DispatcherPassThrough = vtkm::worklet::DispatcherMapField<PassThrough>;
struct VerifyEmptyArrays
{
template <typename T>
@ -455,7 +456,11 @@ private:
};
public:
static VTKM_CONT int Run() { return vtkm::cont::testing::Testing::Run(TryArrayHandleType()); }
static VTKM_CONT int Run()
{
vtkm::cont::GetGlobalRuntimeDeviceTracker().ForceDevice(DeviceAdapterTag());
return vtkm::cont::testing::Testing::Run(TryArrayHandleType());
}
};
}
}

@ -118,7 +118,7 @@ vtkm::cont::DataSet MakeTestDataSet(const vtkm::Vec<vtkm::Id, DIMENSIONS>& dims,
cellset = vtkm::worklet::Triangulate().Run(uniformCs, device);
break;
case 3:
cellset = vtkm::worklet::Tetrahedralize().Run(uniformCs, device);
cellset = vtkm::worklet::Tetrahedralize().Run(uniformCs);
break;
default:
VTKM_ASSERT(false);
@ -181,8 +181,9 @@ void GenerateRandomInput(const vtkm::cont::DataSet& ds,
pcoords.GetPortalControl().Set(i, pc);
}
vtkm::worklet::DispatcherMapTopology<ParametricToWorldCoordinates, DeviceAdapter> dispatcher(
vtkm::worklet::DispatcherMapTopology<ParametricToWorldCoordinates> dispatcher(
ParametricToWorldCoordinates::MakeScatter(cellIds));
dispatcher.SetDevice(DeviceAdapter());
dispatcher.Invoke(ds.GetCellSet(), ds.GetCoordinateSystem().GetData(), pcoords, wcoords);
}

@ -461,7 +461,8 @@ public:
vtkm::cont::ArrayHandle<vtkm::Vec<vtkm::UInt8, 4>> colors;
TransferFunction transfer(table.PrepareForExecution(DeviceAdapterTag{}));
vtkm::worklet::DispatcherMapField<TransferFunction, DeviceAdapterTag> dispatcher(transfer);
vtkm::worklet::DispatcherMapField<TransferFunction> dispatcher(transfer);
dispatcher.SetDevice(DeviceAdapterTag());
dispatcher.Invoke(samples, colors);
const vtkm::Vec<vtkm::UInt8, 4> correct_sampling_points[nvals] = { { 14, 28, 31, 255 },

@ -139,7 +139,8 @@ private:
//run a basic for-each topology algorithm on this
vtkm::cont::ArrayHandle<vtkm::Float32> result;
vtkm::worklet::DispatcherMapTopology<vtkm::worklet::CellAverage, DeviceAdapterTag> dispatcher;
vtkm::worklet::DispatcherMapTopology<vtkm::worklet::CellAverage> dispatcher;
dispatcher.SetDevice(DeviceAdapterTag());
dispatcher.Invoke(cellset, dataSet.GetField("pointvar"), result);
vtkm::Float32 expected[3] = { 20.1333f, 30.1667f, 40.2333f };

@ -168,7 +168,7 @@ private:
vtkm::cont::ArrayHandle<vtkm::Vec<ValueType, 3>> result;
vtkm::worklet::DispatcherMapField<PassThrough, DeviceAdapterTag> dispatcher;
vtkm::worklet::DispatcherMapField<PassThrough> dispatcher;
dispatcher.Invoke(composite, result);
//verify that the control portal works
@ -196,7 +196,7 @@ private:
vtkm::cont::make_ArrayHandleConstant(value, ARRAY_SIZE);
vtkm::cont::ArrayHandle<ValueType> result;
vtkm::worklet::DispatcherMapField<PassThrough, DeviceAdapterTag> dispatcher;
vtkm::worklet::DispatcherMapField<PassThrough> dispatcher;
dispatcher.Invoke(constant, result);
vtkm::cont::printSummary_ArrayHandle(constant, std::cout);
@ -231,7 +231,7 @@ private:
vtkm::cont::make_ArrayHandleCounting(start, ValueType(1), length);
vtkm::cont::ArrayHandle<ValueType> result;
vtkm::worklet::DispatcherMapField<PassThrough, DeviceAdapterTag> dispatcher;
vtkm::worklet::DispatcherMapField<PassThrough> dispatcher;
dispatcher.Invoke(counting, result);
vtkm::cont::printSummary_ArrayHandle(counting, std::cout);
@ -267,7 +267,7 @@ private:
vtkm::cont::ArrayHandle<ValueType> result;
vtkm::worklet::DispatcherMapField<PassThrough, DeviceAdapterTag> dispatcher;
vtkm::worklet::DispatcherMapField<PassThrough> dispatcher;
dispatcher.Invoke(implicit, result);
//verify that the control portal works
@ -320,7 +320,7 @@ private:
vtkm::cont::ArrayHandle<ValueType> result;
vtkm::worklet::DispatcherMapField<PassThrough, DeviceAdapterTag> dispatcher;
vtkm::worklet::DispatcherMapField<PassThrough> dispatcher;
dispatcher.Invoke(concatenate, result);
//verify that the control portal works
@ -374,7 +374,7 @@ private:
vtkm::cont::ArrayHandle<ValueType> result;
vtkm::worklet::DispatcherMapField<PassThrough, DeviceAdapterTag> dispatcher;
vtkm::worklet::DispatcherMapField<PassThrough> dispatcher;
dispatcher.Invoke(permutation, result);
//verify that the control portal works
@ -420,7 +420,7 @@ private:
vtkm::cont::ArrayHandle<ValueType> result;
vtkm::worklet::DispatcherMapField<PassThrough, DeviceAdapterTag> dispatcher;
vtkm::worklet::DispatcherMapField<PassThrough> dispatcher;
dispatcher.Invoke(view, result);
//verify that the control portal works
@ -461,7 +461,7 @@ private:
vtkm::cont::ArrayHandle<ValueType> result;
vtkm::worklet::DispatcherMapField<PassThrough, DeviceAdapterTag> dispatcher;
vtkm::worklet::DispatcherMapField<PassThrough> dispatcher;
dispatcher.Invoke(transformed, result);
//verify that the control portal works
@ -503,7 +503,7 @@ private:
vtkm::cont::ArrayHandle<OutputValueType> result;
vtkm::worklet::DispatcherMapField<PassThrough, DeviceAdapterTag> dispatcher;
vtkm::worklet::DispatcherMapField<PassThrough> dispatcher;
dispatcher.Invoke(countingTransformed, result);
//verify that the control portal works
@ -532,7 +532,7 @@ private:
vtkm::cont::make_ArrayHandleCast(input, CastToType());
vtkm::cont::ArrayHandle<CastToType> result;
vtkm::worklet::DispatcherMapField<PassThrough, DeviceAdapterTag> dispatcher;
vtkm::worklet::DispatcherMapField<PassThrough> dispatcher;
dispatcher.Invoke(castArray, result);
vtkm::cont::printSummary_ArrayHandle(castArray, std::cout);
@ -576,7 +576,7 @@ private:
vtkm::cont::ArrayHandle<ValueType> resultArray;
vtkm::worklet::DispatcherMapField<PassThrough, DeviceAdapterTag> dispatcher;
vtkm::worklet::DispatcherMapField<PassThrough> dispatcher;
dispatcher.Invoke(groupArray, resultArray);
VTKM_TEST_ASSERT(resultArray.GetNumberOfValues() == ARRAY_SIZE, "Got bad result array size.");
@ -615,7 +615,7 @@ private:
vtkm::cont::ArrayHandleGroupVec<vtkm::cont::ArrayHandle<ComponentType>, NUM_COMPONENTS>
groupArray(resultArray);
vtkm::worklet::DispatcherMapField<PassThrough, DeviceAdapterTag> dispatcher;
vtkm::worklet::DispatcherMapField<PassThrough> dispatcher;
dispatcher.Invoke(baseArray, groupArray);
vtkm::cont::printSummary_ArrayHandle(groupArray, std::cout);
@ -696,7 +696,7 @@ private:
vtkm::cont::make_ArrayHandleGroupVecVariable(sourceArray, offsetsArray), std::cout);
std::cout << std::endl;
vtkm::worklet::DispatcherMapField<GroupVariableInputWorklet, DeviceAdapterTag> dispatcher;
vtkm::worklet::DispatcherMapField<GroupVariableInputWorklet> dispatcher;
dispatcher.Invoke(vtkm::cont::make_ArrayHandleGroupVecVariable(sourceArray, offsetsArray));
}
};
@ -742,7 +742,7 @@ private:
vtkm::cont::ArrayHandle<ComponentType> sourceArray;
sourceArray.Allocate(sourceArraySize);
vtkm::worklet::DispatcherMapField<GroupVariableOutputWorklet, DeviceAdapterTag> dispatcher;
vtkm::worklet::DispatcherMapField<GroupVariableOutputWorklet> dispatcher;
dispatcher.Invoke(vtkm::cont::ArrayHandleIndex(ARRAY_SIZE),
vtkm::cont::make_ArrayHandleGroupVecVariable(sourceArray, offsetsArray));
@ -786,7 +786,7 @@ private:
vtkm::cont::ArrayHandle<PairType> result;
vtkm::worklet::DispatcherMapField<PassThrough, DeviceAdapterTag> dispatcher;
vtkm::worklet::DispatcherMapField<PassThrough> dispatcher;
dispatcher.Invoke(zip, result);
//verify that the control portal works
@ -823,7 +823,7 @@ private:
DiscardHandleType discard;
discard.Allocate(length);
vtkm::worklet::DispatcherMapField<PassThrough, DeviceAdapterTag> dispatcher;
vtkm::worklet::DispatcherMapField<PassThrough> dispatcher;
dispatcher.Invoke(input, discard);
// No output to verify since none is stored in memory. Just checking that
@ -859,7 +859,7 @@ private:
KeyHandleType counting = vtkm::cont::make_ArrayHandleCounting<vtkm::Id>(length, 1, length);
PermutationHandleType permutation = vtkm::cont::make_ArrayHandlePermutation(counting, values);
vtkm::worklet::DispatcherMapField<PassThrough, DeviceAdapterTag> dispatcher;
vtkm::worklet::DispatcherMapField<PassThrough> dispatcher;
dispatcher.Invoke(input, permutation);
vtkm::cont::printSummary_ArrayHandle(permutation, std::cout);
@ -900,7 +900,7 @@ private:
values.Allocate(length * 2);
ViewHandleType view = vtkm::cont::make_ArrayHandleView(values, length, length);
vtkm::worklet::DispatcherMapField<PassThrough, DeviceAdapterTag> dispatcher;
vtkm::worklet::DispatcherMapField<PassThrough> dispatcher;
dispatcher.Invoke(input, view);
vtkm::cont::printSummary_ArrayHandle(view, std::cout);
@ -941,7 +941,7 @@ private:
vtkm::cont::ArrayHandle<ValueType>>
result_zip = vtkm::cont::make_ArrayHandleZip(result_keys, result_values);
vtkm::worklet::DispatcherMapField<PassThrough, DeviceAdapterTag> dispatcher;
vtkm::worklet::DispatcherMapField<PassThrough> dispatcher;
dispatcher.Invoke(input, result_zip);
vtkm::cont::printSummary_ArrayHandle(result_zip, std::cout);
@ -974,7 +974,7 @@ private:
vtkm::cont::ArrayHandle<ValueType> outputValues;
outputValues.Allocate(ARRAY_SIZE);
vtkm::worklet::DispatcherMapField<InplaceFunctorPair, DeviceAdapterTag> dispatcher;
vtkm::worklet::DispatcherMapField<InplaceFunctorPair> dispatcher;
dispatcher.Invoke(vtkm::cont::make_ArrayHandleZip(inputValues, outputValues));
vtkm::cont::printSummary_ArrayHandle(outputValues, std::cout);
@ -1132,7 +1132,11 @@ public:
/// all the fancy array handles that vtkm supports. Returns an
/// error code that can be returned from the main function of a test.
///
static VTKM_CONT int Run() { return vtkm::cont::testing::Testing::Run(TestAll()); }
static VTKM_CONT int Run()
{
vtkm::cont::GetGlobalRuntimeDeviceTracker().ForceDevice(DeviceAdapterTag());
return vtkm::cont::testing::Testing::Run(TestAll());
}
};
}
}

@ -71,10 +71,12 @@ void EvaluateOnCoordinates(vtkm::cont::CoordinateSystem points,
vtkm::cont::ArrayHandle<vtkm::FloatDefault>& values,
DeviceAdapter device)
{
using EvalDispatcher = vtkm::worklet::DispatcherMapField<EvaluateImplicitFunction, DeviceAdapter>;
using EvalDispatcher = vtkm::worklet::DispatcherMapField<EvaluateImplicitFunction>;
EvaluateImplicitFunction eval(function.PrepareForExecution(device));
EvalDispatcher(eval).Invoke(points, values);
EvalDispatcher dispatcher(eval);
dispatcher.SetDevice(DeviceAdapter());
dispatcher.Invoke(points, values);
}
template <std::size_t N>

@ -144,16 +144,18 @@ public:
vtkm::cont::ArrayHandle<vtkm::FloatDefault> nnDis_Handle;
PointLocatorUniformGridWorklet pointLocatorUniformGridWorklet;
vtkm::worklet::DispatcherMapField<PointLocatorUniformGridWorklet, DeviceAdapter>
locatorDispatcher(pointLocatorUniformGridWorklet);
vtkm::worklet::DispatcherMapField<PointLocatorUniformGridWorklet> locatorDispatcher(
pointLocatorUniformGridWorklet);
locatorDispatcher.SetDevice(DeviceAdapter());
locatorDispatcher.Invoke(qc_Handle, locator, nnId_Handle, nnDis_Handle);
// brute force
vtkm::cont::ArrayHandle<vtkm::Id> bfnnId_Handle;
vtkm::cont::ArrayHandle<vtkm::Float32> bfnnDis_Handle;
NearestNeighborSearchBruteForce3DWorklet nnsbf3dWorklet;
vtkm::worklet::DispatcherMapField<NearestNeighborSearchBruteForce3DWorklet, DeviceAdapter>
nnsbf3DDispatcher(nnsbf3dWorklet);
vtkm::worklet::DispatcherMapField<NearestNeighborSearchBruteForce3DWorklet> nnsbf3DDispatcher(
nnsbf3dWorklet);
nnsbf3DDispatcher.SetDevice(DeviceAdapter());
nnsbf3DDispatcher.Invoke(
qc_Handle, vtkm::cont::make_ArrayHandle(coordi), bfnnId_Handle, bfnnDis_Handle);

@ -55,8 +55,8 @@ inline VTKM_CONT vtkm::cont::DataSet CellAverage::DoExecute(
//If the input is implicit, we should know what to fall back to
vtkm::cont::ArrayHandle<T> outArray;
vtkm::worklet::DispatcherMapTopology<vtkm::worklet::CellAverage, DeviceAdapter> dispatcher(
this->Worklet);
vtkm::worklet::DispatcherMapTopology<vtkm::worklet::CellAverage> dispatcher(this->Worklet);
dispatcher.SetDevice(DeviceAdapter());
dispatcher.Invoke(vtkm::filter::ApplyPolicy(cellSet, policy), inField, outArray);

@ -50,8 +50,8 @@ inline VTKM_CONT vtkm::cont::DataSet CellMeasures<IntegrationType>::DoExecute(
const auto& cellset = input.GetCellSet(this->GetActiveCellSetIndex());
vtkm::cont::ArrayHandle<T> outArray;
vtkm::worklet::DispatcherMapTopology<vtkm::worklet::CellMeasure<IntegrationType>, DeviceAdapter>
dispatcher;
vtkm::worklet::DispatcherMapTopology<vtkm::worklet::CellMeasure<IntegrationType>> dispatcher;
dispatcher.SetDevice(DeviceAdapter());
dispatcher.Invoke(vtkm::filter::ApplyPolicy(cellset, policy), points, outArray);
vtkm::cont::DataSet result;

@ -38,7 +38,8 @@ struct CrossProductFunctor
template <typename PrimaryFieldType, typename SecondaryFieldType>
void operator()(const SecondaryFieldType& secondaryField, const PrimaryFieldType& primaryField)
{
vtkm::worklet::DispatcherMapField<vtkm::worklet::CrossProduct, DeviceAdapter> dispatcher;
vtkm::worklet::DispatcherMapField<vtkm::worklet::CrossProduct> dispatcher;
dispatcher.SetDevice(DeviceAdapter());
dispatcher.Invoke(primaryField,
vtkm::cont::make_ArrayHandleCast<vtkm::Vec<T, 3>>(secondaryField),
this->OutArray);

@ -39,7 +39,8 @@ struct DotProductFunctor
template <typename PrimaryFieldType, typename SecondaryFieldType>
void operator()(const SecondaryFieldType& secondaryField, const PrimaryFieldType& primaryField)
{
vtkm::worklet::DispatcherMapField<vtkm::worklet::DotProduct, DeviceAdapter> dispatcher;
vtkm::worklet::DispatcherMapField<vtkm::worklet::DotProduct> dispatcher;
dispatcher.SetDevice(DeviceAdapter());
dispatcher.Invoke(primaryField,
vtkm::cont::make_ArrayHandleCast<vtkm::Vec<T, 3>>(secondaryField),
this->OutArray);

@ -84,8 +84,8 @@ inline VTKM_CONT vtkm::cont::DataSet OscillatorSource::DoExecute(
const DeviceAdapter&)
{
vtkm::cont::ArrayHandle<vtkm::Float64> outArray;
vtkm::worklet::DispatcherMapField<vtkm::worklet::OscillatorSource, DeviceAdapter> dispatcher(
this->Worklet);
vtkm::worklet::DispatcherMapField<vtkm::worklet::OscillatorSource> dispatcher(this->Worklet);
dispatcher.SetDevice(DeviceAdapter());
//todo, we need to use the policy to determine the valid conversions
//that the dispatcher should do

@ -55,8 +55,8 @@ inline VTKM_CONT vtkm::cont::DataSet PointAverage::DoExecute(
//If the input is implicit, we should know what to fall back to
vtkm::cont::ArrayHandle<T> outArray;
vtkm::worklet::DispatcherMapTopology<vtkm::worklet::PointAverage, DeviceAdapter> dispatcher(
this->Worklet);
vtkm::worklet::DispatcherMapTopology<vtkm::worklet::PointAverage> dispatcher(this->Worklet);
dispatcher.SetDevice(DeviceAdapter());
dispatcher.Invoke(vtkm::filter::ApplyPolicy(cellSet, policy), inField, outArray);

@ -63,8 +63,8 @@ inline VTKM_CONT vtkm::cont::DataSet PointElevation::DoExecute(
const DeviceAdapter&)
{
vtkm::cont::ArrayHandle<vtkm::Float64> outArray;
vtkm::worklet::DispatcherMapField<vtkm::worklet::PointElevation, DeviceAdapter> dispatcher(
this->Worklet);
vtkm::worklet::DispatcherMapField<vtkm::worklet::PointElevation> dispatcher(this->Worklet);
dispatcher.SetDevice(DeviceAdapter());
//todo, we need to use the policy to determine the valid conversions
//that the dispatcher should do

@ -127,8 +127,8 @@ inline VTKM_CONT vtkm::cont::DataSet PointTransform<S>::DoExecute(
const DeviceAdapter&)
{
vtkm::cont::ArrayHandle<T> outArray;
vtkm::worklet::DispatcherMapField<vtkm::worklet::PointTransform<S>, DeviceAdapter> dispatcher(
this->Worklet);
vtkm::worklet::DispatcherMapField<vtkm::worklet::PointTransform<S>> dispatcher(this->Worklet);
dispatcher.SetDevice(DeviceAdapter());
dispatcher.Invoke(field, outArray);

@ -39,7 +39,7 @@ public:
template <typename CellSetType>
void operator()(const CellSetType& cellset) const
{
this->OutCellSet = Worklet.Run(cellset, DeviceAdapter());
this->OutCellSet = Worklet.Run(cellset);
}
};
}

@ -48,8 +48,8 @@ inline VTKM_CONT vtkm::cont::DataSet VectorMagnitude::DoExecute(
using ReturnType = typename ::vtkm::detail::FloatingPointReturnType<T>::Type;
vtkm::cont::ArrayHandle<ReturnType> outArray;
vtkm::worklet::DispatcherMapField<vtkm::worklet::Magnitude, DeviceAdapter> dispatcher(
this->Worklet);
vtkm::worklet::DispatcherMapField<vtkm::worklet::Magnitude> dispatcher(this->Worklet);
dispatcher.SetDevice(DeviceAdapter());
dispatcher.Invoke(field, outArray);

@ -61,33 +61,6 @@ struct ClearBuffers : public vtkm::worklet::WorkletMapField
}
}; // struct ClearBuffers
struct ClearBuffersExecutor
{
using ColorBufferType = vtkm::rendering::Canvas::ColorBufferType;
using DepthBufferType = vtkm::rendering::Canvas::DepthBufferType;
ColorBufferType ColorBuffer;
DepthBufferType DepthBuffer;
VTKM_CONT
ClearBuffersExecutor(const ColorBufferType& colorBuffer, const DepthBufferType& depthBuffer)
: ColorBuffer(colorBuffer)
, DepthBuffer(depthBuffer)
{
}
template <typename Device>
VTKM_CONT bool operator()(Device) const
{
VTKM_IS_DEVICE_ADAPTER_TAG(Device);
ClearBuffers worklet;
vtkm::worklet::DispatcherMapField<ClearBuffers, Device> dispatcher(worklet);
dispatcher.Invoke(this->ColorBuffer, this->DepthBuffer);
return true;
}
}; // struct ClearBuffersExecutor
struct BlendBackground : public vtkm::worklet::WorkletMapField
{
vtkm::Vec<vtkm::Float32, 4> BackgroundColor;
@ -114,32 +87,6 @@ struct BlendBackground : public vtkm::worklet::WorkletMapField
}
}; // struct BlendBackground
struct BlendBackgroundExecutor
{
using ColorBufferType = vtkm::rendering::Canvas::ColorBufferType;
ColorBufferType ColorBuffer;
BlendBackground Worklet;
VTKM_CONT
BlendBackgroundExecutor(const ColorBufferType& colorBuffer,
const vtkm::Vec<vtkm::Float32, 4>& backgroundColor)
: ColorBuffer(colorBuffer)
, Worklet(backgroundColor)
{
}
template <typename Device>
VTKM_CONT bool operator()(Device) const
{
VTKM_IS_DEVICE_ADAPTER_TAG(Device);
vtkm::worklet::DispatcherMapField<BlendBackground, Device> dispatcher(this->Worklet);
dispatcher.Invoke(this->ColorBuffer);
return true;
}
}; // struct BlendBackgroundExecutor
struct DrawColorSwatch : public vtkm::worklet::WorkletMapField
{
using ControlSignature = void(FieldIn<>, WholeArrayInOut<>);
@ -257,81 +204,6 @@ struct DrawColorBar : public vtkm::worklet::WorkletMapField
bool Horizontal;
}; // struct DrawColorBar
struct ColorSwatchExecutor
{
VTKM_CONT
ColorSwatchExecutor(vtkm::Id2 dims,
vtkm::Id2 xBounds,
vtkm::Id2 yBounds,
const vtkm::Vec<vtkm::Float32, 4>& color,
const vtkm::cont::ArrayHandle<vtkm::Vec<vtkm::Float32, 4>>& colorBuffer)
: Dims(dims)
, XBounds(xBounds)
, YBounds(yBounds)
, Color(color)
, ColorBuffer(colorBuffer)
{
}
template <typename Device>
VTKM_CONT bool operator()(Device) const
{
VTKM_IS_DEVICE_ADAPTER_TAG(Device);
vtkm::Id totalPixels = (XBounds[1] - XBounds[0]) * (YBounds[1] - YBounds[0]);
vtkm::cont::ArrayHandleCounting<vtkm::Id> iterator(0, 1, totalPixels);
vtkm::worklet::DispatcherMapField<DrawColorSwatch, Device> dispatcher(
DrawColorSwatch(this->Dims, this->XBounds, this->YBounds, Color));
dispatcher.Invoke(iterator, this->ColorBuffer);
return true;
}
vtkm::Id2 Dims;
vtkm::Id2 XBounds;
vtkm::Id2 YBounds;
const vtkm::Vec<vtkm::Float32, 4>& Color;
const vtkm::cont::ArrayHandle<vtkm::Vec<vtkm::Float32, 4>>& ColorBuffer;
}; // struct ColorSwatchExecutor
struct ColorBarExecutor
{
VTKM_CONT
ColorBarExecutor(vtkm::Id2 dims,
vtkm::Id2 xBounds,
vtkm::Id2 yBounds,
bool horizontal,
vtkm::cont::ArrayHandle<vtkm::Vec<vtkm::UInt8, 4>>& colorMap,
const vtkm::cont::ArrayHandle<vtkm::Vec<vtkm::Float32, 4>>& colorBuffer)
: Dims(dims)
, XBounds(xBounds)
, YBounds(yBounds)
, Horizontal(horizontal)
, ColorMap(colorMap)
, ColorBuffer(colorBuffer)
{
}
template <typename Device>
VTKM_CONT bool operator()(Device) const
{
VTKM_IS_DEVICE_ADAPTER_TAG(Device);
vtkm::Id totalPixels = (XBounds[1] - XBounds[0]) * (YBounds[1] - YBounds[0]);
vtkm::cont::ArrayHandleCounting<vtkm::Id> iterator(0, 1, totalPixels);
vtkm::worklet::DispatcherMapField<DrawColorBar, Device> dispatcher(
DrawColorBar(this->Dims, this->XBounds, this->YBounds, this->Horizontal));
dispatcher.Invoke(iterator, this->ColorBuffer, this->ColorMap);
return true;
}
vtkm::Id2 Dims;
vtkm::Id2 XBounds;
vtkm::Id2 YBounds;
bool Horizontal;
vtkm::cont::ArrayHandle<vtkm::Vec<vtkm::UInt8, 4>>& ColorMap;
const vtkm::cont::ArrayHandle<vtkm::Vec<vtkm::Float32, 4>>& ColorBuffer;
}; // struct ColorSwatchExecutor
} // namespace internal
struct Canvas::CanvasInternals
@ -441,9 +313,8 @@ void Canvas::Activate()
void Canvas::Clear()
{
// TODO: Should the rendering library support policies or some other way to
// configure with custom devices?
vtkm::cont::TryExecute(internal::ClearBuffersExecutor(GetColorBuffer(), GetDepthBuffer()));
vtkm::worklet::DispatcherMapField<internal::ClearBuffers>().Invoke(this->GetColorBuffer(),
this->GetDepthBuffer());
}
void Canvas::Finish()
@ -452,8 +323,9 @@ void Canvas::Finish()
void Canvas::BlendBackground()
{
vtkm::cont::TryExecute(
internal::BlendBackgroundExecutor(GetColorBuffer(), GetBackgroundColor().Components));
vtkm::worklet::DispatcherMapField<internal::BlendBackground>(
this->GetBackgroundColor().Components)
.Invoke(this->GetColorBuffer());
}
void Canvas::ResizeBuffers(vtkm::Id width, vtkm::Id height)
@ -491,8 +363,12 @@ void Canvas::AddColorSwatch(const vtkm::Vec<vtkm::Float64, 2>& point0,
y[1] = static_cast<vtkm::Id>(((point2[1] + 1.) / 2.) * height + .5);
vtkm::Id2 dims(this->GetWidth(), this->GetHeight());
vtkm::cont::TryExecute(
internal::ColorSwatchExecutor(dims, x, y, color.Components, this->GetColorBuffer()));
vtkm::Id totalPixels = (x[1] - x[0]) * (y[1] - y[0]);
vtkm::cont::ArrayHandleCounting<vtkm::Id> iterator(0, 1, totalPixels);
vtkm::worklet::DispatcherMapField<internal::DrawColorSwatch> dispatcher(
internal::DrawColorSwatch(dims, x, y, color.Components));
dispatcher.Invoke(iterator, this->GetColorBuffer());
}
void Canvas::AddColorSwatch(const vtkm::Float64 x0,
@ -552,8 +428,12 @@ void Canvas::AddColorBar(const vtkm::Bounds& bounds,
colorTable.Sample(static_cast<vtkm::Int32>(numSamples), colorMap);
vtkm::Id2 dims(this->GetWidth(), this->GetHeight());
vtkm::cont::TryExecute(
internal::ColorBarExecutor(dims, x, y, horizontal, colorMap, this->GetColorBuffer()));
vtkm::Id totalPixels = (x[1] - x[0]) * (y[1] - y[0]);
vtkm::cont::ArrayHandleCounting<vtkm::Id> iterator(0, 1, totalPixels);
vtkm::worklet::DispatcherMapField<internal::DrawColorBar> dispatcher(
internal::DrawColorBar(dims, x, y, horizontal));
dispatcher.Invoke(iterator, this->GetColorBuffer(), colorMap);
}
void Canvas::AddColorBar(vtkm::Float32 x,

@ -110,57 +110,24 @@ public:
}
}; //class SurfaceConverter
template <typename Precision>
struct WriteFunctor
{
protected:
vtkm::rendering::CanvasRayTracer* Canvas;
const vtkm::rendering::raytracing::Ray<Precision>& Rays;
const vtkm::cont::ArrayHandle<Precision>& Colors;
const vtkm::rendering::Camera& CameraView;
vtkm::Matrix<vtkm::Float32, 4, 4> ViewProjMat;
public:
VTKM_CONT
WriteFunctor(vtkm::rendering::CanvasRayTracer* canvas,
const vtkm::rendering::raytracing::Ray<Precision>& rays,
const vtkm::cont::ArrayHandle<Precision>& colors,
const vtkm::rendering::Camera& camera)
: Canvas(canvas)
, Rays(rays)
, Colors(colors)
, CameraView(camera)
{
ViewProjMat = vtkm::MatrixMultiply(
CameraView.CreateProjectionMatrix(Canvas->GetWidth(), Canvas->GetHeight()),
CameraView.CreateViewMatrix());
}
template <typename Device>
VTKM_CONT bool operator()(Device)
{
VTKM_IS_DEVICE_ADAPTER_TAG(Device);
vtkm::worklet::DispatcherMapField<SurfaceConverter, Device>(SurfaceConverter(ViewProjMat))
.Invoke(Rays.PixelIdx,
Colors,
Rays.Distance,
Rays.Origin,
Rays.Dir,
Canvas->GetDepthBuffer(),
Canvas->GetColorBuffer());
return true;
}
};
template <typename Precision>
VTKM_CONT void WriteToCanvas(const vtkm::rendering::raytracing::Ray<Precision>& rays,
const vtkm::cont::ArrayHandle<Precision>& colors,
const vtkm::rendering::Camera& camera,
vtkm::rendering::CanvasRayTracer* canvas)
{
WriteFunctor<Precision> functor(canvas, rays, colors, camera);
vtkm::Matrix<vtkm::Float32, 4, 4> viewProjMat =
vtkm::MatrixMultiply(camera.CreateProjectionMatrix(canvas->GetWidth(), canvas->GetHeight()),
camera.CreateViewMatrix());
vtkm::cont::TryExecute(functor);
vtkm::worklet::DispatcherMapField<SurfaceConverter>(SurfaceConverter(viewProjMat))
.Invoke(rays.PixelIdx,
colors,
rays.Distance,
rays.Origin,
rays.Dir,
canvas->GetDepthBuffer(),
canvas->GetColorBuffer());
//Force the transfer so the vectors contain data from device
canvas->GetColorBuffer().GetPortalControl().Get(0);

@ -59,21 +59,6 @@ public:
}
}; // conn
struct ConnFunctor
{
template <typename Device>
VTKM_CONT bool operator()(Device,
vtkm::cont::ArrayHandleCounting<vtkm::Id>& iter,
vtkm::cont::ArrayHandle<vtkm::Id>& conn)
{
VTKM_IS_DEVICE_ADAPTER_TAG(Device);
vtkm::worklet::DispatcherMapField<CreateConnectivity, Device>(CreateConnectivity())
.Invoke(iter, conn);
return true;
}
};
class Convert1DCoordinates : public vtkm::worklet::WorkletMapField
{
private:
@ -123,26 +108,6 @@ public:
}
}; // convert coords
struct ConvertFunctor
{
template <typename Device, typename CoordType, typename ScalarType>
VTKM_CONT bool operator()(Device,
CoordType coords,
ScalarType scalars,
vtkm::cont::ArrayHandle<vtkm::Vec<vtkm::Float32, 3>>& outCoords,
vtkm::cont::ArrayHandle<vtkm::Float32>& outScalars,
bool logY,
bool logX)
{
VTKM_IS_DEVICE_ADAPTER_TAG(Device);
vtkm::worklet::DispatcherMapField<Convert1DCoordinates, Device>(
Convert1DCoordinates(logY, logX))
.Invoke(coords, scalars, outCoords, outScalars);
return true;
}
};
#if defined(VTKM_MSVC)
#pragma warning(push)
#pragma warning(disable : 4127) //conditional expression is constant
@ -176,10 +141,10 @@ struct EdgesExtracter : public vtkm::worklet::WorkletMapPointToCell
using ScatterType = vtkm::worklet::ScatterCounting;
VTKM_CONT
template <typename CountArrayType, typename DeviceTag>
static ScatterType MakeScatter(const CountArrayType& counts, DeviceTag device)
template <typename CountArrayType>
static ScatterType MakeScatter(const CountArrayType& counts)
{
return ScatterType(counts, device);
return ScatterType(counts);
}
template <typename CellShapeTag, typename PointIndexVecType, typename EdgeIndexVecType>
@ -212,33 +177,6 @@ struct EdgesExtracter : public vtkm::worklet::WorkletMapPointToCell
#if defined(VTKM_MSVC)
#pragma warning(pop)
#endif
struct ExtractUniqueEdges
{
vtkm::cont::DynamicCellSet CellSet;
vtkm::cont::ArrayHandle<vtkm::Vec<vtkm::Id, 2>> EdgeIndices;
VTKM_CONT
ExtractUniqueEdges(const vtkm::cont::DynamicCellSet& cellSet)
: CellSet(cellSet)
{
}
template <typename DeviceTag>
VTKM_CONT bool operator()(DeviceTag)
{
VTKM_IS_DEVICE_ADAPTER_TAG(DeviceTag);
vtkm::cont::ArrayHandle<vtkm::IdComponent> counts;
vtkm::worklet::DispatcherMapTopology<EdgesCounter, DeviceTag>().Invoke(CellSet, counts);
vtkm::worklet::DispatcherMapTopology<EdgesExtracter, DeviceTag> extractDispatcher(
EdgesExtracter::MakeScatter(counts, DeviceTag()));
extractDispatcher.Invoke(CellSet, EdgeIndices);
vtkm::cont::DeviceAdapterAlgorithm<DeviceTag>::template Sort<vtkm::Id2>(EdgeIndices);
vtkm::cont::DeviceAdapterAlgorithm<DeviceTag>::template Unique<vtkm::Id2>(EdgeIndices);
return true;
}
}; // struct ExtractUniqueEdges
} // namespace
struct MapperWireframer::InternalsType
@ -340,13 +278,9 @@ void MapperWireframer::RenderCells(const vtkm::cont::DynamicCellSet& inCellSet,
//
// Convert the cell set into something we can draw
//
vtkm::cont::TryExecute(ConvertFunctor(),
coords.GetData(),
inScalarField.GetData(),
newCoords,
newScalars,
this->LogarithmY,
this->LogarithmX);
vtkm::worklet::DispatcherMapField<Convert1DCoordinates>(
Convert1DCoordinates(this->LogarithmY, this->LogarithmX))
.Invoke(coords.GetData(), inScalarField.GetData(), newCoords, newScalars);
actualCoords = vtkm::cont::CoordinateSystem("coords", newCoords);
actualField = vtkm::cont::Field(
@ -357,7 +291,7 @@ void MapperWireframer::RenderCells(const vtkm::cont::DynamicCellSet& inCellSet,
vtkm::cont::ArrayHandleCounting<vtkm::Id> iter =
vtkm::cont::make_ArrayHandleCounting(vtkm::Id(0), vtkm::Id(1), numCells);
conn.Allocate(numCells * 2);
vtkm::cont::TryExecute(ConnFunctor(), iter, conn);
vtkm::worklet::DispatcherMapField<CreateConnectivity>(CreateConnectivity()).Invoke(iter, conn);
vtkm::cont::CellSetSingleType<> newCellSet("cells");
newCellSet.Fill(newCoords.GetNumberOfValues(), vtkm::CELL_SHAPE_LINE, 2, conn);
@ -391,9 +325,14 @@ void MapperWireframer::RenderCells(const vtkm::cont::DynamicCellSet& inCellSet,
}
// Extract unique edges from the cell set.
ExtractUniqueEdges extracter(cellSet);
vtkm::cont::TryExecute(extracter);
vtkm::cont::ArrayHandle<vtkm::Vec<vtkm::Id, 2>> edgeIndices = extracter.EdgeIndices;
vtkm::cont::ArrayHandle<vtkm::IdComponent> counts;
vtkm::cont::ArrayHandle<vtkm::Vec<vtkm::Id, 2>> edgeIndices;
vtkm::worklet::DispatcherMapTopology<EdgesCounter>().Invoke(cellSet, counts);
vtkm::worklet::DispatcherMapTopology<EdgesExtracter> extractDispatcher(
EdgesExtracter::MakeScatter(counts));
extractDispatcher.Invoke(cellSet, edgeIndices);
vtkm::cont::Algorithm::template Sort<vtkm::Id2>(edgeIndices);
vtkm::cont::Algorithm::template Unique<vtkm::Id2>(edgeIndices);
Wireframer renderer(
this->Internals->Canvas, this->Internals->ShowInternalZones, this->Internals->IsOverlay);

@ -165,7 +165,8 @@ struct RenderBitmapFontExecutor
{
VTKM_IS_DEVICE_ADAPTER_TAG(Device);
vtkm::worklet::DispatcherMapField<RenderBitmapFont, Device> dispatcher(Worklet);
vtkm::worklet::DispatcherMapField<RenderBitmapFont> dispatcher(Worklet);
dispatcher.SetDevice(Device());
dispatcher.Invoke(
ScreenCoords, TextureCoords, FontTexture.GetExecObjectFactory(), ColorBuffer, DepthBuffer);
return true;

@ -554,12 +554,14 @@ private:
ColorMap,
FrameBuffer,
Camera.GetClippingRange());
vtkm::worklet::DispatcherMapField<EdgePlotter<DeviceTag>, DeviceTag>(plotter).Invoke(
PointIndices, Coordinates, ScalarField.GetData());
vtkm::worklet::DispatcherMapField<EdgePlotter<DeviceTag>> plotterDispatcher(plotter);
plotterDispatcher.SetDevice(DeviceTag());
plotterDispatcher.Invoke(PointIndices, Coordinates, ScalarField.GetData());
BufferConverter converter;
vtkm::worklet::DispatcherMapField<BufferConverter, DeviceTag>(converter).Invoke(
FrameBuffer, Canvas->GetDepthBuffer(), Canvas->GetColorBuffer());
vtkm::worklet::DispatcherMapField<BufferConverter> converterDispatcher(converter);
converterDispatcher.SetDevice(DeviceTag());
converterDispatcher.Invoke(FrameBuffer, Canvas->GetDepthBuffer(), Canvas->GetColorBuffer());
}
VTKM_CONT

@ -608,7 +608,8 @@ VTKM_CONT void LinearBVHBuilder::SortAABBS(
//create array of indexes to be sorted with morton codes
vtkm::cont::ArrayHandle<vtkm::Id> iterator;
iterator.PrepareForOutput(bvh.GetNumberOfPrimitives(), Device());
vtkm::worklet::DispatcherMapField<CountingIterator, Device> iteratorDispatcher;
vtkm::worklet::DispatcherMapField<CountingIterator> iteratorDispatcher;
iteratorDispatcher.SetDevice(Device());
iteratorDispatcher.Invoke(iterator);
//std::cout<<"\n\n\n";
@ -623,56 +624,77 @@ VTKM_CONT void LinearBVHBuilder::SortAABBS(
tempStorage = new vtkm::cont::ArrayHandle<vtkm::Float32>();
//xmins
vtkm::worklet::DispatcherMapField<GatherFloat32<Device>, Device>(
GatherFloat32<Device>(*bvh.xmins, *tempStorage, arraySize))
.Invoke(iterator);
{
vtkm::worklet::DispatcherMapField<GatherFloat32<Device>> dispatcher(
GatherFloat32<Device>(*bvh.xmins, *tempStorage, arraySize));
dispatcher.SetDevice(Device());
dispatcher.Invoke(iterator);
}
tempPtr = bvh.xmins;
bvh.xmins = tempStorage;
tempStorage = tempPtr;
vtkm::worklet::DispatcherMapField<GatherFloat32<Device>, Device>(
GatherFloat32<Device>(*bvh.ymins, *tempStorage, arraySize))
.Invoke(iterator);
{
vtkm::worklet::DispatcherMapField<GatherFloat32<Device>> dispatcher(
GatherFloat32<Device>(*bvh.ymins, *tempStorage, arraySize));
dispatcher.SetDevice(Device());
dispatcher.Invoke(iterator);
}
tempPtr = bvh.ymins;
bvh.ymins = tempStorage;
tempStorage = tempPtr;
//zmins
vtkm::worklet::DispatcherMapField<GatherFloat32<Device>, Device>(
GatherFloat32<Device>(*bvh.zmins, *tempStorage, arraySize))
.Invoke(iterator);
{
vtkm::worklet::DispatcherMapField<GatherFloat32<Device>> dispatcher(
GatherFloat32<Device>(*bvh.zmins, *tempStorage, arraySize));
dispatcher.SetDevice(Device());
dispatcher.Invoke(iterator);
}
tempPtr = bvh.zmins;
bvh.zmins = tempStorage;
tempStorage = tempPtr;
//xmaxs
vtkm::worklet::DispatcherMapField<GatherFloat32<Device>, Device>(
GatherFloat32<Device>(*bvh.xmaxs, *tempStorage, arraySize))
.Invoke(iterator);
{
vtkm::worklet::DispatcherMapField<GatherFloat32<Device>> dispatcher(
GatherFloat32<Device>(*bvh.xmaxs, *tempStorage, arraySize));
dispatcher.SetDevice(Device());
dispatcher.Invoke(iterator);
}
tempPtr = bvh.xmaxs;
bvh.xmaxs = tempStorage;
tempStorage = tempPtr;
//ymaxs
vtkm::worklet::DispatcherMapField<GatherFloat32<Device>, Device>(
GatherFloat32<Device>(*bvh.ymaxs, *tempStorage, arraySize))
.Invoke(iterator);
{
vtkm::worklet::DispatcherMapField<GatherFloat32<Device>> dispatcher(
GatherFloat32<Device>(*bvh.ymaxs, *tempStorage, arraySize));
dispatcher.SetDevice(Device());
dispatcher.Invoke(iterator);
}
tempPtr = bvh.ymaxs;
bvh.ymaxs = tempStorage;
tempStorage = tempPtr;
//zmaxs
vtkm::worklet::DispatcherMapField<GatherFloat32<Device>, Device>(
GatherFloat32<Device>(*bvh.zmaxs, *tempStorage, arraySize))
.Invoke(iterator);
{
vtkm::worklet::DispatcherMapField<GatherFloat32<Device>> dispatcher(
GatherFloat32<Device>(*bvh.zmaxs, *tempStorage, arraySize));
dispatcher.SetDevice(Device());
dispatcher.Invoke(iterator);
}
tempPtr = bvh.zmaxs;
bvh.zmaxs = tempStorage;
tempStorage = tempPtr;
vtkm::worklet::DispatcherMapField<GatherVecCast<Device>, Device>(
GatherVecCast<Device>(triangleIndices, outputTriangleIndices, arraySize))
.Invoke(iterator);
{
vtkm::worklet::DispatcherMapField<GatherVecCast<Device>> dispatcher(
GatherVecCast<Device>(triangleIndices, outputTriangleIndices, arraySize));
dispatcher.SetDevice(Device());
dispatcher.Invoke(iterator);
}
delete tempStorage;
} // method SortAABBs
@ -699,15 +721,16 @@ VTKM_CONT void LinearBVHBuilder::RunOnDevice(LinearBVH& linearBVH, Device device
BVHData bvh(numBBoxes, device);
vtkm::cont::Timer<Device> timer;
vtkm::worklet::DispatcherMapField<FindAABBs, Device>(FindAABBs())
.Invoke(triangleIndices,
*bvh.xmins,
*bvh.ymins,
*bvh.zmins,
*bvh.xmaxs,
*bvh.ymaxs,
*bvh.zmaxs,
coordsHandle);
vtkm::worklet::DispatcherMapField<FindAABBs> findAABBDispatcher{ (FindAABBs{}) };
findAABBDispatcher.SetDevice(Device());
findAABBDispatcher.Invoke(triangleIndices,
*bvh.xmins,
*bvh.ymins,
*bvh.zmins,
*bvh.xmaxs,
*bvh.ymaxs,
*bvh.zmaxs,
coordsHandle);
vtkm::Float64 time = timer.GetElapsedTime();
logger->AddLogData("find_aabb", time);
@ -742,10 +765,11 @@ VTKM_CONT void LinearBVHBuilder::RunOnDevice(LinearBVH& linearBVH, Device device
}
//Generate the morton codes
vtkm::worklet::DispatcherMapField<MortonCodeAABB, Device>(
MortonCodeAABB(inverseExtent, minExtent))
.Invoke(
*bvh.xmins, *bvh.ymins, *bvh.zmins, *bvh.xmaxs, *bvh.ymaxs, *bvh.zmaxs, bvh.mortonCodes);
vtkm::worklet::DispatcherMapField<MortonCodeAABB> mortonCodeAABBDispatcher(
MortonCodeAABB(inverseExtent, minExtent));
mortonCodeAABBDispatcher.SetDevice(Device());
mortonCodeAABBDispatcher.Invoke(
*bvh.xmins, *bvh.ymins, *bvh.zmins, *bvh.xmaxs, *bvh.ymaxs, *bvh.zmaxs, bvh.mortonCodes);
time = timer.GetElapsedTime();
logger->AddLogData("morton_codes", time);
@ -759,9 +783,10 @@ VTKM_CONT void LinearBVHBuilder::RunOnDevice(LinearBVH& linearBVH, Device device
logger->AddLogData("sort_aabbs", time);
timer.Reset();
vtkm::worklet::DispatcherMapField<TreeBuilder<Device>, Device>(
TreeBuilder<Device>(bvh.mortonCodes, bvh.parent, bvh.GetNumberOfPrimitives()))
.Invoke(bvh.leftChild, bvh.rightChild);
vtkm::worklet::DispatcherMapField<TreeBuilder<Device>> treeBuilderDispatcher(
TreeBuilder<Device>(bvh.mortonCodes, bvh.parent, bvh.GetNumberOfPrimitives()));
treeBuilderDispatcher.SetDevice(Device());
treeBuilderDispatcher.Invoke(bvh.leftChild, bvh.rightChild);
time = timer.GetElapsedTime();
logger->AddLogData("build_tree", time);
@ -772,15 +797,23 @@ VTKM_CONT void LinearBVHBuilder::RunOnDevice(LinearBVH& linearBVH, Device device
vtkm::cont::ArrayHandle<vtkm::Int32> counters;
counters.PrepareForOutput(bvh.GetNumberOfPrimitives() - 1, Device());
vtkm::Int32 zero = 0;
vtkm::worklet::DispatcherMapField<MemSet<vtkm::Int32>, Device>(MemSet<vtkm::Int32>(zero))
.Invoke(counters);
vtkm::worklet::DispatcherMapField<MemSet<vtkm::Int32>> resetCountersDispatcher(
(MemSet<vtkm::Int32>(zero)));
resetCountersDispatcher.SetDevice(Device());
resetCountersDispatcher.Invoke(counters);
vtkm::cont::AtomicArray<vtkm::Int32> atomicCounters(counters);
vtkm::worklet::DispatcherMapField<PropagateAABBs<Device>, Device>(
PropagateAABBs<Device>(
bvh.parent, bvh.leftChild, bvh.rightChild, primitiveCount, linearBVH.FlatBVH, atomicCounters))
.Invoke(*bvh.xmins, *bvh.ymins, *bvh.zmins, *bvh.xmaxs, *bvh.ymaxs, *bvh.zmaxs);
vtkm::worklet::DispatcherMapField<PropagateAABBs<Device>> propagateAABBDispatcher(
PropagateAABBs<Device>(bvh.parent,
bvh.leftChild,
bvh.rightChild,
primitiveCount,
linearBVH.FlatBVH,
atomicCounters));
propagateAABBDispatcher.SetDevice(Device());
propagateAABBDispatcher.Invoke(
*bvh.xmins, *bvh.ymins, *bvh.zmins, *bvh.xmaxs, *bvh.ymaxs, *bvh.zmaxs);
time = timer.GetElapsedTime();
logger->AddLogData("propagate_aabbs", time);

@ -20,6 +20,7 @@
#include <vtkm/VectorAnalysis.h>
#include <vtkm/cont/Algorithm.h>
#include <vtkm/cont/ErrorBadValue.h>
#include <vtkm/cont/Timer.h>
#include <vtkm/cont/TryExecute.h>
@ -659,69 +660,38 @@ struct Camera::CreateRaysFunctor
}
};
struct Camera::PixelDataFunctor
{
vtkm::rendering::raytracing::Camera* Self;
const vtkm::cont::CoordinateSystem& Coords;
vtkm::Int32& ActivePixels;
vtkm::Float32& AveDistPerRay;
VTKM_CONT
PixelDataFunctor(vtkm::rendering::raytracing::Camera* self,
const vtkm::cont::CoordinateSystem& coords,
vtkm::Int32& activePixels,
vtkm::Float32& aveDistPerRay)
: Self(self)
, Coords(coords)
, ActivePixels(activePixels)
, AveDistPerRay(aveDistPerRay)
{
}
template <typename Device>
VTKM_CONT bool operator()(Device)
{
VTKM_IS_DEVICE_ADAPTER_TAG(Device);
vtkm::Bounds boundingBox = Coords.GetBounds();
Self->FindSubset(boundingBox);
//Reset the camera look vector
Self->Look = Self->LookAt - Self->Position;
vtkm::Normalize(Self->Look);
const int size = Self->SubsetWidth * Self->SubsetHeight;
vtkm::cont::ArrayHandle<vtkm::Float32> dists;
vtkm::cont::ArrayHandle<vtkm::Int32> hits;
dists.PrepareForOutput(size, Device());
hits.PrepareForOutput(size, Device());
//Create the ray direction
vtkm::worklet::DispatcherMapField<PixelData, Device>(PixelData(Self->Width,
Self->Height,
Self->FovX,
Self->FovY,
Self->Look,
Self->Up,
Self->Zoom,
Self->SubsetWidth,
Self->SubsetMinX,
Self->SubsetMinY,
Self->Position,
boundingBox))
.Invoke(hits, dists); //X Y Z
ActivePixels = vtkm::cont::DeviceAdapterAlgorithm<Device>::Reduce(hits, vtkm::Int32(0));
AveDistPerRay = vtkm::cont::DeviceAdapterAlgorithm<Device>::Reduce(dists, vtkm::Float32(0)) /
vtkm::Float32(ActivePixels);
return true;
}
};
void Camera::GetPixelData(const vtkm::cont::CoordinateSystem& coords,
vtkm::Int32& activePixels,
vtkm::Float32& aveRayDistance)
{
vtkm::Bounds boundingBox = coords.GetBounds();
this->FindSubset(boundingBox);
//Reset the camera look vector
this->Look = this->LookAt - this->Position;
vtkm::Normalize(this->Look);
const int size = this->SubsetWidth * this->SubsetHeight;
vtkm::cont::ArrayHandle<vtkm::Float32> dists;
vtkm::cont::ArrayHandle<vtkm::Int32> hits;
dists.Allocate(size);
hits.Allocate(size);
PixelDataFunctor functor(this, coords, activePixels, aveRayDistance);
vtkm::cont::TryExecute(functor);
//Create the ray direction
vtkm::worklet::DispatcherMapField<PixelData>(PixelData(this->Width,
this->Height,
this->FovX,
this->FovY,
this->Look,
this->Up,
this->Zoom,
this->SubsetWidth,
this->SubsetMinX,
this->SubsetMinY,
this->Position,
boundingBox))
.Invoke(hits, dists); //X Y Z
activePixels = vtkm::cont::Algorithm::Reduce(hits, vtkm::Int32(0));
aveRayDistance =
vtkm::cont::Algorithm::Reduce(dists, vtkm::Float32(0)) / vtkm::Float32(activePixels);
}
VTKM_CONT
@ -758,18 +728,20 @@ VTKM_CONT void Camera::CreateRaysOnDevice(Ray<Precision>& rays,
Precision infinity;
GetInfinity(infinity);
vtkm::worklet::DispatcherMapField<MemSet<Precision>, Device>(MemSet<Precision>(infinity))
.Invoke(rays.MaxDistance);
vtkm::worklet::DispatcherMapField<MemSet<Precision>> memSetInfDispatcher(
(MemSet<Precision>(infinity)));
memSetInfDispatcher.SetDevice(Device());
memSetInfDispatcher.Invoke(rays.MaxDistance);
vtkm::worklet::DispatcherMapField<MemSet<Precision>, Device>(MemSet<Precision>(0.f))
.Invoke(rays.MinDistance);
vtkm::worklet::DispatcherMapField<MemSet<Precision>, Device>(MemSet<Precision>(0.f))
.Invoke(rays.Distance);
vtkm::worklet::DispatcherMapField<MemSet<Precision>> memSet0Dispatcher((MemSet<Precision>(0.f)));
memSet0Dispatcher.SetDevice(Device());
memSet0Dispatcher.Invoke(rays.MinDistance);
memSet0Dispatcher.Invoke(rays.Distance);
//Reset the Rays Hit Index to -2
vtkm::worklet::DispatcherMapField<MemSet<vtkm::Id>, Device>(MemSet<vtkm::Id>(-2))
.Invoke(rays.HitIdx);
vtkm::worklet::DispatcherMapField<MemSet<vtkm::Id>> memSetM2Dispatcher((MemSet<vtkm::Id>(-2)));
memSetM2Dispatcher.SetDevice(Device());
memSetM2Dispatcher.Invoke(rays.HitIdx);
vtkm::Float64 time = timer.GetElapsedTime();
logger->AddLogData("camera_memset", time);
@ -781,25 +753,26 @@ VTKM_CONT void Camera::CreateRaysOnDevice(Ray<Precision>& rays,
if (ortho)
{
vtkm::worklet::DispatcherMapField<Ortho2DRayGen, Device>(Ortho2DRayGen(this->Width,
this->Height,
this->Zoom,
this->SubsetWidth,
this->SubsetMinX,
this->SubsetMinY,
this->CameraView))
.Invoke(rays.DirX,
rays.DirY,
rays.DirZ,
rays.OriginX,
rays.OriginY,
rays.OriginZ,
rays.PixelIdx); //X Y Z
vtkm::worklet::DispatcherMapField<Ortho2DRayGen> dispatcher(Ortho2DRayGen(this->Width,
this->Height,
this->Zoom,
this->SubsetWidth,
this->SubsetMinX,
this->SubsetMinY,
this->CameraView));
dispatcher.SetDevice(Device());
dispatcher.Invoke(rays.DirX,
rays.DirY,
rays.DirZ,
rays.OriginX,
rays.OriginY,
rays.OriginZ,
rays.PixelIdx); //X Y Z
}
else
{
//Create the ray direction
vtkm::worklet::DispatcherMapField<PerspectiveRayGen, Device>(
vtkm::worklet::DispatcherMapField<PerspectiveRayGen> dispatcher(
PerspectiveRayGen(this->Width,
this->Height,
this->FovX,
@ -809,23 +782,24 @@ VTKM_CONT void Camera::CreateRaysOnDevice(Ray<Precision>& rays,
this->Zoom,
this->SubsetWidth,
this->SubsetMinX,
this->SubsetMinY))
.Invoke(rays.DirX,
rays.DirY,
rays.DirZ,
rays.PixelIdx); //X Y Z
this->SubsetMinY));
dispatcher.SetDevice(Device());
dispatcher.Invoke(rays.DirX, rays.DirY, rays.DirZ, rays.PixelIdx); //X Y Z
vtkm::worklet::DispatcherMapField<MemSet<Precision>, Device>(
MemSet<Precision>(this->Position[0]))
.Invoke(rays.OriginX);
vtkm::worklet::DispatcherMapField<MemSet<Precision>> memSetPos0Dispatcher(
MemSet<Precision>(this->Position[0]));
memSetPos0Dispatcher.SetDevice(Device());
memSetPos0Dispatcher.Invoke(rays.OriginX);
vtkm::worklet::DispatcherMapField<MemSet<Precision>, Device>(
MemSet<Precision>(this->Position[1]))
.Invoke(rays.OriginY);
vtkm::worklet::DispatcherMapField<MemSet<Precision>> memSetPos1Dispatcher(
MemSet<Precision>(this->Position[1]));
memSetPos1Dispatcher.SetDevice(Device());
memSetPos1Dispatcher.Invoke(rays.OriginY);
vtkm::worklet::DispatcherMapField<MemSet<Precision>, Device>(
MemSet<Precision>(this->Position[2]))
.Invoke(rays.OriginZ);
vtkm::worklet::DispatcherMapField<MemSet<Precision>> memSetPos2Dispatcher(
MemSet<Precision>(this->Position[2]));
memSetPos2Dispatcher.SetDevice(Device());
memSetPos2Dispatcher.Invoke(rays.OriginZ);
}
time = timer.GetElapsedTime();

@ -39,26 +39,6 @@ namespace rendering
namespace raytracing
{
template <typename Precision, typename OpWorklet>
struct BufferMathFunctor
{
ChannelBuffer<Precision>* Self;
const ChannelBuffer<Precision>* Other;
BufferMathFunctor(ChannelBuffer<Precision>* self, const ChannelBuffer<Precision>* other)
: Self(self)
, Other(other)
{
}
template <typename Device>
bool operator()(Device vtkmNotUsed(device))
{
vtkm::worklet::DispatcherMapField<OpWorklet, Device>(OpWorklet())
.Invoke(Other->Buffer, Self->Buffer);
return true;
}
};
class BufferAddition : public vtkm::worklet::WorkletMapField
{
public:
@ -150,8 +130,7 @@ void ChannelBuffer<Precision>::AddBuffer(const ChannelBuffer<Precision>& other)
if (this->Size != other.GetSize())
throw vtkm::cont::ErrorBadValue("ChannelBuffer add: size must be equal");
BufferMathFunctor<Precision, BufferAddition> functor(this, &other);
vtkm::cont::TryExecute(functor);
vtkm::worklet::DispatcherMapField<BufferAddition>().Invoke(other.Buffer, this->Buffer);
}
template <typename Precision>
@ -162,8 +141,7 @@ void ChannelBuffer<Precision>::MultiplyBuffer(const ChannelBuffer<Precision>& ot
if (this->Size != other.GetSize())
throw vtkm::cont::ErrorBadValue("ChannelBuffer add: size must be equal");
BufferMathFunctor<Precision, BufferMultiply> functor(this, &other);
vtkm::cont::TryExecute(functor);
vtkm::worklet::DispatcherMapField<BufferMultiply>().Invoke(other.Buffer, this->Buffer);
}
template <typename Precision>
@ -221,9 +199,10 @@ struct ExtractChannelFunctor
bool operator()(Device device)
{
Output.PrepareForOutput(Self->GetSize(), device);
vtkm::worklet::DispatcherMapField<ExtractChannel, Device>(
ExtractChannel(Self->GetNumChannels(), Channel))
.Invoke(Output, Self->Buffer);
vtkm::worklet::DispatcherMapField<ExtractChannel> dispatcher(
ExtractChannel(Self->GetNumChannels(), Channel));
dispatcher.SetDevice(Device());
dispatcher.Invoke(Output, Self->Buffer);
return true;
}
};
@ -307,8 +286,9 @@ struct ExpandFunctorSignature
Output->Buffer.PrepareForOutput(totalSize, device);
ChannelBufferOperations::InitChannels(*Output, Signature, device);
vtkm::worklet::DispatcherMapField<Expand, Device>(Expand(NumChannels))
.Invoke(Input, SparseIndexes, Output->Buffer);
vtkm::worklet::DispatcherMapField<Expand> dispatcher((Expand(NumChannels)));
dispatcher.SetDevice(Device());
dispatcher.Invoke(Input, SparseIndexes, Output->Buffer);
return true;
}
@ -347,8 +327,9 @@ struct ExpandFunctor
Output->Buffer.PrepareForOutput(totalSize, device);
ChannelBufferOperations::InitConst(*Output, InitVal, device);
vtkm::worklet::DispatcherMapField<Expand, Device>(Expand(NumChannels))
.Invoke(Input, SparseIndexes, Output->Buffer);
vtkm::worklet::DispatcherMapField<Expand> dispatcher((Expand(NumChannels)));
dispatcher.SetDevice(Device());
dispatcher.Invoke(Input, SparseIndexes, Output->Buffer);
return true;
}
@ -410,9 +391,10 @@ struct NormalizeFunctor
asField.GetRange(&range);
Precision minScalar = static_cast<Precision>(range.Min);
Precision maxScalar = static_cast<Precision>(range.Max);
vtkm::worklet::DispatcherMapField<NormalizeBuffer<Precision>, Device>(
NormalizeBuffer<Precision>(minScalar, maxScalar, Invert))
.Invoke(Input);
vtkm::worklet::DispatcherMapField<NormalizeBuffer<Precision>> dispatcher(
NormalizeBuffer<Precision>(minScalar, maxScalar, Invert));
dispatcher.SetDevice(Device());
dispatcher.Invoke(Input);
return true;
}

@ -116,9 +116,10 @@ public:
vtkm::cont::ArrayHandle<Precision> compactedBuffer;
compactedBuffer.PrepareForOutput(newSize * buffer.NumChannels, Device());
vtkm::worklet::DispatcherMapField<detail::CompactBuffer, Device>(
detail::CompactBuffer(buffer.NumChannels))
.Invoke(masks, buffer.Buffer, offsets, compactedBuffer);
vtkm::worklet::DispatcherMapField<detail::CompactBuffer> dispatcher(
detail::CompactBuffer(buffer.NumChannels));
dispatcher.SetDevice(Device());
dispatcher.Invoke(masks, buffer.Buffer, offsets, compactedBuffer);
buffer.Buffer = compactedBuffer;
buffer.Size = newSize;
}
@ -133,16 +134,19 @@ public:
std::string msg = "ChannelBuffer: number of bins in sourse signature must match NumChannels";
throw vtkm::cont::ErrorBadValue(msg);
}
vtkm::worklet::DispatcherMapField<detail::InitBuffer, Device>(
detail::InitBuffer(buffer.NumChannels))
.Invoke(buffer.Buffer, sourceSignature);
vtkm::worklet::DispatcherMapField<detail::InitBuffer> initBufferDispatcher(
detail::InitBuffer(buffer.NumChannels));
initBufferDispatcher.SetDevice(Device());
initBufferDispatcher.Invoke(buffer.Buffer, sourceSignature);
}
template <typename Device, typename Precision>
static void InitConst(ChannelBuffer<Precision>& buffer, const Precision value, Device)
{
vtkm::worklet::DispatcherMapField<MemSet<Precision>, Device>(MemSet<Precision>(value))
.Invoke(buffer.Buffer);
vtkm::worklet::DispatcherMapField<MemSet<Precision>> memSetDispatcher(
(MemSet<Precision>(value)));
memSetDispatcher.SetDevice(Device());
memSetDispatcher.Invoke(buffer.Buffer);
}
};
}

@ -101,19 +101,24 @@ void RayTracking<FloatType>::Init(const vtkm::Id size,
//
// Set the initial Distances
//
vtkm::worklet::DispatcherMapField<CopyAndOffset<FloatType>, Device>(
CopyAndOffset<FloatType>(0.0f))
.Invoke(distances, *EnterDist);
vtkm::worklet::DispatcherMapField<CopyAndOffset<FloatType>> resetDistancesDispatcher(
CopyAndOffset<FloatType>(0.0f));
resetDistancesDispatcher.SetDevice(Device());
resetDistancesDispatcher.Invoke(distances, *EnterDist);
//
// Init the exit faces. This value is used to load the next cell
// base on the cell and face it left
//
vtkm::worklet::DispatcherMapField<MemSet<vtkm::Int32>, Device>(MemSet<vtkm::Int32>(-1))
.Invoke(ExitFace);
vtkm::worklet::DispatcherMapField<MemSet<vtkm::Int32>> initExitFaceDispatcher(
MemSet<vtkm::Int32>(-1));
initExitFaceDispatcher.SetDevice(Device());
initExitFaceDispatcher.Invoke(ExitFace);
vtkm::worklet::DispatcherMapField<MemSet<FloatType>, Device>(MemSet<FloatType>(-1))
.Invoke(*ExitDist);
vtkm::worklet::DispatcherMapField<MemSet<FloatType>> initExitDistanceDispatcher(
MemSet<FloatType>(-1));
initExitDistanceDispatcher.SetDevice(Device());
initExitDistanceDispatcher.Invoke(*ExitDist);
}
template <typename FloatType>
@ -956,15 +961,16 @@ void ConnectivityTracer<CellType, ConnectivityType>::IntersectCell(
{
using LocateC = LocateCell<CellType, FloatType, MeshConnExec<ConnectivityType, Device>>;
vtkm::cont::Timer<Device> timer;
vtkm::worklet::DispatcherMapField<LocateC, Device>(LocateC(MeshConn))
.Invoke(rays.HitIdx,
this->MeshConn.GetCoordinates(),
rays.Dir,
*(tracker.EnterDist),
*(tracker.ExitDist),
tracker.ExitFace,
rays.Status,
rays.Origin);
vtkm::worklet::DispatcherMapField<LocateC> dispatcher((LocateC(MeshConn)));
dispatcher.SetDevice(Device());
dispatcher.Invoke(rays.HitIdx,
this->MeshConn.GetCoordinates(),
rays.Dir,
*(tracker.EnterDist),
*(tracker.ExitDist),
tracker.ExitFace,
rays.Status,
rays.Origin);
if (this->CountRayStatus)
RaysLost = RayOperations::GetStatusCount(rays, RAY_LOST, Device());
@ -978,11 +984,11 @@ void ConnectivityTracer<CellType, ConnectivityType>::AccumulatePathLengths(
detail::RayTracking<FloatType>& tracker,
Device)
{
vtkm::worklet::DispatcherMapField<AddPathLengths<FloatType>, Device>(AddPathLengths<FloatType>())
.Invoke(rays.Status,
*(tracker.EnterDist),
*(tracker.ExitDist),
rays.GetBuffer("path_lengths").Buffer);
vtkm::worklet::DispatcherMapField<AddPathLengths<FloatType>> dispatcher(
(AddPathLengths<FloatType>()));
dispatcher.SetDevice(Device());
dispatcher.Invoke(
rays.Status, *(tracker.EnterDist), *(tracker.ExitDist), rays.GetBuffer("path_lengths").Buffer);
}
template <vtkm::Int32 CellType, typename ConnectivityType>
@ -995,15 +1001,16 @@ void ConnectivityTracer<CellType, ConnectivityType>::FindLostRays(
using RayB = RayBumper<CellType, FloatType, Device, MeshConnExec<ConnectivityType, Device>>;
vtkm::cont::Timer<Device> timer;
vtkm::worklet::DispatcherMapField<RayB, Device>(
RayB(rays.DirX, rays.DirY, rays.DirZ, this->MeshConn))
.Invoke(rays.HitIdx,
this->MeshConn.GetCoordinates(),
*(tracker.EnterDist),
*(tracker.ExitDist),
tracker.ExitFace,
rays.Status,
rays.Origin);
vtkm::worklet::DispatcherMapField<RayB> dispatcher(
RayB(rays.DirX, rays.DirY, rays.DirZ, this->MeshConn));
dispatcher.SetDevice(Device());
dispatcher.Invoke(rays.HitIdx,
this->MeshConn.GetCoordinates(),
*(tracker.EnterDist),
*(tracker.ExitDist),
tracker.ExitFace,
rays.Status,
rays.Origin);
this->LostRayTime += timer.GetElapsedTime();
}
@ -1025,38 +1032,40 @@ void ConnectivityTracer<CellType, ConnectivityType>::SampleCells(
if (FieldAssocPoints)
{
vtkm::worklet::DispatcherMapField<SampleP, Device>(
vtkm::worklet::DispatcherMapField<SampleP> dispatcher(
SampleP(this->SampleDistance,
vtkm::Float32(this->ScalarBounds.Min),
vtkm::Float32(this->ScalarBounds.Max),
this->ColorMap,
rays.Buffers.at(0).Buffer,
this->MeshConn))
.Invoke(rays.HitIdx,
this->MeshConn.GetCoordinates(),
this->ScalarField.GetData(),
*(tracker.EnterDist),
*(tracker.ExitDist),
tracker.CurrentDistance,
rays.Dir,
rays.Status,
rays.Origin);
this->MeshConn));
dispatcher.SetDevice(Device());
dispatcher.Invoke(rays.HitIdx,
this->MeshConn.GetCoordinates(),
this->ScalarField.GetData(),
*(tracker.EnterDist),
*(tracker.ExitDist),
tracker.CurrentDistance,
rays.Dir,
rays.Status,
rays.Origin);
}
else
{
vtkm::worklet::DispatcherMapField<SampleC, Device>(
vtkm::worklet::DispatcherMapField<SampleC> dispatcher(
SampleC(this->SampleDistance,
vtkm::Float32(this->ScalarBounds.Min),
vtkm::Float32(this->ScalarBounds.Max),
this->ColorMap,
rays.Buffers.at(0).Buffer,
this->MeshConn))
.Invoke(rays.HitIdx,
this->ScalarField.GetData(),
*(tracker.EnterDist),
*(tracker.ExitDist),
tracker.CurrentDistance,
rays.Status);
this->MeshConn));
dispatcher.SetDevice(Device());
dispatcher.Invoke(rays.HitIdx,
this->ScalarField.GetData(),
*(tracker.EnterDist),
*(tracker.ExitDist),
tracker.CurrentDistance,
rays.Status);
}
this->SampleTime += timer.GetElapsedTime();
@ -1075,29 +1084,31 @@ void ConnectivityTracer<CellType, ConnectivityType>::IntegrateCells(
bool divideEmisByAbsorp = false;
vtkm::cont::ArrayHandle<FloatType> absorp = rays.Buffers.at(0).Buffer;
vtkm::cont::ArrayHandle<FloatType> emission = rays.GetBuffer("emission").Buffer;
vtkm::worklet::DispatcherMapField<IntegrateEmission<FloatType>, Device>(
IntegrateEmission<FloatType>(rays.Buffers.at(0).GetNumChannels(), divideEmisByAbsorp))
.Invoke(rays.Status,
*(tracker.EnterDist),
*(tracker.ExitDist),
rays.Distance,
this->ScalarField.GetData(),
this->EmissionField.GetData(),
absorp,
emission,
rays.HitIdx);
vtkm::worklet::DispatcherMapField<IntegrateEmission<FloatType>> dispatcher(
IntegrateEmission<FloatType>(rays.Buffers.at(0).GetNumChannels(), divideEmisByAbsorp));
dispatcher.SetDevice(Device());
dispatcher.Invoke(rays.Status,
*(tracker.EnterDist),
*(tracker.ExitDist),
rays.Distance,
this->ScalarField.GetData(),
this->EmissionField.GetData(),
absorp,
emission,
rays.HitIdx);
}
else
{
vtkm::worklet::DispatcherMapField<Integrate<FloatType>, Device>(
Integrate<FloatType>(rays.Buffers.at(0).GetNumChannels()))
.Invoke(rays.Status,
*(tracker.EnterDist),
*(tracker.ExitDist),
rays.Distance,
this->ScalarField.GetData(),
rays.Buffers.at(0).Buffer,
rays.HitIdx);
vtkm::worklet::DispatcherMapField<Integrate<FloatType>> dispatcher(
Integrate<FloatType>(rays.Buffers.at(0).GetNumChannels()));
dispatcher.SetDevice(Device());
dispatcher.Invoke(rays.Status,
*(tracker.EnterDist),
*(tracker.ExitDist),
rays.Distance,
this->ScalarField.GetData(),
rays.Buffers.at(0).Buffer,
rays.HitIdx);
}
IntegrateTime += timer.GetElapsedTime();
@ -1136,9 +1147,10 @@ template <typename FloatType, typename Device>
void ConnectivityTracer<CellType, ConnectivityType>::OffsetMinDistances(Ray<FloatType>& rays,
Device)
{
vtkm::worklet::DispatcherMapField<AdvanceRay<FloatType>, Device>(
AdvanceRay<FloatType>(FloatType(0.001)))
.Invoke(rays.Status, rays.MinDistance);
vtkm::worklet::DispatcherMapField<AdvanceRay<FloatType>> dispatcher(
AdvanceRay<FloatType>(FloatType(0.001)));
dispatcher.SetDevice(Device());
dispatcher.Invoke(rays.Status, rays.MinDistance);
}
template <vtkm::Int32 CellType, typename ConnectivityType>
@ -1253,9 +1265,10 @@ void ConnectivityTracer<CellType, ConnectivityType>::RenderOnDevice(Ray<FloatTyp
{
vtkm::cont::ArrayHandleCounting<vtkm::Id> pCounter(0, 1, rays.NumRays);
vtkm::worklet::DispatcherMapField<IdentifyMissedRay, Device>(
IdentifyMissedRay(rays.DebugWidth, rays.DebugHeight, this->BackgroundColor))
.Invoke(pCounter, rays.Buffers.at(0).Buffer);
vtkm::worklet::DispatcherMapField<IdentifyMissedRay> dispatcher(
IdentifyMissedRay(rays.DebugWidth, rays.DebugHeight, this->BackgroundColor));
dispatcher.SetDevice(Device());
dispatcher.Invoke(pCounter, rays.Buffers.at(0).Buffer);
}
vtkm::Float64 renderTime = renderTimer.GetElapsedTime();
this->LogTimers();

@ -571,8 +571,9 @@ public:
// scatter the coonectivity into the original order
vtkm::worklet::DispatcherMapField<WriteFaceConn, DeviceAdapter>(WriteFaceConn())
.Invoke(cellFaceId, this->FaceOffsets, faceConnectivity);
vtkm::worklet::DispatcherMapField<WriteFaceConn> dispatcherWriteFaceConn;
dispatcherWriteFaceConn.SetDevice(DeviceAdapter());
dispatcherWriteFaceConn.Invoke(cellFaceId, this->FaceOffsets, faceConnectivity);
FaceConnectivity = faceConnectivity;
@ -628,8 +629,9 @@ public:
this->ExtractExternalFaces(cellFaceId, faceConnectivity, shapes, conn, shapeOffsets);
// scatter the coonectivity into the original order
vtkm::worklet::DispatcherMapField<WriteFaceConn, DeviceAdapter>(WriteFaceConn())
.Invoke(cellFaceId, this->FaceOffsets, faceConnectivity);
vtkm::worklet::DispatcherMapField<WriteFaceConn> dispatcher{ (WriteFaceConn{}) };
dispatcher.SetDevice(DeviceAdapter());
dispatcher.Invoke(cellFaceId, this->FaceOffsets, faceConnectivity);
FaceConnectivity = faceConnectivity;
OutsideTriangles = externalTriangles;
@ -653,10 +655,11 @@ public:
triangles.PrepareForOutput(numFaces * 2, DeviceAdapter());
vtkm::cont::ArrayHandleCounting<vtkm::Id> counting(0, 1, numFaces);
vtkm::worklet::DispatcherMapField<StructuredExternalTriangles, DeviceAdapter>(
vtkm::worklet::DispatcherMapField<StructuredExternalTriangles> dispatcher(
StructuredExternalTriangles(cellSetStructured.PrepareForInput(
DeviceAdapter(), vtkm::TopologyElementTagPoint(), vtkm::TopologyElementTagCell())))
.Invoke(counting, triangles);
DeviceAdapter(), vtkm::TopologyElementTagPoint(), vtkm::TopologyElementTagCell())));
dispatcher.SetDevice(DeviceAdapter());
dispatcher.Invoke(counting, triangles);
vtkm::Float64 time = timer.GetElapsedTime();
Logger::GetInstance()->AddLogData("structured_external_faces", time);
@ -701,8 +704,9 @@ protected:
// Count the number of total faces in the cell set
vtkm::cont::ArrayHandle<vtkm::Id> facesPerCell;
vtkm::worklet::DispatcherMapField<CountFaces, DeviceAdapter>(CountFaces())
.Invoke(shapes, facesPerCell);
vtkm::worklet::DispatcherMapField<CountFaces> countFacesDispatcher{ (CountFaces{}) };
countFacesDispatcher.SetDevice(DeviceAdapter());
countFacesDispatcher.Invoke(shapes, facesPerCell);
vtkm::Id totalFaces = 0;
totalFaces =
@ -744,9 +748,10 @@ protected:
vtkm::cont::ArrayHandle<vtkm::UInt32> faceMortonCodes;
cellFaceId.PrepareForOutput(totalFaces, DeviceAdapter());
faceMortonCodes.PrepareForOutput(totalFaces, DeviceAdapter());
vtkm::worklet::DispatcherMapTopology<MortonCodeFace, DeviceAdapter>(
MortonCodeFace(inverseExtent, minPoint))
.Invoke(cellSet, coordinates, cellOffsets, faceMortonCodes, cellFaceId);
vtkm::worklet::DispatcherMapTopology<MortonCodeFace> mortonCodeFaceDispatcher(
MortonCodeFace(inverseExtent, minPoint));
mortonCodeFaceDispatcher.SetDevice(DeviceAdapter());
mortonCodeFaceDispatcher.Invoke(cellSet, coordinates, cellOffsets, faceMortonCodes, cellFaceId);
// Sort the "faces" (i.e., morton codes)
vtkm::cont::DeviceAdapterAlgorithm<DeviceAdapter>::SortByKey(faceMortonCodes, cellFaceId);
@ -755,11 +760,15 @@ protected:
faceConnectivity.PrepareForOutput(totalFaces, DeviceAdapter());
// Initialize All connecting faces to -1 (connects to nothing)
vtkm::worklet::DispatcherMapField<MemSet<vtkm::Id>, DeviceAdapter>(MemSet<vtkm::Id>(-1))
.Invoke(faceConnectivity);
vtkm::worklet::DispatcherMapField<MemSet<vtkm::Id>> memSetDispatcher(MemSet<vtkm::Id>(-1));
memSetDispatcher.SetDevice(DeviceAdapter());
memSetDispatcher.Invoke(faceConnectivity);
vtkm::worklet::DispatcherMapField<MortonNeighbor, DeviceAdapter>(MortonNeighbor())
.Invoke(faceMortonCodes, cellFaceId, conn, shapes, shapeOffsets, faceConnectivity);
vtkm::worklet::DispatcherMapField<MortonNeighbor> mortonNeighborDispatcher{ (
MortonNeighbor{}) };
mortonNeighborDispatcher.SetDevice(DeviceAdapter());
mortonNeighborDispatcher.Invoke(
faceMortonCodes, cellFaceId, conn, shapes, shapeOffsets, faceConnectivity);
vtkm::Float64 time = timer.GetElapsedTime();
Logger::GetInstance()->AddLogData("gen_face_conn", time);
@ -792,9 +801,10 @@ protected:
trianglesPerExternalFace.PrepareForOutput(numExternalFaces, DeviceAdapter());
vtkm::worklet::DispatcherMapField<CountExternalTriangles, DeviceAdapter>(
CountExternalTriangles())
.Invoke(externalFacePairs, shapes, trianglesPerExternalFace);
vtkm::worklet::DispatcherMapField<CountExternalTriangles> countExternalDispatcher{ (
CountExternalTriangles{}) };
countExternalDispatcher.SetDevice(DeviceAdapter());
countExternalDispatcher.Invoke(externalFacePairs, shapes, trianglesPerExternalFace);
vtkm::cont::ArrayHandle<vtkm::Id> externalTriangleOffsets;
vtkm::cont::DeviceAdapterAlgorithm<DeviceAdapter>::ScanExclusive(trianglesPerExternalFace,
@ -807,9 +817,11 @@ protected:
externalTriangles.PrepareForOutput(totalExternalTriangles, DeviceAdapter());
//count the number triangles in the external faces
vtkm::worklet::DispatcherMapField<ExternalTriangles, DeviceAdapter>(ExternalTriangles())
.Invoke(
externalFacePairs, shapes, shapeOffsets, conn, externalTriangles, externalTriangleOffsets);
vtkm::worklet::DispatcherMapField<ExternalTriangles> externalTriDispatcher{ (
ExternalTriangles{}) };
externalTriDispatcher.SetDevice(DeviceAdapter());
externalTriDispatcher.Invoke(
externalFacePairs, shapes, shapeOffsets, conn, externalTriangles, externalTriangleOffsets);
vtkm::Float64 time = timer.GetElapsedTime();

@ -27,41 +27,6 @@ namespace rendering
namespace raytracing
{
template <typename T>
struct MapCanvasFunctor
{
const vtkm::Matrix<vtkm::Float32, 4, 4> Inverse;
const vtkm::Id Width;
const vtkm::Id Height;
const vtkm::cont::ArrayHandle<vtkm::Float32>& DepthBuffer;
Ray<T>& Rays;
vtkm::Vec<vtkm::Float32, 3> Origin;
MapCanvasFunctor(Ray<T>& rays,
const vtkm::Matrix<vtkm::Float32, 4, 4> inverse,
const vtkm::Id width,
const vtkm::Id height,
const vtkm::cont::ArrayHandle<vtkm::Float32>& depthBuffer,
const vtkm::Vec<vtkm::Float32, 3>& origin)
: Inverse(inverse)
, Width(width)
, Height(height)
, DepthBuffer(depthBuffer)
, Rays(rays)
, Origin(origin)
{
}
template <typename Device>
bool operator()(Device)
{
vtkm::worklet::DispatcherMapField<detail::RayMapCanvas, Device>(
detail::RayMapCanvas(Inverse, Width, Height, Origin))
.Invoke(Rays.PixelIdx, Rays.MaxDistance, DepthBuffer);
return true;
}
};
void RayOperations::MapCanvasToRays(Ray<vtkm::Float32>& rays,
const vtkm::rendering::Camera& camera,
const vtkm::rendering::CanvasRayTracer& canvas)
@ -75,9 +40,9 @@ void RayOperations::MapCanvasToRays(Ray<vtkm::Float32>& rays,
if (!valid)
throw vtkm::cont::ErrorBadValue("Inverse Invalid");
MapCanvasFunctor<vtkm::Float32> functor(
rays, inverse, width, height, canvas.GetDepthBuffer(), camera.GetPosition());
vtkm::cont::TryExecute(functor);
vtkm::worklet::DispatcherMapField<detail::RayMapCanvas>(
detail::RayMapCanvas(inverse, width, height, camera.GetPosition()))
.Invoke(rays.PixelIdx, rays.MaxDistance, canvas.GetDepthBuffer());
}
}
}

@ -117,8 +117,10 @@ public:
template <typename Device, typename T>
static void ResetStatus(Ray<T>& rays, vtkm::UInt8 status, Device)
{
vtkm::worklet::DispatcherMapField<MemSet<vtkm::UInt8>, Device>(MemSet<vtkm::UInt8>(status))
.Invoke(rays.Status);
vtkm::worklet::DispatcherMapField<MemSet<vtkm::UInt8>> dispatcher(
(MemSet<vtkm::UInt8>(status)));
dispatcher.SetDevice(Device());
dispatcher.Invoke(rays.Status);
}
//
@ -129,8 +131,10 @@ public:
template <typename Device, typename T>
static void UpdateRayStatus(Ray<T>& rays, Device)
{
vtkm::worklet::DispatcherMapField<detail::RayStatusFilter, Device>(detail::RayStatusFilter())
.Invoke(rays.HitIdx, rays.Status);
vtkm::worklet::DispatcherMapField<detail::RayStatusFilter> dispatcher{ (
detail::RayStatusFilter{}) };
dispatcher.SetDevice(Device());
dispatcher.Invoke(rays.HitIdx, rays.Status);
}
static void MapCanvasToRays(Ray<vtkm::Float32>& rays,
@ -146,9 +150,10 @@ public:
vtkm::cont::ArrayHandle<vtkm::UInt8> masks;
vtkm::worklet::DispatcherMapField<ManyMask<vtkm::UInt8, 2>, Device>(
ManyMask<vtkm::UInt8, 2>(maskValues))
.Invoke(rays.Status, masks);
vtkm::worklet::DispatcherMapField<ManyMask<vtkm::UInt8, 2>> dispatcher{ (
ManyMask<vtkm::UInt8, 2>{ maskValues }) };
dispatcher.SetDevice(Device());
dispatcher.Invoke(rays.Status, masks);
vtkm::cont::ArrayHandleCast<vtkm::Id, vtkm::cont::ArrayHandle<vtkm::UInt8>> castedMasks(masks);
const vtkm::Id initVal = 0;
vtkm::Id count = vtkm::cont::DeviceAdapterAlgorithm<Device>::Reduce(castedMasks, initVal);
@ -168,8 +173,10 @@ public:
statusUInt8 = static_cast<vtkm::UInt8>(status);
vtkm::cont::ArrayHandle<vtkm::UInt8> masks;
vtkm::worklet::DispatcherMapField<Mask<vtkm::UInt8>, Device>(Mask<vtkm::UInt8>(statusUInt8))
.Invoke(rays.Status, masks);
vtkm::worklet::DispatcherMapField<Mask<vtkm::UInt8>> dispatcher{ (
Mask<vtkm::UInt8>{ statusUInt8 }) };
dispatcher.SetDevice(Device());
dispatcher.Invoke(rays.Status, masks);
vtkm::cont::ArrayHandleCast<vtkm::Id, vtkm::cont::ArrayHandle<vtkm::UInt8>> castedMasks(masks);
const vtkm::Id initVal = 0;
vtkm::Id count = vtkm::cont::DeviceAdapterAlgorithm<Device>::Reduce(castedMasks, initVal);
@ -187,9 +194,10 @@ public:
vtkm::cont::ArrayHandle<vtkm::UInt8> masks;
vtkm::worklet::DispatcherMapField<ManyMask<vtkm::UInt8, 3>, Device>(
ManyMask<vtkm::UInt8, 3>(maskValues))
.Invoke(rays.Status, masks);
vtkm::worklet::DispatcherMapField<ManyMask<vtkm::UInt8, 3>> dispatcher{ (
ManyMask<vtkm::UInt8, 3>{ maskValues }) };
dispatcher.SetDevice(Device());
dispatcher.Invoke(rays.Status, masks);
vtkm::cont::ArrayHandleCast<vtkm::Id, vtkm::cont::ArrayHandle<vtkm::UInt8>> castedMasks(masks);
const vtkm::Id initVal = 0;
vtkm::Id count = vtkm::cont::DeviceAdapterAlgorithm<Device>::Reduce(castedMasks, initVal);
@ -205,8 +213,10 @@ public:
vtkm::UInt8 statusUInt8 = static_cast<vtkm::UInt8>(RAY_ACTIVE);
vtkm::cont::ArrayHandle<vtkm::UInt8> masks;
vtkm::worklet::DispatcherMapField<Mask<vtkm::UInt8>, Device>(Mask<vtkm::UInt8>(statusUInt8))
.Invoke(rays.Status, masks);
vtkm::worklet::DispatcherMapField<Mask<vtkm::UInt8>> dispatcher{ (
Mask<vtkm::UInt8>{ statusUInt8 }) };
dispatcher.SetDevice(Device());
dispatcher.Invoke(rays.Status, masks);
vtkm::cont::ArrayHandle<T> emptyHandle;
@ -328,9 +338,10 @@ public:
template <typename Device, typename T>
static void CopyDistancesToMin(Ray<T> rays, Device, const T offset = 0.f)
{
vtkm::worklet::DispatcherMapField<CopyAndOffsetMask<T>, Device>(
CopyAndOffsetMask<T>(offset, RAY_EXITED_MESH))
.Invoke(rays.Distance, rays.MinDistance, rays.Status);
vtkm::worklet::DispatcherMapField<CopyAndOffsetMask<T>> dispatcher{ (
CopyAndOffsetMask<T>{ offset, RAY_EXITED_MESH }) };
dispatcher.SetDevice(Device());
dispatcher.Invoke(rays.Distance, rays.MinDistance, rays.Status);
}
};
}

@ -237,22 +237,27 @@ public:
throw vtkm::cont::ErrorBadValue("Field not accociated with cell set or points");
bool isAssocPoints = scalarField.GetAssociation() == vtkm::cont::Field::Association::POINTS;
vtkm::worklet::DispatcherMapField<CalculateNormals, Device>(CalculateNormals(bvh.LeafNodes))
.Invoke(rays.HitIdx, rays.Dir, rays.NormalX, rays.NormalY, rays.NormalZ, coordsHandle);
vtkm::worklet::DispatcherMapField<CalculateNormals> calcNormalsDispatcher(
CalculateNormals(bvh.LeafNodes));
calcNormalsDispatcher.SetDevice(Device());
calcNormalsDispatcher.Invoke(
rays.HitIdx, rays.Dir, rays.NormalX, rays.NormalY, rays.NormalZ, coordsHandle);
if (isAssocPoints)
{
vtkm::worklet::DispatcherMapField<LerpScalar<Precision>, Device>(
vtkm::worklet::DispatcherMapField<LerpScalar<Precision>> lerpScalarDispatcher(
LerpScalar<Precision>(
bvh.LeafNodes, vtkm::Float32(scalarRange.Min), vtkm::Float32(scalarRange.Max)))
.Invoke(rays.HitIdx, rays.U, rays.V, rays.Scalar, scalarField);
bvh.LeafNodes, vtkm::Float32(scalarRange.Min), vtkm::Float32(scalarRange.Max)));
lerpScalarDispatcher.SetDevice(Device());
lerpScalarDispatcher.Invoke(rays.HitIdx, rays.U, rays.V, rays.Scalar, scalarField);
}
else
{
vtkm::worklet::DispatcherMapField<NodalScalar<Precision>, Device>(
vtkm::worklet::DispatcherMapField<NodalScalar<Precision>> nodalScalarDispatcher(
NodalScalar<Precision>(
bvh.LeafNodes, vtkm::Float32(scalarRange.Min), vtkm::Float32(scalarRange.Max)))
.Invoke(rays.HitIdx, rays.Scalar, scalarField);
bvh.LeafNodes, vtkm::Float32(scalarRange.Min), vtkm::Float32(scalarRange.Max)));
nodalScalarDispatcher.SetDevice(Device());
nodalScalarDispatcher.Invoke(rays.HitIdx, rays.Scalar, scalarField);
}
} // Run
@ -373,10 +378,11 @@ public:
vtkm::Vec<vtkm::Float32, 3> scale(2, 2, 2);
vtkm::Vec<vtkm::Float32, 3> lightPosition = camera.GetPosition() + scale * camera.GetUp();
const vtkm::Int32 colorMapSize = vtkm::Int32(colorMap.GetNumberOfValues());
vtkm::worklet::DispatcherMapField<MapScalarToColor, Device>(
MapScalarToColor(
colorMap, colorMapSize, lightPosition, camera.GetPosition(), camera.GetLookAt()))
.Invoke(rays.HitIdx, rays.Scalar, rays.Normal, rays.Intersection, rays.Buffers.at(0).Buffer);
vtkm::worklet::DispatcherMapField<MapScalarToColor> dispatcher(MapScalarToColor(
colorMap, colorMapSize, lightPosition, camera.GetPosition(), camera.GetLookAt()));
dispatcher.SetDevice(Device());
dispatcher.Invoke(
rays.HitIdx, rays.Scalar, rays.Normal, rays.Intersection, rays.Buffers.at(0).Buffer);
}
}; // class SurfaceColor
@ -487,15 +493,16 @@ void RayTracer::RenderOnDevice(Ray<Precision>& rays, Device)
timer.Reset();
// Find the intersection point from hit distance
vtkm::worklet::DispatcherMapField<detail::IntersectionPoint, Device>(
detail::IntersectionPoint())
.Invoke(rays.HitIdx,
rays.Distance,
rays.Dir,
rays.Origin,
rays.IntersectionX,
rays.IntersectionY,
rays.IntersectionZ);
vtkm::worklet::DispatcherMapField<detail::IntersectionPoint> intersectionPointDispatcher{ (
detail::IntersectionPoint{}) };
intersectionPointDispatcher.SetDevice(Device());
intersectionPointDispatcher.Invoke(rays.HitIdx,
rays.Distance,
rays.Dir,
rays.Origin,
rays.IntersectionX,
rays.IntersectionY,
rays.IntersectionZ);
time = timer.GetElapsedTime();
logger->AddLogData("find_point", time);

@ -1049,16 +1049,17 @@ public:
template <typename DynamicCoordType, typename Precision>
VTKM_CONT void run(Ray<Precision>& rays, LinearBVH& bvh, DynamicCoordType coordsHandle)
{
vtkm::worklet::DispatcherMapField<Intersector, Device>(Intersector(false, bvh))
.Invoke(rays.Dir,
rays.Origin,
rays.Distance,
rays.MinDistance,
rays.MaxDistance,
rays.U,
rays.V,
rays.HitIdx,
coordsHandle);
vtkm::worklet::DispatcherMapField<Intersector> dispatcher(Intersector(false, bvh));
dispatcher.SetDevice(Device());
dispatcher.Invoke(rays.Dir,
rays.Origin,
rays.Distance,
rays.MinDistance,
rays.MaxDistance,
rays.U,
rays.V,
rays.HitIdx,
coordsHandle);
}
template <typename DynamicCoordType, typename Precision>
@ -1068,21 +1069,24 @@ public:
bool returnCellIndex)
{
vtkm::worklet::DispatcherMapField<IntersectorHitIndex<Precision>, Device>(
IntersectorHitIndex<Precision>(false, bvh))
.Invoke(rays.Dir,
rays.HitIdx,
coordsHandle,
rays.Distance,
rays.MinDistance,
rays.MaxDistance,
rays.Origin);
vtkm::worklet::DispatcherMapField<IntersectorHitIndex<Precision>> dispatcher(
IntersectorHitIndex<Precision>(false, bvh));
dispatcher.SetDevice(Device());
dispatcher.Invoke(rays.Dir,
rays.HitIdx,
coordsHandle,
rays.Distance,
rays.MinDistance,
rays.MaxDistance,
rays.Origin);
// Normally we return the index of the triangle hit,
// but in some cases we are only interested in the cell
if (returnCellIndex)
{
vtkm::worklet::DispatcherMapField<CellIndexFilter, Device>(CellIndexFilter(bvh))
.Invoke(rays.HitIdx);
vtkm::worklet::DispatcherMapField<CellIndexFilter> cellIndexFilterDispatcher(
(CellIndexFilter(bvh)));
cellIndexFilterDispatcher.SetDevice(Device());
cellIndexFilterDispatcher.Invoke(rays.HitIdx);
}
// Update ray status
RayOperations::UpdateRayStatus(rays, Device());

@ -818,8 +818,11 @@ void VolumeRendererStructured::RenderOnDevice(vtkm::rendering::raytracing::Ray<P
}
vtkm::cont::Timer<Device> timer;
vtkm::worklet::DispatcherMapField<CalcRayStart, Device>(CalcRayStart(this->SpatialExtent))
.Invoke(rays.Dir, rays.MinDistance, rays.Distance, rays.MaxDistance, rays.Origin);
vtkm::worklet::DispatcherMapField<CalcRayStart> calcRayStartDispatcher(
CalcRayStart(this->SpatialExtent));
calcRayStartDispatcher.SetDevice(Device());
calcRayStartDispatcher.Invoke(
rays.Dir, rays.MinDistance, rays.Distance, rays.MaxDistance, rays.Origin);
vtkm::Float64 time = timer.GetElapsedTime();
logger->AddLogData("calc_ray_start", time);
@ -840,18 +843,19 @@ void VolumeRendererStructured::RenderOnDevice(vtkm::rendering::raytracing::Ray<P
if (isAssocPoints)
{
vtkm::worklet::DispatcherMapField<Sampler<Device, UniformLocator<Device>>, Device>(
vtkm::worklet::DispatcherMapField<Sampler<Device, UniformLocator<Device>>> samplerDispatcher(
Sampler<Device, UniformLocator<Device>>(ColorMap,
vtkm::Float32(ScalarRange.Min),
vtkm::Float32(ScalarRange.Max),
SampleDistance,
locator))
.Invoke(rays.Dir,
rays.Origin,
rays.MinDistance,
rays.MaxDistance,
rays.Buffers.at(0).Buffer,
*ScalarField);
locator));
samplerDispatcher.SetDevice(Device());
samplerDispatcher.Invoke(rays.Dir,
rays.Origin,
rays.MinDistance,
rays.MaxDistance,
rays.Buffers.at(0).Buffer,
*ScalarField);
}
else
{
@ -876,34 +880,37 @@ void VolumeRendererStructured::RenderOnDevice(vtkm::rendering::raytracing::Ray<P
RectilinearLocator<Device> locator(vertices, Cellset);
if (isAssocPoints)
{
vtkm::worklet::DispatcherMapField<Sampler<Device, RectilinearLocator<Device>>, Device>(
Sampler<Device, RectilinearLocator<Device>>(ColorMap,
vtkm::Float32(ScalarRange.Min),
vtkm::Float32(ScalarRange.Max),
SampleDistance,
locator))
.Invoke(rays.Dir,
rays.Origin,
rays.MinDistance,
rays.MaxDistance,
rays.Buffers.at(0).Buffer,
*ScalarField);
vtkm::worklet::DispatcherMapField<Sampler<Device, RectilinearLocator<Device>>>
samplerDispatcher(
Sampler<Device, RectilinearLocator<Device>>(ColorMap,
vtkm::Float32(ScalarRange.Min),
vtkm::Float32(ScalarRange.Max),
SampleDistance,
locator));
samplerDispatcher.SetDevice(Device());
samplerDispatcher.Invoke(rays.Dir,
rays.Origin,
rays.MinDistance,
rays.MaxDistance,
rays.Buffers.at(0).Buffer,
*ScalarField);
}
else
{
vtkm::worklet::DispatcherMapField<SamplerCellAssoc<Device, RectilinearLocator<Device>>,
Device>(
SamplerCellAssoc<Device, RectilinearLocator<Device>>(ColorMap,
vtkm::Float32(ScalarRange.Min),
vtkm::Float32(ScalarRange.Max),
SampleDistance,
locator))
.Invoke(rays.Dir,
rays.Origin,
rays.MinDistance,
rays.MaxDistance,
rays.Buffers.at(0).Buffer,
*ScalarField);
vtkm::worklet::DispatcherMapField<SamplerCellAssoc<Device, RectilinearLocator<Device>>>
rectilinearLocatorDispatcher(
SamplerCellAssoc<Device, RectilinearLocator<Device>>(ColorMap,
vtkm::Float32(ScalarRange.Min),
vtkm::Float32(ScalarRange.Max),
SampleDistance,
locator));
rectilinearLocatorDispatcher.SetDevice(Device());
rectilinearLocatorDispatcher.Invoke(rays.Dir,
rays.Origin,
rays.MinDistance,
rays.MaxDistance,
rays.Buffers.at(0).Buffer,
*ScalarField);
}
}

@ -78,7 +78,8 @@ struct AverageByKey
{
VTKM_IS_DEVICE_ADAPTER_TAG(Device);
vtkm::worklet::DispatcherReduceByKey<AverageWorklet, Device> dispatcher;
vtkm::worklet::DispatcherReduceByKey<AverageWorklet> dispatcher;
dispatcher.SetDevice(Device());
dispatcher.Invoke(keys, inValues, outAverages);
}
@ -175,8 +176,9 @@ struct AverageByKey
keyArraySorted, inputZipHandle, outputKeyArray, outputZipHandle, vtkm::Add());
// get average
DispatcherMapField<DivideWorklet, DeviceAdapter>().Invoke(
sumArray, countArray, outputValueArray);
DispatcherMapField<DivideWorklet> dispatcher;
dispatcher.SetDevice(DeviceAdapter());
dispatcher.Invoke(sumArray, countArray, outputValueArray);
}
};
}

@ -89,7 +89,8 @@ struct CellDeepCopy
vtkm::cont::ArrayHandle<vtkm::IdComponent, NumIndicesStorage> numIndices;
vtkm::worklet::DispatcherMapTopology<CountCellPoints, Device> countDispatcher;
vtkm::worklet::DispatcherMapTopology<CountCellPoints> countDispatcher;
countDispatcher.SetDevice(Device());
countDispatcher.Invoke(inCellSet, numIndices);
vtkm::cont::ArrayHandle<vtkm::UInt8, ShapeStorage> shapes;
@ -100,7 +101,8 @@ struct CellDeepCopy
vtkm::cont::ConvertNumComponentsToOffsets(numIndices, offsets, connectivitySize);
connectivity.Allocate(connectivitySize);
vtkm::worklet::DispatcherMapTopology<PassCellStructure, Device> passDispatcher;
vtkm::worklet::DispatcherMapTopology<PassCellStructure> passDispatcher;
passDispatcher.SetDevice(Device());
passDispatcher.Invoke(
inCellSet, shapes, vtkm::cont::make_ArrayHandleGroupVecVariable(connectivity, offsets));

@ -496,8 +496,9 @@ public:
vtkm::cont::ArrayHandle<ClipStats> stats;
ComputeStats<DeviceAdapter> computeStats(value, clipTablesDevicePortal, invert);
DispatcherMapTopology<ComputeStats<DeviceAdapter>, DeviceAdapter>(computeStats)
.Invoke(cellSet, scalars, clipTableIdxs, stats);
DispatcherMapTopology<ComputeStats<DeviceAdapter>> computeStatsDispatcher(computeStats);
computeStatsDispatcher.SetDevice(DeviceAdapter());
computeStatsDispatcher.Invoke(cellSet, scalars, clipTableIdxs, stats);
// compute offsets for each invocation
ClipStats zero;
@ -522,15 +523,17 @@ public:
this->CellIdMap.Allocate(total.NumberOfCells);
GenerateCellSet<DeviceAdapter> generateCellSet(value, clipTablesDevicePortal);
DispatcherMapTopology<GenerateCellSet<DeviceAdapter>, DeviceAdapter>(generateCellSet)
.Invoke(cellSet,
scalars,
clipTableIdxs,
cellSetIndices,
outConnectivity,
newPoints,
newPointsConnectivityReverseMap,
this->CellIdMap);
DispatcherMapTopology<GenerateCellSet<DeviceAdapter>> generateCellSetDispatcher(
generateCellSet);
generateCellSetDispatcher.SetDevice(DeviceAdapter());
generateCellSetDispatcher.Invoke(cellSet,
scalars,
clipTableIdxs,
cellSetIndices,
outConnectivity,
newPoints,
newPointsConnectivityReverseMap,
this->CellIdMap);
cellSetIndices.ReleaseResources();
// Step 3. remove duplicates from the list of new points

@ -192,12 +192,14 @@ public:
{
if (CartesianToSpherical)
{
vtkm::worklet::DispatcherMapField<detail::CarToSphere<T>, DeviceAdapterTag> dispatcher;
vtkm::worklet::DispatcherMapField<detail::CarToSphere<T>> dispatcher;
dispatcher.SetDevice(DeviceAdapterTag());
dispatcher.Invoke(inPoints, outPoints);
}
else
{
vtkm::worklet::DispatcherMapField<detail::SphereToCar<T>, DeviceAdapterTag> dispatcher;
vtkm::worklet::DispatcherMapField<detail::SphereToCar<T>> dispatcher;
dispatcher.SetDevice(DeviceAdapterTag());
dispatcher.Invoke(inPoints, outPoints);
}
}
@ -209,12 +211,14 @@ public:
{
if (CartesianToSpherical)
{
vtkm::worklet::DispatcherMapField<detail::CarToSphere<T>, DeviceAdapterTag> dispatcher;
vtkm::worklet::DispatcherMapField<detail::CarToSphere<T>> dispatcher;
dispatcher.SetDevice(DeviceAdapterTag());
dispatcher.Invoke(inPoints, outPoints);
}
else
{
vtkm::worklet::DispatcherMapField<detail::SphereToCar<T>, DeviceAdapterTag> dispatcher;
vtkm::worklet::DispatcherMapField<detail::SphereToCar<T>> dispatcher;
dispatcher.SetDevice(DeviceAdapterTag());
dispatcher.Invoke(inPoints, outPoints);
}
}

@ -20,7 +20,6 @@
#ifndef vtk_m_worklet_Dispatcher_MapField_h
#define vtk_m_worklet_Dispatcher_MapField_h
#include <vtkm/cont/DeviceAdapter.h>
#include <vtkm/worklet/WorkletMapField.h>
#include <vtkm/worklet/internal/DispatcherBase.h>
@ -31,16 +30,15 @@ namespace worklet
/// \brief Dispatcher for worklets that inherit from \c WorkletMapField.
///
template <typename WorkletType, typename Device = VTKM_DEFAULT_DEVICE_ADAPTER_TAG>
template <typename WorkletType>
class DispatcherMapField
: public vtkm::worklet::internal::DispatcherBase<DispatcherMapField<WorkletType, Device>,
: public vtkm::worklet::internal::DispatcherBase<DispatcherMapField<WorkletType>,
WorkletType,
vtkm::worklet::WorkletMapField>
{
using Superclass =
vtkm::worklet::internal::DispatcherBase<DispatcherMapField<WorkletType, Device>,
WorkletType,
vtkm::worklet::WorkletMapField>;
using Superclass = vtkm::worklet::internal::DispatcherBase<DispatcherMapField<WorkletType>,
WorkletType,
vtkm::worklet::WorkletMapField>;
using ScatterType = typename Superclass::ScatterType;
public:
@ -80,7 +78,7 @@ public:
// A MapField is a pretty straightforward dispatch. Once we know the number
// of invocations, the superclass can take care of the rest.
this->BasicInvoke(invocation, numInstances, Device());
this->BasicInvoke(invocation, numInstances);
}
};
}

@ -32,14 +32,14 @@ namespace worklet
/// \brief Dispatcher for worklets that inherit from \c WorkletMapTopology.
///
template <typename WorkletType, typename Device = VTKM_DEFAULT_DEVICE_ADAPTER_TAG>
template <typename WorkletType>
class DispatcherMapTopology
: public vtkm::worklet::internal::DispatcherBase<DispatcherMapTopology<WorkletType, Device>,
: public vtkm::worklet::internal::DispatcherBase<DispatcherMapTopology<WorkletType>,
WorkletType,
vtkm::worklet::detail::WorkletMapTopologyBase>
{
using Superclass =
vtkm::worklet::internal::DispatcherBase<DispatcherMapTopology<WorkletType, Device>,
vtkm::worklet::internal::DispatcherBase<DispatcherMapTopology<WorkletType>,
WorkletType,
vtkm::worklet::detail::WorkletMapTopologyBase>;
using ScatterType = typename Superclass::ScatterType;
@ -81,8 +81,7 @@ public:
// Now that we have the input domain, we can extract the range of the
// scheduling and call BadicInvoke.
this->BasicInvoke(
invocation, internal::scheduling_range(inputDomain, SchedulingRangeType{}), Device());
this->BasicInvoke(invocation, internal::scheduling_range(inputDomain, SchedulingRangeType{}));
}
};
}

@ -33,14 +33,14 @@ namespace worklet
/// \brief Dispatcher for worklets that inherit from \c WorkletPointNeighborhood.
///
template <typename WorkletType, typename Device = VTKM_DEFAULT_DEVICE_ADAPTER_TAG>
template <typename WorkletType>
class DispatcherPointNeighborhood
: public vtkm::worklet::internal::DispatcherBase<DispatcherPointNeighborhood<WorkletType, Device>,
: public vtkm::worklet::internal::DispatcherBase<DispatcherPointNeighborhood<WorkletType>,
WorkletType,
vtkm::worklet::WorkletPointNeighborhoodBase>
{
using Superclass =
vtkm::worklet::internal::DispatcherBase<DispatcherPointNeighborhood<WorkletType, Device>,
vtkm::worklet::internal::DispatcherBase<DispatcherPointNeighborhood<WorkletType>,
WorkletType,
vtkm::worklet::WorkletPointNeighborhoodBase>;
using ScatterType = typename Superclass::ScatterType;
@ -82,7 +82,7 @@ public:
// This is pretty straightforward dispatch. Once we know the number
// of invocations, the superclass can take care of the rest.
this->BasicInvoke(invocation, inputRange, Device());
this->BasicInvoke(invocation, inputRange);
}
};
}

@ -33,16 +33,15 @@ namespace worklet
/// \brief Dispatcher for worklets that inherit from \c WorkletReduceByKey.
///
template <typename WorkletType, typename Device = VTKM_DEFAULT_DEVICE_ADAPTER_TAG>
template <typename WorkletType>
class DispatcherReduceByKey
: public vtkm::worklet::internal::DispatcherBase<DispatcherReduceByKey<WorkletType, Device>,
: public vtkm::worklet::internal::DispatcherBase<DispatcherReduceByKey<WorkletType>,
WorkletType,
vtkm::worklet::WorkletReduceByKey>
{
using Superclass =
vtkm::worklet::internal::DispatcherBase<DispatcherReduceByKey<WorkletType, Device>,
WorkletType,
vtkm::worklet::WorkletReduceByKey>;
using Superclass = vtkm::worklet::internal::DispatcherBase<DispatcherReduceByKey<WorkletType>,
WorkletType,
vtkm::worklet::WorkletReduceByKey>;
using ScatterType = typename Superclass::ScatterType;
public:
@ -83,7 +82,7 @@ public:
// Now that we have the input domain, we can extract the range of the
// scheduling and call BadicInvoke.
this->BasicInvoke(invocation, inputDomain.GetInputRange(), Device());
this->BasicInvoke(invocation, inputDomain.GetInputRange());
}
};
}

@ -33,7 +33,22 @@ namespace worklet
namespace detail
{
template <typename ControlInterface, typename Device>
struct DispatcherStreamingTryExecuteFunctor
{
template <typename Device, typename DispatcherBaseType, typename Invocation, typename RangeType>
VTKM_CONT bool operator()(Device device,
const DispatcherBaseType* self,
Invocation& invocation,
const RangeType& dimensions,
const RangeType& globalIndexOffset)
{
self->InvokeTransportParameters(
invocation, dimensions, globalIndexOffset, self->Scatter.GetOutputRange(dimensions), device);
return true;
}
};
template <typename ControlInterface>
struct DispatcherStreamingMapFieldTransformFunctor
{
vtkm::Id BlockIndex;
@ -116,7 +131,7 @@ struct DispatcherStreamingMapFieldTransformFunctor
}
};
template <typename ControlInterface, typename Device>
template <typename ControlInterface>
struct DispatcherStreamingMapFieldTransferFunctor
{
VTKM_CONT
@ -163,14 +178,14 @@ struct DispatcherStreamingMapFieldTransferFunctor
/// \brief Dispatcher for worklets that inherit from \c WorkletMapField.
///
template <typename WorkletType, typename Device = VTKM_DEFAULT_DEVICE_ADAPTER_TAG>
template <typename WorkletType>
class DispatcherStreamingMapField
: public vtkm::worklet::internal::DispatcherBase<DispatcherStreamingMapField<WorkletType, Device>,
: public vtkm::worklet::internal::DispatcherBase<DispatcherStreamingMapField<WorkletType>,
WorkletType,
vtkm::worklet::WorkletMapField>
{
using Superclass =
vtkm::worklet::internal::DispatcherBase<DispatcherStreamingMapField<WorkletType, Device>,
vtkm::worklet::internal::DispatcherBase<DispatcherStreamingMapField<WorkletType>,
WorkletType,
vtkm::worklet::WorkletMapField>;
using ScatterType = typename Superclass::ScatterType;
@ -199,17 +214,23 @@ public:
VTKM_CONT
void SetNumberOfBlocks(vtkm::Id numberOfBlocks) { NumberOfBlocks = numberOfBlocks; }
template <typename Invocation, typename DeviceAdapter>
friend struct detail::DispatcherStreamingTryExecuteFunctor;
template <typename Invocation>
VTKM_CONT void BasicInvoke(Invocation& invocation,
vtkm::Id numInstances,
vtkm::Id globalIndexOffset,
DeviceAdapter device) const
vtkm::Id globalIndexOffset) const
{
this->InvokeTransportParameters(invocation,
numInstances,
globalIndexOffset,
this->Scatter.GetOutputRange(numInstances),
device);
bool success = vtkm::cont::TryExecuteOnDevice(this->GetDevice(),
detail::DispatcherStreamingTryExecuteFunctor(),
this,
invocation,
numInstances,
globalIndexOffset);
if (!success)
{
throw vtkm::cont::ErrorExecution("Failed to execute worklet on any device.");
}
}
template <typename Invocation>
@ -232,11 +253,9 @@ public:
blockSize += 1;
using TransformFunctorType =
detail::DispatcherStreamingMapFieldTransformFunctor<typename Invocation::ControlInterface,
Device>;
detail::DispatcherStreamingMapFieldTransformFunctor<typename Invocation::ControlInterface>;
using TransferFunctorType =
detail::DispatcherStreamingMapFieldTransferFunctor<typename Invocation::ControlInterface,
Device>;
detail::DispatcherStreamingMapFieldTransferFunctor<typename Invocation::ControlInterface>;
for (vtkm::Id block = 0; block < NumberOfBlocks; block++)
{
@ -255,7 +274,7 @@ public:
using ChangedType = typename Invocation::template ChangeParametersType<ReportedType>::type;
ChangedType changedParams = invocation.ChangeParameters(newParams);
this->BasicInvoke(changedParams, numberOfInstances, globalIndexOffset, Device());
this->BasicInvoke(changedParams, numberOfInstances, globalIndexOffset);
// Loop over parameters again to sync results for this block into control array
using ParameterInterfaceType2 = typename ChangedType::ParameterInterface;

@ -737,8 +737,9 @@ public:
// Create a worklet to count the number of external faces on each cell
vtkm::cont::ArrayHandle<vtkm::IdComponent> numExternalFaces;
vtkm::worklet::DispatcherMapTopology<NumExternalFacesPerStructuredCell, DeviceAdapter>
vtkm::worklet::DispatcherMapTopology<NumExternalFacesPerStructuredCell>
numExternalFacesDispatcher((NumExternalFacesPerStructuredCell(MinPoint, MaxPoint)));
numExternalFacesDispatcher.SetDevice(DeviceAdapter());
numExternalFacesDispatcher.Invoke(inCellSet, numExternalFaces, coordData);
@ -761,9 +762,10 @@ public:
// information to.
faceConnectivity.Allocate(connectivitySize);
vtkm::worklet::DispatcherMapTopology<BuildConnectivityStructured, DeviceAdapter>
vtkm::worklet::DispatcherMapTopology<BuildConnectivityStructured>
buildConnectivityStructuredDispatcher(BuildConnectivityStructured(MinPoint, MaxPoint),
scatterCellToExternalFace);
buildConnectivityStructuredDispatcher.SetDevice(DeviceAdapter());
buildConnectivityStructuredDispatcher.Invoke(
inCellSet,
@ -797,7 +799,8 @@ public:
//Create a worklet to map the number of faces to each cell
vtkm::cont::ArrayHandle<vtkm::IdComponent> facesPerCell;
vtkm::worklet::DispatcherMapTopology<NumFacesPerCell, DeviceAdapter> numFacesDispatcher;
vtkm::worklet::DispatcherMapTopology<NumFacesPerCell> numFacesDispatcher;
numFacesDispatcher.SetDevice(DeviceAdapter());
numFacesDispatcher.Invoke(inCellSet, facesPerCell);
@ -813,7 +816,8 @@ public:
if (this->PassPolyData)
{
vtkm::cont::ArrayHandle<vtkm::IdComponent> isPolyDataCell;
vtkm::worklet::DispatcherMapTopology<IsPolyDataCell, DeviceAdapter> isPolyDataCellDispatcher;
vtkm::worklet::DispatcherMapTopology<IsPolyDataCell> isPolyDataCellDispatcher;
isPolyDataCellDispatcher.SetDevice(DeviceAdapter());
isPolyDataCellDispatcher.Invoke(inCellSet, isPolyDataCell);
@ -823,16 +827,18 @@ public:
if (scatterPolyDataCells.GetOutputRange(inCellSet.GetNumberOfCells()) != 0)
{
vtkm::worklet::DispatcherMapTopology<CountPolyDataCellPoints, DeviceAdapter>
vtkm::worklet::DispatcherMapTopology<CountPolyDataCellPoints>
countPolyDataCellPointsDispatcher(scatterPolyDataCells);
countPolyDataCellPointsDispatcher.SetDevice(DeviceAdapter());
countPolyDataCellPointsDispatcher.Invoke(inCellSet, polyDataPointCount);
vtkm::cont::ConvertNumComponentsToOffsets(
polyDataPointCount, polyDataOffsets, polyDataConnectivitySize);
vtkm::worklet::DispatcherMapTopology<PassPolyDataCells, DeviceAdapter>
passPolyDataCellsDispatcher(scatterPolyDataCells);
vtkm::worklet::DispatcherMapTopology<PassPolyDataCells> passPolyDataCellsDispatcher(
scatterPolyDataCells);
passPolyDataCellsDispatcher.SetDevice(DeviceAdapter());
polyDataConnectivity.Allocate(polyDataConnectivitySize);
@ -869,23 +875,25 @@ public:
vtkm::cont::ArrayHandle<vtkm::HashType> faceHashes;
vtkm::cont::ArrayHandle<vtkm::Id> originCells;
vtkm::cont::ArrayHandle<vtkm::IdComponent> originFaces;
vtkm::worklet::DispatcherMapTopology<FaceHash, DeviceAdapter> faceHashDispatcher(
scatterCellToFace);
vtkm::worklet::DispatcherMapTopology<FaceHash> faceHashDispatcher(scatterCellToFace);
faceHashDispatcher.SetDevice(DeviceAdapter());
faceHashDispatcher.Invoke(inCellSet, faceHashes, originCells, originFaces);
vtkm::worklet::Keys<vtkm::HashType> faceKeys(faceHashes, DeviceAdapter());
vtkm::cont::ArrayHandle<vtkm::IdComponent> faceOutputCount;
vtkm::worklet::DispatcherReduceByKey<FaceCounts, DeviceAdapter> faceCountDispatcher;
vtkm::worklet::DispatcherReduceByKey<FaceCounts> faceCountDispatcher;
faceCountDispatcher.SetDevice(DeviceAdapter());
faceCountDispatcher.Invoke(faceKeys, inCellSet, originCells, originFaces, faceOutputCount);
auto scatterCullInternalFaces = NumPointsPerFace::MakeScatter(faceOutputCount, DeviceAdapter());
PointCountArrayType facePointCount;
vtkm::worklet::DispatcherReduceByKey<NumPointsPerFace, DeviceAdapter> pointsPerFaceDispatcher(
vtkm::worklet::DispatcherReduceByKey<NumPointsPerFace> pointsPerFaceDispatcher(
scatterCullInternalFaces);
pointsPerFaceDispatcher.SetDevice(DeviceAdapter());
pointsPerFaceDispatcher.Invoke(faceKeys, inCellSet, originCells, originFaces, facePointCount);
@ -900,8 +908,9 @@ public:
// information to.
faceConnectivity.Allocate(connectivitySize);
vtkm::worklet::DispatcherReduceByKey<BuildConnectivity, DeviceAdapter>
buildConnectivityDispatcher(scatterCullInternalFaces);
vtkm::worklet::DispatcherReduceByKey<BuildConnectivity> buildConnectivityDispatcher(
scatterCullInternalFaces);
buildConnectivityDispatcher.SetDevice(DeviceAdapter());
vtkm::cont::ArrayHandle<vtkm::Id> faceToCellIdMap;

@ -169,7 +169,8 @@ public:
extractInside,
extractBoundaryCells,
extractOnlyBoundaryCells);
DispatcherMapTopology<ExtractCellsByVOI, DeviceAdapter> dispatcher(worklet);
DispatcherMapTopology<ExtractCellsByVOI> dispatcher(worklet);
dispatcher.SetDevice(DeviceAdapter());
dispatcher.Invoke(cellSet, coordinates, passFlags);
vtkm::cont::ArrayHandleCounting<vtkm::Id> indices =

@ -107,7 +107,8 @@ public:
vtkm::cont::ArrayHandle<bool> passFlags;
ExtractPointsByVOI worklet(implicitFunction.PrepareForExecution(device), extractInside);
DispatcherMapTopology<ExtractPointsByVOI, DeviceAdapter> dispatcher(worklet);
DispatcherMapTopology<ExtractPointsByVOI> dispatcher(worklet);
dispatcher.SetDevice(DeviceAdapter());
dispatcher.Invoke(cellSet, coordinates, passFlags);
vtkm::cont::ArrayHandleCounting<vtkm::Id> indices =

@ -91,8 +91,9 @@ public:
///// calculate information content of each bin using self-define worklet /////
vtkm::cont::ArrayHandle<vtkm::Float64> informationContent;
SetBinInformationContent binWorklet(static_cast<vtkm::Float64>(freqSum));
vtkm::worklet::DispatcherMapField<SetBinInformationContent, DeviceAdapter>
setBinInformationContentDispatcher(binWorklet);
vtkm::worklet::DispatcherMapField<SetBinInformationContent> setBinInformationContentDispatcher(
binWorklet);
setBinInformationContentDispatcher.SetDevice(DeviceAdapter());
setBinInformationContentDispatcher.Invoke(binArray, informationContent);
///// calculate entropy by summing up information conetent of all bins /////

@ -166,8 +166,9 @@ public:
// Worklet to set the bin number for each data value
SetHistogramBin<FieldType> binWorklet(numberOfBins, fieldMinValue, fieldDelta);
vtkm::worklet::DispatcherMapField<SetHistogramBin<FieldType>, DeviceAdapter>
setHistogramBinDispatcher(binWorklet);
vtkm::worklet::DispatcherMapField<SetHistogramBin<FieldType>> setHistogramBinDispatcher(
binWorklet);
setHistogramBinDispatcher.SetDevice(DeviceAdapter());
setHistogramBinDispatcher.Invoke(fieldArray, binIndex);
// Sort the resulting bin array for counting
@ -179,7 +180,8 @@ public:
DeviceAlgorithms::UpperBounds(binIndex, binCounter, totalCount);
// Difference between adjacent items is the bin count
vtkm::worklet::DispatcherMapField<AdjacentDifference, DeviceAdapter> dispatcher;
vtkm::worklet::DispatcherMapField<AdjacentDifference> dispatcher;
dispatcher.SetDevice(DeviceAdapter());
dispatcher.Invoke(binCounter, totalCount, binArray);
//update the users data

@ -152,8 +152,9 @@ public:
pow4Array.Allocate(dataSize);
// Raw moments via Worklet
vtkm::worklet::DispatcherMapField<CalculatePowers, DeviceAdapter> calculatePowersDispatcher(
vtkm::worklet::DispatcherMapField<CalculatePowers> calculatePowersDispatcher(
CalculatePowers(4));
calculatePowersDispatcher.SetDevice(DeviceAdapter());
calculatePowersDispatcher.Invoke(fieldArray, pow1Array, pow2Array, pow3Array, pow4Array);
// Accumulate the results using ScanInclusive
@ -163,8 +164,9 @@ public:
statinfo.rawMoment[FOURTH] = DeviceAlgorithms::ScanInclusive(pow4Array, pow4Array) / numValues;
// Subtract the mean from every value and leave in tempArray
vtkm::worklet::DispatcherMapField<SubtractConst, DeviceAdapter> subtractConstDispatcher(
vtkm::worklet::DispatcherMapField<SubtractConst> subtractConstDispatcher(
SubtractConst(statinfo.mean));
subtractConstDispatcher.SetDevice(DeviceAdapter());
subtractConstDispatcher.Invoke(fieldArray, tempArray);
// Calculate sums of powers on the (value - mean) array

@ -60,7 +60,8 @@ struct DeducedPointGrad
template <typename CellSetType>
void operator()(const CellSetType& cellset) const
{
vtkm::worklet::DispatcherMapTopology<PointGradient<T>, Device> dispatcher;
vtkm::worklet::DispatcherMapTopology<PointGradient<T>> dispatcher;
dispatcher.SetDevice(Device());
dispatcher.Invoke(cellset, //topology to iterate on a per point basis
cellset, //whole cellset in
*this->Points,
@ -70,7 +71,8 @@ struct DeducedPointGrad
void operator()(const vtkm::cont::CellSetStructured<3>& cellset) const
{
vtkm::worklet::DispatcherPointNeighborhood<StructuredPointGradient<T>, Device> dispatcher;
vtkm::worklet::DispatcherPointNeighborhood<StructuredPointGradient<T>> dispatcher;
dispatcher.SetDevice(Device());
dispatcher.Invoke(cellset, //topology to iterate on a per point basis
*this->Points,
*this->Field,
@ -81,7 +83,8 @@ struct DeducedPointGrad
void operator()(const vtkm::cont::CellSetPermutation<vtkm::cont::CellSetStructured<3>,
PermIterType>& cellset) const
{
vtkm::worklet::DispatcherPointNeighborhood<StructuredPointGradient<T>, Device> dispatcher;
vtkm::worklet::DispatcherPointNeighborhood<StructuredPointGradient<T>> dispatcher;
dispatcher.SetDevice(Device());
dispatcher.Invoke(cellset, //topology to iterate on a per point basis
*this->Points,
*this->Field,
@ -90,7 +93,8 @@ struct DeducedPointGrad
void operator()(const vtkm::cont::CellSetStructured<2>& cellset) const
{
vtkm::worklet::DispatcherPointNeighborhood<StructuredPointGradient<T>, Device> dispatcher;
vtkm::worklet::DispatcherPointNeighborhood<StructuredPointGradient<T>> dispatcher;
dispatcher.SetDevice(Device());
dispatcher.Invoke(cellset, //topology to iterate on a per point basis
*this->Points,
*this->Field,
@ -101,7 +105,8 @@ struct DeducedPointGrad
void operator()(const vtkm::cont::CellSetPermutation<vtkm::cont::CellSetStructured<2>,
PermIterType>& cellset) const
{
vtkm::worklet::DispatcherPointNeighborhood<StructuredPointGradient<T>, Device> dispatcher;
vtkm::worklet::DispatcherPointNeighborhood<StructuredPointGradient<T>> dispatcher;
dispatcher.SetDevice(Device());
dispatcher.Invoke(cellset, //topology to iterate on a per point basis
*this->Points,
*this->Field,
@ -273,11 +278,11 @@ public:
DeviceAdapter)
{
using DispatcherType =
vtkm::worklet::DispatcherMapTopology<vtkm::worklet::gradient::CellGradient<T>, DeviceAdapter>;
vtkm::worklet::DispatcherMapTopology<vtkm::worklet::gradient::CellGradient<T>>;
vtkm::worklet::gradient::CellGradient<T> worklet;
DispatcherType dispatcher(worklet);
dispatcher.SetDevice(DeviceAdapter());
dispatcher.Invoke(cells, coords, field, extraOutput);
return extraOutput.Gradient;

@ -431,8 +431,8 @@ struct KernelSplatterFilterUniformGrid
IdHandleType localNeighborIds;
GetFootprint footprint_worklet(origin_, spacing_, pointDimensions, kernel_);
vtkm::worklet::DispatcherMapField<GetFootprint, DeviceAdapter> footprintDispatcher(
footprint_worklet);
vtkm::worklet::DispatcherMapField<GetFootprint> footprintDispatcher(footprint_worklet);
footprintDispatcher.SetDevice(DeviceAdapter());
START_TIMER_BLOCK(GetFootprint)
footprintDispatcher.Invoke(
@ -495,7 +495,8 @@ struct KernelSplatterFilterUniformGrid
IdPermType offsets(neighbor2SplatId, numNeighborsExclusiveSum);
debug::OutputArrayDebug(offsets, "offsets");
vtkm::worklet::DispatcherMapField<ComputeLocalNeighborId, DeviceAdapter> idDispatcher;
vtkm::worklet::DispatcherMapField<ComputeLocalNeighborId> idDispatcher;
idDispatcher.SetDevice(DeviceAdapter());
START_TIMER_BLOCK(idDispatcher)
idDispatcher.Invoke(modulii, offsets, localNeighborIds);
END_TIMER_BLOCK(idDispatcher)
@ -528,8 +529,8 @@ struct KernelSplatterFilterUniformGrid
FloatHandleType splatValues;
GetSplatValue splatterDispatcher_worklet(origin_, spacing_, pointDimensions, kernel_);
vtkm::worklet::DispatcherMapField<GetSplatValue, DeviceAdapter> splatterDispatcher(
splatterDispatcher_worklet);
vtkm::worklet::DispatcherMapField<GetSplatValue> splatterDispatcher(splatterDispatcher_worklet);
splatterDispatcher.SetDevice(DeviceAdapter());
START_TIMER_BLOCK(GetSplatValue)
splatterDispatcher.Invoke(ptSplatPoints,
@ -582,7 +583,8 @@ struct KernelSplatterFilterUniformGrid
// initialize each field value to zero to begin with
//---------------------------------------------------------------
IdCountingType indexArray(vtkm::Id(0), 1, numVolumePoints);
vtkm::worklet::DispatcherMapField<zero_voxel, DeviceAdapter> zeroDispatcher;
vtkm::worklet::DispatcherMapField<zero_voxel> zeroDispatcher;
zeroDispatcher.SetDevice(DeviceAdapter());
zeroDispatcher.Invoke(indexArray, scalarSplatOutput);
//
indexArray.ReleaseResources();
@ -591,7 +593,8 @@ struct KernelSplatterFilterUniformGrid
// Scatter operation to write the previously-computed splat
// value sums into their corresponding entries in the output array
//---------------------------------------------------------------
vtkm::worklet::DispatcherMapField<UpdateVoxelSplats, DeviceAdapter> scatterDispatcher;
vtkm::worklet::DispatcherMapField<UpdateVoxelSplats> scatterDispatcher;
scatterDispatcher.SetDevice(DeviceAdapter());
START_TIMER_BLOCK(UpdateVoxelSplats)
scatterDispatcher.Invoke(uniqueVoxelIds, voxelSplatSums, scalarSplatOutput);

@ -469,7 +469,8 @@ void MergeDuplicates(const vtkm::cont::ArrayHandle<KeyType, KeyStorage>& origina
input_keys.ReleaseResources();
{
vtkm::worklet::DispatcherReduceByKey<MergeDuplicateValues, DeviceAdapterTag> dispatcher;
vtkm::worklet::DispatcherReduceByKey<MergeDuplicateValues> dispatcher;
dispatcher.SetDevice(DeviceAdapterTag());
vtkm::cont::ArrayHandle<vtkm::Id> writeCells;
vtkm::cont::ArrayHandle<vtkm::FloatDefault> writeWeights;
dispatcher.Invoke(keys, weights, cellids, writeWeights, writeCells);
@ -483,7 +484,8 @@ void MergeDuplicates(const vtkm::cont::ArrayHandle<KeyType, KeyStorage>& origina
uniqueKeys, original_keys, connectivity, marchingcubes::MultiContourLess());
//update the edge ids
vtkm::worklet::DispatcherMapField<CopyEdgeIds, DeviceAdapterTag> edgeDispatcher;
vtkm::worklet::DispatcherMapField<CopyEdgeIds> edgeDispatcher;
edgeDispatcher.SetDevice(DeviceAdapterTag());
edgeDispatcher.Invoke(uniqueKeys, edgeIds);
}
@ -677,13 +679,15 @@ struct GenerateNormalsDeduced
// The final normal is interpolated from the two gradient values and stored
// in the normals array.
//
vtkm::worklet::DispatcherMapTopology<NormalsWorkletPass1, DeviceAdapterTag>
dispatcherNormalsPass1(NormalsWorkletPass1::MakeScatter(*edges));
vtkm::worklet::DispatcherMapTopology<NormalsWorkletPass1> dispatcherNormalsPass1(
NormalsWorkletPass1::MakeScatter(*edges));
dispatcherNormalsPass1.SetDevice(DeviceAdapterTag());
dispatcherNormalsPass1.Invoke(
*cellset, *cellset, coordinates, marchingcubes::make_ScalarField(*field), *normals);
vtkm::worklet::DispatcherMapTopology<NormalsWorkletPass2, DeviceAdapterTag>
dispatcherNormalsPass2(NormalsWorkletPass2::MakeScatter(*edges));
vtkm::worklet::DispatcherMapTopology<NormalsWorkletPass2> dispatcherNormalsPass2(
NormalsWorkletPass2::MakeScatter(*edges));
dispatcherNormalsPass2.SetDevice(DeviceAdapterTag());
dispatcherNormalsPass2.Invoke(
*cellset, *cellset, coordinates, marchingcubes::make_ScalarField(*field), *weights, *normals);
}
@ -797,8 +801,8 @@ public:
{
using vtkm::worklet::marchingcubes::MapPointField;
MapPointField applyToField;
vtkm::worklet::DispatcherMapField<MapPointField, DeviceAdapter> applyFieldDispatcher(
applyToField);
vtkm::worklet::DispatcherMapField<MapPointField> applyFieldDispatcher(applyToField);
applyFieldDispatcher.SetDevice(DeviceAdapter());
vtkm::cont::ArrayHandle<ValueType> output;
applyFieldDispatcher.Invoke(
@ -940,12 +944,10 @@ private:
using vtkm::worklet::marchingcubes::MapPointField;
// Setup the Dispatcher Typedefs
using ClassifyDispatcher =
typename vtkm::worklet::DispatcherMapTopology<ClassifyCell<ValueType>, DeviceAdapter>;
using ClassifyDispatcher = vtkm::worklet::DispatcherMapTopology<ClassifyCell<ValueType>>;
using GenerateDispatcher =
typename vtkm::worklet::DispatcherMapTopology<EdgeWeightGenerate<ValueType, DeviceAdapter>,
DeviceAdapter>;
vtkm::worklet::DispatcherMapTopology<EdgeWeightGenerate<ValueType, DeviceAdapter>>;
vtkm::cont::ArrayHandle<ValueType> isoValuesHandle =
vtkm::cont::make_ArrayHandle(isovalues, numIsoValues);
@ -957,6 +959,7 @@ private:
{
ClassifyCell<ValueType> classifyCell;
ClassifyDispatcher classifyCellDispatcher(classifyCell);
classifyCellDispatcher.SetDevice(DeviceAdapter());
classifyCellDispatcher.Invoke(
isoValuesHandle, inputField, cells, numOutputTrisPerCell, this->NumTrianglesTable);
}
@ -983,6 +986,7 @@ private:
EdgeWeightGenerate<ValueType, DeviceAdapter> weightGenerate(metaData);
GenerateDispatcher edgeDispatcher(weightGenerate, scatter);
edgeDispatcher.SetDevice(DeviceAdapter());
edgeDispatcher.Invoke(
cells,
//cast to a scalar field if not one, as cellderivative only works on those
@ -1034,8 +1038,8 @@ private:
//generate the vertices's
MapPointField applyToField;
vtkm::worklet::DispatcherMapField<MapPointField, DeviceAdapter> applyFieldDispatcher(
applyToField);
vtkm::worklet::DispatcherMapField<MapPointField> applyFieldDispatcher(applyToField);
applyFieldDispatcher.SetDevice(DeviceAdapter());
applyFieldDispatcher.Invoke(
this->InterpolationEdgeIds, this->InterpolationWeights, coordinateSystem, vertices);

@ -80,9 +80,9 @@ public:
vtkm::cont::ArrayHandle<vtkm::Float64> informationContent;
vtkm::worklet::histogram::SetBinInformationContent binWorklet(
static_cast<vtkm::Float64>(freqSum));
vtkm::worklet::DispatcherMapField<vtkm::worklet::histogram::SetBinInformationContent,
DeviceAdapter>
vtkm::worklet::DispatcherMapField<vtkm::worklet::histogram::SetBinInformationContent>
setBinInformationContentDispatcher(binWorklet);
setBinInformationContentDispatcher.SetDevice(DeviceAdapter());
setBinInformationContentDispatcher.Invoke(freqs, informationContent);
///// calculate entropy by summing up information conetent of all bins /////

@ -94,8 +94,9 @@ public:
numMarginalVariables++;
const vtkm::Id nFieldBins = numberOfBins.GetPortalControl().Get(i);
vtkm::worklet::histogram::To1DIndex binWorklet(nFieldBins);
vtkm::worklet::DispatcherMapField<vtkm::worklet::histogram::To1DIndex, DeviceAdapter>
to1DIndexDispatcher(binWorklet);
vtkm::worklet::DispatcherMapField<vtkm::worklet::histogram::To1DIndex> to1DIndexDispatcher(
binWorklet);
to1DIndexDispatcher.SetDevice(DeviceAdapter());
size_t vecIndex = static_cast<size_t>(i);
to1DIndexDispatcher.Invoke(binId[vecIndex], bin1DIndex, bin1DIndex);
}
@ -107,9 +108,9 @@ public:
conditionFunc
};
conditionalFreqWorklet.setVar(i);
vtkm::worklet::DispatcherMapField<vtkm::worklet::histogram::ConditionalFreq<BinaryCompare>,
DeviceAdapter>
vtkm::worklet::DispatcherMapField<vtkm::worklet::histogram::ConditionalFreq<BinaryCompare>>
cfDispatcher(conditionalFreqWorklet);
cfDispatcher.SetDevice(DeviceAdapter());
size_t vecIndex = static_cast<size_t>(i);
cfDispatcher.Invoke(binId[vecIndex], freqs, freqs);
}
@ -138,11 +139,11 @@ public:
{
const vtkm::Id nFieldBins = numberOfBins.GetPortalControl().Get(i);
vtkm::worklet::histogram::ConvertHistBinToND binWorklet(nFieldBins);
vtkm::worklet::DispatcherMapField<vtkm::worklet::histogram::ConvertHistBinToND,
DeviceAdapter>
ConvertHistBinToNDDispatcher(binWorklet);
vtkm::worklet::DispatcherMapField<vtkm::worklet::histogram::ConvertHistBinToND>
convertHistBinToNDDispatcher(binWorklet);
convertHistBinToNDDispatcher.SetDevice(DeviceAdapter());
size_t vecIndex = static_cast<size_t>(marginalVarIdx);
ConvertHistBinToNDDispatcher.Invoke(
convertHistBinToNDDispatcher.Invoke(
sparseMarginal1DBinId, sparseMarginal1DBinId, marginalBinId[vecIndex]);
marginalVarIdx--;
}
@ -181,8 +182,9 @@ public:
numMarginalVariables++;
const vtkm::Id nFieldBins = numberOfBins.GetPortalControl().Get(i);
vtkm::worklet::histogram::To1DIndex binWorklet(nFieldBins);
vtkm::worklet::DispatcherMapField<vtkm::worklet::histogram::To1DIndex, DeviceAdapter>
to1DIndexDispatcher(binWorklet);
vtkm::worklet::DispatcherMapField<vtkm::worklet::histogram::To1DIndex> to1DIndexDispatcher(
binWorklet);
to1DIndexDispatcher.SetDevice(DeviceAdapter());
size_t vecIndex = static_cast<size_t>(i);
to1DIndexDispatcher.Invoke(binId[vecIndex], bin1DIndex, bin1DIndex);
}
@ -203,11 +205,11 @@ public:
{
const vtkm::Id nFieldBins = numberOfBins.GetPortalControl().Get(i);
vtkm::worklet::histogram::ConvertHistBinToND binWorklet(nFieldBins);
vtkm::worklet::DispatcherMapField<vtkm::worklet::histogram::ConvertHistBinToND,
DeviceAdapter>
ConvertHistBinToNDDispatcher(binWorklet);
vtkm::worklet::DispatcherMapField<vtkm::worklet::histogram::ConvertHistBinToND>
convertHistBinToNDDispatcher(binWorklet);
convertHistBinToNDDispatcher.SetDevice(DeviceAdapter());
size_t vecIndex = static_cast<size_t>(marginalVarIdx);
ConvertHistBinToNDDispatcher.Invoke(bin1DIndex, bin1DIndex, marginalBinId[vecIndex]);
convertHistBinToNDDispatcher.Invoke(bin1DIndex, bin1DIndex, marginalBinId[vecIndex]);
marginalVarIdx--;
}
}

@ -109,10 +109,11 @@ public:
{
const vtkm::Id nFieldBins = NumberOfBins[static_cast<size_t>(i)];
vtkm::worklet::histogram::ConvertHistBinToND binWorklet(nFieldBins);
vtkm::worklet::DispatcherMapField<vtkm::worklet::histogram::ConvertHistBinToND, DeviceAdapter>
ConvertHistBinToNDDispatcher(binWorklet);
vtkm::worklet::DispatcherMapField<vtkm::worklet::histogram::ConvertHistBinToND>
convertHistBinToNDDispatcher(binWorklet);
convertHistBinToNDDispatcher.SetDevice(DeviceAdapter());
size_t vectorId = static_cast<size_t>(i);
ConvertHistBinToNDDispatcher.Invoke(Bin1DIndex, Bin1DIndex, binId[vectorId]);
convertHistBinToNDDispatcher.Invoke(Bin1DIndex, Bin1DIndex, binId[vectorId]);
}
}

@ -149,8 +149,9 @@ private:
this->CellIds);
this->ParametricCoordinates.Allocate(points.GetNumberOfValues());
vtkm::worklet::DispatcherMapTopology<ProbeUniformPoints, Device>().Invoke(
cells, coords, points, this->CellIds, this->ParametricCoordinates);
vtkm::worklet::DispatcherMapTopology<ProbeUniformPoints> dispatcher;
dispatcher.SetDevice(Device());
dispatcher.Invoke(cells, coords, points, this->CellIds, this->ParametricCoordinates);
}
//============================================================================
@ -215,12 +216,13 @@ public:
InputCellSetTypeList icsTypes = InputCellSetTypeList()) const
{
vtkm::cont::ArrayHandle<T> result;
vtkm::worklet::DispatcherMapField<InterpolatePointField, Device>().Invoke(
this->CellIds,
this->ParametricCoordinates,
this->InputCellSet.ResetCellSetList(icsTypes),
field,
result);
vtkm::worklet::DispatcherMapField<InterpolatePointField> dispatcher;
dispatcher.SetDevice(Device());
dispatcher.Invoke(this->CellIds,
this->ParametricCoordinates,
this->InputCellSet.ResetCellSetList(icsTypes),
field,
result);
return result;
}
@ -255,7 +257,9 @@ public:
Device) const
{
vtkm::cont::ArrayHandle<T> result;
vtkm::worklet::DispatcherMapField<MapCellField, Device>().Invoke(this->CellIds, field, result);
vtkm::worklet::DispatcherMapField<MapCellField> dispatcher;
dispatcher.SetDevice(Device());
dispatcher.Invoke(this->CellIds, field, result);
return result;
}
@ -277,8 +281,9 @@ public:
vtkm::cont::ArrayHandle<vtkm::UInt8> GetHiddenPointsField(DeviceAdapter) const
{
vtkm::cont::ArrayHandle<vtkm::UInt8> field;
vtkm::worklet::DispatcherMapField<HiddenPointsWorklet, DeviceAdapter>().Invoke(this->CellIds,
field);
vtkm::worklet::DispatcherMapField<HiddenPointsWorklet> dispatcher;
dispatcher.SetDevice(DeviceAdapter());
dispatcher.Invoke(this->CellIds, field);
return field;
}
@ -312,8 +317,9 @@ public:
vtkm::cont::ArrayHandle<vtkm::UInt8> GetHiddenCellsField(CellSetType cellset, DeviceAdapter) const
{
vtkm::cont::ArrayHandle<vtkm::UInt8> field;
vtkm::worklet::DispatcherMapTopology<HiddenCellsWorklet, DeviceAdapter>().Invoke(
cellset, this->CellIds, field);
vtkm::worklet::DispatcherMapTopology<HiddenCellsWorklet> dispatcher;
dispatcher.SetDevice(DeviceAdapter());
dispatcher.Invoke(cellset, this->CellIds, field);
return field;
}

@ -134,7 +134,8 @@ public:
}
VTKM_ASSERT(this->MaskArray.GetNumberOfValues() == inCellSet.GetNumberOfPoints());
vtkm::worklet::DispatcherMapField<GeneratePointMask, Device> dispatcher;
vtkm::worklet::DispatcherMapField<GeneratePointMask> dispatcher;
dispatcher.SetDevice(Device());
dispatcher.Invoke(inCellSet.GetConnectivityArray(vtkm::TopologyElementTagPoint(),
vtkm::TopologyElementTagCell()),
this->MaskArray);
@ -181,7 +182,8 @@ public:
vtkm::cont::ArrayHandle<vtkm::Id, NewConnectivityStorage> newConnectivityArray;
vtkm::worklet::DispatcherMapField<TransformPointIndices, Device> dispatcher;
vtkm::worklet::DispatcherMapField<TransformPointIndices> dispatcher;
dispatcher.SetDevice(Device());
dispatcher.Invoke(inCellSet.GetConnectivityArray(FromTopology(), ToTopology()),
this->PointScatter->GetInputToOutputMap(),
newConnectivityArray);

@ -71,13 +71,15 @@ void ScalarsToColors::Run(const vtkm::cont::ArrayHandle<T, S>& values,
const bool shiftscale = needShiftScale(BaseT{}, this->Shift, this->Scale);
if (shiftscale)
{
vtkm::worklet::DispatcherMapField<ShiftScaleToRGBA, Device> dispatcher(
vtkm::worklet::DispatcherMapField<ShiftScaleToRGBA> dispatcher(
ShiftScaleToRGBA(this->Shift, this->Scale, this->Alpha));
dispatcher.SetDevice(Device());
dispatcher.Invoke(values, rgbaOut);
}
else
{
vtkm::worklet::DispatcherMapField<ConvertToRGBA, Device> dispatcher(ConvertToRGBA(this->Alpha));
vtkm::worklet::DispatcherMapField<ConvertToRGBA> dispatcher(ConvertToRGBA(this->Alpha));
dispatcher.SetDevice(Device());
dispatcher.Invoke(values, rgbaOut);
}
}
@ -94,13 +96,15 @@ void ScalarsToColors::Run(const vtkm::cont::ArrayHandle<T, S>& values,
const bool shiftscale = needShiftScale(BaseT{}, this->Shift, this->Scale);
if (shiftscale)
{
vtkm::worklet::DispatcherMapField<ShiftScaleToRGB, Device> dispatcher(
vtkm::worklet::DispatcherMapField<ShiftScaleToRGB> dispatcher(
ShiftScaleToRGB(this->Shift, this->Scale));
dispatcher.SetDevice(Device());
dispatcher.Invoke(values, rgbOut);
}
else
{
vtkm::worklet::DispatcherMapField<ConvertToRGB, Device> dispatcher;
vtkm::worklet::DispatcherMapField<ConvertToRGB> dispatcher;
dispatcher.SetDevice(Device());
dispatcher.Invoke(values, rgbOut);
}
}
@ -120,14 +124,16 @@ void ScalarsToColors::RunMagnitude(const vtkm::cont::ArrayHandle<vtkm::Vec<T, N>
const bool shiftscale = needShiftScale(BaseT{}, this->Shift, this->Scale);
if (shiftscale)
{
vtkm::worklet::DispatcherMapField<ShiftScaleToRGBA, Device> dispatcher(
vtkm::worklet::DispatcherMapField<ShiftScaleToRGBA> dispatcher(
ShiftScaleToRGBA(this->Shift, this->Scale, this->Alpha));
dispatcher.SetDevice(Device());
dispatcher.Invoke(
vtkm::cont::make_ArrayHandleTransform(values, colorconversion::MagnitudePortal()), rgbaOut);
}
else
{
vtkm::worklet::DispatcherMapField<ConvertToRGBA, Device> dispatcher(ConvertToRGBA(this->Alpha));
vtkm::worklet::DispatcherMapField<ConvertToRGBA> dispatcher(ConvertToRGBA(this->Alpha));
dispatcher.SetDevice(Device());
dispatcher.Invoke(
vtkm::cont::make_ArrayHandleTransform(values, colorconversion::MagnitudePortal()), rgbaOut);
}
@ -146,14 +152,16 @@ void ScalarsToColors::RunMagnitude(const vtkm::cont::ArrayHandle<vtkm::Vec<T, N>
const bool shiftscale = needShiftScale(BaseT{}, this->Shift, this->Scale);
if (shiftscale)
{
vtkm::worklet::DispatcherMapField<ShiftScaleToRGB, Device> dispatcher(
vtkm::worklet::DispatcherMapField<ShiftScaleToRGB> dispatcher(
ShiftScaleToRGB(this->Shift, this->Scale));
dispatcher.SetDevice(Device());
dispatcher.Invoke(
vtkm::cont::make_ArrayHandleTransform(values, colorconversion::MagnitudePortal()), rgbOut);
}
else
{
vtkm::worklet::DispatcherMapField<ConvertToRGB, Device> dispatcher;
vtkm::worklet::DispatcherMapField<ConvertToRGB> dispatcher;
dispatcher.SetDevice(Device());
dispatcher.Invoke(
vtkm::cont::make_ArrayHandleTransform(values, colorconversion::MagnitudePortal()), rgbOut);
}

@ -22,14 +22,21 @@
#ifndef vtk_m_worklet_ScatterCounting_h
#define vtk_m_worklet_ScatterCounting_h
#include <vtkm/cont/Algorithm.h>
#include <vtkm/cont/ArrayCopy.h>
#include <vtkm/cont/ArrayHandle.h>
#include <vtkm/cont/ArrayHandleCast.h>
#include <vtkm/cont/ArrayHandleConcatenate.h>
#include <vtkm/cont/ArrayHandleConstant.h>
#include <vtkm/cont/ArrayHandleIndex.h>
#include <vtkm/cont/DeviceAdapterAlgorithm.h>
#include <vtkm/cont/ArrayHandleView.h>
#include <vtkm/cont/ErrorBadValue.h>
#include <vtkm/exec/FunctorBase.h>
#include <vtkm/worklet/DispatcherMapField.h>
#include <vtkm/worklet/WorkletMapField.h>
#include <sstream>
namespace vtkm
@ -40,112 +47,69 @@ namespace worklet
namespace detail
{
template <typename Device>
struct ReverseInputToOutputMapKernel : vtkm::exec::FunctorBase
VTKM_CONT
inline vtkm::cont::ArrayHandleConcatenate<
vtkm::cont::ArrayHandleConstant<vtkm::Id>,
vtkm::cont::ArrayHandleView<vtkm::cont::ArrayHandle<vtkm::Id>>>
ShiftArrayHandleByOne(const vtkm::cont::ArrayHandle<vtkm::Id>& array)
{
using InputMapType =
typename vtkm::cont::ArrayHandle<vtkm::Id>::ExecutionTypes<Device>::PortalConst;
using OutputMapType = typename vtkm::cont::ArrayHandle<vtkm::Id>::ExecutionTypes<Device>::Portal;
using VisitType =
typename vtkm::cont::ArrayHandle<vtkm::IdComponent>::ExecutionTypes<Device>::Portal;
return vtkm::cont::make_ArrayHandleConcatenate(
vtkm::cont::make_ArrayHandleConstant<vtkm::Id>(0, 1),
vtkm::cont::make_ArrayHandleView(array, 0, array.GetNumberOfValues() - 1));
}
InputMapType InputToOutputMap;
OutputMapType OutputToInputMap;
VisitType Visit;
vtkm::Id OutputSize;
struct ReverseInputToOutputMapWorklet : vtkm::worklet::WorkletMapField
{
using ControlSignature = void(FieldIn<IdType> outputStartIndices,
FieldIn<IdType> outputEndIndices,
WholeArrayOut<IdType> outputToInputMap,
WholeArrayOut<IdComponentType> visit);
using ExecutionSignature = void(_1, _2, _3, _4, InputIndex);
using InputDomain = _2;
VTKM_CONT
ReverseInputToOutputMapKernel(const InputMapType& inputToOutputMap,
const OutputMapType& outputToInputMap,
const VisitType& visit,
vtkm::Id outputSize)
: InputToOutputMap(inputToOutputMap)
, OutputToInputMap(outputToInputMap)
, Visit(visit)
, OutputSize(outputSize)
template <typename OutputMapType, typename VisitType>
VTKM_EXEC void operator()(vtkm::Id outputStartIndex,
vtkm::Id outputEndIndex,
const OutputMapType& outputToInputMap,
const VisitType& visit,
vtkm::Id inputIndex) const
{
}
VTKM_EXEC
void operator()(vtkm::Id inputIndex) const
{
vtkm::Id outputStartIndex;
if (inputIndex > 0)
{
outputStartIndex = this->InputToOutputMap.Get(inputIndex - 1);
}
else
{
outputStartIndex = 0;
}
vtkm::Id outputEndIndex = this->InputToOutputMap.Get(inputIndex);
vtkm::IdComponent visitIndex = 0;
for (vtkm::Id outputIndex = outputStartIndex; outputIndex < outputEndIndex; outputIndex++)
{
this->OutputToInputMap.Set(outputIndex, inputIndex);
this->Visit.Set(outputIndex, visitIndex);
outputToInputMap.Set(outputIndex, inputIndex);
visit.Set(outputIndex, visitIndex);
visitIndex++;
}
}
};
template <typename Device>
struct SubtractToVisitIndexKernel : vtkm::exec::FunctorBase
{
using StartsOfGroupsType =
typename vtkm::cont::ArrayHandle<vtkm::Id>::ExecutionTypes<Device>::PortalConst;
using VisitType =
typename vtkm::cont::ArrayHandle<vtkm::IdComponent>::ExecutionTypes<Device>::Portal;
StartsOfGroupsType StartsOfGroups;
VisitType Visit;
VTKM_CONT
SubtractToVisitIndexKernel(const StartsOfGroupsType& startsOfGroups, const VisitType& visit)
: StartsOfGroups(startsOfGroups)
, Visit(visit)
static void Run(const vtkm::cont::ArrayHandle<vtkm::Id>& inputToOutputMap,
const vtkm::cont::ArrayHandle<vtkm::Id>& outputToInputMap,
const vtkm::cont::ArrayHandle<vtkm::IdComponent>& visit,
vtkm::cont::DeviceAdapterId device)
{
vtkm::worklet::DispatcherMapField<ReverseInputToOutputMapWorklet> dispatcher;
dispatcher.SetDevice(device);
dispatcher.Invoke(
ShiftArrayHandleByOne(inputToOutputMap), inputToOutputMap, outputToInputMap, visit);
}
};
VTKM_EXEC
void operator()(vtkm::Id inputIndex) const
struct SubtractToVisitIndexWorklet : vtkm::worklet::WorkletMapField
{
using ControlSignature = void(FieldIn<IdType> startsOfGroup,
WholeArrayOut<IdComponentType> visit);
using ExecutionSignature = void(InputIndex, _1, _2);
using InputDomain = _1;
template <typename VisitType>
VTKM_EXEC void operator()(vtkm::Id inputIndex,
vtkm::Id startOfGroup,
const VisitType& visit) const
{
vtkm::Id startOfGroup = this->StartsOfGroups.Get(inputIndex);
vtkm::IdComponent visitIndex = static_cast<vtkm::IdComponent>(inputIndex - startOfGroup);
this->Visit.Set(inputIndex, visitIndex);
}
};
template <typename Device>
struct AdjustMapByOne : vtkm::exec::FunctorBase
{
using OffByOnePortalType =
typename vtkm::cont::ArrayHandle<vtkm::Id>::ExecutionTypes<Device>::PortalConst;
using CorrectedPortalType =
typename vtkm::cont::ArrayHandle<vtkm::Id>::ExecutionTypes<Device>::Portal;
OffByOnePortalType MapOffByOne;
CorrectedPortalType MapCorrected;
VTKM_CONT
AdjustMapByOne(const OffByOnePortalType& mapOffByOne, const CorrectedPortalType& mapCorrected)
: MapOffByOne(mapOffByOne)
, MapCorrected(mapCorrected)
{
}
VTKM_EXEC
void operator()(vtkm::Id index) const
{
if (index != 0)
{
this->MapCorrected.Set(index, this->MapOffByOne.Get(index - 1));
}
else
{
this->MapCorrected.Set(0, 0);
}
visit.Set(inputIndex, visitIndex);
}
};
@ -172,12 +136,17 @@ struct ScatterCounting
/// other users might make use of it, so you can instruct the constructor
/// to save the input to output map.
///
template <typename CountArrayType, typename Device>
template <typename CountArrayType>
VTKM_CONT ScatterCounting(const CountArrayType& countArray,
Device,
vtkm::cont::DeviceAdapterId device = vtkm::cont::DeviceAdapterTagAny(),
bool saveInputToOutputMap = false)
{
this->BuildArrays(countArray, Device(), saveInputToOutputMap);
this->BuildArrays(countArray, device, saveInputToOutputMap);
}
template <typename CountArrayType>
VTKM_CONT ScatterCounting(const CountArrayType& countArray, bool saveInputToOutputMap)
{
this->BuildArrays(countArray, vtkm::cont::DeviceAdapterTagAny(), saveInputToOutputMap);
}
using OutputToInputMapType = vtkm::cont::ArrayHandle<vtkm::Id>;
@ -228,11 +197,12 @@ private:
OutputToInputMapType OutputToInputMap;
VisitArrayType VisitArray;
template <typename CountArrayType, typename Device>
VTKM_CONT void BuildArrays(const CountArrayType& count, Device, bool saveInputToOutputMap)
template <typename CountArrayType>
VTKM_CONT void BuildArrays(const CountArrayType& count,
vtkm::cont::DeviceAdapterId device,
bool saveInputToOutputMap)
{
VTKM_IS_ARRAY_HANDLE(CountArrayType);
VTKM_IS_DEVICE_ADAPTER_TAG(Device);
this->InputRange = count.GetNumberOfValues();
@ -242,8 +212,8 @@ private:
// building the output to input map. Later we will either correct the
// map or delete it.
vtkm::cont::ArrayHandle<vtkm::Id> inputToOutputMapOffByOne;
vtkm::Id outputSize = vtkm::cont::DeviceAdapterAlgorithm<Device>::ScanInclusive(
vtkm::cont::make_ArrayHandleCast(count, vtkm::Id()), inputToOutputMapOffByOne);
vtkm::Id outputSize = vtkm::cont::Algorithm::ScanInclusive(
device, vtkm::cont::make_ArrayHandleCast(count, vtkm::Id()), inputToOutputMapOffByOne);
// We have implemented two different ways to compute the output to input
// map. The first way is to use a binary search on each output index into
@ -257,60 +227,52 @@ private:
// place for optimization.
if (outputSize < this->InputRange)
{
this->BuildOutputToInputMapWithFind(outputSize, inputToOutputMapOffByOne, Device());
this->BuildOutputToInputMapWithFind(outputSize, device, inputToOutputMapOffByOne);
}
else
{
this->BuildOutputToInputMapWithIterate(outputSize, inputToOutputMapOffByOne, Device());
this->BuildOutputToInputMapWithIterate(outputSize, device, inputToOutputMapOffByOne);
}
if (saveInputToOutputMap)
{
// Since we are saving it, correct the input to output map.
detail::AdjustMapByOne<Device> kernel(
inputToOutputMapOffByOne.PrepareForInput(Device()),
this->InputToOutputMap.PrepareForOutput(this->InputRange, Device()));
vtkm::cont::DeviceAdapterAlgorithm<Device>::Schedule(kernel, this->InputRange);
vtkm::cont::Algorithm::Copy(
device, detail::ShiftArrayHandleByOne(inputToOutputMapOffByOne), this->InputToOutputMap);
}
}
template <typename Device>
VTKM_CONT void BuildOutputToInputMapWithFind(
vtkm::Id outputSize,
vtkm::cont::ArrayHandle<vtkm::Id> inputToOutputMapOffByOne,
Device)
vtkm::cont::DeviceAdapterId device,
vtkm::cont::ArrayHandle<vtkm::Id> inputToOutputMapOffByOne)
{
vtkm::cont::ArrayHandleIndex outputIndices(outputSize);
vtkm::cont::DeviceAdapterAlgorithm<Device>::UpperBounds(
inputToOutputMapOffByOne, outputIndices, this->OutputToInputMap);
vtkm::cont::Algorithm::UpperBounds(
device, inputToOutputMapOffByOne, outputIndices, this->OutputToInputMap);
vtkm::cont::ArrayHandle<vtkm::Id> startsOfGroups;
// This find gives the index of the start of a group.
vtkm::cont::DeviceAdapterAlgorithm<Device>::LowerBounds(
this->OutputToInputMap, this->OutputToInputMap, startsOfGroups);
vtkm::cont::Algorithm::LowerBounds(
device, this->OutputToInputMap, this->OutputToInputMap, startsOfGroups);
detail::SubtractToVisitIndexKernel<Device> kernel(
startsOfGroups.PrepareForInput(Device()),
this->VisitArray.PrepareForOutput(outputSize, Device()));
vtkm::cont::DeviceAdapterAlgorithm<Device>::Schedule(kernel, outputSize);
this->VisitArray.Allocate(outputSize);
vtkm::worklet::DispatcherMapField<detail::SubtractToVisitIndexWorklet> dispatcher;
dispatcher.SetDevice(device);
dispatcher.Invoke(startsOfGroups, this->VisitArray);
}
template <typename Device>
VTKM_CONT void BuildOutputToInputMapWithIterate(
vtkm::Id outputSize,
vtkm::cont::ArrayHandle<vtkm::Id> inputToOutputMapOffByOne,
Device)
vtkm::cont::DeviceAdapterId device,
vtkm::cont::ArrayHandle<vtkm::Id> inputToOutputMapOffByOne)
{
detail::ReverseInputToOutputMapKernel<Device> kernel(
inputToOutputMapOffByOne.PrepareForInput(Device()),
this->OutputToInputMap.PrepareForOutput(outputSize, Device()),
this->VisitArray.PrepareForOutput(outputSize, Device()),
outputSize);
this->OutputToInputMap.Allocate(outputSize);
this->VisitArray.Allocate(outputSize);
vtkm::cont::DeviceAdapterAlgorithm<Device>::Schedule(
kernel, inputToOutputMapOffByOne.GetNumberOfValues());
detail::ReverseInputToOutputMapWorklet::Run(
inputToOutputMapOffByOne, this->OutputToInputMap, this->VisitArray, device);
}
};
}

@ -396,9 +396,9 @@ public:
// Worklet to make the streamlines
MakeStreamLines makeStreamLines(
timeStep, streamMode, maxSteps, vdims, fieldArray.PrepareForInput(DeviceAdapter()));
using MakeStreamLinesDispatcher =
typename vtkm::worklet::DispatcherMapField<MakeStreamLines, DeviceAdapter>;
using MakeStreamLinesDispatcher = vtkm::worklet::DispatcherMapField<MakeStreamLines>;
MakeStreamLinesDispatcher makeStreamLinesDispatcher(makeStreamLines);
makeStreamLinesDispatcher.SetDevice(DeviceAdapter());
makeStreamLinesDispatcher.Invoke(
seedIdArray, seedPosArray, numIndices, validPoint, streamArray);

@ -134,12 +134,14 @@ public:
{
if (this->Normalize)
{
vtkm::worklet::DispatcherMapTopology<Worklet<>, DeviceAdapter> dispatcher;
vtkm::worklet::DispatcherMapTopology<Worklet<>> dispatcher;
dispatcher.SetDevice(DeviceAdapter());
dispatcher.Invoke(cellset, points, normals);
}
else
{
vtkm::worklet::DispatcherMapTopology<Worklet<detail::PassThrough>, DeviceAdapter> dispatcher;
vtkm::worklet::DispatcherMapTopology<Worklet<detail::PassThrough>> dispatcher;
dispatcher.SetDevice(DeviceAdapter());
dispatcher.Invoke(cellset, points, normals);
}
}
@ -156,12 +158,14 @@ public:
{
if (this->Normalize)
{
vtkm::worklet::DispatcherMapTopology<Worklet<>, DeviceAdapter> dispatcher;
vtkm::worklet::DispatcherMapTopology<Worklet<>> dispatcher;
dispatcher.SetDevice(DeviceAdapter());
dispatcher.Invoke(cellset, points, normals);
}
else
{
vtkm::worklet::DispatcherMapTopology<Worklet<detail::PassThrough>, DeviceAdapter> dispatcher;
vtkm::worklet::DispatcherMapTopology<Worklet<detail::PassThrough>> dispatcher;
dispatcher.SetDevice(DeviceAdapter());
dispatcher.Invoke(cellset, points, normals);
}
}
@ -214,7 +218,8 @@ public:
vtkm::cont::ArrayHandle<vtkm::Vec<NormalCompType, 3>>& pointNormals,
DeviceAdapter)
{
vtkm::worklet::DispatcherMapTopology<Worklet, DeviceAdapter> dispatcher;
vtkm::worklet::DispatcherMapTopology<Worklet> dispatcher;
dispatcher.SetDevice(DeviceAdapter());
dispatcher.Invoke(cellset, faceNormals, pointNormals);
}
@ -229,7 +234,8 @@ public:
vtkm::cont::ArrayHandle<vtkm::Vec<NormalCompType, 3>>& pointNormals,
DeviceAdapter)
{
vtkm::worklet::DispatcherMapTopology<Worklet, DeviceAdapter> dispatcher;
vtkm::worklet::DispatcherMapTopology<Worklet> dispatcher;
dispatcher.SetDevice(DeviceAdapter());
dispatcher.Invoke(cellset, faceNormals, pointNormals);
}
};

@ -60,24 +60,21 @@ public:
}
// Tetrahedralize explicit data set, save number of tetra cells per input
template <typename CellSetType, typename DeviceAdapter>
vtkm::cont::CellSetSingleType<> Run(const CellSetType& cellSet, const DeviceAdapter&)
template <typename CellSetType>
vtkm::cont::CellSetSingleType<> Run(const CellSetType& cellSet)
{
TetrahedralizeExplicit<DeviceAdapter> worklet;
TetrahedralizeExplicit worklet;
return worklet.Run(cellSet, this->OutCellsPerCell);
}
// Tetrahedralize structured data set, save number of tetra cells per input
template <typename DeviceAdapter>
vtkm::cont::CellSetSingleType<> Run(const vtkm::cont::CellSetStructured<3>& cellSet,
const DeviceAdapter&)
vtkm::cont::CellSetSingleType<> Run(const vtkm::cont::CellSetStructured<3>& cellSet)
{
TetrahedralizeStructured<DeviceAdapter> worklet;
TetrahedralizeStructured worklet;
return worklet.Run(cellSet, this->OutCellsPerCell);
}
template <typename DeviceAdapter>
vtkm::cont::CellSetSingleType<> Run(const vtkm::cont::CellSetStructured<2>&, const DeviceAdapter&)
vtkm::cont::CellSetSingleType<> Run(const vtkm::cont::CellSetStructured<2>&)
{
throw vtkm::cont::ErrorBadType("CellSetStructured<2> can't be tetrahedralized");
}
@ -89,8 +86,9 @@ public:
{
vtkm::cont::ArrayHandle<T> output;
vtkm::worklet::DispatcherMapField<DistributeCellData, DeviceAdapter> dispatcher(
vtkm::worklet::DispatcherMapField<DistributeCellData> dispatcher(
DistributeCellData::MakeScatter(this->OutCellsPerCell, device));
dispatcher.SetDevice(DeviceAdapter());
dispatcher.Invoke(input, output);
return output;

@ -141,7 +141,8 @@ public:
using ThresholdWorklet = ThresholdByPointField<UnaryPredicate>;
ThresholdWorklet worklet(predicate);
DispatcherMapTopology<ThresholdWorklet, DeviceAdapter> dispatcher(worklet);
DispatcherMapTopology<ThresholdWorklet> dispatcher(worklet);
dispatcher.SetDevice(DeviceAdapter());
dispatcher.Invoke(cellSet, field, passFlags);
break;
}
@ -150,7 +151,8 @@ public:
using ThresholdWorklet = ThresholdByCellField<UnaryPredicate>;
ThresholdWorklet worklet(predicate);
DispatcherMapTopology<ThresholdWorklet, DeviceAdapter> dispatcher(worklet);
DispatcherMapTopology<ThresholdWorklet> dispatcher(worklet);
dispatcher.SetDevice(DeviceAdapter());
dispatcher.Invoke(cellSet, field, passFlags);
break;
}

@ -86,7 +86,8 @@ public:
using ThresholdWorklet = ThresholdPointField<UnaryPredicate>;
ThresholdWorklet worklet(predicate);
DispatcherMapTopology<ThresholdWorklet, DeviceAdapter> dispatcher(worklet);
DispatcherMapTopology<ThresholdWorklet> dispatcher(worklet);
dispatcher.SetDevice(DeviceAdapter());
dispatcher.Invoke(cellSet, scalars, passFlags);
vtkm::cont::ArrayHandle<vtkm::Id> pointIds;

@ -60,11 +60,12 @@ public:
}
// Triangulate explicit data set, save number of triangulated cells per input
template <typename CellSetType, typename DeviceAdapter>
vtkm::cont::CellSetSingleType<> Run(const CellSetType& cellSet, const DeviceAdapter&)
template <typename CellSetType>
vtkm::cont::CellSetSingleType<> Run(const CellSetType& cellSet,
vtkm::cont::DeviceAdapterId device)
{
TriangulateExplicit<DeviceAdapter> worklet;
return worklet.Run(cellSet, this->OutCellsPerCell);
TriangulateExplicit worklet;
return worklet.Run(cellSet, this->OutCellsPerCell, device);
}
// Triangulate structured data set, save number of triangulated cells per input
@ -90,8 +91,9 @@ public:
{
vtkm::cont::ArrayHandle<ValueType> output;
vtkm::worklet::DispatcherMapField<DistributeCellData, DeviceAdapter> dispatcher(
vtkm::worklet::DispatcherMapField<DistributeCellData> dispatcher(
DistributeCellData::MakeScatter(this->OutCellsPerCell, device));
dispatcher.SetDevice(DeviceAdapter());
dispatcher.Invoke(input, output);
return output;

@ -88,7 +88,8 @@ struct SelectRepresentativePoint : public vtkm::worklet::WorkletReduceByKey
{
vtkm::cont::ArrayHandle<typename InputPointsArrayType::ValueType> out;
vtkm::worklet::DispatcherReduceByKey<SelectRepresentativePoint, DeviceAdapterTag> dispatcher;
vtkm::worklet::DispatcherReduceByKey<SelectRepresentativePoint> dispatcher;
dispatcher.SetDevice(DeviceAdapterTag());
dispatcher.Invoke(keys, points, out);
output = out;
@ -374,8 +375,10 @@ public:
/// map points
vtkm::cont::ArrayHandle<vtkm::Id> pointCidArray;
vtkm::worklet::DispatcherMapField<MapPointsWorklet, DeviceAdapter>(MapPointsWorklet(gridInfo))
.Invoke(coordinates, pointCidArray);
vtkm::worklet::DispatcherMapField<MapPointsWorklet> mapPointsDispatcher(
(MapPointsWorklet(gridInfo)));
mapPointsDispatcher.SetDevice(DeviceAdapter());
mapPointsDispatcher.Invoke(coordinates, pointCidArray);
#ifdef __VTKM_VERTEX_CLUSTERING_BENCHMARK
std::cout << "Time map points (s): " << timer.GetElapsedTime() << std::endl;
@ -415,8 +418,9 @@ public:
/// of the cell vertices
vtkm::cont::ArrayHandle<vtkm::Id3> cid3Array;
vtkm::worklet::DispatcherMapTopology<MapCellsWorklet, DeviceAdapter>(MapCellsWorklet())
.Invoke(cellSet, pointCidArray, cid3Array);
vtkm::worklet::DispatcherMapTopology<MapCellsWorklet> mapCellsDispatcher;
mapCellsDispatcher.SetDevice(DeviceAdapter());
mapCellsDispatcher.Invoke(cellSet, pointCidArray, cid3Array);
#ifdef __VTKM_VERTEX_CLUSTERING_BENCHMARK
std::cout << "Time after clustering cells (s): " << timer.GetElapsedTime() << std::endl;
@ -428,8 +432,9 @@ public:
cidIndexArray.PrepareForOutput(gridInfo.dim[0] * gridInfo.dim[1] * gridInfo.dim[2],
DeviceAdapter());
vtkm::worklet::DispatcherMapField<IndexingWorklet, DeviceAdapter>().Invoke(repPointCidArray,
cidIndexArray);
vtkm::worklet::DispatcherMapField<IndexingWorklet> indexingDispatcher;
indexingDispatcher.SetDevice(DeviceAdapter());
indexingDispatcher.Invoke(repPointCidArray, cidIndexArray);
pointCidArray.ReleaseResources();
repPointCidArray.ReleaseResources();
@ -443,9 +448,10 @@ public:
vtkm::cont::ArrayHandle<vtkm::Id3> pointId3Array;
vtkm::worklet::DispatcherMapField<Cid2PointIdWorklet, DeviceAdapter>(
Cid2PointIdWorklet(nPoints))
.Invoke(cid3Array, pointId3Array, cidIndexArray);
vtkm::worklet::DispatcherMapField<Cid2PointIdWorklet> cid2PointIdDispatcher(
(Cid2PointIdWorklet(nPoints)));
cid2PointIdDispatcher.SetDevice(DeviceAdapter());
cid2PointIdDispatcher.Invoke(cid3Array, pointId3Array, cidIndexArray);
cid3Array.ReleaseResources();
cidIndexArray.ReleaseResources();
@ -457,8 +463,10 @@ public:
/// Create hashed array
vtkm::cont::ArrayHandle<vtkm::Int64> pointId3HashArray;
vtkm::worklet::DispatcherMapField<Cid3HashWorklet, DeviceAdapter>(Cid3HashWorklet(nPoints))
.Invoke(pointId3Array, pointId3HashArray);
vtkm::worklet::DispatcherMapField<Cid3HashWorklet> cid3HashDispatcher(
(Cid3HashWorklet(nPoints)));
cid3HashDispatcher.SetDevice(DeviceAdapter());
cid3HashDispatcher.Invoke(pointId3Array, pointId3HashArray);
pointId3Array.ReleaseResources();
@ -481,9 +489,10 @@ public:
auto tmpPerm = vtkm::cont::make_ArrayHandlePermutation(this->CellIdMap, pointId3HashArray);
// decode
vtkm::worklet::DispatcherMapField<Cid3UnhashWorklet, DeviceAdapter>(
Cid3UnhashWorklet(nPoints))
.Invoke(tmpPerm, pointId3Array);
vtkm::worklet::DispatcherMapField<Cid3UnhashWorklet> cid3UnhashDispatcher(
(Cid3UnhashWorklet(nPoints)));
cid3UnhashDispatcher.SetDevice(DeviceAdapter());
cid3UnhashDispatcher.Invoke(tmpPerm, pointId3Array);
}
else
{

@ -90,7 +90,8 @@ public:
DeviceAdapter vtkmNotUsed(adapter))
{
WarpScalarImp warpScalarImp(scale);
vtkm::worklet::DispatcherMapField<WarpScalarImp, DeviceAdapter> dispatcher(warpScalarImp);
vtkm::worklet::DispatcherMapField<WarpScalarImp> dispatcher(warpScalarImp);
dispatcher.SetDevice(DeviceAdapter());
dispatcher.Invoke(point, normal, scaleFactor, warpedPoint);
}
};

@ -82,7 +82,8 @@ public:
DeviceAdapter vtkmNotUsed(adapter))
{
WarpVectorImp warpVectorImp(scale);
vtkm::worklet::DispatcherMapField<WarpVectorImp, DeviceAdapter> dispatcher(warpVectorImp);
vtkm::worklet::DispatcherMapField<WarpVectorImp> dispatcher(warpVectorImp);
dispatcher.SetDevice(DeviceAdapter());
dispatcher.Invoke(point, vector, warpedPoint);
}
};

@ -488,7 +488,8 @@ public:
using ThresholdType = vtkm::worklet::wavelets::ThresholdWorklet;
ThresholdType thresholdWorklet(nthVal);
vtkm::worklet::DispatcherMapField<ThresholdType, DeviceTag> dispatcher(thresholdWorklet);
vtkm::worklet::DispatcherMapField<ThresholdType> dispatcher(thresholdWorklet);
dispatcher.SetDevice(DeviceTag());
dispatcher.Invoke(coeffIn);
}
@ -512,12 +513,14 @@ public:
// Use a worklet to calculate point-wise error, and its square
using DifferencerWorklet = vtkm::worklet::wavelets::Differencer;
DifferencerWorklet dw;
vtkm::worklet::DispatcherMapField<DifferencerWorklet, DeviceTag> dwDispatcher(dw);
vtkm::worklet::DispatcherMapField<DifferencerWorklet> dwDispatcher(dw);
dwDispatcher.SetDevice(DeviceTag());
dwDispatcher.Invoke(original, reconstruct, errorArray);
using SquareWorklet = vtkm::worklet::wavelets::SquareWorklet;
SquareWorklet sw;
vtkm::worklet::DispatcherMapField<SquareWorklet, DeviceTag> swDispatcher(sw);
vtkm::worklet::DispatcherMapField<SquareWorklet> swDispatcher(sw);
swDispatcher.SetDevice(DeviceTag());
swDispatcher.Invoke(errorArray, errorSquare);
VAL varErr = WaveletBase::DeviceCalculateVariance(errorArray, DeviceTag());

@ -123,14 +123,14 @@ public:
{
// Get number of edges for each cell and use it as scatter count.
vtkm::cont::ArrayHandle<vtkm::IdComponent> numEdgesPerCell;
vtkm::worklet::DispatcherMapTopology<detail::EdgeCount, DeviceAdapter> edgesPerCellDisp;
vtkm::worklet::DispatcherMapTopology<detail::EdgeCount> edgesPerCellDisp;
edgesPerCellDisp.SetDevice(DeviceAdapter());
edgesPerCellDisp.Invoke(cellSet, numEdgesPerCell);
// Get uncompress Cell to Edge mapping
vtkm::worklet::ScatterCounting scatter{ numEdgesPerCell, DeviceAdapter() };
vtkm::worklet::DispatcherMapTopology<detail::EdgeExtract, DeviceAdapter> edgeExtractDisp{
scatter
};
vtkm::worklet::DispatcherMapTopology<detail::EdgeExtract> edgeExtractDisp{ scatter };
edgeExtractDisp.SetDevice(DeviceAdapter());
edgeExtractDisp.Invoke(cellSet, cellIds, cellEdges);
}
@ -172,7 +172,8 @@ public:
vtkm::cont::ArrayHandle<vtkm::Id> connTo;
connFrom.Allocate(sharedEdges.GetNumberOfValues() * 2);
connTo.Allocate(sharedEdges.GetNumberOfValues() * 2);
vtkm::worklet::DispatcherMapField<detail::CellToCellConnectivity, DeviceAdapter> c2cDisp;
vtkm::worklet::DispatcherMapField<detail::CellToCellConnectivity> c2cDisp;
c2cDisp.SetDevice(DeviceAdapter());
c2cDisp.Invoke(lb, cellIds, connFrom, connTo);
// Turn dual graph into Compressed Sparse Row format

@ -90,16 +90,19 @@ public:
do
{
vtkm::worklet::DispatcherMapField<detail::Graft, DeviceAdapter> graftDispatcher;
vtkm::worklet::DispatcherMapField<detail::Graft> graftDispatcher;
graftDispatcher.SetDevice(DeviceAdapter());
graftDispatcher.Invoke(
cellIds, indexOffsetArray, numIndexArray, connectivityArray, components);
// Detection of allStar has to come before pointer jumping. Don't try to rearrange it.
vtkm::worklet::DispatcherMapField<IsStar, DeviceAdapter> isStarDisp;
vtkm::worklet::DispatcherMapField<IsStar> isStarDisp;
isStarDisp.SetDevice(DeviceAdapter());
isStarDisp.Invoke(cellIds, components, isStar);
allStar = Algorithm::Reduce(isStar, true, vtkm::LogicalAnd());
vtkm::worklet::DispatcherMapField<PointerJumping, DeviceAdapter> pointJumpingDispatcher;
vtkm::worklet::DispatcherMapField<PointerJumping> pointJumpingDispatcher;
pointJumpingDispatcher.SetDevice(DeviceAdapter());
pointJumpingDispatcher.Invoke(cellIds, components);
} while (!allStar);

@ -102,19 +102,20 @@ public:
bool allStar = false;
vtkm::cont::ArrayHandle<bool> isStar;
using DispatcherType =
vtkm::worklet::DispatcherPointNeighborhood<detail::ImageGraft<2>, Device>;
do
{
DispatcherType().Invoke(input, componentsOut, pixels, newComponents);
vtkm::worklet::DispatcherPointNeighborhood<detail::ImageGraft<2>> imageGraftDispatcher;
imageGraftDispatcher.SetDevice(Device());
imageGraftDispatcher.Invoke(input, componentsOut, pixels, newComponents);
// Detection of allStar has to come before pointer jumping. Don't try to rearrange it.
vtkm::worklet::DispatcherMapField<IsStar, Device> isStarDisp;
vtkm::worklet::DispatcherMapField<IsStar> isStarDisp;
isStarDisp.SetDevice(Device());
isStarDisp.Invoke(pixelIds, newComponents, isStar);
allStar = Algorithm::Reduce(isStar, true, vtkm::LogicalAnd());
vtkm::worklet::DispatcherMapField<PointerJumping, Device> pointJumpingDispatcher;
vtkm::worklet::DispatcherMapField<PointerJumping> pointJumpingDispatcher;
pointJumpingDispatcher.SetDevice(Device());
pointJumpingDispatcher.Invoke(pixelIds, newComponents);
Algorithm::Copy(newComponents, componentsOut);

@ -90,7 +90,8 @@ public:
Algorithm::Transform(ubs, lbs, counts, vtkm::Subtract());
vtkm::worklet::ScatterCounting scatter{ counts, DeviceAdapter() };
vtkm::worklet::DispatcherMapField<Merge, DeviceAdapter> mergeDisp(scatter);
vtkm::worklet::DispatcherMapField<Merge> mergeDisp(scatter);
mergeDisp.SetDevice(DeviceAdapter());
mergeDisp.Invoke(key1, value1, lbs, value2, keyOut, value1Out, value2Out);
}
};

@ -336,8 +336,9 @@ void ChainGraph<T, StorageType, DeviceAdapter>::FindGoverningSaddles()
// now loop through the edges
GoverningSaddleFinder governingSaddleFinder;
vtkm::worklet::DispatcherMapField<GoverningSaddleFinder, DeviceAdapter>
governingSaddleFinderDispatcher(governingSaddleFinder);
vtkm::worklet::DispatcherMapField<GoverningSaddleFinder> governingSaddleFinderDispatcher(
governingSaddleFinder);
governingSaddleFinderDispatcher.SetDevice(DeviceAdapter());
vtkm::Id nEdges = edgeSorter.GetNumberOfValues();
vtkm::cont::ArrayHandleIndex edgeIndexArray(nEdges);
@ -364,8 +365,9 @@ void ChainGraph<T, StorageType, DeviceAdapter>::TransferRegularPoints()
std::cout << std::endl;
#endif
RegularPointTransferrer<T> regularPointTransferrer(isJoinGraph);
vtkm::worklet::DispatcherMapField<RegularPointTransferrer<T>, DeviceAdapter>
regularPointTransferrerDispatcher(regularPointTransferrer);
vtkm::worklet::DispatcherMapField<RegularPointTransferrer<T>> regularPointTransferrerDispatcher(
regularPointTransferrer);
regularPointTransferrerDispatcher.SetDevice(DeviceAdapter());
regularPointTransferrerDispatcher.Invoke(activeVertices, // input
chainExtremum, // input (whole array)
@ -433,8 +435,9 @@ void ChainGraph<T, StorageType, DeviceAdapter>::CompactActiveEdges()
// WARNING: Using chainMaximum for I/O in parallel loop
// See functor description for algorithmic justification of safety
VertexDegreeUpdater vertexDegreeUpdater;
vtkm::worklet::DispatcherMapField<VertexDegreeUpdater, DeviceAdapter>
vertexDegreeUpdaterDispatcher(vertexDegreeUpdater);
vtkm::worklet::DispatcherMapField<VertexDegreeUpdater> vertexDegreeUpdaterDispatcher(
vertexDegreeUpdater);
vertexDegreeUpdaterDispatcher.SetDevice(DeviceAdapter());
vertexDegreeUpdaterDispatcher.Invoke(activeVertices, // input
activeEdges, // input (whole array)
@ -460,8 +463,9 @@ void ChainGraph<T, StorageType, DeviceAdapter>::CompactActiveEdges()
// See functor description for algorithmic justification of safety
ActiveEdgeTransferrer<DeviceAdapter> activeEdgeTransferrer(
activeEdges.PrepareForInput(DeviceAdapter()), prunesTo.PrepareForInput(DeviceAdapter()));
vtkm::worklet::DispatcherMapField<ActiveEdgeTransferrer<DeviceAdapter>, DeviceAdapter>
vtkm::worklet::DispatcherMapField<ActiveEdgeTransferrer<DeviceAdapter>>
activeEdgeTransferrerDispatcher(activeEdgeTransferrer);
activeEdgeTransferrerDispatcher.SetDevice(DeviceAdapter());
activeEdgeTransferrerDispatcher.Invoke(activeVertices, // input
newPosition, // input
@ -502,8 +506,8 @@ void ChainGraph<T, StorageType, DeviceAdapter>::BuildChains()
nLogSteps++;
ChainDoubler chainDoubler;
vtkm::worklet::DispatcherMapField<ChainDoubler, DeviceAdapter> chainDoublerDispatcher(
chainDoubler);
vtkm::worklet::DispatcherMapField<ChainDoubler> chainDoublerDispatcher(chainDoubler);
chainDoublerDispatcher.SetDevice(DeviceAdapter());
// 2. Use path compression / step doubling to collect vertices along ascending chains
// until every vertex has been assigned to *an* extremum
@ -545,8 +549,9 @@ void ChainGraph<T, StorageType, DeviceAdapter>::TransferSaddleStarts()
// 2. now test all active vertices to see if they have only one chain maximum
SaddleAscentFunctor saddleAscentFunctor;
vtkm::worklet::DispatcherMapField<SaddleAscentFunctor, DeviceAdapter>
saddleAscentFunctorDispatcher(saddleAscentFunctor);
vtkm::worklet::DispatcherMapField<SaddleAscentFunctor> saddleAscentFunctorDispatcher(
saddleAscentFunctor);
saddleAscentFunctorDispatcher.SetDevice(DeviceAdapter());
saddleAscentFunctorDispatcher.Invoke(activeVertices, // input
firstEdge, // input (whole array)
@ -565,8 +570,9 @@ void ChainGraph<T, StorageType, DeviceAdapter>::TransferSaddleStarts()
edgeSorter.Allocate(nEdgesToSort);
SaddleAscentTransferrer saddleAscentTransferrer;
vtkm::worklet::DispatcherMapField<SaddleAscentTransferrer, DeviceAdapter>
saddleAscentTransferrerDispatcher(saddleAscentTransferrer);
vtkm::worklet::DispatcherMapField<SaddleAscentTransferrer> saddleAscentTransferrerDispatcher(
saddleAscentTransferrer);
saddleAscentTransferrerDispatcher.SetDevice(DeviceAdapter());
saddleAscentTransferrerDispatcher.Invoke(activeVertices, // input
newOutdegree, // input
@ -593,8 +599,8 @@ void ChainGraph<T, StorageType, DeviceAdapter>::BuildTrunk()
#endif
TrunkBuilder trunkBuilder;
vtkm::worklet::DispatcherMapField<TrunkBuilder, DeviceAdapter> trunkBuilderDispatcher(
trunkBuilder);
vtkm::worklet::DispatcherMapField<TrunkBuilder> trunkBuilderDispatcher(trunkBuilder);
trunkBuilderDispatcher.SetDevice(DeviceAdapter());
trunkBuilderDispatcher.Invoke(activeVertices, // input
chainExtremum, // input (whole array)
@ -624,8 +630,9 @@ void ChainGraph<T, StorageType, DeviceAdapter>::TransferToMergeTree(
DeviceAlgorithm::Copy(arcArray, saddles);
JoinTreeTransferrer joinTreeTransferrer;
vtkm::worklet::DispatcherMapField<JoinTreeTransferrer, DeviceAdapter>
joinTreeTransferrerDispatcher(joinTreeTransferrer);
vtkm::worklet::DispatcherMapField<JoinTreeTransferrer> joinTreeTransferrerDispatcher(
joinTreeTransferrer);
joinTreeTransferrerDispatcher.SetDevice(DeviceAdapter());
vtkm::cont::ArrayHandleIndex valueIndexArray(valueIndex.GetNumberOfValues());
joinTreeTransferrerDispatcher.Invoke(valueIndexArray, // input

@ -367,8 +367,9 @@ void ContourTree<T, StorageType, DeviceAdapter>::FindSupernodes()
if (nCandidates > 0)
{
RegularToCriticalUp regularToCriticalUp;
vtkm::worklet::DispatcherMapField<RegularToCriticalUp, DeviceAdapter>
regularToCriticalUpDispatcher(regularToCriticalUp);
vtkm::worklet::DispatcherMapField<RegularToCriticalUp> regularToCriticalUpDispatcher(
regularToCriticalUp);
regularToCriticalUpDispatcher.SetDevice(DeviceAdapter());
regularToCriticalUpDispatcher.Invoke(candidateIndexArray, // input
candidates, // input
@ -404,8 +405,9 @@ void ContourTree<T, StorageType, DeviceAdapter>::FindSupernodes()
if (nCandidates > 0)
{
RegularToCandidate regularToCandidate;
vtkm::worklet::DispatcherMapField<RegularToCandidate, DeviceAdapter>
regularToCandidateDispatcher(regularToCandidate);
vtkm::worklet::DispatcherMapField<RegularToCandidate> regularToCandidateDispatcher(
regularToCandidate);
regularToCandidateDispatcher.SetDevice(DeviceAdapter());
regularToCandidateDispatcher.Invoke(candidates, // input
joinTree.mergeArcs, // input (whole array)
@ -424,8 +426,8 @@ void ContourTree<T, StorageType, DeviceAdapter>::FindSupernodes()
if (nCandidates > 0)
{
SubrangeOffset subRangeOffset;
vtkm::worklet::DispatcherMapField<SubrangeOffset, DeviceAdapter> subrangeOffsetDispatcher(
subRangeOffset);
vtkm::worklet::DispatcherMapField<SubrangeOffset> subrangeOffsetDispatcher(subRangeOffset);
subrangeOffsetDispatcher.SetDevice(DeviceAdapter());
subrangeOffsetDispatcher.Invoke(subsetIndexArray, // index
sortVector, // input
@ -436,8 +438,8 @@ void ContourTree<T, StorageType, DeviceAdapter>::FindSupernodes()
if (nCandidates > 0)
{
DegreeDelta degreeDelta(nCandidates);
vtkm::worklet::DispatcherMapField<DegreeDelta, DeviceAdapter> degreeDeltaDispatcher(
degreeDelta);
vtkm::worklet::DispatcherMapField<DegreeDelta> degreeDeltaDispatcher(degreeDelta);
degreeDeltaDispatcher.SetDevice(DeviceAdapter());
degreeDeltaDispatcher.Invoke(subsetIndexArray, // input
sortVector, // input (whole array)
@ -449,8 +451,9 @@ void ContourTree<T, StorageType, DeviceAdapter>::FindSupernodes()
if (nCandidates > 0)
{
RegularToCriticalDown regularToCriticalDown;
vtkm::worklet::DispatcherMapField<RegularToCriticalDown, DeviceAdapter>
regularToCriticalDownDispatcher(regularToCriticalDown);
vtkm::worklet::DispatcherMapField<RegularToCriticalDown> regularToCriticalDownDispatcher(
regularToCriticalDown);
regularToCriticalDownDispatcher.SetDevice(DeviceAdapter());
regularToCriticalDownDispatcher.Invoke(candidates, // input
splitTree.mergeArcs, // input (whole array)
@ -468,8 +471,8 @@ void ContourTree<T, StorageType, DeviceAdapter>::FindSupernodes()
if (nCandidates > 0)
{
SubrangeOffset subRangeOffset;
vtkm::worklet::DispatcherMapField<SubrangeOffset, DeviceAdapter> subrangeOffsetDispatcher(
subRangeOffset);
vtkm::worklet::DispatcherMapField<SubrangeOffset> subrangeOffsetDispatcher(subRangeOffset);
subrangeOffsetDispatcher.SetDevice(DeviceAdapter());
subrangeOffsetDispatcher.Invoke(subsetIndexArray, // index
sortVector, // input
@ -480,8 +483,8 @@ void ContourTree<T, StorageType, DeviceAdapter>::FindSupernodes()
if (nCandidates > 0)
{
DegreeDelta degreeDelta(nCandidates);
vtkm::worklet::DispatcherMapField<DegreeDelta, DeviceAdapter> degreeDeltaDispatcher(
degreeDelta);
vtkm::worklet::DispatcherMapField<DegreeDelta> degreeDeltaDispatcher(degreeDelta);
degreeDeltaDispatcher.SetDevice(DeviceAdapter());
degreeDeltaDispatcher.Invoke(subsetIndexArray, // index
sortVector, // input
@ -496,8 +499,8 @@ void ContourTree<T, StorageType, DeviceAdapter>::FindSupernodes()
if (nCandidates > 0)
{
FillSupernodes fillSupernodes;
vtkm::worklet::DispatcherMapField<FillSupernodes, DeviceAdapter> fillSupernodesDispatcher(
fillSupernodes);
vtkm::worklet::DispatcherMapField<FillSupernodes> fillSupernodesDispatcher(fillSupernodes);
fillSupernodesDispatcher.SetDevice(DeviceAdapter());
fillSupernodesDispatcher.Invoke(upCandidate, // input
downCandidate, // input
@ -526,8 +529,8 @@ void ContourTree<T, StorageType, DeviceAdapter>::FindSupernodes()
if (nCandidates > 0)
{
CopySupernodes copySupernodes;
vtkm::worklet::DispatcherMapField<CopySupernodes, DeviceAdapter> copySupernodesDispatcher(
copySupernodes);
vtkm::worklet::DispatcherMapField<CopySupernodes> copySupernodesDispatcher(copySupernodes);
copySupernodesDispatcher.SetDevice(DeviceAdapter());
copySupernodesDispatcher.Invoke(isSupernode, // input
candidates, // input
@ -554,8 +557,9 @@ void ContourTree<T, StorageType, DeviceAdapter>::FindSupernodes()
// and copy them across, setting IDs for both ends
SetJoinAndSplitArcs setJoinAndSplitArcs;
vtkm::worklet::DispatcherMapField<SetJoinAndSplitArcs, DeviceAdapter>
setJoinAndSplitArcsDispatcher(setJoinAndSplitArcs);
vtkm::worklet::DispatcherMapField<SetJoinAndSplitArcs> setJoinAndSplitArcsDispatcher(
setJoinAndSplitArcs);
setJoinAndSplitArcsDispatcher.SetDevice(DeviceAdapter());
setJoinAndSplitArcsDispatcher.Invoke(supernodes, // input
joinTree.mergeArcs, // input (whole array)
@ -584,7 +588,8 @@ template <typename T, typename StorageType, typename DeviceAdapter>
void ContourTree<T, StorageType, DeviceAdapter>::TransferLeaves()
{
FindLeaves findLeaves;
vtkm::worklet::DispatcherMapField<FindLeaves, DeviceAdapter> findLeavesDispatcher(findLeaves);
vtkm::worklet::DispatcherMapField<FindLeaves> findLeavesDispatcher(findLeaves);
findLeavesDispatcher.SetDevice(DeviceAdapter());
findLeavesDispatcher.Invoke(activeSupernodes, // input
updegree, // input (whole array)
@ -627,8 +632,8 @@ void ContourTree<T, StorageType, DeviceAdapter>::CollapseRegular(bool isJoin)
// loop to copy join/split
CopyJoinSplit copyJoinSplit;
vtkm::worklet::DispatcherMapField<CopyJoinSplit, DeviceAdapter> copyJoinSplitDispatcher(
copyJoinSplit);
vtkm::worklet::DispatcherMapField<CopyJoinSplit> copyJoinSplitDispatcher(copyJoinSplit);
copyJoinSplitDispatcher.SetDevice(DeviceAdapter());
copyJoinSplitDispatcher.Invoke(activeSupernodes, // input
inbound, // input (whole array)
@ -647,8 +652,8 @@ void ContourTree<T, StorageType, DeviceAdapter>::CollapseRegular(bool isJoin)
for (vtkm::Id iteration = 0; iteration < nLogSteps; iteration++)
{
UpdateOutbound updateOutbound;
vtkm::worklet::DispatcherMapField<UpdateOutbound, DeviceAdapter> updateOutboundDispatcher(
updateOutbound);
vtkm::worklet::DispatcherMapField<UpdateOutbound> updateOutboundDispatcher(updateOutbound);
updateOutboundDispatcher.SetDevice(DeviceAdapter());
updateOutboundDispatcher.Invoke(activeSupernodes, // input
outbound); // i/o (whole array)
@ -661,8 +666,9 @@ void ContourTree<T, StorageType, DeviceAdapter>::CollapseRegular(bool isJoin)
// a. outbound is not -1 (i.e. vertex is regular)
// b. superarc[outbound] is not -1 (i.e. outbound is a leaf)
SetSupernodeInward setSupernodeInward;
vtkm::worklet::DispatcherMapField<SetSupernodeInward, DeviceAdapter> setSupernodeInwardDispatcher(
vtkm::worklet::DispatcherMapField<SetSupernodeInward> setSupernodeInwardDispatcher(
setSupernodeInward);
setSupernodeInwardDispatcher.SetDevice(DeviceAdapter());
setSupernodeInwardDispatcher.Invoke(activeSupernodes, // input
inbound, // input (whole array)
@ -691,7 +697,8 @@ void ContourTree<T, StorageType, DeviceAdapter>::CompressTrees()
for (vtkm::Id logStep = 0; logStep < nLogSteps; logStep++)
{
SkipVertex skipVertex;
vtkm::worklet::DispatcherMapField<SkipVertex, DeviceAdapter> skipVertexDispatcher(skipVertex);
vtkm::worklet::DispatcherMapField<SkipVertex> skipVertexDispatcher(skipVertex);
skipVertexDispatcher.SetDevice(DeviceAdapter());
skipVertexDispatcher.Invoke(activeSupernodes, // input
superarcs, // input (whole array)
@ -713,8 +720,8 @@ void ContourTree<T, StorageType, DeviceAdapter>::CompressActiveSupernodes()
noSuperarcArray.Allocate(activeSupernodes.GetNumberOfValues());
VertexAssigned vertexAssigned(false);
vtkm::worklet::DispatcherMapField<VertexAssigned, DeviceAdapter> vertexAssignedDispatcher(
vertexAssigned);
vtkm::worklet::DispatcherMapField<VertexAssigned> vertexAssignedDispatcher(vertexAssigned);
vertexAssignedDispatcher.SetDevice(DeviceAdapter());
vertexAssignedDispatcher.Invoke(activeSupernodes, superarcs, noSuperarcArray);
@ -738,8 +745,8 @@ void ContourTree<T, StorageType, DeviceAdapter>::FindDegrees()
vtkm::Id nActiveSupernodes = activeSupernodes.GetNumberOfValues();
ResetDegrees resetDegrees;
vtkm::worklet::DispatcherMapField<ResetDegrees, DeviceAdapter> resetDegreesDispatcher(
resetDegrees);
vtkm::worklet::DispatcherMapField<ResetDegrees> resetDegreesDispatcher(resetDegrees);
resetDegreesDispatcher.SetDevice(DeviceAdapter());
resetDegreesDispatcher.Invoke(activeSupernodes, // input
updegree, // output (whole array)
@ -754,8 +761,8 @@ void ContourTree<T, StorageType, DeviceAdapter>::FindDegrees()
if (nActiveSupernodes > 0)
{
CopyNeighbors copyNeighbors;
vtkm::worklet::DispatcherMapField<CopyNeighbors, DeviceAdapter> copyNeighborsDispatcher(
copyNeighbors);
vtkm::worklet::DispatcherMapField<CopyNeighbors> copyNeighborsDispatcher(copyNeighbors);
copyNeighborsDispatcher.SetDevice(DeviceAdapter());
copyNeighborsDispatcher.Invoke(activeSupernodeIndexArray, // input
activeSupernodes, // input (whole array)
@ -774,8 +781,9 @@ void ContourTree<T, StorageType, DeviceAdapter>::FindDegrees()
if (nActiveSupernodes > 1)
{
DegreeSubrangeOffset degreeSubrangeOffset;
vtkm::worklet::DispatcherMapField<DegreeSubrangeOffset, DeviceAdapter>
degreeSubrangeOffsetDispatcher(degreeSubrangeOffset);
vtkm::worklet::DispatcherMapField<DegreeSubrangeOffset> degreeSubrangeOffsetDispatcher(
degreeSubrangeOffset);
degreeSubrangeOffsetDispatcher.SetDevice(DeviceAdapter());
degreeSubrangeOffsetDispatcher.Invoke(subsetIndexArray, // input
sortVector, // input (whole array)
@ -786,8 +794,8 @@ void ContourTree<T, StorageType, DeviceAdapter>::FindDegrees()
if (nActiveSupernodes > 1)
{
DegreeDelta degreeDelta(nActiveSupernodes);
vtkm::worklet::DispatcherMapField<DegreeDelta, DeviceAdapter> degreeDeltaDispatcher(
degreeDelta);
vtkm::worklet::DispatcherMapField<DegreeDelta> degreeDeltaDispatcher(degreeDelta);
degreeDeltaDispatcher.SetDevice(DeviceAdapter());
degreeDeltaDispatcher.Invoke(subsetIndexArray, // input
sortVector, // input
@ -799,8 +807,8 @@ void ContourTree<T, StorageType, DeviceAdapter>::FindDegrees()
if (nActiveSupernodes > 0)
{
CopyNeighbors copyNeighbors;
vtkm::worklet::DispatcherMapField<CopyNeighbors, DeviceAdapter> copyNeighborsDispatcher(
copyNeighbors);
vtkm::worklet::DispatcherMapField<CopyNeighbors> copyNeighborsDispatcher(copyNeighbors);
copyNeighborsDispatcher.SetDevice(DeviceAdapter());
copyNeighborsDispatcher.Invoke(activeSupernodeIndexArray, // input
activeSupernodes, // input (whole array)
@ -818,8 +826,9 @@ void ContourTree<T, StorageType, DeviceAdapter>::FindDegrees()
if (nActiveSupernodes > 1)
{
DegreeSubrangeOffset degreeSubrangeOffset;
vtkm::worklet::DispatcherMapField<DegreeSubrangeOffset, DeviceAdapter>
degreeSubrangeOffsetDispatcher(degreeSubrangeOffset);
vtkm::worklet::DispatcherMapField<DegreeSubrangeOffset> degreeSubrangeOffsetDispatcher(
degreeSubrangeOffset);
degreeSubrangeOffsetDispatcher.SetDevice(DeviceAdapter());
degreeSubrangeOffsetDispatcher.Invoke(subsetIndexArray, // input
sortVector, // input (whole array)
@ -830,8 +839,8 @@ void ContourTree<T, StorageType, DeviceAdapter>::FindDegrees()
if (nActiveSupernodes > 1)
{
DegreeDelta degreeDelta(nActiveSupernodes);
vtkm::worklet::DispatcherMapField<DegreeDelta, DeviceAdapter> degreeDeltaDispatcher(
degreeDelta);
vtkm::worklet::DispatcherMapField<DegreeDelta> degreeDeltaDispatcher(degreeDelta);
degreeDeltaDispatcher.SetDevice(DeviceAdapter());
degreeDeltaDispatcher.Invoke(subsetIndexArray, // input
sortVector, // input (whole array)

@ -224,8 +224,8 @@ void MergeTree<T, StorageType, DeviceAdapter>::BuildRegularChains()
vtkm::cont::ArrayHandleIndex vertexIndexArray(nVertices);
ChainDoubler chainDoubler;
vtkm::worklet::DispatcherMapField<ChainDoubler, DeviceAdapter> chainDoublerDispatcher(
chainDoubler);
vtkm::worklet::DispatcherMapField<ChainDoubler> chainDoublerDispatcher(chainDoubler);
chainDoublerDispatcher.SetDevice(DeviceAdapter());
// 3. Apply pointer-doubling to build chains to maxima, rocking between two arrays
for (vtkm::Id logStep = 0; logStep < nLogSteps; logStep++)
@ -256,8 +256,9 @@ void MergeTree<T, StorageType, DeviceAdapter>::ComputeAugmentedSuperarcs()
vtkm::Id nExtrema = extrema.GetNumberOfValues();
JoinSuperArcFinder<T> joinSuperArcFinder(isJoinTree);
vtkm::worklet::DispatcherMapField<JoinSuperArcFinder<T>, DeviceAdapter>
joinSuperArcFinderDispatcher(joinSuperArcFinder);
vtkm::worklet::DispatcherMapField<JoinSuperArcFinder<T>> joinSuperArcFinderDispatcher(
joinSuperArcFinder);
joinSuperArcFinderDispatcher.SetDevice(DeviceAdapter());
vtkm::cont::ArrayHandleIndex vertexIndexArray(nExtrema);
joinSuperArcFinderDispatcher.Invoke(vertexIndexArray, // input
@ -308,8 +309,8 @@ void MergeTree<T, StorageType, DeviceAdapter>::ComputeAugmentedArcs(
vtkm::cont::ArrayHandleIndex critVertexIndexArray(nCriticalVerts);
JoinArcConnector joinArcConnector;
vtkm::worklet::DispatcherMapField<JoinArcConnector, DeviceAdapter> joinArcConnectorDispatcher(
joinArcConnector);
vtkm::worklet::DispatcherMapField<JoinArcConnector> joinArcConnectorDispatcher(joinArcConnector);
joinArcConnectorDispatcher.SetDevice(DeviceAdapter());
joinArcConnectorDispatcher.Invoke(critVertexIndexArray, // input
vertexSorter, // input (whole array)

@ -144,8 +144,9 @@ void Mesh2D_DEM_Triangulation<T, StorageType, DeviceAdapter>::SetStarts(
// For each vertex set the next vertex in the chain
vtkm::cont::ArrayHandleIndex vertexIndexArray(nVertices);
Mesh2D_DEM_VertexStarter<T> vertexStarter(nRows, nCols, ascending);
vtkm::worklet::DispatcherMapField<Mesh2D_DEM_VertexStarter<T>, DeviceAdapter>
vertexStarterDispatcher(vertexStarter);
vtkm::worklet::DispatcherMapField<Mesh2D_DEM_VertexStarter<T>> vertexStarterDispatcher(
vertexStarter);
vertexStarterDispatcher.SetDevice(DeviceAdapter());
vertexStarterDispatcher.Invoke(vertexIndexArray, // input
values, // input (whole array)
@ -187,8 +188,9 @@ void Mesh2D_DEM_Triangulation<T, StorageType, DeviceAdapter>::SetSaddleStarts(
vtkm::cont::ArrayHandleIndex vertexIndexArray(nVertices);
Mesh2D_DEM_VertexOutdegreeStarter vertexOutdegreeStarter(nRows, nCols, ascending);
vtkm::worklet::DispatcherMapField<Mesh2D_DEM_VertexOutdegreeStarter, DeviceAdapter>
vtkm::worklet::DispatcherMapField<Mesh2D_DEM_VertexOutdegreeStarter>
vertexOutdegreeStarterDispatcher(vertexOutdegreeStarter);
vertexOutdegreeStarterDispatcher.SetDevice(DeviceAdapter());
vertexOutdegreeStarterDispatcher.Invoke(vertexIndexArray, // input
neighbourhoodMask, // input
@ -243,8 +245,9 @@ void Mesh2D_DEM_Triangulation<T, StorageType, DeviceAdapter>::SetSaddleStarts(
Mesh2D_DEM_SaddleStarter saddleStarter(nRows, // input
nCols, // input
ascending); // input
vtkm::worklet::DispatcherMapField<Mesh2D_DEM_SaddleStarter, DeviceAdapter>
saddleStarterDispatcher(saddleStarter);
vtkm::worklet::DispatcherMapField<Mesh2D_DEM_SaddleStarter> saddleStarterDispatcher(
saddleStarter);
saddleStarterDispatcher.SetDevice(DeviceAdapter());
vtkm::cont::ArrayHandleZip<vtkm::cont::ArrayHandle<vtkm::Id>, vtkm::cont::ArrayHandle<vtkm::Id>>
outDegFirstEdge = vtkm::cont::make_ArrayHandleZip(mergeGraph.outdegree, mergeGraph.firstEdge);

@ -178,8 +178,9 @@ void Mesh3D_DEM_Triangulation<T, StorageType, DeviceAdapter>::SetStarts(
// For each vertex set the next vertex in the chain
vtkm::cont::ArrayHandleIndex vertexIndexArray(nVertices);
Mesh3D_DEM_VertexStarter<T> vertexStarter(nRows, nCols, nSlices, ascending);
vtkm::worklet::DispatcherMapField<Mesh3D_DEM_VertexStarter<T>, DeviceAdapter>
vertexStarterDispatcher(vertexStarter);
vtkm::worklet::DispatcherMapField<Mesh3D_DEM_VertexStarter<T>> vertexStarterDispatcher(
vertexStarter);
vertexStarterDispatcher.SetDevice(DeviceAdapter());
vertexStarterDispatcher.Invoke(vertexIndexArray, // input
values, // input (whole array)
@ -209,8 +210,9 @@ void Mesh3D_DEM_Triangulation<T, StorageType, DeviceAdapter>::SetSaddleStarts(
ascending,
neighbourOffsets3D.PrepareForInput(DeviceAdapter()),
linkComponentCaseTable3D.PrepareForInput(DeviceAdapter()));
vtkm::worklet::DispatcherMapField<Mesh3D_DEM_VertexOutdegreeStarter<DeviceAdapter>, DeviceAdapter>
vtkm::worklet::DispatcherMapField<Mesh3D_DEM_VertexOutdegreeStarter<DeviceAdapter>>
vertexOutdegreeStarterDispatcher(vertexOutdegreeStarter);
vertexOutdegreeStarterDispatcher.SetDevice(DeviceAdapter());
vertexOutdegreeStarterDispatcher.Invoke(vertexIndexArray, // input
neighbourhoodMask, // input
@ -269,8 +271,9 @@ void Mesh3D_DEM_Triangulation<T, StorageType, DeviceAdapter>::SetSaddleStarts(
ascending, // input
neighbourOffsets3D.PrepareForInput(DeviceAdapter()),
linkComponentCaseTable3D.PrepareForInput(DeviceAdapter()));
vtkm::worklet::DispatcherMapField<Mesh3D_DEM_SaddleStarter<DeviceAdapter>, DeviceAdapter>
vtkm::worklet::DispatcherMapField<Mesh3D_DEM_SaddleStarter<DeviceAdapter>>
saddleStarterDispatcher(saddleStarter);
saddleStarterDispatcher.SetDevice(DeviceAdapter());
vtkm::cont::ArrayHandleZip<vtkm::cont::ArrayHandle<vtkm::Id>, vtkm::cont::ArrayHandle<vtkm::Id>>
outDegFirstEdge = vtkm::cont::make_ArrayHandleZip(mergeGraph.outdegree, mergeGraph.firstEdge);

@ -127,8 +127,9 @@ vtkm::Id CosmoTools<T, StorageType, DeviceAdapter>::MBPCenterFinderMxN(T* mxnPot
// Estimate only across the uniqueBins that contain particles
ComputePotentialBin<T> computePotentialBin(uniqueBins.GetNumberOfValues(), particleMass, linkLen);
vtkm::worklet::DispatcherMapField<ComputePotentialBin<T>, DeviceAdapter>
computePotentialBinDispatcher(computePotentialBin);
vtkm::worklet::DispatcherMapField<ComputePotentialBin<T>> computePotentialBinDispatcher(
computePotentialBin);
computePotentialBinDispatcher.SetDevice(DeviceAdapter());
computePotentialBinDispatcher.Invoke(uniqueIndex, // input
partPerBin, // input (whole array)
@ -157,8 +158,9 @@ vtkm::Id CosmoTools<T, StorageType, DeviceAdapter>::MBPCenterFinderMxN(T* mxnPot
DeviceAlgorithm::Copy(vtkm::cont::ArrayHandleConstant<vtkm::Id>(0, nParticles), candidate);
SetCandidateParticles<T> setCandidateParticles(cutoffPotential);
vtkm::worklet::DispatcherMapField<SetCandidateParticles<T>, DeviceAdapter>
setCandidateParticlesDispatcher(setCandidateParticles);
vtkm::worklet::DispatcherMapField<SetCandidateParticles<T>> setCandidateParticlesDispatcher(
setCandidateParticles);
setCandidateParticlesDispatcher.SetDevice(DeviceAdapter());
setCandidateParticlesDispatcher.Invoke(bestEstPotential, // input
particleOffset, // input
partPerBin, // input
@ -171,8 +173,9 @@ vtkm::Id CosmoTools<T, StorageType, DeviceAdapter>::MBPCenterFinderMxN(T* mxnPot
// Compute potentials only on the candidate particles
vtkm::cont::ArrayHandle<T> mpotential;
ComputePotentialOnCandidates<T> computePotentialOnCandidates(nParticles, particleMass);
vtkm::worklet::DispatcherMapField<ComputePotentialOnCandidates<T>, DeviceAdapter>
vtkm::worklet::DispatcherMapField<ComputePotentialOnCandidates<T>>
computePotentialOnCandidatesDispatcher(computePotentialOnCandidates);
computePotentialOnCandidatesDispatcher.SetDevice(DeviceAdapter());
computePotentialOnCandidatesDispatcher.Invoke(mparticles,
xLoc, // input (whole array)
@ -255,8 +258,8 @@ void CosmoTools<T, StorageType, DeviceAdapter>::BinParticlesHalo(
numBinsX,
numBinsY,
numBinsZ); // Size of superimposed mesh
vtkm::worklet::DispatcherMapField<ComputeBins<T>, DeviceAdapter> computeBinsDispatcher(
computeBins);
vtkm::worklet::DispatcherMapField<ComputeBins<T>> computeBinsDispatcher(computeBins);
computeBinsDispatcher.SetDevice(DeviceAdapter());
computeBinsDispatcher.Invoke(xLoc, // input
yLoc, // input
zLoc, // input
@ -289,8 +292,9 @@ void CosmoTools<T, StorageType, DeviceAdapter>::BinParticlesHalo(
// Calculate the bin indices
vtkm::cont::ArrayHandleIndex uniqueIndex(uniqueBins.GetNumberOfValues());
ComputeBinIndices<T> computeBinIndices(numBinsX, numBinsY, numBinsZ);
vtkm::worklet::DispatcherMapField<ComputeBinIndices<T>, DeviceAdapter>
computeBinIndicesDispatcher(computeBinIndices);
vtkm::worklet::DispatcherMapField<ComputeBinIndices<T>> computeBinIndicesDispatcher(
computeBinIndices);
computeBinIndicesDispatcher.SetDevice(DeviceAdapter());
computeBinIndicesDispatcher.Invoke(uniqueBins, // input
binX, // input
@ -329,14 +333,15 @@ void CosmoTools<T, StorageType, DeviceAdapter>::MBPCenterFindingByKey(
vtkm::cont::ArrayHandleIndex countArray(nParticles);
ComputeNeighborBins computeNeighborBins(numBinsX, numBinsY, numBinsZ, NUM_NEIGHBORS);
vtkm::worklet::DispatcherMapField<ComputeNeighborBins, DeviceAdapter>
computeNeighborBinsDispatcher(computeNeighborBins);
vtkm::worklet::DispatcherMapField<ComputeNeighborBins> computeNeighborBinsDispatcher(
computeNeighborBins);
computeNeighborBinsDispatcher.SetDevice(DeviceAdapter());
computeNeighborBinsDispatcher.Invoke(countArray, keyId, leftNeighbor);
// Compute indices of all right neighbor bins
ComputeBinRange computeBinRange(numBinsX);
vtkm::worklet::DispatcherMapField<ComputeBinRange, DeviceAdapter> computeBinRangeDispatcher(
computeBinRange);
vtkm::worklet::DispatcherMapField<ComputeBinRange> computeBinRangeDispatcher(computeBinRange);
computeBinRangeDispatcher.SetDevice(DeviceAdapter());
computeBinRangeDispatcher.Invoke(leftNeighbor, rightNeighbor);
// Convert bin range to particle range within the bins
@ -351,8 +356,9 @@ void CosmoTools<T, StorageType, DeviceAdapter>::MBPCenterFindingByKey(
// Compute potentials on particles in 27 neighbors to find minimum
ComputePotentialNeighbors<T> computePotentialNeighbors(
numBinsX, numBinsY, numBinsZ, NUM_NEIGHBORS, particleMass);
vtkm::worklet::DispatcherMapField<ComputePotentialNeighbors<T>, DeviceAdapter>
vtkm::worklet::DispatcherMapField<ComputePotentialNeighbors<T>>
computePotentialNeighborsDispatcher(computePotentialNeighbors);
computePotentialNeighborsDispatcher.SetDevice(DeviceAdapter());
computePotentialNeighborsDispatcher.Invoke(indexArray,
keyId, // input (whole array)
@ -375,8 +381,9 @@ void CosmoTools<T, StorageType, DeviceAdapter>::MBPCenterFindingByKey(
// Find the particle id matching the minimum potential
vtkm::cont::ArrayHandle<vtkm::Id> centerId;
EqualsMinimumPotential<T> equalsMinimumPotential;
vtkm::worklet::DispatcherMapField<EqualsMinimumPotential<T>, DeviceAdapter>
equalsMinimumPotentialDispatcher(equalsMinimumPotential);
vtkm::worklet::DispatcherMapField<EqualsMinimumPotential<T>> equalsMinimumPotentialDispatcher(
equalsMinimumPotential);
equalsMinimumPotentialDispatcher.SetDevice(DeviceAdapter());
equalsMinimumPotentialDispatcher.Invoke(partId, potential, minPotential, centerId);
}
@ -400,8 +407,9 @@ vtkm::Id CosmoTools<T, StorageType, DeviceAdapter>::MBPCenterFinderNxN(T* nxnPot
// Compute potentials (Worklet)
ComputePotentialNxN<T> computePotentialHalo(nParticles, particleMass);
vtkm::worklet::DispatcherMapField<ComputePotentialNxN<T>, DeviceAdapter>
computePotentialHaloDispatcher(computePotentialHalo);
vtkm::worklet::DispatcherMapField<ComputePotentialNxN<T>> computePotentialHaloDispatcher(
computePotentialHalo);
computePotentialHaloDispatcher.SetDevice(DeviceAdapter());
computePotentialHaloDispatcher.Invoke(particleIndex, // input
xLoc, // input (whole array)
@ -416,8 +424,9 @@ vtkm::Id CosmoTools<T, StorageType, DeviceAdapter>::MBPCenterFinderNxN(T* nxnPot
// Find the particle id matching the minimum potential
vtkm::cont::ArrayHandle<vtkm::Id> centerId;
EqualsMinimumPotential<T> equalsMinimumPotential;
vtkm::worklet::DispatcherMapField<EqualsMinimumPotential<T>, DeviceAdapter>
equalsMinimumPotentialDispatcher(equalsMinimumPotential);
vtkm::worklet::DispatcherMapField<EqualsMinimumPotential<T>> equalsMinimumPotentialDispatcher(
equalsMinimumPotential);
equalsMinimumPotentialDispatcher.SetDevice(DeviceAdapter());
equalsMinimumPotentialDispatcher.Invoke(particleIndex, potential, minPotential, centerId);

@ -107,8 +107,9 @@ void CosmoTools<T, StorageType, DeviceAdapter>::HaloFinder(
// Mark active neighbor bins, meaning at least one particle in the bin
// is within linking length of the given particle indicated by mask
MarkActiveNeighbors<T> markActiveNeighbors(numBinsX, numBinsY, numBinsZ, NUM_NEIGHBORS, linkLen);
vtkm::worklet::DispatcherMapField<MarkActiveNeighbors<T>, DeviceAdapter>
markActiveNeighborsDispatcher(markActiveNeighbors);
vtkm::worklet::DispatcherMapField<MarkActiveNeighbors<T>> markActiveNeighborsDispatcher(
markActiveNeighbors);
markActiveNeighborsDispatcher.SetDevice(DeviceAdapter());
markActiveNeighborsDispatcher.Invoke(
indexArray, // (input) index into all particles
partId, // (input) particle id sorted by bin
@ -133,8 +134,8 @@ void CosmoTools<T, StorageType, DeviceAdapter>::HaloFinder(
{
// Connect each particle to another close particle to build halos
GraftParticles<T> graftParticles(numBinsX, numBinsY, numBinsZ, NUM_NEIGHBORS, linkLen);
vtkm::worklet::DispatcherMapField<GraftParticles<T>, DeviceAdapter> graftParticlesDispatcher(
graftParticles);
vtkm::worklet::DispatcherMapField<GraftParticles<T>> graftParticlesDispatcher(graftParticles);
graftParticlesDispatcher.SetDevice(DeviceAdapter());
graftParticlesDispatcher.Invoke(indexArray, // (input) index into particles
partId, // (input) particle id sorted by bin
@ -155,7 +156,8 @@ void CosmoTools<T, StorageType, DeviceAdapter>::HaloFinder(
// By comparing the haloIds from the last pass and this one
// determine if any particles are still migrating to halos
IsStar isStar;
vtkm::worklet::DispatcherMapField<IsStar, DeviceAdapter> isStarDispatcher(isStar);
vtkm::worklet::DispatcherMapField<IsStar> isStarDispatcher(isStar);
isStarDispatcher.SetDevice(DeviceAdapter());
isStarDispatcher.Invoke(indexArray,
haloIdCurrent, // input (whole array)
haloIdLast, // input (whole array)
@ -171,8 +173,8 @@ void CosmoTools<T, StorageType, DeviceAdapter>::HaloFinder(
// Otherwise copy current halo ids to last pass halo ids
{
PointerJump pointerJump;
vtkm::worklet::DispatcherMapField<PointerJump, DeviceAdapter> pointerJumpDispatcher(
pointerJump);
vtkm::worklet::DispatcherMapField<PointerJump> pointerJumpDispatcher(pointerJump);
pointerJumpDispatcher.SetDevice(DeviceAdapter());
pointerJumpDispatcher.Invoke(indexArray, haloIdCurrent); // input (whole array)
DeviceAlgorithm::Copy(haloIdCurrent, haloIdLast);
}
@ -243,8 +245,8 @@ void CosmoTools<T, StorageType, DeviceAdapter>::BinParticlesAll(
numBinsX,
numBinsY,
numBinsZ); // Size of superimposed mesh
vtkm::worklet::DispatcherMapField<ComputeBins<T>, DeviceAdapter> computeBinsDispatcher(
computeBins);
vtkm::worklet::DispatcherMapField<ComputeBins<T>> computeBinsDispatcher(computeBins);
computeBinsDispatcher.SetDevice(DeviceAdapter());
computeBinsDispatcher.Invoke(xLoc, // input
yLoc, // input
zLoc, // input
@ -275,14 +277,15 @@ void CosmoTools<T, StorageType, DeviceAdapter>::BinParticlesAll(
// Compute indices of all left neighbor bins
vtkm::cont::ArrayHandleIndex countArray(nParticles);
ComputeNeighborBins computeNeighborBins(numBinsX, numBinsY, numBinsZ, NUM_NEIGHBORS);
vtkm::worklet::DispatcherMapField<ComputeNeighborBins, DeviceAdapter>
computeNeighborBinsDispatcher(computeNeighborBins);
vtkm::worklet::DispatcherMapField<ComputeNeighborBins> computeNeighborBinsDispatcher(
computeNeighborBins);
computeNeighborBinsDispatcher.SetDevice(DeviceAdapter());
computeNeighborBinsDispatcher.Invoke(countArray, binId, leftNeighbor);
// Compute indices of all right neighbor bins
ComputeBinRange computeBinRange(numBinsX);
vtkm::worklet::DispatcherMapField<ComputeBinRange, DeviceAdapter> computeBinRangeDispatcher(
computeBinRange);
vtkm::worklet::DispatcherMapField<ComputeBinRange> computeBinRangeDispatcher(computeBinRange);
computeBinRangeDispatcher.SetDevice(DeviceAdapter());
computeBinRangeDispatcher.Invoke(leftNeighbor, rightNeighbor);
// Convert bin range to particle range within the bins
@ -334,8 +337,8 @@ void CosmoTools<T, StorageType, DeviceAdapter>::MBPCenterFindingByHalo(
// Setup the ScatterCounting worklets needed to expand the ReduceByKeyResults
vtkm::worklet::ScatterCounting scatter(particlesPerHalo, DeviceAdapter());
vtkm::worklet::DispatcherMapField<ScatterWorklet<vtkm::Id>> scatterWorkletIdDispatcher(scatter);
vtkm::worklet::DispatcherMapField<ScatterWorklet<T>, DeviceAdapter> scatterWorkletDispatcher(
scatter);
vtkm::worklet::DispatcherMapField<ScatterWorklet<T>> scatterWorkletDispatcher(scatter);
scatterWorkletDispatcher.SetDevice(DeviceAdapter());
// Calculate the minimum particle index per halo id and scatter
DeviceAlgorithm::ScanExclusive(particlesPerHalo, tempI);
@ -358,8 +361,9 @@ void CosmoTools<T, StorageType, DeviceAdapter>::MBPCenterFindingByHalo(
// Compute potentials
ComputePotential<T> computePotential(particleMass);
vtkm::worklet::DispatcherMapField<ComputePotential<T>, DeviceAdapter> computePotentialDispatcher(
vtkm::worklet::DispatcherMapField<ComputePotential<T>> computePotentialDispatcher(
computePotential);
computePotentialDispatcher.SetDevice(DeviceAdapter());
computePotentialDispatcher.Invoke(indexArray,
partId, // input (whole array)
@ -380,8 +384,9 @@ void CosmoTools<T, StorageType, DeviceAdapter>::MBPCenterFindingByHalo(
// Find the particle id matching the minimum potential (Worklet)
EqualsMinimumPotential<T> equalsMinimumPotential;
vtkm::worklet::DispatcherMapField<EqualsMinimumPotential<T>, DeviceAdapter>
equalsMinimumPotentialDispatcher(equalsMinimumPotential);
vtkm::worklet::DispatcherMapField<EqualsMinimumPotential<T>> equalsMinimumPotentialDispatcher(
equalsMinimumPotential);
equalsMinimumPotentialDispatcher.SetDevice(DeviceAdapter());
equalsMinimumPotentialDispatcher.Invoke(partId, potential, minPotential, mbpId);

@ -59,10 +59,12 @@ struct Transpose3x3 : vtkm::worklet::WorkletMapField
field[2][1] = tempC;
}
template <typename S, typename DeviceAdapter>
void Run(vtkm::cont::ArrayHandle<vtkm::Vec<vtkm::Vec<T, 3>, 3>, S>& field, DeviceAdapter)
template <typename S>
void Run(vtkm::cont::ArrayHandle<vtkm::Vec<vtkm::Vec<T, 3>, 3>, S>& field,
vtkm::cont::DeviceAdapterId device = vtkm::cont::DeviceAdapterTagAny())
{
vtkm::worklet::DispatcherMapField<Transpose3x3<T>, DeviceAdapter> dispatcher;
vtkm::worklet::DispatcherMapField<Transpose3x3<T>> dispatcher;
dispatcher.SetDevice(device);
dispatcher.Invoke(field);
}
};

@ -112,8 +112,9 @@ public:
BinDelta = compute_delta(MinMax.Min, MinMax.Max, NumOfBins);
SetHistogramBin<T> binWorklet(NumOfBins, MinMax.Min, BinDelta);
vtkm::worklet::DispatcherMapField<vtkm::worklet::histogram::SetHistogramBin<T>, DeviceAdapter>
vtkm::worklet::DispatcherMapField<vtkm::worklet::histogram::SetHistogramBin<T>>
setHistogramBinDispatcher(binWorklet);
setHistogramBinDispatcher.SetDevice(DeviceAdapter());
setHistogramBinDispatcher.Invoke(field, Bin1DIdx, Bin1DIdx);
}

@ -26,8 +26,8 @@
#include <vtkm/internal/Invocation.h>
#include <vtkm/cont/DeviceAdapter.h>
#include <vtkm/cont/ErrorBadType.h>
#include <vtkm/cont/TryExecute.h>
#include <vtkm/cont/arg/ControlSignatureTagBase.h>
#include <vtkm/cont/arg/Transport.h>
@ -257,6 +257,20 @@ struct DispatcherBaseExecutionSignatureTagCheck
};
};
struct DispatcherBaseTryExecuteFunctor
{
template <typename Device, typename DispatcherBaseType, typename Invocation, typename RangeType>
VTKM_CONT bool operator()(Device device,
const DispatcherBaseType* self,
Invocation& invocation,
const RangeType& dimensions)
{
self->InvokeTransportParameters(
invocation, dimensions, self->Scatter.GetOutputRange(dimensions), device);
return true;
}
};
// A look up helper used by DispatcherBaseTransportFunctor to determine
//the types independent of the device we are templated on.
template <typename ControlInterface, vtkm::IdComponent Index>
@ -627,9 +641,18 @@ private:
static_cast<const DerivedClass*>(this)->DoInvoke(ivc);
}
public:
//@{
/// Setting the device ID will force the execute to happen on a particular device. If no device
/// is specified (or the device ID is set to any), then a device will automatically be chosen
/// based on the runtime device tracker.
///
VTKM_CONT
void SetDevice(vtkm::cont::DeviceAdapterId device) { this->Device = device; }
VTKM_CONT vtkm::cont::DeviceAdapterId GetDevice() const { return this->Device; }
//@}
using ScatterType = typename WorkletType::ScatterType;
template <typename... Args>
@ -643,33 +666,46 @@ protected:
DispatcherBase(const WorkletType& worklet, const ScatterType& scatter)
: Worklet(worklet)
, Scatter(scatter)
, Device(vtkm::cont::DeviceAdapterTagAny())
{
}
template <typename Invocation, typename DeviceAdapter>
VTKM_CONT void BasicInvoke(Invocation& invocation,
vtkm::Id numInstances,
DeviceAdapter device) const
friend struct internal::detail::DispatcherBaseTryExecuteFunctor;
template <typename Invocation>
VTKM_CONT void BasicInvoke(Invocation& invocation, vtkm::Id numInstances) const
{
this->InvokeTransportParameters(
invocation, numInstances, this->Scatter.GetOutputRange(numInstances), device);
bool success =
vtkm::cont::TryExecuteOnDevice(this->Device,
internal::detail::DispatcherBaseTryExecuteFunctor(),
this,
invocation,
numInstances);
if (!success)
{
throw vtkm::cont::ErrorExecution("Failed to execute worklet on any device.");
}
}
template <typename Invocation, typename DeviceAdapter>
VTKM_CONT void BasicInvoke(Invocation& invocation,
vtkm::Id2 dimensions,
DeviceAdapter device) const
template <typename Invocation>
VTKM_CONT void BasicInvoke(Invocation& invocation, vtkm::Id2 dimensions) const
{
this->BasicInvoke(invocation, vtkm::Id3(dimensions[0], dimensions[1], 1), device);
this->BasicInvoke(invocation, vtkm::Id3(dimensions[0], dimensions[1], 1));
}
template <typename Invocation, typename DeviceAdapter>
VTKM_CONT void BasicInvoke(Invocation& invocation,
vtkm::Id3 dimensions,
DeviceAdapter device) const
template <typename Invocation>
VTKM_CONT void BasicInvoke(Invocation& invocation, vtkm::Id3 dimensions) const
{
this->InvokeTransportParameters(
invocation, dimensions, this->Scatter.GetOutputRange(dimensions), device);
bool success =
vtkm::cont::TryExecuteOnDevice(this->Device,
internal::detail::DispatcherBaseTryExecuteFunctor(),
this,
invocation,
dimensions);
if (!success)
{
throw vtkm::cont::ErrorExecution("Failed to execute worklet on any device.");
}
}
WorkletType Worklet;
@ -680,6 +716,8 @@ private:
DispatcherBase(const MyType&) = delete;
void operator=(const MyType&) = delete;
vtkm::cont::DeviceAdapterId Device;
template <typename Invocation,
typename InputRangeType,
typename OutputRangeType,

Some files were not shown because too many files have changed in this diff Show More