MCPcopy Create free account
hub / github.com/Kitware/VTK / Gather

Method Gather

Rendering/ParallelLIC/vtkParallelTimer.cxx:287–338  ·  view source on GitHub ↗

------------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

285
286//------------------------------------------------------------------------------
287void vtkParallelTimerBuffer::Gather(int rootRank)
288{
289 int mpiOk;
290 MPI_Initialized(&mpiOk);
291 if (!mpiOk)
292 {
293 return;
294 }
295 int worldRank;
296 MPI_Comm_rank(MPI_COMM_WORLD, &worldRank);
297 int worldSize;
298 MPI_Comm_size(MPI_COMM_WORLD, &worldSize);
299
300 // in serial this is a no-op
301 if (worldSize > 1)
302 {
303 int* bufferSizes = nullptr;
304 int* disp = nullptr;
305 if (worldRank == rootRank)
306 {
307 bufferSizes = static_cast<int*>(malloc(worldSize * sizeof(int)));
308 disp = static_cast<int*>(malloc(worldSize * sizeof(int)));
309 }
310 int bufferSize = static_cast<int>(this->GetSize());
311 MPI_Gather(&bufferSize, 1, MPI_INT, bufferSizes, 1, MPI_INT, rootRank, MPI_COMM_WORLD);
312 char* log = nullptr;
313 int cumSize = 0;
314 if (worldRank == rootRank)
315 {
316 for (int i = 0; i < worldSize; ++i)
317 {
318 disp[i] = cumSize;
319 cumSize += bufferSizes[i];
320 }
321 log = static_cast<char*>(malloc(cumSize));
322 }
323 MPI_Gatherv(
324 this->Data, bufferSize, MPI_CHAR, log, bufferSizes, disp, MPI_CHAR, rootRank, MPI_COMM_WORLD);
325 if (worldRank == rootRank)
326 {
327 this->Clear();
328 this->PushBack(log, cumSize);
329 free(bufferSizes);
330 free(disp);
331 free(log);
332 }
333 else
334 {
335 this->Clear();
336 }
337 }
338}
339
340//------------------------------------------------------------------------------
341void vtkParallelTimerBuffer::PushBack(const void* data, size_t n)

Callers 2

GatherVectorsMethod · 0.45
UpdateMethod · 0.45

Calls 3

GetSizeMethod · 0.95
ClearMethod · 0.95
PushBackMethod · 0.95

Tested by

no test coverage detected