Commit bdb9c37e authored by Li-Ta Lo's avatar Li-Ta Lo

update based on issues pointed out by Robert

parent a713a0d8
......@@ -25,12 +25,13 @@
#include <vtkm/worklet/connectivities/CellSetDualGraph.h>
#include <vtkm/worklet/connectivities/GraphConnectivity.h>
template <typename DeviceAdapter>
class CellSetConnectivity
{
public:
template <template <typename> class CellSetType, typename T>
void Run(const CellSetType<T>& cellSet, vtkm::cont::ArrayHandle<vtkm::Id>& componentArray) const
template <typename CellSetType, typename DeviceAdapter>
void Run(const CellSetType& cellSet,
vtkm::cont::ArrayHandle<vtkm::Id>& componentArray,
DeviceAdapter) const
{
vtkm::cont::ArrayHandle<vtkm::Id> numIndicesArray;
vtkm::cont::ArrayHandle<vtkm::Id> indexOffsetArray;
......
......@@ -62,7 +62,7 @@ struct EdgeExtract : public vtkm::worklet::WorkletMapPointToCell
typename EdgeIndexVecType>
VTKM_EXEC void operator()(CellShapeTag cellShape,
CellIndexType cellIndex,
PointIndexVecType& pointIndices,
const PointIndexVecType& pointIndices,
vtkm::IdComponent visitIndex,
CellIndexType& cellIndexOut,
EdgeIndexVecType& edgeIndices) const
......@@ -119,12 +119,12 @@ public:
{
// Get number of edges for each cell and use it as scatter count.
vtkm::cont::ArrayHandle<vtkm::IdComponent> numEdgesPerCell;
vtkm::worklet::DispatcherMapTopology<EdgeCount> edgesPerCellDisp;
vtkm::worklet::DispatcherMapTopology<EdgeCount, DeviceAdapter> edgesPerCellDisp;
edgesPerCellDisp.Invoke(cellSet, numEdgesPerCell);
// Get uncompress Cell to Edge mapping
vtkm::worklet::ScatterCounting scatter{ numEdgesPerCell, DeviceAdapter() };
vtkm::worklet::DispatcherMapTopology<EdgeExtract> edgeExtractDisp{ scatter };
vtkm::worklet::DispatcherMapTopology<EdgeExtract, DeviceAdapter> edgeExtractDisp{ scatter };
edgeExtractDisp.Invoke(cellSet, cellIds, cellEdges);
}
......@@ -166,7 +166,7 @@ public:
vtkm::cont::ArrayHandle<vtkm::Id> connTo;
connFrom.Allocate(sharedEdges.GetNumberOfValues() * 2);
connTo.Allocate(sharedEdges.GetNumberOfValues() * 2);
vtkm::worklet::DispatcherMapField<CellToCellConnectivity> c2cDisp;
vtkm::worklet::DispatcherMapField<CellToCellConnectivity, DeviceAdapter> c2cDisp;
c2cDisp.Invoke(lb, cellIds, connFrom, connTo);
// Turn dual graph into Compressed Sparse Row format
......
......@@ -67,11 +67,11 @@ public:
template <typename InOutPortalType>
VTKM_EXEC void operator()(vtkm::Id index, InOutPortalType& comp) const
{
while (comp.Get(comp.Get(index)) != comp.Get(index))
comp.Set(index, comp.Get(comp.Get(index)));
//vtkm::Id parent = comp.Get(index);
//comp.Set(index, comp.Get(comp.Get(index)));
// keep updating component id until we reach the root of the tree.
for (auto parent = comp.Get(index); comp.Get(parent) != parent; parent = comp.Get(index))
{
comp.Set(index, comp.Get(parent));
}
};
};
......@@ -113,16 +113,16 @@ public:
do
{
vtkm::worklet::DispatcherMapField<Graft> graftDispatcher;
vtkm::worklet::DispatcherMapField<Graft, DeviceAdapter> graftDispatcher;
graftDispatcher.Invoke(
cellIds, indexOffsetArray, numIndexArray, connectivityArray, components);
// Detection of allStar has come before pointer jumping. Don't try to rearrange it.
vtkm::worklet::DispatcherMapField<IsStar> isStarDisp;
// Detection of allStar has to come before pointer jumping. Don't try to rearrange it.
vtkm::worklet::DispatcherMapField<IsStar, DeviceAdapter> isStarDisp;
isStarDisp.Invoke(cellIds, components, isStar);
allStar = Algorithm::Reduce(isStar, true, vtkm::LogicalAnd());
vtkm::worklet::DispatcherMapField<PointerJumping> pointJumpingDispatcher;
vtkm::worklet::DispatcherMapField<PointerJumping, DeviceAdapter> pointJumpingDispatcher;
pointJumpingDispatcher.Invoke(cellIds, components);
} while (!allStar);
......
......@@ -100,9 +100,6 @@ public:
vtkm::cont::ArrayHandle<vtkm::Id> counts;
Algorithm::Transform(ubs, lbs, counts, vtkm::Subtract());
vtkm::cont::ArrayHandle<vtkm::Id> output_offset;
Algorithm::ScanExclusive(counts, output_offset);
vtkm::worklet::ScatterCounting scatter{ counts, DeviceAdapter() };
Merge merge(scatter);
vtkm::worklet::DispatcherMapField<Merge, DeviceAdapter> mergeDisp(merge);
......
......@@ -135,7 +135,7 @@ public:
auto cellSet = outputData.GetCellSet().Cast<vtkm::cont::CellSetSingleType<>>();
vtkm::cont::ArrayHandle<vtkm::Id> componentArray;
CellSetConnectivity<DeviceAdapter>().Run(cellSet, componentArray);
CellSetConnectivity().Run(cellSet, componentArray, DeviceAdapter());
using Algorithm = vtkm::cont::DeviceAdapterAlgorithm<DeviceAdapter>;
Algorithm::Sort(componentArray);
......
......@@ -60,10 +60,8 @@ public:
vtkm::cont::ArrayHandle<vtkm::Id> idxA;
vtkm::cont::ArrayHandle<vtkm::Id> idxB;
Algorithm::Copy(vtkm::cont::ArrayHandleCounting<vtkm::Id>(0, 1, A_arr.GetNumberOfValues()),
idxA);
Algorithm::Copy(vtkm::cont::ArrayHandleCounting<vtkm::Id>(0, 1, B_arr.GetNumberOfValues()),
idxB);
Algorithm::Copy(vtkm::cont::ArrayHandleIndex(A_arr.GetNumberOfValues()), idxA);
Algorithm::Copy(vtkm::cont::ArrayHandleIndex(B_arr.GetNumberOfValues()), idxB);
vtkm::cont::ArrayHandle<vtkm::Id> joinedIndex;
vtkm::cont::ArrayHandle<vtkm::Id> outA;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment