40 MPI_Datatype datatype,
44 if (!UPstream::parRun())
49 profilingPstream::beginTiming();
61 profilingPstream::addBroadcastTime();
70 MPI_Datatype datatype,
75 if (!UPstream::parRun())
80 if (UPstream::warnComm != -1 && comm != UPstream::warnComm)
82 Pout<<
"** reducing:";
91 Pout<<
" with comm:" << comm
92 <<
" warnComm:" << UPstream::warnComm <<
endl;
93 error::printStack(
Pout);
96 profilingPstream::beginTiming();
110 profilingPstream::addReduceTime();
119 MPI_Datatype datatype,
125 if (!UPstream::parRun())
130 if (UPstream::warnComm != -1 && comm != UPstream::warnComm)
132 if (requestID !=
nullptr)
134 Pout<<
"** MPI_Iallreduce (non-blocking):";
138 Pout<<
"** MPI_Allreduce (blocking):";
148 Pout<<
" with comm:" << comm
149 <<
" warnComm:" << UPstream::warnComm <<
endl;
150 error::printStack(
Pout);
153 profilingPstream::beginTiming();
157 #if defined(MPI_VERSION) && (MPI_VERSION >= 3) 158 if (requestID !=
nullptr)
177 <<
"MPI_Iallreduce failed for " 188 if (requestID !=
nullptr)
206 <<
"MPI_Allreduce failed for " 212 profilingPstream::addReduceTime();
221 MPI_Datatype datatype,
226 const label np = UPstream::nProcs(comm);
228 if (UPstream::warnComm != -1 && comm != UPstream::warnComm)
230 if (requestID !=
nullptr)
232 Pout<<
"** MPI_Ialltoall (non-blocking):";
236 Pout<<
"** MPI_Alltoall (blocking):";
239 <<
" sendData:" << sendData.
size()
240 <<
" with comm:" << comm
241 <<
" warnComm:" << UPstream::warnComm
243 error::printStack(
Pout);
246 if (sendData.
size() != np || recvData.
size() != np)
249 <<
"Have " << np <<
" ranks, but size of sendData:" 250 << sendData.
size() <<
" or recvData:" << recvData.
size()
255 if (!UPstream::parRun())
261 profilingPstream::beginTiming();
265 #if defined(MPI_VERSION) && (MPI_VERSION >= 3) 266 if (requestID !=
nullptr)
276 const_cast<Type*>(sendData.
cdata()),
288 <<
"MPI_Ialltoall [comm: " << comm <<
"] failed." 289 <<
" For " << sendData
300 if (requestID !=
nullptr)
310 const_cast<Type*>(sendData.
cdata()),
321 <<
"MPI_Alltoall [comm: " << comm <<
"] failed." 322 <<
" For " << sendData
327 profilingPstream::addAllToAllTime();
334 const Type* sendData,
342 MPI_Datatype datatype,
347 const label np = UPstream::nProcs(comm);
349 if (UPstream::warnComm != -1 && comm != UPstream::warnComm)
351 if (requestID !=
nullptr)
353 Pout<<
"** MPI_Ialltoallv (non-blocking):";
357 Pout<<
"** MPI_Alltoallv (blocking):";
359 Pout<<
" sendCounts:" << sendCounts
360 <<
" sendOffsets:" << sendOffsets
361 <<
" with comm:" << comm
362 <<
" warnComm:" << UPstream::warnComm
364 error::printStack(
Pout);
369 (sendCounts.
size() != np || sendOffsets.
size() < np)
370 || (recvCounts.
size() != np || recvOffsets.
size() < np)
374 <<
"Have " << np <<
" ranks, but sendCounts:" << sendCounts.
size()
375 <<
", sendOffsets:" << sendOffsets.
size()
376 <<
", recvCounts:" << recvCounts.
size()
377 <<
" or recvOffsets:" << recvOffsets.
size()
382 if (!UPstream::parRun())
384 if (recvCounts[0] != sendCounts[0])
387 <<
"Bytes to send " << sendCounts[0]
388 <<
" does not equal bytes to receive " << recvCounts[0]
394 (sendData + sendOffsets[0]),
395 recvCounts[0]*
sizeof(Type)
400 profilingPstream::beginTiming();
404 #if defined(MPI_VERSION) && (MPI_VERSION >= 3) 405 if (requestID !=
nullptr)
414 const_cast<Type*>(sendData),
415 const_cast<int*>(sendCounts.
cdata()),
416 const_cast<int*>(sendOffsets.
cdata()),
419 const_cast<int*>(recvCounts.
cdata()),
420 const_cast<int*>(recvOffsets.
cdata()),
428 <<
"MPI_Ialltoallv [comm: " << comm <<
"] failed." 429 <<
" For sendCounts " << sendCounts
430 <<
" recvCounts " << recvCounts
440 if (requestID !=
nullptr)
448 const_cast<Type*>(sendData),
449 const_cast<int*>(sendCounts.
cdata()),
450 const_cast<int*>(sendOffsets.
cdata()),
453 const_cast<int*>(recvCounts.
cdata()),
454 const_cast<int*>(recvOffsets.
cdata()),
461 <<
"MPI_Alltoallv [comm: " << comm <<
"] failed." 462 <<
" For sendCounts " << sendCounts
463 <<
" recvCounts " << recvCounts
468 profilingPstream::addAllToAllTime();
475 const Type* sendData,
481 MPI_Datatype datatype,
486 if (!UPstream::parRun())
488 std::memmove(recvData, sendData, recvCount*
sizeof(Type));
492 const label np = UPstream::nProcs(comm);
494 if (UPstream::warnComm != -1 && comm != UPstream::warnComm)
496 if (requestID !=
nullptr)
498 Pout<<
"** MPI_Igather (non-blocking):";
502 Pout<<
"** MPI_Gather (blocking):";
505 <<
" recvCount:" << recvCount
506 <<
" with comm:" << comm
507 <<
" warnComm:" << UPstream::warnComm
509 error::printStack(
Pout);
512 profilingPstream::beginTiming();
516 #if defined(MPI_VERSION) && (MPI_VERSION >= 3) 517 if (requestID !=
nullptr)
525 const_cast<Type*>(sendData),
538 <<
"MPI_Igather [comm: " << comm <<
"] failed." 539 <<
" sendCount " << sendCount
540 <<
" recvCount " << recvCount
550 if (requestID !=
nullptr)
558 const_cast<Type*>(sendData),
570 <<
"MPI_Gather [comm: " << comm <<
"] failed." 571 <<
" sendCount " << sendCount
572 <<
" recvCount " << recvCount
577 profilingPstream::addGatherTime();
584 const Type* sendData,
590 MPI_Datatype datatype,
595 if (!UPstream::parRun())
597 std::memmove(recvData, sendData, recvCount*
sizeof(Type));
601 const label np = UPstream::nProcs(comm);
603 if (UPstream::warnComm != -1 && comm != UPstream::warnComm)
605 if (requestID !=
nullptr)
607 Pout<<
"** MPI_Iscatter (non-blocking):";
611 Pout<<
"** MPI_Scatter (blocking):";
614 <<
" recvCount:" << recvCount
615 <<
" with comm:" << comm
616 <<
" warnComm:" << UPstream::warnComm
618 error::printStack(
Pout);
621 profilingPstream::beginTiming();
625 #if defined(MPI_VERSION) && (MPI_VERSION >= 3) 626 if (requestID !=
nullptr)
634 const_cast<Type*>(sendData),
647 <<
"MPI_Iscatter [comm: " << comm <<
"] failed." 648 <<
" sendCount " << sendCount
649 <<
" recvCount " << recvCount
659 if (requestID !=
nullptr)
667 const_cast<Type*>(sendData),
679 <<
"MPI_Iscatter [comm: " << comm <<
"] failed." 680 <<
" sendCount " << sendCount
681 <<
" recvCount " << recvCount
686 profilingPstream::addScatterTime();
693 const Type* sendData,
700 MPI_Datatype datatype,
705 if (!UPstream::parRun())
708 std::memmove(recvData, sendData, sendCount*
sizeof(Type));
712 const label np = UPstream::nProcs(comm);
714 if (UPstream::warnComm != -1 && comm != UPstream::warnComm)
716 if (requestID !=
nullptr)
718 Pout<<
"** MPI_Igatherv (non-blocking):";
722 Pout<<
"** MPI_Gatherv (blocking):";
725 <<
" recvCounts:" << recvCounts
726 <<
" recvOffsets:" << recvOffsets
727 <<
" with comm:" << comm
728 <<
" warnComm:" << UPstream::warnComm
730 error::printStack(
Pout);
735 UPstream::master(comm)
736 && (recvCounts.
size() != np || recvOffsets.
size() < np)
743 <<
"Have " << np <<
" ranks, but recvCounts:" << recvCounts.
size()
744 <<
" or recvOffsets:" << recvOffsets.
size()
749 profilingPstream::beginTiming();
752 if (UPstream::master(comm) && !recvCounts[0])
759 #if defined(MPI_VERSION) && (MPI_VERSION >= 3) 760 if (requestID !=
nullptr)
768 const_cast<Type*>(sendData),
772 const_cast<int*>(recvCounts.
cdata()),
773 const_cast<int*>(recvOffsets.
cdata()),
782 <<
"MPI_Igatherv failed [comm: " << comm <<
']' 783 <<
" sendCount " << sendCount
784 <<
" recvCounts " << recvCounts
794 if (requestID !=
nullptr)
802 const_cast<Type*>(sendData),
806 const_cast<int*>(recvCounts.
cdata()),
807 const_cast<int*>(recvOffsets.
cdata()),
815 <<
"MPI_Gatherv failed [comm: " << comm <<
']' 816 <<
" sendCount " << sendCount
817 <<
" recvCounts " << recvCounts
822 profilingPstream::addGatherTime();
829 const Type* sendData,
836 MPI_Datatype datatype,
841 if (!UPstream::parRun())
843 std::memmove(recvData, sendData, recvCount*
sizeof(Type));
847 const label np = UPstream::nProcs(comm);
849 if (UPstream::warnComm != -1 && comm != UPstream::warnComm)
851 if (requestID !=
nullptr)
853 Pout<<
"** MPI_Iscatterv (non-blocking):";
857 Pout<<
"** MPI_Scatterv (blocking):";
860 <<
" sendCounts:" << sendCounts
861 <<
" sendOffsets:" << sendOffsets
862 <<
" with comm:" << comm
863 <<
" warnComm:" << UPstream::warnComm
865 error::printStack(
Pout);
870 UPstream::master(comm)
871 && (sendCounts.
size() != np || sendOffsets.
size() < np)
878 <<
"Have " << np <<
" ranks, but sendCounts:" << sendCounts.
size()
879 <<
" or sendOffsets:" << sendOffsets.
size()
884 profilingPstream::beginTiming();
888 #if defined(MPI_VERSION) && (MPI_VERSION >= 3) 889 if (requestID !=
nullptr)
897 const_cast<Type*>(sendData),
898 const_cast<int*>(sendCounts.
cdata()),
899 const_cast<int*>(sendOffsets.
cdata()),
911 <<
"MPI_Iscatterv [comm: " << comm <<
"] failed." 912 <<
" sendCounts " << sendCounts
913 <<
" sendOffsets " << sendOffsets
923 if (requestID !=
nullptr)
931 const_cast<Type*>(sendData),
932 const_cast<int*>(sendCounts.
cdata()),
933 const_cast<int*>(sendOffsets.
cdata()),
944 <<
"MPI_Scatterv [comm: " << comm <<
"] failed." 945 <<
" sendCounts " << sendCounts
946 <<
" sendOffsets " << sendOffsets
951 profilingPstream::addScatterTime();
void size(const label n)
Older name for setAddressableSize.
void scatterv(const Type *sendData, const UList< int > &sendCounts, const UList< int > &sendOffsets, Type *recvData, int recvCount, MPI_Datatype datatype, const label comm, label *requestID=nullptr)
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
T * data() noexcept
Return pointer to the underlying array serving as data storage.
void gatherv(const Type *sendData, int sendCount, Type *recvData, const UList< int > &recvCounts, const UList< int > &recvOffsets, MPI_Datatype datatype, const label comm, label *requestID=nullptr)
DynamicList< MPI_Comm > MPICommunicators_
Ostream & endl(Ostream &os)
Add newline and flush stream.
void allReduce(Type *values, int count, MPI_Datatype datatype, MPI_Op optype, const label comm, label *requestID=nullptr)
void broadcast0(Type *values, int count, MPI_Datatype datatype, const label comm)
List< T > values(const HashTable< T, Key, Hash > &tbl, const bool doSort=false)
List of values from HashTable, optionally sorted.
unsigned int count(const UList< bool > &bools, const bool val=true)
Count number of 'true' entries.
void gather(const Type *sendData, int sendCount, Type *recvData, int recvCount, MPI_Datatype datatype, const label comm, label *requestID=nullptr)
errorManip< error > abort(error &err)
void allToAll(const UList< Type > &sendData, UList< Type > &recvData, MPI_Datatype datatype, const label comm, label *requestID=nullptr)
label push_request(MPI_Request request)
Reuse previously freed request locations or push request onto list of outstanding requests...
void allToAllv(const Type *sendData, const UList< int > &sendCounts, const UList< int > &sendOffsets, Type *recvData, const UList< int > &recvCounts, const UList< int > &recvOffsets, MPI_Datatype datatype, const label comm, label *requestID=nullptr)
const T * cdata() const noexcept
Return pointer to the underlying array serving as data storage.
void deepCopy(const UList< T > &list)
Copy elements of the given UList. Sizes must match!
void reduce0(Type *values, int count, MPI_Datatype datatype, MPI_Op optype, const label comm)
void scatter(const Type *sendData, int sendCount, Type *recvData, int recvCount, MPI_Datatype datatype, const label comm, label *requestID=nullptr)
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.