53 #ifndef vtk_m_worklet_contourtree_distributed_computedistributedcontourtreefunctor_h
54 #define vtk_m_worklet_contourtree_distributed_computedistributedcontourtreefunctor_h
64 VTKM_THIRDPARTY_PRE_INCLUDE
65 #include <vtkm/thirdparty/diy/diy.h>
66 VTKM_THIRDPARTY_POST_INCLUDE
74 namespace contourtree_distributed
78 template <
typename FieldType>
90 bool useBoundaryExtremaOnly,
106 const vtkmdiy::ReduceProxy& rp,
107 const vtkmdiy::RegularSwapPartners&)
const
114 std::stringstream timingsStream;
118 const auto selfid = rp.gid();
124 std::vector<int> incoming;
125 rp.incoming(incoming);
127 timingsStream <<
" " << std::setw(38) << std::left <<
"DIY Incoming Data"
132 for (
const int ingid : incoming)
144 rp.dequeue(ingid, otherBlockOrigin);
146 rp.dequeue(ingid, otherBlockSize);
148 rp.dequeue(ingid, otherContourTreeMesh);
150 timingsStream <<
" Subphase of Merge Block" << std::endl;
151 timingsStream <<
" |-->" << std::setw(38) << std::left <<
"DIY Deque Data"
155 #ifdef DEBUG_PRINT_CTUD
159 <<
"Combining with block received from ID " << ingid
160 <<
" with extents: " << otherBlockOrigin <<
" "
161 << otherBlockSize << std::endl);
165 std::stringstream mergeMessageStream;
166 mergeMessageStream <<
" Rank : " << rank << std::endl
167 <<
" DIY Id : " << selfid << std::endl
168 <<
" Other Id: " << ingid << std::endl
169 <<
" Round : " << rp.round() << std::endl;
171 otherContourTreeMesh, this->
TimingsLogLevel, mergeMessageStream.str());
173 timingsStream <<
" |-->" << std::setw(38) << std::left <<
"Merge Contour Tree Mesh"
177 #ifdef DEBUG_PRINT_CTUD
179 std::string contourTreeMeshFileName = std::string(
"Rank_") +
180 std::to_string(
static_cast<int>(rank)) + std::string(
"_Block_") +
181 std::to_string(
static_cast<int>(block->
LocalBlockNo)) +
"_Round_" +
182 std::to_string(rp.round()) +
"_Partner_" + std::to_string(ingid) +
183 std::string(
"_Step_0_Combined_Mesh.gv");
184 std::string contourTreeMeshLabel = std::string(
"Block ") +
185 std::to_string(
static_cast<int>(block->
LocalBlockNo)) +
" Round " +
186 std::to_string(rp.round()) +
" Partner " + std::to_string(ingid) +
187 std::string(
" Step 0 Combined Mesh");
188 std::string contourTreeMeshString =
189 vtkm::worklet::contourtree_distributed::ContourTreeMeshDotGraphPrint<FieldType>(
190 contourTreeMeshLabel,
193 std::ofstream contourTreeMeshFile(contourTreeMeshFileName);
194 contourTreeMeshFile << contourTreeMeshString;
195 timingsStream <<
" |-->" << std::setw(38) << std::left
196 <<
"Save Contour Tree Mesh Dot"
203 std::min(otherBlockOrigin[0], block->
BlockOrigin[0]),
204 std::min(otherBlockOrigin[1], block->
BlockOrigin[1]),
205 std::min(otherBlockOrigin[2], block->
BlockOrigin[2]),
208 std::max(otherBlockOrigin[0] + otherBlockSize[0],
210 std::max(otherBlockOrigin[1] + otherBlockSize[1],
212 std::max(otherBlockOrigin[2] + otherBlockSize[2],
215 vtkm::Id3 currBlockSize{ currBlockMaxIndex[0] - currBlockOrigin[0],
216 currBlockMaxIndex[1] - currBlockOrigin[1],
217 currBlockMaxIndex[2] - currBlockOrigin[2] };
226 vtkm::Id3 maxIdx{ currBlockOrigin[0] + currBlockSize[0] - 1,
227 currBlockOrigin[1] + currBlockSize[1] - 1,
228 currBlockOrigin[2] + currBlockSize[2] - 1 };
229 auto meshBoundaryExecObj = block->
ContourTreeMeshes.back().GetMeshBoundaryExecutionObject(
240 meshBoundaryExecObj);
246 std::stringstream ex_message;
247 ex_message << ex.
what();
248 ex_message <<
" Self/In DIY Id=(" << selfid <<
", " << ingid <<
")";
249 ex_message <<
" Rank=" << rank <<
" Round=" << rp.round();
252 ex_message <<
" Origin In=(" << otherBlockOrigin[0] <<
", " << otherBlockOrigin[1] <<
", "
253 << otherBlockOrigin[2] <<
")";
254 ex_message <<
" Origin Comb=(" << currBlockOrigin[0] <<
", " << currBlockOrigin[1] <<
", "
255 << currBlockOrigin[2] <<
")";
256 ex_message <<
" Size Self=(" << block->
BlockSize[0] <<
", " << block->
BlockSize[1] <<
", "
258 ex_message <<
" Size In=(" << otherBlockSize[0] <<
", " << otherBlockSize[1] <<
", "
259 << otherBlockSize[2] <<
")";
260 ex_message <<
" Size Comb=(" << currBlockSize[0] <<
", " << currBlockSize[1] <<
", "
261 << currBlockSize[2] <<
")";
269 timingsStream <<
" |-->" << std::setw(38) << std::left
270 <<
"Compute Joint Contour Tree"
274 #ifdef DEBUG_PRINT_CTUD
327 <<
" ---------------- Contour Tree Worklet Timings ------------------"
329 <<
" Rank : " << rank << std::endl
330 <<
" DIY Id : " << selfid << std::endl
331 <<
" In Id : " << ingid << std::endl
332 <<
" Round : " << rp.round() << std::endl
337 <<
" ---------------- Contour Tree Array Sizes ---------------------"
339 <<
" Rank : " << rank << std::endl
340 <<
" DIY Id : " << selfid << std::endl
341 <<
" In Id : " << ingid << std::endl
342 <<
" Round : " << rp.round() << std::endl
349 timingsStream <<
" " << std::setw(38) << std::left <<
"Merge Block (Compute Joint Tree)"
356 if (rp.round() != 0 && rp.out_link().size() != 0)
365 auto meshBoundaryExecObj = block->
ContourTreeMeshes.back().GetMeshBoundaryExecutionObject(
384 #ifdef DEBUG_PRINT_CTUD
438 <<
" ---------------- Boundary Tree Array Sizes ---------------------"
440 <<
" Rank : " << rank << std::endl
441 <<
" DIY Id : " << selfid << std::endl
442 <<
" Round : " << rp.round() << std::endl
447 <<
" ---------------- Interior Forest Array Sizes ---------------------"
449 <<
" Rank : " << rank << std::endl
450 <<
" DIY Id : " << selfid << std::endl
451 <<
" Round : " << rp.round() << std::endl
456 timingsStream <<
" " << std::setw(38) << std::left <<
"Compute Trees To Send"
463 for (
int cc = 0; cc < rp.out_link().size(); ++cc)
465 auto target = rp.out_link().target(cc);
466 if (target.gid != selfid)
473 <<
"FanInEnqueue: Rank=" << rank <<
"; Round=" << rp.round()
474 <<
"; DIY Send Id=" << selfid <<
"; DIY Target ID=" << target.gid
480 timingsStream <<
" " << std::setw(38) << std::left <<
"DIY Enqueue Data"
483 timingsStream <<
" " << std::setw(38) << std::left <<
"Total Time Functor Step"
484 <<
": " << totalTimer.
GetElapsedTime() <<
" seconds" << std::endl;
488 <<
" ---------------- Fan In Functor Step ---------------------" << std::endl
489 <<
" Rank : " << rank << std::endl
490 <<
" DIY Id : " << selfid << std::endl
491 <<
" Round : " << rp.round() << std::endl
492 << timingsStream.str());