Avoid ReadPortal/WritePortal to get/set individual values as possible.

This commit is contained in:
Oliver Ruebel 2021-03-24 21:00:20 -07:00 committed by Gunther H. Weber
parent 2f720d5ac2
commit 370fd5de52
8 changed files with 111 additions and 109 deletions

@ -253,6 +253,7 @@ inline void ContourTree::PrintDotSuperStructure() const
printf("digraph G\n\t{\n");
printf("\tsize=\"6.5, 9\"\n\tratio=\"fill\"\n");
// We use regular ReadPortal here since we need access to most values on the host anyways
auto whenTransferredPortal = this->WhenTransferred.ReadPortal();
auto supernodesPortal = this->Supernodes.ReadPortal();
auto superarcsPortal = this->Superarcs.ReadPortal();
@ -341,6 +342,7 @@ inline std::string ContourTree::PrintHyperStructureStatistics(bool print) const
std::vector<vtkm::Id> maxPath;
std::vector<vtkm::Id> supernodeCount;
std::vector<vtkm::Id> hypernodeCount;
// We use regular ReadPortal here since we need access to all values anyways
auto whenTransferredPortal = this->WhenTransferred.ReadPortal();
auto hypernodesPortal = this->Hypernodes.ReadPortal();

@ -240,15 +240,15 @@ inline void MergeTree::DebugPrintTree(const char* message,
for (vtkm::Id entry = 0; entry < mesh.NumVertices; entry++)
{
vtkm::Id sortIndex = mesh.SortIndices.ReadPortal().Get(entry);
vtkm::Id arc = this->Arcs.ReadPortal().Get(sortIndex);
vtkm::Id sortIndex = vtkm::cont::ArrayGetValue(entry, mesh.SortIndices);
vtkm::Id arc = vtkm::cont::ArrayGetValue(sortIndex, this->Arcs);
if (NoSuchElement(arc))
{
std::cout << "-1" << std::endl;
}
else
{
std::cout << mesh.SortOrder.ReadPortal().Get(arc) << std::endl;
std::cout << vtkm::cont::ArrayGetValue(arc, mesh.SortOrder) << std::endl;
}
if (mesh.MeshSize[2] == 1)
{ // 2D Mesh

@ -55,7 +55,9 @@
#define vtk_m_worklet_contourtree_augmented_types_h
#include <vtkm/Types.h>
#include <vtkm/cont/Algorithm.h>
#include <vtkm/cont/ArrayHandle.h>
#include <vtkm/cont/ArrayHandleConstant.h>
#include <vtkm/cont/CellSetStructured.h>
namespace vtkm
@ -126,13 +128,21 @@ inline vtkm::Id MaskedIndex(vtkm::Id flaggedIndex)
return (flaggedIndex & INDEX_MASK);
} // MaskedIndex()
// Used in the context of CombinedVector class used in ContourTreeMesh to merge the mesh of contour trees
/// Used in the context of CombinedVector class used in ContourTreeMesh to merge the mesh of contour trees
VTKM_EXEC_CONT
inline bool IsThis(vtkm::Id flaggedIndex)
{ // IsThis
return ((flaggedIndex & CV_OTHER_FLAG) == 0);
} // IsThis
/// Helper function to set a single array valye with CopySubRange to avoid pulling the array to the control environment
VTKM_EXEC_CONT
inline void IdArraySetValue(vtkm::Id index, vtkm::Id value, IdArrayType& arr)
{ // IdArraySetValue
vtkm::cont::Algorithm::CopySubRange(
vtkm::cont::ArrayHandleConstant<vtkm::Id>(value, 1), 0, 1, arr, index);
} // IdArraySetValues
template <typename T>
struct MaskedIndexFunctor
{

@ -132,6 +132,7 @@ std::string BoundaryTree::Print()
resultStream << "Boundary-Restricted Augmented Contour Tree" << std::endl;
resultStream << "==========================================" << std::endl;
// fill it up
// We use regular ReadPortal here since we need access to all values anyways
auto superarcsPortal = this->Superarcs.ReadPortal();
auto vertexIndexPortal = this->VertexIndex.ReadPortal();
for (vtkm::Id node = 0; node < superarcsPortal.GetNumberOfValues(); node++)
@ -171,6 +172,7 @@ std::string BoundaryTree::PrintGlobalDot(const char* label,
blockOrigin, blockSize, globalSize);
// loop through all nodes
// We use regular ReadPortal here since we need access to most values anyways
auto vertexIndexPortal = this->VertexIndex.ReadPortal();
auto superarcsPortal = this->Superarcs.ReadPortal();
auto sortOrderPortal = mesh.SortOrder.ReadPortal();
@ -226,6 +228,7 @@ std::string BoundaryTree::PrintGlobalDot(
resultStream << "\tlabel=\"" << label << "\"\n\tlabelloc=t\n\tfontsize=30\n" << std::endl;
// loop through all nodes
// We use regular ReadPortal here since we need access to all values anyways
auto vertexIndexPortal = this->VertexIndex.ReadPortal();
auto globalMeshIndexPortal = mesh.GlobalMeshIndex.ReadPortal();
auto sortedValuesPortal = mesh.SortedValues.ReadPortal();

@ -454,18 +454,16 @@ void BoundaryTreeMaker<MeshType, MeshBoundaryExecObjType>::PropagateBoundaryCoun
#endif
// b. Iterate, propagating counts inwards
auto firstSupernodePerIterationReadPortal =
this->ContourTree.FirstSupernodePerIteration.ReadPortal();
auto firstHypernodePerIterationReadPortal =
this->ContourTree.FirstHypernodePerIteration.ReadPortal();
for (vtkm::Id iteration = 0; iteration < this->ContourTree.NumIterations; iteration++)
{ // b. per iteration
#ifdef DEBUG_PRINT
VTKM_LOG_S(vtkm::cont::LogLevel::Info, this->DebugPrint("Top of Loop:", __FILE__, __LINE__));
#endif
// i. Pull the array bounds into register
vtkm::Id firstSupernode = firstSupernodePerIterationReadPortal.Get(iteration);
vtkm::Id lastSupernode = firstSupernodePerIterationReadPortal.Get(iteration + 1);
vtkm::Id firstSupernode =
vtkm::cont::ArrayGetValue(iteration, this->ContourTree.FirstSupernodePerIteration);
vtkm::Id lastSupernode =
vtkm::cont::ArrayGetValue(iteration + 1, this->ContourTree.FirstSupernodePerIteration);
if (lastSupernode == firstSupernode)
{
@ -477,8 +475,10 @@ void BoundaryTreeMaker<MeshType, MeshBoundaryExecObjType>::PropagateBoundaryCoun
continue;
}
vtkm::Id firstHypernode = firstHypernodePerIterationReadPortal.Get(iteration);
vtkm::Id lastHypernode = firstHypernodePerIterationReadPortal.Get(iteration + 1);
vtkm::Id firstHypernode =
vtkm::cont::ArrayGetValue(iteration, this->ContourTree.FirstHypernodePerIteration);
vtkm::Id lastHypernode =
vtkm::cont::ArrayGetValue(iteration + 1, this->ContourTree.FirstHypernodePerIteration);
// ii. Add xfer + int & store in dependent count
// Compute the sum of this->SupernodeTransferBoundaryCount and this->SuperarcIntrinsicBoundaryCount
@ -639,13 +639,15 @@ void BoundaryTreeMaker<MeshType, MeshBoundaryExecObjType>::PropagateBoundaryCoun
// when we are done, we need to force the summation for the root node, JUST IN CASE it is a boundary node itself
// BTW, the value *SHOULD* be the number of boundary nodes, anyway
vtkm::Id rootSuperId = this->ContourTree.Supernodes.GetNumberOfValues() - 1;
this->SuperarcDependentBoundaryCount.WritePortal().Set(
vtkm::worklet::contourtree_augmented::IdArraySetValue(
rootSuperId,
this->SupernodeTransferBoundaryCount.ReadPortal().Get(rootSuperId) +
this->SuperarcIntrinsicBoundaryCount.ReadPortal().Get(rootSuperId));
this->HyperarcDependentBoundaryCount.WritePortal().Set(
vtkm::cont::ArrayGetValue(rootSuperId, this->SupernodeTransferBoundaryCount) +
vtkm::cont::ArrayGetValue(rootSuperId, this->SuperarcIntrinsicBoundaryCount),
this->SuperarcDependentBoundaryCount);
vtkm::worklet::contourtree_augmented::IdArraySetValue(
this->ContourTree.Hypernodes.GetNumberOfValues() - 1,
this->SuperarcDependentBoundaryCount.ReadPortal().Get(rootSuperId));
vtkm::cont::ArrayGetValue(rootSuperId, this->SuperarcDependentBoundaryCount),
this->HyperarcDependentBoundaryCount);
#ifdef DEBUG_PRINT
VTKM_LOG_S(vtkm::cont::LogLevel::Info,
@ -1137,7 +1139,8 @@ void BoundaryTreeMaker<MeshType, MeshBoundaryExecObjType>::CompressRegularisedNo
// first create the array: start by observing that the last entry is guaranteed
// to hold the total number of necessary vertices
this->NumKept = keptInBoundaryTree.ReadPortal().Get(keptInBoundaryTree.GetNumberOfValues() - 1);
this->NumKept =
vtkm::cont::ArrayGetValue(keptInBoundaryTree.GetNumberOfValues() - 1, keptInBoundaryTree);
// create an array to store the new superarc Ids and initalize it with NO_SUCH_ELEMENT
vtkm::worklet::contourtree_augmented::IdArrayType newSuperarc;
vtkm::cont::Algorithm::Copy(

@ -519,6 +519,7 @@ void HierarchicalAugmenter<FieldType>::PrepareAugmentedTree()
// The last element in the array is always set to the size as a sentinel value
// We need to pull the firstAttachmentPointInRound array to the control environment
// anyways for the loop afterwards so can do this set here without using Copy
// Use regular WritePortal here since we need to update a number of values and the array should be small
auto firstAttachmentPointInRoundPortal = this - FirstAttachmentPointInRound.WritePortal();
firstAttachmentPointInRoundPortal.Set(this->BaseTree->nRounds + 1,
this->AttachmentIs.GetNumberOfValues());
@ -894,13 +895,12 @@ void HierarchicalAugmenter<FieldType>::ResizeArrays(vtkm::Id roundNumber)
vtkm::Id newSupernodeCount = numSupernodesAlready + numSupernodesThisLevel;
// conveniently, the value numSupernodesThisLevel is the number of supernodes *!AND!* regular nodes to store for the round
// TODO: These calls could be changed to avoid potential device copy, but I believe they are actually used
// mainly in the control environment and they should be small arrays, so setting them directly should be Ok.
this->AugmentedTree->NumRegularNodesInRound.WritePortal().Set(roundNumber,
numSupernodesThisLevel);
this->AugmentedTree->NumSupernodesInRound.WritePortal().Set(roundNumber, numSupernodesThisLevel);
this->AugmentedTree->FirstSupernodePerIteration[roundNumber].WritePortal().Set(
0, numSupernodesAlready);
vtkm::worklet::contourtree_augmented::IdArraySetValue(
roundNumber, numSupernodesThisLevel, this->AugmentedTree->NumRegularNodesInRound);
vtkm::worklet::contourtree_augmented::IdArraySetValue(
roundNumber, numSupernodesThisLevel, this->AugmentedTree->NumSupernodesInRound);
vtkm::worklet::contourtree_augmented::IdArraySetValue(
0, numSupernodesAlready, this->AugmentedTree->FirstSupernodePerIteration[roundNumber]);
// resize the arrays accordingly
{
@ -1158,12 +1158,15 @@ void HierarchicalAugmenter<FieldType>::CreateSuperarcs(vtkm::Id roundNumber)
if (lastIterationThisLevel < iterationArraySize - 1)
{ // attachment point round was removed
// decrement the iteration count (still with an extra element as sentinel)
this->AugmentedTree->NumIterations.WritePortal(roundNumber, iterationArraySize - 1);
vtkm::worklet::contourtree_augmented::IdArraySetValue(
roundNumber, iterationArraySize - 1, this->AugmentedTree->NumIterations);
// shrink the supernode array
this->AugmentedTree->FirstSupernodePerIteration[roundNumber].Allocate(
iterationArraySize, vtkm::CopyFlag::On); // shrink array but keep values
this->AugmentedTree->FirstSupernodePerIteration[roundNumber].WritePortal().Set(
iterationArraySize - 1, this->AugmentedTree->Supernodes.GetNumberOfValues());
vtkm::worklet::contourtree_augmented::IdArraySetValue(
iterationArraySize - 1,
this->AugmentedTree->Supernodes.GetNumberOfValues(),
this->AugmentedTree->FirstSupernodePerIteration[roundNumber]);
// for the hypernode array, the last iteration is guaranteed not to have hyperarcs by construction
// so the last iteration will already have the correct sentinel value, and we just need to shrink the array
this->AugmentedTree->FirstHypernodePerIteration[roundNumber].Allocate(

@ -259,27 +259,31 @@ void HierarchicalContourTree<FieldType>::Initialize(
auto tempZeroArray = vtkm::cont::ArrayHandleConstant<vtkm::Id>(0, this->NumRounds + 1);
vtkm::cont::Algorithm::Copy(tempZeroArray, this->NumIterations);
vtkm::cont::Algorithm::Copy(tempZeroArray, this->NumRegularNodesInRound);
this->NumRegularNodesInRound.WritePortal().Set(this->NumRounds, tree.Nodes.GetNumberOfValues());
vtkm::worklet::contourtree_augmented::IdArraySetValue(
this->NumRounds, tree.Nodes.GetNumberOfValues(), this->NumRegularNodesInRound);
vtkm::cont::Algorithm::Copy(tempZeroArray, this->NumSupernodesInRound);
this->NumSupernodesInRound.WritePortal().Set(this->NumRounds,
tree.Supernodes.GetNumberOfValues());
vtkm::worklet::contourtree_augmented::IdArraySetValue(
this->NumRounds, tree.Supernodes.GetNumberOfValues(), this->NumSupernodesInRound);
vtkm::cont::Algorithm::Copy(tempZeroArray, this->NumHypernodesInRound);
this->NumHypernodesInRound.WritePortal().Set(this->NumRounds,
tree.Hypernodes.GetNumberOfValues());
vtkm::worklet::contourtree_augmented::IdArraySetValue(
this->NumRounds, tree.Hypernodes.GetNumberOfValues(), this->NumHypernodesInRound);
}
// copy the iterations of the top level hypersweep - this is +1: one because we are counting inclusively
// HAC JAN 15, 2020: In order to make this consistent with grafting rounds for hybrid hypersweeps, we add one to the logical number of
// iterations instead of the prior version which stored an extra extra element (ie +2)
// WARNING! WARNING! WARNING! This is a departure from the treatment in the contour tree, where the last iteration to the NULL root was
// treated as an implicit round.
this->NumIterations.WritePortal().Set(this->NumRounds, tree.NumIterations + 1);
this->FirstSupernodePerIteration.resize(static_cast<std::size_t>(this->NumRounds + 1));
this->FirstSupernodePerIteration[static_cast<std::size_t>(this->NumRounds)].Allocate(
this->NumIterations.ReadPortal().Get(this->NumRounds) + 1);
this->FirstHypernodePerIteration.resize(static_cast<std::size_t>(this->NumRounds + 1));
this->FirstHypernodePerIteration[static_cast<std::size_t>(this->NumRounds)].Allocate(
this->NumIterations.ReadPortal().Get(this->NumRounds) + 1);
{
vtkm::Id tempSizeVal = vtkm::cont::ArrayGetValue(this->NumRounds, this->NumIterations) + 1;
vtkm::worklet::contourtree_augmented::IdArraySetValue(
this->NumRounds, tree.NumIterations + 1, this->NumIterations);
this->FirstSupernodePerIteration.resize(static_cast<std::size_t>(this->NumRounds + 1));
this->FirstSupernodePerIteration[static_cast<std::size_t>(this->NumRounds)].Allocate(
tempSizeVal);
this->FirstHypernodePerIteration.resize(static_cast<std::size_t>(this->NumRounds + 1));
this->FirstHypernodePerIteration[static_cast<std::size_t>(this->NumRounds)].Allocate(
tempSizeVal);
}
// now copy in the details. Use CopySubRagnge to ensure that the Copy does not shrink the size
// of the array as the arrays are in this case allocated above to the approbriate size
vtkm::cont::Algorithm::CopySubRange(
@ -386,18 +390,18 @@ std::string HierarchicalContourTree<FieldType>::RegularString(const vtkm::Id reg
{
resultStream << "Regular ID: ";
vtkm::worklet::contourtree_augmented::PrintIndexType(regularId, resultStream);
resultStream << " Value: " << this->DataValues.ReadPortal().Get(regularId);
resultStream << " Value: " << vtkm::cont::ArrayGetValue(regularId, this->DataValues);
resultStream << " Global ID: ";
vtkm::worklet::contourtree_augmented::PrintIndexType(
this->RegularNodeGlobalIds.ReadPortal().Get(regularId), resultStream);
vtkm::cont::ArrayGetValue(regularId, this->RegularNodeGlobalIds), resultStream);
resultStream << " Regular ID: ";
vtkm::worklet::contourtree_augmented::PrintIndexType(regularId, resultStream);
resultStream << " SNode ID: ";
vtkm::worklet::contourtree_augmented::PrintIndexType(
this->Regular2Supernode.ReadPortal().Get(regularId), resultStream);
vtkm::cont::ArrayGetValue(regularId, this->Regular2Supernode), resultStream);
resultStream << "Superparents: ";
vtkm::worklet::contourtree_augmented::PrintIndexType(
this->Superparents.ReadPortal().Get(regularId));
vtkm::cont::ArrayGetValue(regularId, this->Superparents));
}
return resultStream.str();
} // RegularString()
@ -415,43 +419,32 @@ std::string HierarchicalContourTree<FieldType>::SuperString(const vtkm::Id super
}
else
{
vtkm::Id unmaskedSuperId = vtkm::worklet::contourtree_augmented::MaskedIndex(superId);
vtkm::Id tempSupernodeOfSuperId = vtkm::cont::ArrayGetValue(unmaskedSuperId, this->Supernodes);
resultStream << "Super ID: ";
vtkm::worklet::contourtree_augmented::PrintIndexType(superId, resultStream);
resultStream << " Value: "
<< this->DataValues.ReadPortal().Get(this->Supernodes.ReadPortal().Get(
vtkm::worklet::contourtree_augmented::MaskedIndex(superId)));
<< vtkm::cont::ArrayGetValue(tempSupernodeOfSuperId, this->DataValues);
resultStream << " Global ID: ";
vtkm::worklet::contourtree_augmented::PrintIndexType(
this->RegularNodeGlobalIds.ReadPortal().Get(this->Supernodes.ReadPortal().Get(
vtkm::worklet::contourtree_augmented::MaskedIndex(superId))),
resultStream);
vtkm::cont::ArrayGetValue(tempSupernodeOfSuperId, this->RegularNodeGlobalIds), resultStream);
resultStream << " Regular Id: ";
vtkm::worklet::contourtree_augmented::PrintIndexType(
this->Supernodes.ReadPortal().Get(vtkm::worklet::contourtree_augmented::MaskedIndex(superId)),
resultStream);
vtkm::worklet::contourtree_augmented::PrintIndexType(tempSupernodeOfSuperId, resultStream);
resultStream << " Superarc: ";
vtkm::worklet::contourtree_augmented::PrintIndexType(
this->Superarcs.ReadPortal().Get(vtkm::worklet::contourtree_augmented::MaskedIndex(superId)),
resultStream);
vtkm::cont::ArrayGetValue(unmaskedSuperId, this->Superarcs), resultStream);
resultStream << " HNode ID: ";
vtkm::worklet::contourtree_augmented::PrintIndexType(
this->Super2Hypernode.ReadPortal().Get(
vtkm::worklet::contourtree_augmented::MaskedIndex(superId)),
resultStream);
vtkm::cont::ArrayGetValue(unmaskedSuperId, this->Super2Hypernode), resultStream);
resultStream << " Hyperparent: ";
vtkm::worklet::contourtree_augmented::PrintIndexType(
this->Hyperparents.ReadPortal().Get(
vtkm::worklet::contourtree_augmented::MaskedIndex(superId)),
resultStream);
vtkm::cont::ArrayGetValue(unmaskedSuperId, this->Hyperparents), resultStream);
resultStream << " Round: ";
vtkm::worklet::contourtree_augmented::PrintIndexType(
this->WhichRound.ReadPortal().Get(vtkm::worklet::contourtree_augmented::MaskedIndex(superId)),
resultStream);
vtkm::cont::ArrayGetValue(unmaskedSuperId, this->WhichRound), resultStream);
resultStream << " Iteration: ";
vtkm::worklet::contourtree_augmented::PrintIndexType(
this->WhichIteration.ReadPortal().Get(
vtkm::worklet::contourtree_augmented::MaskedIndex(superId)),
resultStream);
vtkm::cont::ArrayGetValue(unmaskedSuperId, this->WhichIteration), resultStream);
}
return resultStream.str();
} // SuperString()
@ -469,34 +462,24 @@ std::string HierarchicalContourTree<FieldType>::HyperString(const vtkm::Id hyper
}
else
{
vtkm::Id unmaskedHyperId = vtkm::worklet::contourtree_augmented::MaskedIndex(hyperId);
vtkm::Id hypernodeOfHyperId = vtkm::cont::ArrayGetValue(unmaskedHyperId, this->Hypernodes);
vtkm::Id supernodeOfHyperId = vtkm::cont::ArrayGetValue(hypernodeOfHyperId, this->Supernodes);
resultStream << "Hyper Id: ";
vtkm::worklet::contourtree_augmented::PrintIndexType(hyperId, resultStream);
resultStream << " Value: "
<< this->DataValues.ReadPortal().Get(
this->Supernodes.ReadPortal().Get(this->Hypernodes.ReadPortal().Get(
vtkm::worklet::contourtree_augmented::MaskedIndex(hyperId))));
resultStream << " Value: " << vtkm::cont::ArrayGetValue(supernodeOfHyperId, this->DataValues);
resultStream << " Global ID: ";
vtkm::worklet::contourtree_augmented::PrintIndexType(
this->RegularNodeGlobalIds.ReadPortal().Get(
this->Supernodes.ReadPortal().Get(this->Hypernodes.ReadPortal().Get(
vtkm::worklet::contourtree_augmented::MaskedIndex(hyperId)))),
resultStream);
vtkm::cont::ArrayGetValue(supernodeOfHyperId, this->RegularNodeGlobalIds), resultStream);
resultStream << " Regular ID: ";
vtkm::worklet::contourtree_augmented::PrintIndexType(
this->Supernodes.ReadPortal().Get(this->Hypernodes.ReadPortal().Get(
vtkm::worklet::contourtree_augmented::MaskedIndex(hyperId))),
resultStream);
vtkm::worklet::contourtree_augmented::PrintIndexType(supernodeOfHyperId, resultStream);
resultStream << " Super ID: ";
vtkm::worklet::contourtree_augmented::PrintIndexType(
this->Hypernodes.ReadPortal().Get(vtkm::worklet::contourtree_augmented::MaskedIndex(hyperId)),
resultStream);
vtkm::worklet::contourtree_augmented::PrintIndexType(hypernodeOfHyperId, resultStream);
resultStream << " Hyperarc: ";
vtkm::worklet::contourtree_augmented::PrintIndexType(
this->Hyperarcs.ReadPortal().Get(vtkm::worklet::contourtree_augmented::MaskedIndex(hyperId)),
resultStream);
vtkm::cont::ArrayGetValue(unmaskedHyperId, this->Hyperarcs), resultStream);
resultStream << " Superchildren: "
<< this->Superchildren.ReadPortal().Get(
vtkm::worklet::contourtree_augmented::MaskedIndex(hyperId));
<< vtkm::cont::ArrayGetValue(unmaskedHyperId, this->Superchildren);
}
return resultStream.str();
} // HyperString()
@ -511,11 +494,11 @@ std::string HierarchicalContourTree<FieldType>::ProbeHyperPath(const vtkm::Id re
resultStream << "Node: " << this->RegularString(regularId) << std::endl;
// find the superparent
vtkm::Id superparent = this->Superparents.ReadPortal().Get(regularId);
vtkm::Id superparent = vtkm::cont::ArrayGetValue(regularId, this->Superparents);
resultStream << "Superparent: " << SuperString(superparent) << std::endl;
// and the hyperparent
vtkm::Id hyperparent = this->Hyperparents.ReadPortal().Get(superparent);
vtkm::Id hyperparent = vtkm::cont::ArrayGetValue(superparent, this->Hyperparents);
// now trace the path inwards: terminate on last round when we have null hyperarc
vtkm::Id length = 0;
@ -529,7 +512,7 @@ std::string HierarchicalContourTree<FieldType>::ProbeHyperPath(const vtkm::Id re
resultStream << "Hyperparent: " << this->HyperString(hyperparent) << std::endl;
// retrieve the target of the hyperarc
vtkm::Id hypertarget = this->Hyperarcs.ReadPortal().Get(hyperparent);
vtkm::Id hypertarget = vtkm::cont::ArrayGetValue(hyperparent, this->Hyperarcs);
resultStream << "Hypertarget: "
<< SuperString(vtkm::worklet::contourtree_augmented::MaskedIndex(hypertarget))
@ -546,11 +529,11 @@ std::string HierarchicalContourTree<FieldType>::ProbeHyperPath(const vtkm::Id re
} // root or attachment point
else
{ // ordinary supernode
hyperparent = this->Hyperparents.ReadPortal().Get(maskedHypertarget);
hyperparent = vtkm::cont::ArrayGetValue(maskedHypertarget, this->Hyperparents);
} // ordinary supernode
// now take the new superparent's hyperparent/hypertarget
hypertarget = this->Hyperarcs.ReadPortal().Get(hyperparent);
hypertarget = vtkm::cont::ArrayGetValue(hyperparent, this->Hyperarcs);
} // loop inwards
resultStream << "Probe Complete" << std::endl << std::endl;
@ -565,9 +548,7 @@ std::string HierarchicalContourTree<FieldType>::ProbeSuperPath(const vtkm::Id re
{
std::stringstream resultStream;
// find the superparent
vtkm::Id superparent = this->Superparents.ReadPortal().Get(regularId);
auto superarcsPortal = this->Superarcs.ReadPortal();
auto whichRoundPortal = this->WhichRound.ReadPortal();
vtkm::Id superparent = vtkm::cont::ArrayGetValue(regularId, this->Superparents);
// now trace the path inwards: terminate on last round when we have null hyperarc
vtkm::Id length = 0;
while (true)
@ -578,7 +559,7 @@ std::string HierarchicalContourTree<FieldType>::ProbeSuperPath(const vtkm::Id re
break;
}
// retrieve the target of the superarc
vtkm::Id supertarget = superarcsPortal.Get(superparent);
vtkm::Id supertarget = vtkm::cont::ArrayGetValue(superparent, this->Superarcs);
resultStream << "Superparent: " << this->SuperString(superparent) << std::endl;
resultStream << "Supertarget: "
@ -589,7 +570,7 @@ std::string HierarchicalContourTree<FieldType>::ProbeSuperPath(const vtkm::Id re
// mask the supertarget
vtkm::Id maskedSupertarget = vtkm::worklet::contourtree_augmented::MaskedIndex(supertarget);
// and retrieve it's supertarget
vtkm::Id nextSupertarget = superarcsPortal.Get(maskedSupertarget);
vtkm::Id nextSupertarget = vtkm::cont::ArrayGetValue(maskedSupertarget, this->Superarcs);
vtkm::Id maskedNextSupertarget =
vtkm::worklet::contourtree_augmented::MaskedIndex(nextSupertarget);
resultStream << "Next target: " << this->SuperString(nextSupertarget) << std::endl;
@ -598,7 +579,7 @@ std::string HierarchicalContourTree<FieldType>::ProbeSuperPath(const vtkm::Id re
if (vtkm::worklet::contourtree_augmented::NoSuchElement(nextSupertarget))
{ // root or attachment point
// test round: if it's the last one, only the root has a null edge
if (whichRoundPortal.Get(maskedNextSupertarget) == this->NumRounds)
if (vtkm::cont::ArrayGetValue(maskedNextSupertarget, this->WhichRound) == this->NumRounds)
// we're done
break;
else // attachment point
@ -644,6 +625,7 @@ std::string HierarchicalContourTree<FieldType>::PrintDotSuperStructure(const cha
outstream << "\t// Supernodes\n";
// loop through all supernodes
// We use regular ReadPortals here since this requires access to many values anyways
auto supernodesPortal = this->Supernodes.ReadPortal();
auto hypernodesPortal = this->Hypernodes.ReadPortal();
auto hyperparentsPortal = this->Hyperparents.ReadPortal();
@ -888,7 +870,8 @@ std::string HierarchicalContourTree<FieldType>::DumpVolumes(
outStream << "============" << std::endl;
outStream << "Contour Tree" << std::endl;
// loop through all superarcs
// loop through all superarcs.
// We use regular ReadPortals here since this requires access to many values anyways
auto supernodesPortal = this->Supernodes.ReadPortal();
auto regularNodeGlobalIdsPortal = this->RegularNodeGlobalIds.ReadPortal();
auto superarcsPortal = this->Superarcs.ReadPortal();

@ -606,7 +606,8 @@ void TreeGrafter<MeshType, FieldType>::InitializeActiveSuperarcs()
// vtkm::cont::Algorithm::ScanInclusive(activeSuperarcId , activeSuperarcId);
}
// the final element will hold the result
vtkm::Id nFree = activeSuperarcId.ReadPortal().Get(activeSuperarcId.GetNumberOfValues() - 1);
vtkm::Id nFree =
vtkm::cont::ArrayGetValue(activeSuperarcId.GetNumberOfValues() - 1, activeSuperarcId);
// TODO FIX nFree is 0 here. Check that this is correct. I believe it should be non-zero.
// resize the active list accordingly
this->ActiveSuperarcs.Allocate(nFree);
@ -1422,14 +1423,15 @@ void TreeGrafter<MeshType, FieldType>::CopyIterationDetails(
#endif
// update the round counts
hierarchicalTree.NumRegularNodesInRound.WritePortal().Set(theRound,
this->NewNodes.GetNumberOfValues());
hierarchicalTree.NumSupernodesInRound.WritePortal().Set(theRound,
this->NewSupernodes.GetNumberOfValues());
hierarchicalTree.NumHypernodesInRound.WritePortal().Set(theRound,
this->NewHypernodes.GetNumberOfValues());
vtkm::worklet::contourtree_augmented::IdArraySetValue(
theRound, this->NewNodes.GetNumberOfValues(), hierarchicalTree.NumRegularNodesInRound);
vtkm::worklet::contourtree_augmented::IdArraySetValue(
theRound, this->NewSupernodes.GetNumberOfValues(), hierarchicalTree.NumSupernodesInRound);
vtkm::worklet::contourtree_augmented::IdArraySetValue(
theRound, this->NewHypernodes.GetNumberOfValues(), hierarchicalTree.NumHypernodesInRound);
// last iteration is just setting attachment points (but we are including this now) (previously added -1)
hierarchicalTree.NumIterations.WritePortal().Set(theRound, this->NumTransferIterations);
vtkm::worklet::contourtree_augmented::IdArraySetValue(
theRound, this->NumTransferIterations, hierarchicalTree.NumIterations);
#ifdef DEBUG_PRINT
VTKM_LOG_S(vtkm::cont::LogLevel::Info,
@ -1502,10 +1504,6 @@ void TreeGrafter<MeshType, FieldType>::CopyIterationDetails(
);
}
// force the extra one to be one-off-the end for safety; REMOVED - SEE ABOVE FOR LOGIC
//hierarchicalTree.FirstHypernodePerIteration[static_cast<size_t>(theRound)].WritePortal().Set(
// this->NumTransferIterations, hierarchicalTree.Hypernodes.GetNumberOfValues());
#ifdef DEBUG_PRINT
VTKM_LOG_S(vtkm::cont::LogLevel::Info,
hierarchicalTree.DebugPrint("Hypernode Iteration Counts Set", __FILE__, __LINE__));