Adding loggings for stats related to k

This commit is contained in:
Mingzhe Li 2024-06-17 12:36:30 -07:00
parent ee6aeeb10a
commit 9f3f886711
3 changed files with 46 additions and 24 deletions

@ -235,23 +235,23 @@ VTKM_CONT vtkm::cont::PartitionedDataSet SelectTopVolumeContoursFilter::DoExecut
// We check the branchGRId of top volume branches to see whether there are matches within the block
const vtkm::Id nTopVolBranches = b->TopVolumeBranchLowerEndGRId.GetNumberOfValues();
// sortedBranchIndex: the branch index (in the ascending order of branch root)
// sortedBranchOrder: the branch order (in the ascending order of branch root)
// the high-level idea is to sort the branch root global regular ids
// and for each top-volume branch, we use binary search to get the original branch index
// if the top-volume branch does not exist in the block, it will be dropped out
IdArrayType sortedBranchGRId;
IdArrayType sortedBranchIndex;
IdArrayType sortedBranchOrder;
vtkm::cont::Algorithm::Copy(vtkm::cont::ArrayHandleIndex(b->BranchRootGRId.GetNumberOfValues()),
sortedBranchIndex);
sortedBranchOrder);
vtkm::cont::Algorithm::Copy(b->BranchRootGRId, sortedBranchGRId);
vtkm::cont::Algorithm::SortByKey(sortedBranchGRId, sortedBranchIndex);
vtkm::cont::Algorithm::SortByKey(sortedBranchGRId, sortedBranchOrder);
b->TopVolBranchKnownByBlockStencil.Allocate(nTopVolBranches);
b->TopVolBranchGROrder.Allocate(nTopVolBranches);
// we reuse the IdxIfWithinBlockWorklet
// b->TopVolBranchGROrder: the order among all branches by root GR IDs
// if the branch is stored by the block
// We reuse the IdxIfWithinBlockWorklet.
// This worklet searches for given values in a sorted array and returns the stencil & index if the value exists in the array.
// b->TopVolBranchGROrder: the order of the topVolBranch among all known branches if the branch is known by the block.
auto idxIfBranchWithinBlockWorklet =
vtkm::worklet::scalar_topology::select_top_volume_contours::IdxIfWithinBlockWorklet();
invoke(idxIfBranchWithinBlockWorklet,
@ -260,8 +260,9 @@ VTKM_CONT vtkm::cont::PartitionedDataSet SelectTopVolumeContoursFilter::DoExecut
b->TopVolBranchKnownByBlockStencil,
b->TopVolBranchGROrder);
// dropping out top-volume branches that do not overlap with the block
// index of top-volume branches known by the block among all top-volume branches
// Dropping out top-volume branches that are not known by the block.
// the index of top-volume branches known by the block among all top-volume branches
IdArrayType topVolBranchKnownByBlockIndex;
vtkm::cont::ArrayHandleIndex topVolBranchesIndex(nTopVolBranches);
vtkm::cont::Algorithm::CopyIf(
@ -276,7 +277,7 @@ VTKM_CONT vtkm::cont::PartitionedDataSet SelectTopVolumeContoursFilter::DoExecut
vtkm::cont::Algorithm::CopyIf(
b->TopVolBranchGROrder, b->TopVolBranchKnownByBlockStencil, topVolBranchFilteredGROrder);
vtkm::worklet::contourtree_augmented::PermuteArrayWithMaskedIndex<vtkm::Id, IdArrayType>(
sortedBranchIndex, topVolBranchFilteredGROrder, b->TopVolBranchInfoActualIndex);
sortedBranchOrder, topVolBranchFilteredGROrder, b->TopVolBranchInfoActualIndex);
// filtered branch saddle epsilons, global lower/upper end GR ids,
IdArrayType topVolFilteredBranchSaddleEpsilon;
@ -450,12 +451,16 @@ VTKM_CONT vtkm::cont::PartitionedDataSet SelectTopVolumeContoursFilter::DoExecut
vtkm::cont::ArrayHandleConstant<bool>(true, nChildBranch),
b->IsParentBranch);
// Update 06/17/2024: temporarily moving the initialization of IsOuterSaddle outside the function below
// due to a compile error on ubuntu1604+gcc5
IdArrayType IsOuterSaddle;
IsOuterSaddle.Allocate(nTopVolBranches);
// sort all top-volume branches based on
// 1. parent branch info id: b->TopVolumeBranchParent
// 2. saddle-end value: b->TopVolumeBranchSaddleIsovalue
// 3. branch root global regular id (anything that can break tie)
/* auto resolveBranchParent = [&](const auto& inArray)
{
auto resolveBranchParent = [&](const auto& inArray) {
using InArrayHandleType = std::decay_t<decltype(inArray)>;
using ValueType = typename InArrayHandleType::ValueType;
@ -484,8 +489,6 @@ VTKM_CONT vtkm::cont::PartitionedDataSet SelectTopVolumeContoursFilter::DoExecut
// or both if branchSaddleEpsilon(parent) == 0
vtkm::worklet::scalar_topology::select_top_volume_contours::CollectOuterSaddle
collectOuterSaddleWorklet;
IdArrayType IsOuterSaddle;
IsOuterSaddle.Allocate(nTopVolBranches);
invoke(
collectOuterSaddleWorklet, parentSaddleEpsPermutation, parentPermutation, IsOuterSaddle);
@ -600,7 +603,7 @@ VTKM_CONT vtkm::cont::PartitionedDataSet SelectTopVolumeContoursFilter::DoExecut
};
b->TopVolumeBranchSaddleIsoValue
.CastAndCallForTypes<vtkm::TypeListScalarAll, vtkm::cont::StorageListBasic>(
resolveBranchParent); */
resolveBranchParent);
});
timingsStream << " " << std::setw(60) << std::left << "ComputeTopVolumeBranchHierarchy"
@ -876,7 +879,7 @@ VTKM_CONT vtkm::cont::PartitionedDataSet SelectTopVolumeContoursFilter::DoExecut
vtkm::worklet::contourtree_augmented::PrintIndices(
"Sorted Branch GR", sortedBranchGRId, -1, branchStream);
vtkm::worklet::contourtree_augmented::PrintIndices(
"Sorted Branch Id", sortedBranchIndex, -1, branchStream);
"Sorted Branch Id", sortedBranchOrder, -1, branchStream);
vtkm::worklet::contourtree_augmented::PrintHeader(nIsoValues, branchStream);
vtkm::worklet::contourtree_augmented::PrintIndices(
@ -984,8 +987,11 @@ VTKM_CONT vtkm::cont::PartitionedDataSet SelectTopVolumeContoursFilter::DoExecut
auto isosurfaceValuePortal = isosurfaceIsoValue.WritePortal();
vtkm::Id nContourCandidateMeshes = 0;
// NOTE: nContours denotes the number of isosurfaces for visualization
// The number is usually small, so linear loop is not too costly
// NOTE: nContours denotes the number of isosurfaces for visualization.
// The number is usually small, so linear loop is not too costly.
// NOTE update 06/16/2024: it is hard to pre-compute the superarc of mesh edges,
// because we always need the isovalue of the contour.
// As a result, we have to iterate through nContours (=O(k)).
for (vtkm::Id branchIdx = 0; branchIdx < nContours; branchIdx++)
{
ValueType isoValue;
@ -1199,7 +1205,8 @@ VTKM_CONT vtkm::cont::PartitionedDataSet SelectTopVolumeContoursFilter::DoExecut
std::endl
<< "----------- Draw Isosurface (block=" << b->LocalBlockNo << ")------------"
<< std::endl
<< " " << std::setw(60) << std::left
<< " " << std::setw(60) << std::left << "Number of Contours: " << nContours
<< std::setw(60) << std::left
<< "Number of Isosurface Meshes: " << nContourCandidateMeshes << std::endl);
};
b->TopVolumeBranchSaddleIsoValue

@ -76,7 +76,8 @@ void ParentBranchIsoValueFunctor::operator()(SelectTopVolumeContoursBlock* b,
const vtkmdiy::ReduceProxy& rp // communication proxy
) const
{
// Get our rank andconst vtkm::Id rank = vtkm::cont::EnvironmentTracker::GetCommunicator().rank();
// Get our rank and
const vtkm::Id rank = vtkm::cont::EnvironmentTracker::GetCommunicator().rank();
const auto selfid = rp.gid();
// Aliases to reduce verbosity
@ -330,8 +331,8 @@ void ParentBranchIsoValueFunctor::operator()(SelectTopVolumeContoursBlock* b,
resolveMinArray);
// The logging is commented because the size of exchange is limited by K,
// the number of top-volume branches, which is usually small (e.g., <= 10)
/* std::stringstream dataSizeStream;
// the number of top-volume branches, which is usually small
std::stringstream dataSizeStream;
// Log the amount of exchanged data
dataSizeStream << " " << std::setw(38) << std::left << "Incoming branch size"
<< ": " << nIncomingMaxBranch + nIncomingMinBranch << std::endl;
@ -343,7 +344,7 @@ void ParentBranchIsoValueFunctor::operator()(SelectTopVolumeContoursBlock* b,
<< " Rank : " << rank << std::endl
<< " DIY Id : " << selfid << std::endl
<< " Inc Id : " << ingid << std::endl
<< dataSizeStream.str());*/
<< dataSizeStream.str());
}
}
}

@ -81,7 +81,7 @@ void SelectTopVolumeContoursFunctor::operator()(
if (this->nSavedBranches < 1)
return;
// Get our rank and DIY id
// const vtkm::Id rank = vtkm::cont::EnvironmentTracker::GetCommunicator().rank();
const vtkm::Id rank = vtkm::cont::EnvironmentTracker::GetCommunicator().rank();
const auto selfid = rp.gid();
// Aliases to reduce verbosity
@ -249,6 +249,20 @@ void SelectTopVolumeContoursFunctor::operator()(
incomingTopVolBranchSaddleIsoValuePortal.Set(branch, incomingSaddleValue);
}
std::stringstream dataSizeStream;
// Log the amount of exchanged data
dataSizeStream << " " << std::setw(38) << std::left << "Incoming top volume branch size"
<< ": " << nIncoming << std::endl;
VTKM_LOG_S(this->TimingsLogLevel,
std::endl
<< " ---------------- Select Top Volume Branches Step ---------------------"
<< std::endl
<< " Rank : " << rank << std::endl
<< " DIY Id : " << selfid << std::endl
<< " Inc Id : " << ingid << std::endl
<< dataSizeStream.str());
// TODO/FIXME: This is a workaround for a bug in DIY/vtk-m.
// Replace with dequeuing ArrayHandles once bug is fixed.
// rp.dequeue<InArrayHandleType>(ingid, incomingTopVolBranchSaddleIsoValue);