diff --git a/vtkm/worklet/contourtree_distributed/TreeGrafter.h b/vtkm/worklet/contourtree_distributed/TreeGrafter.h index 075a4c6be..082317c1c 100644 --- a/vtkm/worklet/contourtree_distributed/TreeGrafter.h +++ b/vtkm/worklet/contourtree_distributed/TreeGrafter.h @@ -88,7 +88,7 @@ #include #include #include -#include +#include #include #include @@ -342,11 +342,7 @@ void TreeGrafter::GraftInteriorForests( // whether it is already present, saving the regular and super IDs if it is, NO_SUCH_ELEMENT otherwise #ifdef DEBUG_PRINT - { - std::stringstream tempResultStream; - tempResultStream << "theRound: " << theRound << std::endl; - VTKM_LOG_S(vtkm::cont::LogLevel::Info, tempResultStream.str()); - } + VTKM_LOG_S(vtkm::cont::LogLevel::Info, "theRound: " << theRound); VTKM_LOG_S(vtkm::cont::LogLevel::Info, this->DebugPrint("Before GraftResidue()", __FILE__, __LINE__)); VTKM_LOG_S( @@ -390,7 +386,6 @@ void TreeGrafter::GraftInteriorForests( this->NumTransferIterations++; } // loop to transfer - #ifdef DEBUG_PRINT VTKM_LOG_S(vtkm::cont::LogLevel::Info, DebugPrint("Finished Transfer Iterations", __FILE__, __LINE__)); @@ -647,22 +642,18 @@ template void TreeGrafter::FindCriticalPoints() { // FindCriticalPoints() // allocate memory for type of supernode + this->resizeIndexVector(this->SupernodeType, + this->ContourTree.Supernodes.GetNumberOfValues(), + vtkm::worklet::contourtree_augmented::NO_SUCH_ELEMENT); + // Reset the UpNeighbour and DownNeighbour array vtkm::cont::Algorithm::Copy( vtkm::cont::make_ArrayHandleConstant(vtkm::worklet::contourtree_augmented::NO_SUCH_ELEMENT, - this->ContourTree.Supernodes.GetNumberOfValues()), - this->SupernodeType); - // TODO: Hamish: I removed the code below to set UpNeighbour and DownNeighbour. According to the orginal code, - // this could be removed later for performance, since we always reset the ones we use. Also - // UpNeighbour and DownNeighbour are already initalized in InitializeActiveSuperarcs() so we - // should not need to do this again here. - /*vtkm::cont::Algorithm::Copy( - vtkm::cont::make_ArrayHandleConstant(vtkm::worklet::contourtree_augmented::NO_SUCH_ELEMENT, - this->UpNeighbour.GetNumberOfValues()), - this->UpNeighbour); + this->UpNeighbour.GetNumberOfValues()), + this->UpNeighbour); vtkm::cont::Algorithm::Copy( - vtkm::cont::make_ArrayHandleConstant(vtkm::worklet::contourtree_augmented::NO_SUCH_ELEMENT, - this->DownNeighbour.GetNumberOfValues()), - this->DownNeighbour);*/ + vtkm::cont::make_ArrayHandleConstant(vtkm::worklet::contourtree_augmented::NO_SUCH_ELEMENT, + this->DownNeighbour.GetNumberOfValues()), + this->DownNeighbour); #ifdef DEBUG_PRINT // TODO: Hamish: I don't think we need this DebugPrint here. @@ -828,8 +819,10 @@ void TreeGrafter::CompressActiveArrays() // create an array where we can put the compressed array vtkm::worklet::contourtree_augmented::EdgePairArray compressedActiveSuperarcs; // prediate for deciding which active superarcs to keep + // NOTE: The original PPP used std::remove_if instead of CopyIf so the predicate inverts the logic, i.e, the predicate indictes + // which values to keep rather than which ones to remove auto superarcWasTransferredPredicate = - vtkm::worklet::contourtree_distributed::tree_grafter::SuperarcWasTransferredPredicate( + vtkm::worklet::contourtree_distributed::tree_grafter::SuperarcWasNotTransferredPredicate( this->WhenTransferred); // compress the array vtkm::cont::Algorithm::CopyIf( @@ -846,7 +839,6 @@ void TreeGrafter::CompressActiveArrays() VTKM_LOG_S(vtkm::cont::LogLevel::Info, DebugPrint("CompressActiveArrays() Complete", __FILE__, __LINE__)); #endif - } // CompressActiveArrays() diff --git a/vtkm/worklet/contourtree_distributed/tree_grafter/CMakeLists.txt b/vtkm/worklet/contourtree_distributed/tree_grafter/CMakeLists.txt index 682b2c8ae..ae036c5d7 100644 --- a/vtkm/worklet/contourtree_distributed/tree_grafter/CMakeLists.txt +++ b/vtkm/worklet/contourtree_distributed/tree_grafter/CMakeLists.txt @@ -19,7 +19,7 @@ set(headers FindCriticalPointsFindTerminalElementsWorklet.h CollapseRegularChainsWorklet.h IdentifyLeafHyperarcsWorklet.h - SuperarcWasTransferredPredicate.h + SuperarcWasNotTransferredPredicate.h NewHypernodePredicate.h HyperNodeWhenComparator.h SuperNodeWhenComparator.h diff --git a/vtkm/worklet/contourtree_distributed/tree_grafter/FindCriticalPointsSetUpDownNeighboursWorklet.h b/vtkm/worklet/contourtree_distributed/tree_grafter/FindCriticalPointsSetUpDownNeighboursWorklet.h index 97ff988c2..96d4f34a3 100644 --- a/vtkm/worklet/contourtree_distributed/tree_grafter/FindCriticalPointsSetUpDownNeighboursWorklet.h +++ b/vtkm/worklet/contourtree_distributed/tree_grafter/FindCriticalPointsSetUpDownNeighboursWorklet.h @@ -74,9 +74,9 @@ public: FieldIn activeSuperarcs, // input iteration index. loop to one less than ContourTree->Supernodes.GetNumberOfValues() WholeArrayIn interiorForstIsNecessary, // input - WholeArrayOut upNeighbour, // output - WholeArrayOut downNeighbour, // output - WholeArrayOut supernodeType // output + WholeArrayInOut upNeighbour, // output (Need In/Out to prevent overwrite?) + WholeArrayInOut downNeighbour, // output (Need In/Out to prevent overwrite?) + WholeArrayInOut supernodeType // output (Need In/Out to prevent overwrite?) ); using ExecutionSignature = void(_1, _2, _3, _4, _5); diff --git a/vtkm/worklet/contourtree_distributed/tree_grafter/SuperarcWasTransferredPredicate.h b/vtkm/worklet/contourtree_distributed/tree_grafter/SuperarcWasNotTransferredPredicate.h similarity index 84% rename from vtkm/worklet/contourtree_distributed/tree_grafter/SuperarcWasTransferredPredicate.h rename to vtkm/worklet/contourtree_distributed/tree_grafter/SuperarcWasNotTransferredPredicate.h index e92ffec5f..f95a31fbd 100644 --- a/vtkm/worklet/contourtree_distributed/tree_grafter/SuperarcWasTransferredPredicate.h +++ b/vtkm/worklet/contourtree_distributed/tree_grafter/SuperarcWasNotTransferredPredicate.h @@ -50,8 +50,8 @@ // Oliver Ruebel (LBNL) //============================================================================== -#ifndef vtk_m_worklet_contourtree_distributed_tree_grafter_superarc_was_transferred_predicate_h -#define vtk_m_worklet_contourtree_distributed_tree_grafter_superarc_was_transferred_predicate_h +#ifndef vtk_m_worklet_contourtree_distributed_tree_grafter_superarc_was_not_transferred_predicate_h +#define vtk_m_worklet_contourtree_distributed_tree_grafter_superarc_was_not_transferred_predicate_h #include @@ -68,7 +68,7 @@ namespace tree_grafter // Uniary predicate used in TreeGrafter.CompressActiveArrays to decide which active superarcs to keep template -class SuperarcWasTransferredPredicateImpl : public vtkm::worklet::WorkletMapField +class SuperarcWasNotTransferredPredicateImpl : public vtkm::worklet::WorkletMapField { public: using IdArrayPortalType = @@ -77,7 +77,7 @@ public: // Default Constructor VTKM_EXEC_CONT - SuperarcWasTransferredPredicateImpl(const IdArrayPortalType& whenTransferredPortal) + SuperarcWasNotTransferredPredicateImpl(const IdArrayPortalType& whenTransferredPortal) : WhenTransferredPortal(whenTransferredPortal) { } @@ -85,10 +85,10 @@ public: VTKM_EXEC bool operator()(const vtkm::worklet::contourtree_augmented::EdgePair& superarc) const { // operator () // if either end is marked as transferred, the arc must be gone already - return ((!vtkm::worklet::contourtree_augmented::NoSuchElement( - this->WhenTransferredPortal.Get(superarc.first))) || - (!vtkm::worklet::contourtree_augmented::NoSuchElement( - this->WhenTransferredPortal.Get(superarc.second)))); + return !((!vtkm::worklet::contourtree_augmented::NoSuchElement( + this->WhenTransferredPortal.Get(superarc.first))) || + (!vtkm::worklet::contourtree_augmented::NoSuchElement( + this->WhenTransferredPortal.Get(superarc.second)))); } // operator () @@ -96,25 +96,25 @@ private: IdArrayPortalType WhenTransferredPortal; -}; // SuperarcWasTransferredPredicate +}; // SuperarcWasNotTransferredPredicate -class SuperarcWasTransferredPredicate : public vtkm::cont::ExecutionObjectBase +class SuperarcWasNotTransferredPredicate : public vtkm::cont::ExecutionObjectBase { public: VTKM_CONT - SuperarcWasTransferredPredicate( + SuperarcWasNotTransferredPredicate( const vtkm::worklet::contourtree_augmented::IdArrayType& whenTransferred) : WhenTransferred(whenTransferred) { } template - VTKM_CONT SuperarcWasTransferredPredicateImpl PrepareForExecution( + VTKM_CONT SuperarcWasNotTransferredPredicateImpl PrepareForExecution( DeviceAdapter device, vtkm::cont::Token& token) const { - return SuperarcWasTransferredPredicateImpl( + return SuperarcWasNotTransferredPredicateImpl( this->WhenTransferred.PrepareForInput(device, token)); }