Add support for using only necessary boundary vertices

This commit is contained in:
Oliver Ruebel 2020-11-10 04:19:10 -08:00 committed by Gunther H. Weber
parent e734c6358c
commit 08447c24b1
10 changed files with 183 additions and 23 deletions

@ -234,7 +234,11 @@ int main(int argc, char* argv[])
ParseCL parser;
parser.parse(argc, argv);
std::string filename = parser.getOptions().back();
bool useBoundaryExtremaOnly = true;
if (parser.hasOption("--useFullBoundary"))
{
useBoundaryExtremaOnly = false;
}
bool useMarchingCubes = false;
if (parser.hasOption("--mc"))
{
@ -319,6 +323,11 @@ int main(int argc, char* argv[])
std::cout << "Options: (Bool options are give via int, i.e. =0 for False and =1 for True)"
<< std::endl;
std::cout << "--mc Use marching cubes connectivity (Default=False)." << std::endl;
std::cout << "--useFullBoundary Use the full boundary during. Typically only useful"
<< std::endl;
std::cout << " to compare the performance between using the full boundary"
<< std::endl;
std::cout << " and when using only boundary extrema." << std::endl;
std::cout << "--preSplitFiles Input data is already pre-split into blocks." << std::endl;
std::cout << "--saveDot Save DOT files of the distributed contour tree "
<< "computation (Default=False). " << std::endl;
@ -347,6 +356,7 @@ int main(int argc, char* argv[])
<< " preSplitFiles=" << preSplitFiles << std::endl
<< " device=" << device.GetName() << std::endl
<< " mc=" << useMarchingCubes << std::endl
<< " useFullBoundary=" << !useBoundaryExtremaOnly << std::endl
<< " saveDot=" << saveDotFiles << std::endl
<< " saveTreeCompilerData=" << saveTreeCompilerData << std::endl
<< " forwardSummary=" << forwardSummary << std::endl
@ -909,6 +919,7 @@ int main(int argc, char* argv[])
localBlockIndices,
localBlockOrigins,
localBlockSizes,
useBoundaryExtremaOnly,
useMarchingCubes,
saveDotFiles,
timingsLogLevel,

@ -116,6 +116,7 @@ public:
const vtkm::cont::ArrayHandle<vtkm::Id3>& localBlockIndices,
const vtkm::cont::ArrayHandle<vtkm::Id3>& localBlockOrigins,
const vtkm::cont::ArrayHandle<vtkm::Id3>& localBlockSizes,
bool useBoundaryExtremaOnly = true,
bool useMarchingCubes = false,
bool saveDotFiles = false,
vtkm::cont::LogLevel timingsLogLevel = vtkm::cont::LogLevel::Perf,
@ -176,6 +177,9 @@ public:
//@}
private:
/// Use only boundary critical points in the parallel merge to reduce communication. Disabling this should only be needed for performance testing.
bool UseBoundaryExtremaOnly;
/// Use marching cubes connectivity for computing the contour tree
bool UseMarchingCubes;

@ -200,11 +200,13 @@ ContourTreeUniformDistributed::ContourTreeUniformDistributed(
const vtkm::cont::ArrayHandle<vtkm::Id3>& localBlockIndices,
const vtkm::cont::ArrayHandle<vtkm::Id3>& localBlockOrigins,
const vtkm::cont::ArrayHandle<vtkm::Id3>& localBlockSizes,
bool useBoundaryExtremaOnly,
bool useMarchingCubes,
bool saveDotFiles,
vtkm::cont::LogLevel timingsLogLevel,
vtkm::cont::LogLevel treeLogLevel)
: vtkm::filter::FilterField<ContourTreeUniformDistributed>()
, UseBoundaryExtremaOnly(useBoundaryExtremaOnly)
, UseMarchingCubes(useMarchingCubes)
, SaveDotFiles(saveDotFiles)
, TimingsLogLevel(timingsLogLevel)
@ -343,7 +345,7 @@ void ContourTreeUniformDistributed::ComputeLocalTreeImpl(
blockIndex)] // The interior forest (a.k.a. Residue) to be computed
);
// Execute the BRACT construction, including the compute of the InteriorForest
boundaryTreeMaker.Construct(&localToGlobalIdRelabeler);
boundaryTreeMaker.Construct(&localToGlobalIdRelabeler, this->UseBoundaryExtremaOnly);
// Log timing statistics
VTKM_LOG_S(this->TimingsLogLevel,
std::endl
@ -823,8 +825,10 @@ VTKM_CONT void ContourTreeUniformDistributed::DoPostExecute(
// 1.3 execute the fan in reduction
const vtkm::worklet::contourtree_distributed::ComputeDistributedContourTreeFunctor<FieldType>
computeDistributedContourTreeFunctor(
this->MultiBlockSpatialDecomposition.GlobalSize, this->TimingsLogLevel, this->TreeLogLevel);
computeDistributedContourTreeFunctor(this->MultiBlockSpatialDecomposition.GlobalSize,
this->UseBoundaryExtremaOnly,
this->TimingsLogLevel,
this->TreeLogLevel);
vtkmdiy::reduce(master, assigner, partners, computeDistributedContourTreeFunctor);
// Record timing for the actual reduction

@ -122,7 +122,7 @@ public:
}
else
{
// if not a corner, keeep only vertices that are local extrema
// if not a corner, keep only vertices that are local extrema
vtkm::Id sp, sn;
if (pos[1] == 0 || pos[1] == this->MeshStructure.MeshSize[1] - 1)
{
@ -138,9 +138,13 @@ public:
assert(meshIndex >= this->MeshStructure.MeshSize[0]);
sp = this->SortIndicesPortal.Get(meshIndex - this->MeshStructure.MeshSize[0]);
assert(meshIndex + this->MeshStructure.MeshSize[0] <
this->SortIndices.GetNumberOfValues());
this->SortIndicesPortal.GetNumberOfValues());
sn = this->SortIndicesPortal.Get(meshIndex + this->MeshStructure.MeshSize[0]);
}
else
{
return false;
}
return (sortIndex < sp && sortIndex < sn) || (sortIndex > sp && sortIndex > sn);
}
}

@ -225,14 +225,16 @@ public:
{ // On [2]-perpendicular face
VTKM_ASSERT(pos[0] != 0 && pos[0] != this->MeshStructure.MeshSize[0]);
VTKM_ASSERT(pos[1] != 0 && pos[1] != this->MeshStructure.MeshSize[1]);
return CountLinkComponentsIn2DSlice(meshIndex, this->MeshStructure.MeshSize[0], 1) ==
1; // FIXME: or != 2;
return CountLinkComponentsIn2DSlice(meshIndex,
vtkm::Id2(this->MeshStructure.MeshSize[0], 1)) != 2;
// == 1; // FIXME: or != 2;
}
else if (pos[1] == 0 || pos[1] == this->MeshStructure.MeshSize[1] - 1)
{ // On [1]-perpendicular face
VTKM_ASSERT(pos[0] != 0 && pos[0] != this->MeshStructure.MeshSize[0]);
VTKM_ASSERT(pos[2] != 0 && pos[2] != this->MeshStructure.MeshSize[2]);
return CountLinkComponentsIn2DSlice(meshIndex, nPerSlice, 1) == 1; // FIXME: or != 2;
return CountLinkComponentsIn2DSlice(meshIndex, vtkm::Id2(nPerSlice, 1)) != 2;
// == 1; // FIXME: or != 2;
}
else
{ // On [0]-perpendicular face
@ -240,7 +242,8 @@ public:
VTKM_ASSERT(pos[1] != 0 && pos[1] != this->MeshStructure.MeshSize[1]);
VTKM_ASSERT(pos[2] != 0 && pos[2] != this->MeshStructure.MeshSize[2]);
return CountLinkComponentsIn2DSlice(
meshIndex, this->MeshStructure.MeshSize[0], nPerSlice) == 1; // FIXME: or != 2;
meshIndex, vtkm::Id2(this->MeshStructure.MeshSize[0], nPerSlice)) != 2;
// == 1; // FIXME: or != 2;
}
}
}

@ -75,6 +75,7 @@
#include <vtkm/worklet/contourtree_distributed/boundary_tree_maker/CompressRegularisedNodesResolveRootWorklet.h>
#include <vtkm/worklet/contourtree_distributed/boundary_tree_maker/CompressRegularisedNodesTransferVerticesWorklet.h>
#include <vtkm/worklet/contourtree_distributed/boundary_tree_maker/ContourTreeNodeHyperArcComparator.h>
#include <vtkm/worklet/contourtree_distributed/boundary_tree_maker/FindBoundaryVerticesIsNecessaryWorklet.h>
#include <vtkm/worklet/contourtree_distributed/boundary_tree_maker/FindBractSuperarcsSuperarcToWorklet.h>
#include <vtkm/worklet/contourtree_distributed/boundary_tree_maker/FindNecessaryInteriorSetSuperparentNecessaryWorklet.h>
#include <vtkm/worklet/contourtree_distributed/boundary_tree_maker/FindNecessaryInteriorSupernodesFindNodesWorklet.h>
@ -196,13 +197,20 @@ public:
/// @param[in] localToGlobalIdRelabeler IdRelabeler for the mesh needed to call
/// this->Mesh->GetGlobalIdsFromMeshIndices(...) used by the
/// this->SetInteriorForest function (default=nullptr).
/// @param[in] boundaryCritical If True then use only boundary critical points
/// in the BoundaryTree, otherwise use the full boundary between blocks.
/// (default=true)
VTKM_CONT
void Construct(const vtkm::worklet::contourtree_augmented::mesh_dem::IdRelabeler*
localToGlobalIdRelabeler = nullptr);
localToGlobalIdRelabeler = nullptr,
bool boundaryCritical = true);
/// routine to find the set of boundary vertices
/// @param[in] boundaryCritical If True then use only boundary critical points
/// in the BoundaryTree, otherwise use the full boundary between blocks.
/// (default=true)
VTKM_CONT
void FindBoundaryVertices();
void FindBoundaryVertices(bool boundaryCritical);
/// routine to compute the initial dependent counts (i.e. along each superarc)
/// in preparation for hyper-propagation
@ -271,7 +279,8 @@ private:
template <typename MeshType, typename MeshBoundaryExecObjType>
void BoundaryTreeMaker<MeshType, MeshBoundaryExecObjType>::Construct(
const vtkm::worklet::contourtree_augmented::mesh_dem::IdRelabeler* localToGlobalIdRelabeler)
const vtkm::worklet::contourtree_augmented::mesh_dem::IdRelabeler* localToGlobalIdRelabeler,
bool boundaryCritical)
{ // Construct
// 0. Retrieve the number of iterations used to construct the contour tree
@ -282,7 +291,7 @@ void BoundaryTreeMaker<MeshType, MeshBoundaryExecObjType>::Construct(
// Step I: Initialise the bract to hold the set of boundary vertices
// & save how many for later
this->FindBoundaryVertices();
this->FindBoundaryVertices(boundaryCritical);
// Step II: For each supernode / superarc, compute the dependent boundary counts
this->ComputeDependentBoundaryCounts();
@ -321,21 +330,38 @@ void BoundaryTreeMaker<MeshType, MeshBoundaryExecObjType>::Construct(
/// - this->this->BractVertexSuperset
/// - this->BoundaryIndices
template <typename MeshType, typename MeshBoundaryExecObjType>
void BoundaryTreeMaker<MeshType, MeshBoundaryExecObjType>::FindBoundaryVertices()
void BoundaryTreeMaker<MeshType, MeshBoundaryExecObjType>::FindBoundaryVertices(
bool boundaryCritical)
{ // FindBoundaryVertices
// ask the mesh to give us a list of boundary verticels (with their regular indices)
this->Mesh->GetBoundaryVertices(
this->BractVertexSuperset, this->BoundaryIndices, &(this->MeshBoundaryExecutionObject));
// pull a local copy of the size (they can diverge)
this->Bract->NumBoundary = this->BractVertexSuperset.GetNumberOfValues();
// Identify the points that are boundary critical and update this->BractVertexSuperset,
// and this->BoundaryIndices accordingly by removing all boundary vertices that are
// not boundary cirtical, and hence, are not neccessary for merging neighboring data blocks
if (boundaryCritical)
{
vtkm::worklet::contourtree_distributed::bract_maker::FindBoundaryVerticesIsNecessaryWorklet
isNecessaryWorklet;
vtkm::cont::ArrayHandle<bool> isBoundaryCritical;
this->Invoke(isNecessaryWorklet,
this->BractVertexSuperset,
&(this->MeshBoundaryExecutionObject),
isBoundaryCritical);
vtkm::worklet::contourtree_augmented::IdArrayType necessaryBractVertexSuperset;
vtkm::worklet::contourtree_augmented::IdArrayType necessaryBoundaryIndices;
vtkm::cont::Algorithm::CopyIf(
this->BractVertexSuperset, isBoundaryCritical, necessaryBractVertexSuperset);
this->BractVertexSuperset = necessaryBractVertexSuperset;
vtkm::cont::Algorithm::CopyIf(
this->BoundaryIndices, isBoundaryCritical, necessaryBoundaryIndices);
this->BoundaryIndices = necessaryBoundaryIndices;
}
this->NumBoundary = this->BractVertexSuperset.GetNumberOfValues();
// TODO: Need to update this function to optionally use only boundary critical points,
// i.e., remove those boundary verticies from the list that are not critical.
// This should be a flag that we can set on the Construct method so that we
// can do performance tests for both code paths.
// We also need to updated this->NumBoundary and this->BoundaryTree.NumBoundaryUsed
// accordingly if we only used boundary critical points
this->Bract->NumBoundary = this->NumBoundary;
this->Bract->NumBoundaryUsed = this->NumBoundary;
#ifdef DEBUG_PRINT

@ -98,9 +98,11 @@ public:
/// about the various trees computed as part of the hierarchical contour tree compute
ComputeDistributedContourTreeFunctor(
vtkm::Id3 globalSize,
bool useBoundaryExtremaOnly,
vtkm::cont::LogLevel timingsLogLevel = vtkm::cont::LogLevel::Perf,
vtkm::cont::LogLevel treeLogLevel = vtkm::cont::LogLevel::Info)
: GlobalSize(globalSize)
, UseBoundaryExtremaOnly(useBoundaryExtremaOnly)
, TimingsLogLevel(timingsLogLevel)
, TreeLogLevel(treeLogLevel)
{
@ -350,7 +352,7 @@ public:
&(block->InteriorForests.back()));
// Construct the BRACT and InteriorForest. Since we are working on a ContourTreeMesh we do
// not need to provide and IdRelabeler here in order to compute the InteriorForest
boundaryTreeMaker.Construct();
boundaryTreeMaker.Construct(nullptr, this->UseBoundaryExtremaOnly);
// Construct contour tree mesh from BRACT
block->ContourTreeMeshes.emplace_back(
boundaryTree.VertexIndex, boundaryTree.Superarcs, block->ContourTreeMeshes.back());
@ -467,6 +469,9 @@ private:
/// Extends of the global mesh
vtkm::Id3 GlobalSize;
/// Use boundary extrema only (instead of the full boundary) during the fan in
bool UseBoundaryExtremaOnly;
/// Log level to be used for outputting timing information. Default is vtkm::cont::LogLevel::Perf
vtkm::cont::LogLevel TimingsLogLevel = vtkm::cont::LogLevel::Perf;

@ -758,6 +758,8 @@ std::string BoundaryTreeDotGraphPrint(
boundaryVertexSortIndexArray, // output
&meshBoundaryExecutionObject //input
);
// TODO Add option for boundary critical only
auto boundaryVertexArrayPortal = boundaryVertexArray.ReadPortal();
// vtkm::cont::ArrayHandle<vtkm::Range> rangeArray = vtkm::cont::ArrayRangeCompute(mesh.SortOrder);
// vtkm::Id maxId = static_cast<vtkm::Id>(rangeArray.ReadPortal().Get(0).Max) + 1;

@ -9,6 +9,7 @@
##============================================================================
set(headers
FindBoundaryVerticesIsNecessaryWorklet.h
BoundaryVerticesPerSuperArcWorklets.h
PropagateBoundaryCountsSubtractDependentCountsWorklet.h
PropagateBoundaryCountsTransferDependentCountsWorklet.h

@ -0,0 +1,100 @@
//============================================================================
// Copyright (c) Kitware, Inc.
// All rights reserved.
// See LICENSE.txt for details.
//
// This software is distributed WITHOUT ANY WARRANTY; without even
// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
// PURPOSE. See the above copyright notice for more information.
//============================================================================
// Copyright (c) 2018, The Regents of the University of California, through
// Lawrence Berkeley National Laboratory (subject to receipt of any required approvals
// from the U.S. Dept. of Energy). All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
// (1) Redistributions of source code must retain the above copyright notice, this
// list of conditions and the following disclaimer.
//
// (2) Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// (3) Neither the name of the University of California, Lawrence Berkeley National
// Laboratory, U.S. Dept. of Energy nor the names of its contributors may be
// used to endorse or promote products derived from this software without
// specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
// IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
// INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
// BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
// OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
// OF THE POSSIBILITY OF SUCH DAMAGE.
//
//=============================================================================
//
// This code is an extension of the algorithm presented in the paper:
// Parallel Peak Pruning for Scalable SMP Contour Tree Computation.
// Hamish Carr, Gunther Weber, Christopher Sewell, and James Ahrens.
// Proceedings of the IEEE Symposium on Large Data Analysis and Visualization
// (LDAV), October 2016, Baltimore, Maryland.
//
// The PPP2 algorithm and software were jointly developed by
// Hamish Carr (University of Leeds), Gunther H. Weber (LBNL), and
// Oliver Ruebel (LBNL)
//==============================================================================
#ifndef vtk_m_worklet_contourtree_distributed_bract_maker_find_boundary_vertices_is_necessary_h
#define vtk_m_worklet_contourtree_distributed_bract_maker_find_boundary_vertices_is_necessary_h
#include <vtkm/worklet/WorkletMapField.h>
#include <vtkm/worklet/contourtree_augmented/Types.h>
namespace vtkm
{
namespace worklet
{
namespace contourtree_distributed
{
namespace bract_maker
{
/// Worklet used in BoundaryTreeMaker<>::FindBoundaryVertices to create a stencil of the vertices that are
/// necessary for merging neighbouring data blocks (a.k.a., the points on shared boundaries that are
/// boundary cirtical)
class FindBoundaryVerticesIsNecessaryWorklet : public vtkm::worklet::WorkletMapField
{
public:
using ControlSignature = void(FieldIn bractVertexSuperset, // (input)
ExecObject meshBoundaryExec, // (input)
FieldOut necessaryBractVertexSuperset // (output)
);
using ExecutionSignature = _3(_1, _2);
using InputDomain = _1;
// Default Constructor
VTKM_EXEC_CONT
FindBoundaryVerticesIsNecessaryWorklet() {}
template <typename MeshBoundaryExecType>
VTKM_EXEC bool operator()(const vtkm::Id& node,
const MeshBoundaryExecType& meshBoundaryExec) const
{
return meshBoundaryExec.IsNecessary(node);
}
}; // FindBoundaryVerticesIsNecessaryWorklet
} // namespace bract_maker
} // namespace contourtree_distributed
} // namespace worklet
} // namespace vtkm
#endif