10#include "Teuchos_CommHelpers.hpp"
11#ifdef HAVE_TEUCHOS_MPI
12# include "Teuchos_Details_MpiCommRequest.hpp"
15#ifdef HAVE_TEUCHOSCORE_CXX11
21#ifdef HAVE_TEUCHOS_MPI
24std::string getMpiErrorString (
const int errCode) {
27 char errString [MPI_MAX_ERROR_STRING+1];
28 int errStringLen = MPI_MAX_ERROR_STRING;
29 (void) MPI_Error_string (errCode, errString, &errStringLen);
34 if (errString[errStringLen-1] !=
'\0') {
35 errString[errStringLen] =
'\0';
37 return std::string (errString);
47alltoAllImpl (
const T sendBuf[],
53#ifdef HAVE_TEUCHOS_MPI
54 using Teuchos::Details::MpiTypeTraits;
60 if (mpiComm == NULL) {
63 if (serialComm == NULL) {
66 alltoAll (sendBuf, sendCount, recvBuf, recvCount, comm);
69 std::copy (sendBuf, sendBuf + sendCount, recvBuf);
72 MPI_Comm rawMpiComm = * (mpiComm->getRawMpiComm ());
74 MPI_Datatype rawMpiType = MpiTypeTraits<T>::getType (t);
76 int err = MPI_SUCCESS;
77 err = MPI_Alltoall(sendBuf, sendCount, rawMpiType,
78 recvBuf, recvCount, rawMpiType,
84 "MPI_Alltoall failed with the following error: "
85 << ::Teuchos::Details::getMpiErrorString (err));
89 std::copy (sendBuf, sendBuf + sendCount, recvBuf);
95alltoAllvImpl (
const T sendBuf[],
96 const int sendCounts[],
97 const int sendDispls[],
99 const int recvCounts[],
100 const int recvDispls[],
103#ifdef HAVE_TEUCHOS_MPI
104 using Teuchos::Details::MpiTypeTraits;
110 if (mpiComm == NULL) {
113 if (serialComm == NULL) {
116 alltoAllv (sendBuf, sendCounts, sendDispls, recvBuf, recvCounts, recvDispls, comm);
119 std::copy (sendBuf, sendBuf + sendCounts[0], recvBuf);
122 MPI_Comm rawMpiComm = * (mpiComm->getRawMpiComm ());
124 MPI_Datatype rawMpiType = MpiTypeTraits<T>::getType (t);
126 int err = MPI_SUCCESS;
127 err = MPI_Alltoallv(sendBuf, sendCounts, sendDispls, rawMpiType,
128 recvBuf, recvCounts, recvDispls, rawMpiType,
134 "MPI_Alltoallv failed with the following error: "
135 << ::Teuchos::Details::getMpiErrorString (err));
139 std::copy (sendBuf, sendBuf + sendCounts[0], recvBuf);
153 const EReductionType reductType,
155 const T sendBuffer[],
158#ifdef HAVE_TEUCHOS_MPI
159 using Teuchos::Details::MpiTypeTraits;
165 if (mpiComm == NULL) {
168 if (serialComm == NULL) {
171#ifdef HAVE_TEUCHOSCORE_CXX11
172 std::unique_ptr<ValueTypeReductionOp<int, T> >
174 std::auto_ptr<ValueTypeReductionOp<int, T> >
176 reductOp (createOp<int, T> (reductType));
177 reduceAll (comm, *reductOp, count, sendBuffer, globalReducts);
180 std::copy (sendBuffer, sendBuffer + count, globalReducts);
183 MPI_Op rawMpiOp = ::Teuchos::Details::getMpiOpForEReductionType (reductType);
184 MPI_Comm rawMpiComm = * (mpiComm->getRawMpiComm ());
186 MPI_Datatype rawMpiType = MpiTypeTraits<T>::getType (t);
188 int err = MPI_SUCCESS;
189 if (sendBuffer == globalReducts) {
193 err = MPI_Allreduce (MPI_IN_PLACE, globalReducts,
194 count, rawMpiType, rawMpiOp, rawMpiComm);
197 err = MPI_Allreduce (
const_cast<T*
> (sendBuffer), globalReducts,
198 count, rawMpiType, rawMpiOp, rawMpiComm);
203 "MPI_Allreduce failed with the following error: "
204 << ::Teuchos::Details::getMpiErrorString (err));
208 std::copy (sendBuffer, sendBuffer + count, globalReducts);
222gatherImpl (
const T sendBuf[],
229#ifdef HAVE_TEUCHOS_MPI
230 using Teuchos::Details::MpiTypeTraits;
236 if (mpiComm == NULL) {
239 if (serialComm == NULL) {
242 gather<int, T> (sendBuf, sendCount, recvBuf, recvCount, root, comm);
245 std::copy (sendBuf, sendBuf + sendCount, recvBuf);
248 MPI_Comm rawMpiComm = * (mpiComm->getRawMpiComm ());
250 MPI_Datatype rawMpiType = MpiTypeTraits<T>::getType (t);
251 const int err = MPI_Gather (
const_cast<T*
> (sendBuf), sendCount, rawMpiType,
252 recvBuf, recvCount, rawMpiType,
257 "MPI_Gather failed with the following error: "
258 << ::Teuchos::Details::getMpiErrorString (err));
262 std::copy (sendBuf, sendBuf + sendCount, recvBuf);
276scatterImpl (
const T sendBuf[],
283#ifdef HAVE_TEUCHOS_MPI
284 using Teuchos::Details::MpiTypeTraits;
290 if (mpiComm == NULL) {
293 if (serialComm == NULL) {
296 scatter<int, T> (sendBuf, sendCount, recvBuf, recvCount, root, comm);
299 std::copy (sendBuf, sendBuf + sendCount, recvBuf);
302 MPI_Comm rawMpiComm = * (mpiComm->getRawMpiComm ());
304 MPI_Datatype rawMpiType = MpiTypeTraits<T>::getType (t);
306 MPI_Scatter (
const_cast<T*
> (sendBuf), sendCount, rawMpiType,
307 recvBuf, recvCount, rawMpiType,
310 (err != MPI_SUCCESS, std::runtime_error,
311 "MPI_Scatter failed with the following error: "
312 << ::Teuchos::Details::getMpiErrorString (err));
317 std::copy (sendBuf, sendBuf + sendCount, recvBuf);
323scattervImpl (
const T sendBuf[],
324 const int sendCounts[],
331#ifdef HAVE_TEUCHOS_MPI
332 using Teuchos::Details::MpiTypeTraits;
338 if (mpiComm == NULL) {
341 if (serialComm == NULL) {
344 scatterv<int, T> (sendBuf, sendCounts, displs, recvBuf, recvCount, root, comm);
347 std::copy (sendBuf, sendBuf + sendCounts[0], recvBuf);
350 MPI_Comm rawMpiComm = * (mpiComm->getRawMpiComm ());
352 MPI_Datatype rawMpiType = MpiTypeTraits<T>::getType (t);
354 MPI_Scatterv (
const_cast<T*
> (sendBuf), sendCounts, displs, rawMpiType,
355 recvBuf, recvCount, rawMpiType,
358 (err != MPI_SUCCESS, std::runtime_error,
359 "MPI_Scatter failed with the following error: "
360 << ::Teuchos::Details::getMpiErrorString (err));
365 std::copy (sendBuf, sendBuf + sendCounts[0], recvBuf);
379reduceImpl (
const T sendBuf[],
382 const EReductionType reductType,
386#ifdef HAVE_TEUCHOS_MPI
387 using Teuchos::Details::MpiTypeTraits;
393 if (mpiComm == NULL) {
396 if (serialComm == NULL) {
402 std::copy (sendBuf, sendBuf + count, recvBuf);
405 MPI_Op rawMpiOp = ::Teuchos::Details::getMpiOpForEReductionType (reductType);
406 MPI_Comm rawMpiComm = * (mpiComm->getRawMpiComm ());
408 MPI_Datatype rawMpiType = MpiTypeTraits<T>::getType (t);
409 const int err = MPI_Reduce (
const_cast<T*
> (sendBuf), recvBuf, count,
410 rawMpiType, rawMpiOp, root, rawMpiComm);
412 (err != MPI_SUCCESS, std::runtime_error,
"MPI_Reduce failed with the "
413 "following error: " << ::Teuchos::Details::getMpiErrorString (err));
417 std::copy (sendBuf, sendBuf + count, recvBuf);
431gathervImpl (
const T sendBuf[],
434 const int recvCounts[],
439#ifdef HAVE_TEUCHOS_MPI
440 using Teuchos::Details::MpiTypeTraits;
446 if (mpiComm == NULL) {
449 if (serialComm == NULL) {
452 gatherv<int, T> (sendBuf, sendCount, recvBuf, recvCounts, displs, root, comm);
456 recvCounts[0] > sendCount, std::invalid_argument,
457 "Teuchos::gatherv: If the input communicator contains only one "
458 "process, then you cannot receive more entries than you send. "
459 "You aim to receive " << recvCounts[0] <<
" entries, but to send "
460 << sendCount <<
" entries.");
464 std::copy (sendBuf, sendBuf + recvCounts[0], recvBuf + displs[0]);
467 MPI_Comm rawMpiComm = * (mpiComm->getRawMpiComm ());
469 MPI_Datatype rawMpiType = MpiTypeTraits<T>::getType (t);
470 const int err = MPI_Gatherv (
const_cast<T*
> (sendBuf),
474 const_cast<int*
> (recvCounts),
475 const_cast<int*
> (displs),
482 "MPI_Gatherv failed with the following error: "
483 << ::Teuchos::Details::getMpiErrorString (err));
488 recvCounts[0] > sendCount, std::invalid_argument,
489 "Teuchos::gatherv: If the input communicator contains only one "
490 "process, then you cannot receive more entries than you send. "
491 "You aim to receive " << recvCounts[0] <<
" entries, but to send "
492 << sendCount <<
" entries.");
496 std::copy (sendBuf, sendBuf + recvCounts[0], recvBuf + displs[0]);
505template<
typename Packet>
509 const int sourceRank)
511 TEUCHOS_COMM_TIME_MONITOR(
513 <<
"> ( value type )"
516 charRecvBuffer (recvBuffer.size (), recvBuffer.getRawPtr ());
518 comm.ireceive (charRecvBuffer.getCharBufferView (), sourceRank);
525template<
typename Packet>
528 const int sourceRank,
532 TEUCHOS_COMM_TIME_MONITOR(
534 <<
"> ( value type )"
537 charRecvBuffer (recvBuffer.size (), recvBuffer.getRawPtr ());
539 comm.ireceive (charRecvBuffer.getCharBufferView (), sourceRank, tag);
560 const int sourceRank)
562#ifdef HAVE_TEUCHOS_MPI
563 using Teuchos::Details::MpiTypeTraits;
569 if (mpiComm == NULL) {
572 if (serialComm == NULL) {
575 return ireceiveGeneral<T> (comm, recvBuffer, sourceRank);
581 "ireceiveImpl: Not implemented for a serial communicator.");
585 MPI_Comm rawComm = * (mpiComm->getRawMpiComm ());
587 MPI_Datatype rawType = MpiTypeTraits<T>::getType (t);
588 T* rawRecvBuf = recvBuffer.getRawPtr ();
589 const int count =
as<int> (recvBuffer.size ());
590 const int tag = mpiComm->getTag ();
591 MPI_Request rawRequest = MPI_REQUEST_NULL;
592 const int err = MPI_Irecv (rawRecvBuf, count, rawType, sourceRank, tag,
593 rawComm, &rawRequest);
595 err != MPI_SUCCESS, std::runtime_error,
596 "MPI_Irecv failed with the following error: "
597 << ::Teuchos::Details::getMpiErrorString (err));
608 "ireceiveImpl: Not implemented for a serial communicator.");
627 const int sourceRank,
631#ifdef HAVE_TEUCHOS_MPI
632 using Teuchos::Details::MpiTypeTraits;
638 if (mpiComm == NULL) {
641 if (serialComm == NULL) {
644 return ireceiveGeneral<T> (recvBuffer, sourceRank, tag, comm);
650 "ireceiveImpl: Not implemented for a serial communicator.");
654 MPI_Comm rawComm = * (mpiComm->getRawMpiComm ());
656 MPI_Datatype rawType = MpiTypeTraits<T>::getType (t);
657 T* rawRecvBuf = recvBuffer.getRawPtr ();
658 const int count =
as<int> (recvBuffer.size ());
659 MPI_Request rawRequest = MPI_REQUEST_NULL;
660 const int err = MPI_Irecv (rawRecvBuf, count, rawType, sourceRank, tag,
661 rawComm, &rawRequest);
663 err != MPI_SUCCESS, std::runtime_error,
664 "MPI_Irecv failed with the following error: "
665 << ::Teuchos::Details::getMpiErrorString (err));
676 "ireceiveImpl: Not implemented for a serial communicator.");
691 const T sendBuffer[],
694 TEUCHOS_COMM_TIME_MONITOR(
697 comm.send (charSendBuffer.getBytes (),
698 charSendBuffer.getCharBuffer (),
706sendGeneral (
const T sendBuffer[],
712 TEUCHOS_COMM_TIME_MONITOR(
715 comm.send (charSendBuffer.getBytes (),
716 charSendBuffer.getCharBuffer (),
736 const T sendBuffer[],
739#ifdef HAVE_TEUCHOS_MPI
740 using Teuchos::Details::MpiTypeTraits;
746 if (mpiComm == NULL) {
749 if (serialComm == NULL) {
752 sendGeneral<T> (comm, count, sendBuffer, destRank);
758 "sendImpl: Not implemented for a serial communicator.");
762 TEUCHOS_COMM_TIME_MONITOR(
764 MPI_Comm rawComm = * (mpiComm->getRawMpiComm ());
766 MPI_Datatype rawType = MpiTypeTraits<T>::getType (t);
767 T* rawBuf =
const_cast<T*
> (sendBuffer);
768 const int tag = mpiComm->getTag ();
769 const int err = MPI_Send (rawBuf, count, rawType, destRank, tag, rawComm);
773 "MPI_Send failed with the following error: "
774 << ::Teuchos::Details::getMpiErrorString (err));
780 "sendImpl: Not implemented for a serial communicator.");
788sendImpl (
const T sendBuffer[],
794#ifdef HAVE_TEUCHOS_MPI
795 using Teuchos::Details::MpiTypeTraits;
801 if (mpiComm == NULL) {
804 if (serialComm == NULL) {
807 sendGeneral<T> (sendBuffer, count, destRank, tag, comm);
813 "sendImpl: Not implemented for a serial communicator.");
817 TEUCHOS_COMM_TIME_MONITOR(
819 MPI_Comm rawComm = * (mpiComm->getRawMpiComm ());
821 MPI_Datatype rawType = MpiTypeTraits<T>::getType (t);
822 T* rawBuf =
const_cast<T*
> (sendBuffer);
823 const int err = MPI_Send (rawBuf, count, rawType, destRank, tag, rawComm);
827 "MPI_Send failed with the following error: "
828 << ::Teuchos::Details::getMpiErrorString (err));
834 "sendImpl: Not implemented for a serial communicator.");
849 TEUCHOS_COMM_TIME_MONITOR(
852 charSendBuffer (sendBuffer.size (), sendBuffer.getRawPtr ());
854 comm.isend (charSendBuffer.getCharBufferView (), destRank);
872 TEUCHOS_COMM_TIME_MONITOR(
875 charSendBuffer (sendBuffer.size (), sendBuffer.getRawPtr ());
877 comm.isend (charSendBuffer.getCharBufferView (), destRank, tag);
891#ifdef HAVE_TEUCHOS_MPI
892 using Teuchos::Details::MpiTypeTraits;
898 if (mpiComm == NULL) {
901 if (serialComm == NULL) {
904 return isendGeneral<T> (sendBuffer, destRank, tag, comm);
908 true, std::logic_error,
909 "isendImpl: Not implemented for a serial communicator.");
913 TEUCHOS_COMM_TIME_MONITOR(
916 MPI_Comm rawComm = * (mpiComm->getRawMpiComm ());
918 MPI_Datatype rawType = MpiTypeTraits<T>::getType (t);
922 T* rawSendBuf =
const_cast<T*
> (sendBuffer.getRawPtr ());
923 const int count =
as<int> (sendBuffer.size ());
924 MPI_Request rawRequest = MPI_REQUEST_NULL;
925 const int err = MPI_Isend (rawSendBuf, count, rawType, destRank, tag,
926 rawComm, &rawRequest);
930 "MPI_Isend failed with the following error: "
931 << ::Teuchos::Details::getMpiErrorString (err));
941 "isendImpl: Not implemented for a serial communicator.");
958#ifdef HAVE_TEUCHOS_COMPLEX
963 const EReductionType reductType,
965 const std::complex<double> sendBuffer[],
966 std::complex<double> globalReducts[])
968 TEUCHOS_COMM_TIME_MONITOR(
969 "Teuchos::reduceAll<int, std::complex<double> > (" << count <<
", "
970 << toString (reductType) <<
")"
972 reduceAllImpl<std::complex<double> > (comm, reductType, count, sendBuffer, globalReducts);
979 const int sourceRank)
981 TEUCHOS_COMM_TIME_MONITOR(
"ireceive<int, std::complex<double> >");
982 return ireceiveImpl<std::complex<double> > (comm, recvBuffer, sourceRank);
988 const int sourceRank,
992 TEUCHOS_COMM_TIME_MONITOR(
"ireceive<int, std::complex<double> >");
993 return ireceiveImpl<std::complex<double> > (recvBuffer, sourceRank, tag, comm);
1000 const std::complex<double> sendBuffer[],
1003 sendImpl<std::complex<double> > (comm, count, sendBuffer, destRank);
1014 sendImpl<std::complex<double> > (sendBuffer, count, destRank, tag, comm);
1019isend (
const ArrayRCP<
const std::complex<double> >& sendBuffer,
1024 return isendImpl<std::complex<double> > (sendBuffer, destRank, tag, comm);
1031 const EReductionType reductType,
1033 const std::complex<float> sendBuffer[],
1034 std::complex<float> globalReducts[])
1036 TEUCHOS_COMM_TIME_MONITOR(
1037 "Teuchos::reduceAll<int, std::complex<float> > (" << count <<
", "
1038 << toString (reductType) <<
")"
1040 reduceAllImpl<std::complex<float> > (comm, reductType, count, sendBuffer, globalReducts);
1047 const int sourceRank)
1049 TEUCHOS_COMM_TIME_MONITOR(
"ireceive<int, std::complex<float> >");
1050 return ireceiveImpl<std::complex<float> > (comm, recvBuffer, sourceRank);
1056 const int sourceRank,
1060 TEUCHOS_COMM_TIME_MONITOR(
"ireceive<int, std::complex<float> >");
1061 return ireceiveImpl<std::complex<float> > (recvBuffer, sourceRank, tag, comm);
1068 const std::complex<float> sendBuffer[],
1071 return sendImpl<std::complex<float> > (comm, count, sendBuffer, destRank);
1082 return sendImpl<std::complex<float> > (sendBuffer, count, destRank, tag, comm);
1087isend (
const ArrayRCP<
const std::complex<float> >& sendBuffer,
1092 return isendImpl<std::complex<float> > (sendBuffer, destRank, tag, comm);
1101 const int sendCounts[],
1102 const int sendDispls[],
1104 const int recvCounts[],
1105 const int recvDispls[],
1108 alltoAllvImpl<double> (sendBuf, sendCounts, sendDispls,
1109 recvBuf, recvCounts, recvDispls, comm);
1115 const EReductionType reductType,
1117 const double sendBuffer[],
1118 double globalReducts[])
1120 TEUCHOS_COMM_TIME_MONITOR(
1121 "Teuchos::reduceAll<int, double> (" << count <<
", "
1122 << toString (reductType) <<
")"
1124 reduceAllImpl<double> (comm, reductType, count, sendBuffer, globalReducts);
1131 const int sourceRank)
1133 TEUCHOS_COMM_TIME_MONITOR(
"ireceive<int, double>");
1134 return ireceiveImpl<double> (comm, recvBuffer, sourceRank);
1140 const int sourceRank,
1144 TEUCHOS_COMM_TIME_MONITOR(
"ireceive<int, double>");
1145 return ireceiveImpl<double> (recvBuffer, sourceRank, tag, comm);
1152 const double sendBuffer[],
1155 return sendImpl<double> (comm, count, sendBuffer, destRank);
1166 return sendImpl<double> (sendBuffer, count, destRank, tag, comm);
1176 return isendImpl<double> (sendBuffer, destRank, tag, comm);
1182 const int sendCount,
1184 const int recvCounts[],
1189 gathervImpl<double> (sendBuf, sendCount, recvBuf, recvCounts, displs, root, comm);
1197 const EReductionType reductType,
1199 const float sendBuffer[],
1200 float globalReducts[])
1202 TEUCHOS_COMM_TIME_MONITOR(
1203 "Teuchos::reduceAll<int, float> (" << count <<
", "
1204 << toString (reductType) <<
")"
1206 reduceAllImpl<float> (comm, reductType, count, sendBuffer, globalReducts);
1213 const int sourceRank)
1215 TEUCHOS_COMM_TIME_MONITOR(
"ireceive<int, float>");
1216 return ireceiveImpl<float> (comm, recvBuffer, sourceRank);
1222 const int sourceRank,
1226 TEUCHOS_COMM_TIME_MONITOR(
"ireceive<int, float>");
1227 return ireceiveImpl<float> (recvBuffer, sourceRank, tag, comm);
1234 const float sendBuffer[],
1237 return sendImpl<float> (comm, count, sendBuffer, destRank);
1248 return sendImpl<float> (sendBuffer, count, destRank, tag, comm);
1258 return isendImpl<float> (sendBuffer, destRank, tag, comm);
1264 const int sendCount,
1266 const int recvCounts[],
1271 gathervImpl<float> (sendBuf, sendCount, recvBuf, recvCounts, displs, root, comm);
1279 const int sendCount,
1280 long long recvBuf[],
1281 const int recvCount,
1285 gatherImpl<long long> (sendBuf, sendCount, recvBuf, recvCount, root, comm);
1291 const int sendCount,
1292 long long recvBuf[],
1293 const int recvCounts[],
1298 gathervImpl<long long> (sendBuf, sendCount, recvBuf, recvCounts, displs, root, comm);
1304 const EReductionType reductType,
1306 const long long sendBuffer[],
1307 long long globalReducts[])
1309 TEUCHOS_COMM_TIME_MONITOR(
1310 "Teuchos::reduceAll<int, long long> (" << count <<
", "
1311 << toString (reductType) <<
")"
1313 reduceAllImpl<long long> (comm, reductType, count, sendBuffer, globalReducts);
1320 const int sourceRank)
1322 TEUCHOS_COMM_TIME_MONITOR(
"ireceive<int, long long>");
1323 return ireceiveImpl<long long> (comm, recvBuffer, sourceRank);
1329 const int sourceRank,
1333 TEUCHOS_COMM_TIME_MONITOR(
"ireceive<int, long long>");
1334 return ireceiveImpl<long long> (recvBuffer, sourceRank, tag, comm);
1341 const long long sendBuffer[],
1344 return sendImpl<long long> (comm, count, sendBuffer, destRank);
1355 return sendImpl<long long> (sendBuffer, count, destRank, tag, comm);
1365 return isendImpl<long long> (sendBuffer, destRank, tag, comm);
1372 const int sendCount,
1373 unsigned long long recvBuf[],
1374 const int recvCount,
1378 gatherImpl<unsigned long long> (sendBuf, sendCount, recvBuf, recvCount, root, comm);
1384 const int sendCount,
1385 unsigned long long recvBuf[],
1386 const int recvCounts[],
1391 gathervImpl<unsigned long long> (sendBuf, sendCount, recvBuf, recvCounts, displs, root, comm);
1397 const EReductionType reductType,
1399 const unsigned long long sendBuffer[],
1400 unsigned long long globalReducts[])
1402 TEUCHOS_COMM_TIME_MONITOR(
1403 "Teuchos::reduceAll<int, unsigned long long> (" << count <<
", "
1404 << toString (reductType) <<
")"
1406 reduceAllImpl<unsigned long long> (comm, reductType, count, sendBuffer, globalReducts);
1413 const int sourceRank)
1415 TEUCHOS_COMM_TIME_MONITOR(
"ireceive<int, unsigned long long>");
1416 return ireceiveImpl<unsigned long long> (comm, recvBuffer, sourceRank);
1422 const int sourceRank,
1426 TEUCHOS_COMM_TIME_MONITOR(
"ireceive<int, unsigned long long>");
1427 return ireceiveImpl<unsigned long long> (recvBuffer, sourceRank, tag, comm);
1434 const unsigned long long sendBuffer[],
1437 return sendImpl<unsigned long long> (comm, count, sendBuffer, destRank);
1448 return sendImpl<unsigned long long> (sendBuffer, count, destRank, tag, comm);
1458 return isendImpl<unsigned long long> (sendBuffer, destRank, tag, comm);
1466 const int sendCount,
1468 const int recvCount,
1472 gatherImpl<long> (sendBuf, sendCount, recvBuf, recvCount, root, comm);
1478 const int sendCount,
1480 const int recvCounts[],
1485 gathervImpl<long> (sendBuf, sendCount, recvBuf, recvCounts, displs, root, comm);
1491 const EReductionType reductType,
1493 const long sendBuffer[],
1494 long globalReducts[])
1496 TEUCHOS_COMM_TIME_MONITOR(
1497 "Teuchos::reduceAll<int, long> (" << count <<
", "
1498 << toString (reductType) <<
")"
1500 reduceAllImpl<long> (comm, reductType, count, sendBuffer, globalReducts);
1507 const int sourceRank)
1509 TEUCHOS_COMM_TIME_MONITOR(
"ireceive<int, long>");
1510 return ireceiveImpl<long> (comm, recvBuffer, sourceRank);
1516 const int sourceRank,
1520 TEUCHOS_COMM_TIME_MONITOR(
"ireceive<int, long>");
1521 return ireceiveImpl<long> (recvBuffer, sourceRank, tag, comm);
1528 const long sendBuffer[],
1531 return sendImpl<long> (comm, count, sendBuffer, destRank);
1542 return sendImpl<long> (sendBuffer, count, destRank, tag, comm);
1552 return isendImpl<long> (sendBuffer, destRank, tag, comm);
1560 const int sendCount,
1561 unsigned long recvBuf[],
1562 const int recvCount,
1566 gatherImpl<unsigned long> (sendBuf, sendCount, recvBuf, recvCount, root, comm);
1572 const int sendCount,
1573 unsigned long recvBuf[],
1574 const int recvCounts[],
1579 gathervImpl<unsigned long> (sendBuf, sendCount, recvBuf, recvCounts, displs, root, comm);
1585 const EReductionType reductType,
1587 const unsigned long sendBuffer[],
1588 unsigned long globalReducts[])
1590 TEUCHOS_COMM_TIME_MONITOR(
1591 "Teuchos::reduceAll<int, unsigned long> (" << count <<
", "
1592 << toString (reductType) <<
")"
1594 reduceAllImpl<unsigned long> (comm, reductType, count, sendBuffer, globalReducts);
1601 const int sourceRank)
1603 TEUCHOS_COMM_TIME_MONITOR(
"ireceive<int, unsigned long>");
1604 return ireceiveImpl<unsigned long> (comm, recvBuffer, sourceRank);
1610 const int sourceRank,
1614 TEUCHOS_COMM_TIME_MONITOR(
"ireceive<int, unsigned long>");
1615 return ireceiveImpl<unsigned long> (recvBuffer, sourceRank, tag, comm);
1622 const unsigned long sendBuffer[],
1625 return sendImpl<unsigned long> (comm, count, sendBuffer, destRank);
1636 return sendImpl<unsigned long> (sendBuffer, count, destRank, tag, comm);
1646 return isendImpl<unsigned long> (sendBuffer, destRank, tag, comm);
1653 const int sendCount,
1655 const int recvCount,
1658 alltoAllImpl<int> (sendBuf, sendCount, recvBuf, recvCount, comm);
1664 const int sendCounts[],
1665 const int sendDispls[],
1667 const int recvCounts[],
1668 const int recvDispls[],
1671 alltoAllvImpl<int> (sendBuf, sendCounts, sendDispls,
1672 recvBuf, recvCounts, recvDispls, comm);
1678 const int sendCount,
1680 const int recvCount,
1684 gatherImpl<int> (sendBuf, sendCount, recvBuf, recvCount, root, comm);
1690 const int sendCount,
1692 const int recvCounts[],
1697 gathervImpl<int> (sendBuf, sendCount, recvBuf, recvCounts, displs, root, comm);
1702scatter<int, int> (
const int sendBuf[],
1703 const int sendCount,
1705 const int recvCount,
1709 scatterImpl<int> (sendBuf, sendCount, recvBuf, recvCount, root, comm);
1714scatterv<int, int> (
const int sendBuf[],
1715 const int sendCount[],
1718 const int recvCount,
1722 scattervImpl<int> (sendBuf, sendCount, displs, recvBuf, recvCount, root, comm);
1727scatterv<int, double> (
const double sendBuf[],
1728 const int sendCount[],
1731 const int recvCount,
1735 scattervImpl<double> (sendBuf, sendCount, displs, recvBuf, recvCount, root, comm);
1740scatterv<int, float> (
const float sendBuf[],
1741 const int sendCounts[],
1744 const int recvCount,
1748 scattervImpl<float> (sendBuf, sendCounts, displs, recvBuf, recvCount, root, comm);
1756 const EReductionType reductType,
1760 TEUCHOS_COMM_TIME_MONITOR
1761 (
"Teuchos::reduce<int, int> (" << count <<
", " << toString (reductType)
1763 reduceImpl<int> (sendBuf, recvBuf, count, reductType, root, comm);
1770 const EReductionType reductType,
1774 TEUCHOS_COMM_TIME_MONITOR
1775 (
"Teuchos::reduce<int, int> (" << count <<
", " << toString (reductType)
1777 reduceImpl<long> (sendBuf, recvBuf, count, reductType, root, comm);
1783 unsigned long recvBuf[],
1785 const EReductionType reductType,
1789 TEUCHOS_COMM_TIME_MONITOR
1790 (
"Teuchos::reduce<int, int> (" << count <<
", " << toString (reductType)
1792 reduceImpl<unsigned long> (sendBuf, recvBuf, count, reductType, root, comm);
1798 unsigned long long recvBuf[],
1800 const EReductionType reductType,
1804 TEUCHOS_COMM_TIME_MONITOR
1805 (
"Teuchos::reduce<int, int> (" << count <<
", " << toString (reductType)
1807 reduceImpl<unsigned long long> (sendBuf, recvBuf, count, reductType, root, comm);
1815 const EReductionType reductType,
1819 TEUCHOS_COMM_TIME_MONITOR
1820 (
"Teuchos::reduce<int, int> (" << count <<
", " << toString (reductType)
1822 reduceImpl<double> (sendBuf, recvBuf, count, reductType, root, comm);
1827 const EReductionType reductType,
1829 const int sendBuffer[],
1830 int globalReducts[])
1832 TEUCHOS_COMM_TIME_MONITOR(
1833 "Teuchos::reduceAll<int, int> (" << count <<
", "
1834 << toString (reductType) <<
")"
1836 reduceAllImpl<int> (comm, reductType, count, sendBuffer, globalReducts);
1843 const int sourceRank)
1845 TEUCHOS_COMM_TIME_MONITOR(
"ireceive<int, int>");
1846 return ireceiveImpl<int> (comm, recvBuffer, sourceRank);
1852 const int sourceRank,
1856 TEUCHOS_COMM_TIME_MONITOR(
"ireceive<int, int>");
1857 return ireceiveImpl<int> (recvBuffer, sourceRank, tag, comm);
1864 const int sendBuffer[],
1867 return sendImpl<int> (comm, count, sendBuffer, destRank);
1878 return sendImpl<int> (sendBuffer, count, destRank, tag, comm);
1888 return isendImpl<int> (sendBuffer, destRank, tag, comm);
1895 const int sendCount,
1896 unsigned int recvBuf[],
1897 const int recvCount,
1901 gatherImpl<unsigned int> (sendBuf, sendCount, recvBuf, recvCount, root, comm);
1907 const int sendCount,
1908 unsigned int recvBuf[],
1909 const int recvCounts[],
1914 gathervImpl<unsigned int> (sendBuf, sendCount, recvBuf, recvCounts, displs, root, comm);
1920 const EReductionType reductType,
1922 const unsigned int sendBuffer[],
1923 unsigned int globalReducts[])
1925 TEUCHOS_COMM_TIME_MONITOR(
1926 "Teuchos::reduceAll<int, unsigned int> (" << count <<
", "
1927 << toString (reductType) <<
")"
1929 reduceAllImpl<unsigned int> (comm, reductType, count, sendBuffer, globalReducts);
1936 const int sourceRank)
1938 TEUCHOS_COMM_TIME_MONITOR(
"ireceive<int, unsigned int>");
1939 return ireceiveImpl<unsigned int> (comm, recvBuffer, sourceRank);
1945 const int sourceRank,
1949 TEUCHOS_COMM_TIME_MONITOR(
"ireceive<int, unsigned int>");
1950 return ireceiveImpl<unsigned int> (recvBuffer, sourceRank, tag, comm);
1957 const unsigned int sendBuffer[],
1960 return sendImpl<unsigned int> (comm, count, sendBuffer, destRank);
1971 return sendImpl<unsigned int> (sendBuffer, count, destRank, tag, comm);
1981 return isendImpl<unsigned int> (sendBuffer, destRank, tag, comm);
1989 const int sendCount,
1991 const int recvCount,
1995 gatherImpl<short> (sendBuf, sendCount, recvBuf, recvCount, root, comm);
2001 const int sendCount,
2003 const int recvCounts[],
2008 gathervImpl<short> (sendBuf, sendCount, recvBuf, recvCounts, displs, root, comm);
2014 const EReductionType reductType,
2016 const short sendBuffer[],
2017 short globalReducts[])
2019 TEUCHOS_COMM_TIME_MONITOR(
2020 "Teuchos::reduceAll<int, short> (" << count <<
", "
2021 << toString (reductType) <<
")"
2023 reduceAllImpl<short> (comm, reductType, count, sendBuffer, globalReducts);
2030 const int sourceRank)
2032 TEUCHOS_COMM_TIME_MONITOR(
"ireceive<int, short>");
2033 return ireceiveImpl<short> (comm, recvBuffer, sourceRank);
2039 const int sourceRank,
2043 TEUCHOS_COMM_TIME_MONITOR(
"ireceive<int, short>");
2044 return ireceiveImpl<short> (recvBuffer, sourceRank, tag, comm);
2051 const short sendBuffer[],
2054 return sendImpl<short> (comm, count, sendBuffer, destRank);
2065 return sendImpl<short> (sendBuffer, count, destRank, tag, comm);
2075 return isendImpl<short> (sendBuffer, destRank, tag, comm);
2091 const EReductionType reductType,
2093 const char sendBuffer[],
2094 char globalReducts[])
2096 TEUCHOS_COMM_TIME_MONITOR(
2097 "Teuchos::reduceAll<int, char> (" << count <<
", "
2098 << toString (reductType) <<
")"
2100 reduceAllImpl<char> (comm, reductType, count, sendBuffer, globalReducts);
Declaration of Teuchos::Details::MpiTypeTraits (only if building with MPI).
Reference-counted smart pointer for managing arrays.
ArrayRCP< T2 > arcp_reinterpret_cast(const ArrayRCP< T1 > &p1)
Reinterpret cast of underlying ArrayRCP type from T1* to T2*.
void set_extra_data(const T1 &extra_data, const std::string &name, const Ptr< ArrayRCP< T2 > > &p, EPrePostDestruction destroy_when=POST_DESTROY, bool force_unique=true)
Set extra data associated with a ArrayRCP object.
ArrayRCP< T2 > arcp_const_cast(const ArrayRCP< T1 > &p1)
Const cast of underlying ArrayRCP type from const T* to T*.
Abstract interface for distributed-memory communication.
void alltoAll(const Packet sendBuf[], const Ordinal sendCount, Packet recvBuf[], const Ordinal recvCount, const Comm< Ordinal > &comm)
Scatter values from all processes to all processes.
void alltoAllv(const Packet sendBuf[], const Ordinal sendCounts[], const Ordinal sendDispls[], Packet recvBuf[], const Ordinal recvCounts[], const Ordinal recvDispls[], const Comm< Ordinal > &comm)
Scatter values from all processes to all processes.
void reduce(const Packet sendBuf[], Packet recvBuf[], const Ordinal count, const EReductionType reductType, const Ordinal root, const Comm< Ordinal > &comm)
Wrapper for MPI_Reduce; reduction to one process, using a built-in reduction operator selected by enu...
void gather(const Packet sendBuf[], const Ordinal sendCount, Packet recvBuf[], const Ordinal recvCount, const int root, const Comm< Ordinal > &comm)
Gather values from each process to the root process.
void gatherv(const Packet sendBuf[], const Ordinal sendCount, Packet recvBuf[], const Ordinal recvCounts[], const Ordinal displs[], const int root, const Comm< Ordinal > &comm)
Gather arrays of possibly different lengths from each process to the root process.
void reduceAll(const Comm< Ordinal > &comm, const ValueTypeReductionOp< Ordinal, Packet > &reductOp, const Ordinal count, const Packet sendBuffer[], Packet globalReducts[])
Wrapper for MPI_Allreduce that takes a custom reduction operator.
Encapsulate how an array of const objects with value sematics is serialized into a const char[] array...
MPI implementation of CommRequest<int>.
Implementation of Comm that uses MPI for communication.
Ptr< T > inOutArg(T &arg)
create a non-persisting (required or optional) input/output argument for a function call.
Smart reference counting pointer class for automatic garbage collection.
RCP< T2 > rcp_implicit_cast(const RCP< T1 > &p1)
Implicit cast of underlying RCP type from T1* to T2*.
Concrete serial communicator subclass.
static std::string name()
Encapsulate how an array of non-const objects with value sematics is serialized into a char[] array.
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
Macro for throwing an exception with breakpointing to ease debugging.
TypeTo as(const TypeFrom &t)
Convert from one value type to another.
The Teuchos namespace contains all of the classes, structs and enums used by Teuchos,...
RCP< CommRequest< Ordinal > > ireceive(const ArrayRCP< Packet > &recvBuffer, const int sourceRank, const int tag, const Comm< Ordinal > &comm)
Variant of ireceive that takes a tag argument (and restores the correct order of arguments).
void send(const Packet sendBuffer[], const Ordinal count, const int destRank, const int tag, const Comm< Ordinal > &comm)
Variant of send() that takes a tag (and restores the correct order of arguments).