33 template<
class SubListType>
38 const bool checkOverflow
43 const label len = lists.size();
50 for (label i = 0; i < len; ++i)
53 start += lists[i].size();
55 if (checkOverflow && start <
values[i])
58 <<
"Overflow : sum of sizes exceeds labelMax ("
60 <<
"Please recompile with larger datatype for label." <<
nl
73 template<
class ProcIDsContainer,
class Type>
78 const ProcIDsContainer& procIDs,
88 && commsType == Pstream::commsTypes::nonBlocking
92 <<
"Cannot use nonBlocking with non-contiguous data"
97 if (Pstream::myProcNo(comm) == procIDs[0])
111 commsType == Pstream::commsTypes::scheduled
112 || commsType == Pstream::commsTypes::blocking
115 for (label i = 1; i < procIDs.size(); ++i)
125 procSlot.data_bytes(),
126 procSlot.size_bytes(),
141 fromProc >> procSlot;
149 const label startOfRequests = Pstream::nRequests();
152 for (label i = 1; i < procIDs.size(); ++i)
160 procSlot.data_bytes(),
161 procSlot.size_bytes(),
168 Pstream::waitRequests(startOfRequests);
175 commsType == Pstream::commsTypes::scheduled
176 || commsType == Pstream::commsTypes::blocking
208 const label startOfRequests = Pstream::nRequests();
222 Pstream::waitRequests(startOfRequests);
228 template<
class Type,
class Addr>
240 if (commsType == Pstream::commsTypes::nonBlocking)
243 <<
"Cannot use nonBlocking with indirect list of data"
248 if (Pstream::myProcNo(comm) == procIDs[0])
256 if (!localSlot.empty())
262 for (label i = 1; i < procIDs.
size(); ++i)
274 fromProc >> procSlot;
305 UPstream::procID(comm),
314 template<
class Type,
class Addr>
328 UPstream::procID(comm),
337 template<
class ProcIDsContainer,
class Type>
342 const ProcIDsContainer& procIDs,
350 gather(off, comm, procIDs,
fld, allFld, tag, commsType);
352 if (Pstream::myProcNo(comm) == procIDs[0])
354 fld.transfer(allFld);
373 UPstream::procID(comm),
380 if (Pstream::master(comm))
382 fld.transfer(allFld);
391 template<
class Type,
class OutputContainer>
395 OutputContainer& allValues,
402 <<
"Cannot be called for non-contiguous data" <<
nl
406 const label proci = Pstream::myProcNo(comm);
411 const label nproc = globalAddr.
nProcs();
418 if (proci < nproc && !globalAddr.
localSize(proci))
426 if (Pstream::master(comm))
431 recvOffsets.
resize(nproc+1);
433 for (label proci = 0; proci < nproc; ++proci)
435 recvSizes[proci] = globalAddr.
localSize(proci) *
sizeof(Type);
436 recvOffsets[proci] = globalAddr.
localStart(proci) *
sizeof(Type);
438 recvOffsets[nproc] = globalAddr.
size() *
sizeof(Type);
449 allValues.data_bytes(),
457 template<
class Type,
class OutputContainer>
464 OutputContainer allValues;
465 mpiGather<Type, OutputContainer>(sendData, allValues, comm);
495 template<
class ProcIDsContainer,
class Type>
500 const ProcIDsContainer& procIDs,
510 && commsType == Pstream::commsTypes::nonBlocking
514 <<
"Cannot use nonBlocking with non-contiguous data"
519 if (Pstream::myProcNo(comm) == procIDs[0])
521 const SubList<Type> localSlot(allFld, off[1]-off[0], off[0]);
523 if (!localSlot.empty())
525 fld.deepCopy(localSlot);
530 commsType == Pstream::commsTypes::scheduled
531 || commsType == Pstream::commsTypes::blocking
534 for (label i = 1; i < procIDs.size(); ++i)
536 const SubList<Type> procSlot(allFld, off[i+1]-off[i], off[i]);
544 procSlot.cdata_bytes(),
545 procSlot.size_bytes(),
568 const label startOfRequests = Pstream::nRequests();
571 for (label i = 1; i < procIDs.size(); ++i)
573 const SubList<Type> procSlot(allFld, off[i+1]-off[i], off[i]);
579 procSlot.cdata_bytes(),
580 procSlot.size_bytes(),
587 Pstream::waitRequests(startOfRequests);
594 commsType == Pstream::commsTypes::scheduled
595 || commsType == Pstream::commsTypes::blocking
627 const label startOfRequests = Pstream::nRequests();
641 Pstream::waitRequests(startOfRequests);
661 UPstream::procID(comm),
670 template<
class Type,
class CombineOp>
675 const CombineOp& cop,
681 if (globalIds.
size())
697 PstreamBuffers sendBufs(Pstream::commsTypes::nonBlocking, tag, comm);
699 for (
const auto proci : validBins)
706 localIDs[i] = toLocal(proci, es[i]);
716 PstreamBuffers returnBufs(Pstream::commsTypes::nonBlocking, tag, comm);
720 if (recvSizes[proci])
736 for (
const auto proci : validBins)
738 label start = bins.
offsets()[proci];