diff --git a/vtkm/worklet/contourtree_augmented/ContourTree.h b/vtkm/worklet/contourtree_augmented/ContourTree.h index b7c99f3a3..93bfcd0f3 100644 --- a/vtkm/worklet/contourtree_augmented/ContourTree.h +++ b/vtkm/worklet/contourtree_augmented/ContourTree.h @@ -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 maxPath; std::vector supernodeCount; std::vector hypernodeCount; + // We use regular ReadPortal here since we need access to all values anyways auto whenTransferredPortal = this->WhenTransferred.ReadPortal(); auto hypernodesPortal = this->Hypernodes.ReadPortal(); diff --git a/vtkm/worklet/contourtree_augmented/MergeTree.h b/vtkm/worklet/contourtree_augmented/MergeTree.h index 8099ddf32..7ad849049 100644 --- a/vtkm/worklet/contourtree_augmented/MergeTree.h +++ b/vtkm/worklet/contourtree_augmented/MergeTree.h @@ -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 diff --git a/vtkm/worklet/contourtree_augmented/Types.h b/vtkm/worklet/contourtree_augmented/Types.h index d28104c66..dd8f45071 100644 --- a/vtkm/worklet/contourtree_augmented/Types.h +++ b/vtkm/worklet/contourtree_augmented/Types.h @@ -55,7 +55,9 @@ #define vtk_m_worklet_contourtree_augmented_types_h #include +#include #include +#include #include 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(value, 1), 0, 1, arr, index); +} // IdArraySetValues + template struct MaskedIndexFunctor { diff --git a/vtkm/worklet/contourtree_distributed/BoundaryTree.h b/vtkm/worklet/contourtree_distributed/BoundaryTree.h index e78264576..cba92148a 100644 --- a/vtkm/worklet/contourtree_distributed/BoundaryTree.h +++ b/vtkm/worklet/contourtree_distributed/BoundaryTree.h @@ -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(); diff --git a/vtkm/worklet/contourtree_distributed/BoundaryTreeMaker.h b/vtkm/worklet/contourtree_distributed/BoundaryTreeMaker.h index 537ea7e69..b53e38249 100644 --- a/vtkm/worklet/contourtree_distributed/BoundaryTreeMaker.h +++ b/vtkm/worklet/contourtree_distributed/BoundaryTreeMaker.h @@ -454,18 +454,16 @@ void BoundaryTreeMaker::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::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::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::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( diff --git a/vtkm/worklet/contourtree_distributed/HierarchicalAugmenter.h b/vtkm/worklet/contourtree_distributed/HierarchicalAugmenter.h index 1224cab00..63740669c 100644 --- a/vtkm/worklet/contourtree_distributed/HierarchicalAugmenter.h +++ b/vtkm/worklet/contourtree_distributed/HierarchicalAugmenter.h @@ -519,6 +519,7 @@ void HierarchicalAugmenter::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::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::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( diff --git a/vtkm/worklet/contourtree_distributed/HierarchicalContourTree.h b/vtkm/worklet/contourtree_distributed/HierarchicalContourTree.h index 43416ca4a..d43c83d1d 100644 --- a/vtkm/worklet/contourtree_distributed/HierarchicalContourTree.h +++ b/vtkm/worklet/contourtree_distributed/HierarchicalContourTree.h @@ -259,27 +259,31 @@ void HierarchicalContourTree::Initialize( auto tempZeroArray = vtkm::cont::ArrayHandleConstant(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(this->NumRounds + 1)); - this->FirstSupernodePerIteration[static_cast(this->NumRounds)].Allocate( - this->NumIterations.ReadPortal().Get(this->NumRounds) + 1); - this->FirstHypernodePerIteration.resize(static_cast(this->NumRounds + 1)); - this->FirstHypernodePerIteration[static_cast(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(this->NumRounds + 1)); + this->FirstSupernodePerIteration[static_cast(this->NumRounds)].Allocate( + tempSizeVal); + this->FirstHypernodePerIteration.resize(static_cast(this->NumRounds + 1)); + this->FirstHypernodePerIteration[static_cast(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::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::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::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::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::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::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::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::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::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::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::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::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(); diff --git a/vtkm/worklet/contourtree_distributed/TreeGrafter.h b/vtkm/worklet/contourtree_distributed/TreeGrafter.h index a60eba2d8..95db1b38c 100644 --- a/vtkm/worklet/contourtree_distributed/TreeGrafter.h +++ b/vtkm/worklet/contourtree_distributed/TreeGrafter.h @@ -606,7 +606,8 @@ void TreeGrafter::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::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::CopyIterationDetails( ); } - // force the extra one to be one-off-the end for safety; REMOVED - SEE ABOVE FOR LOGIC - //hierarchicalTree.FirstHypernodePerIteration[static_cast(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__));