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);
55 const EReductionType reductType,
60#ifdef HAVE_TEUCHOS_MPI
61 using Teuchos::Details::MpiTypeTraits;
66 const MpiComm<int>* mpiComm =
dynamic_cast<const MpiComm<int>*
> (&comm);
67 if (mpiComm == NULL) {
70 if (serialComm == NULL) {
73#ifdef HAVE_TEUCHOSCORE_CXX11
74 std::unique_ptr<ValueTypeReductionOp<int, T> >
76 std::auto_ptr<ValueTypeReductionOp<int, T> >
78 reductOp (createOp<int, T> (reductType));
79 reduceAll (comm, *reductOp, count, sendBuffer, globalReducts);
82 std::copy (sendBuffer, sendBuffer + count, globalReducts);
85 MPI_Op rawMpiOp = ::Teuchos::Details::getMpiOpForEReductionType (reductType);
86 MPI_Comm rawMpiComm = * (mpiComm->getRawMpiComm ());
88 MPI_Datatype rawMpiType = MpiTypeTraits<T>::getType (t);
90 int err = MPI_SUCCESS;
91 if (sendBuffer == globalReducts) {
95 err = MPI_Allreduce (MPI_IN_PLACE, globalReducts,
96 count, rawMpiType, rawMpiOp, rawMpiComm);
99 err = MPI_Allreduce (
const_cast<T*
> (sendBuffer), globalReducts,
100 count, rawMpiType, rawMpiOp, rawMpiComm);
105 "MPI_Allreduce failed with the following error: "
106 << ::Teuchos::Details::getMpiErrorString (err));
110 std::copy (sendBuffer, sendBuffer + count, globalReducts);
124gatherImpl (
const T sendBuf[],
131#ifdef HAVE_TEUCHOS_MPI
132 using Teuchos::Details::MpiTypeTraits;
137 const MpiComm<int>* mpiComm =
dynamic_cast<const MpiComm<int>*
> (&comm);
138 if (mpiComm == NULL) {
141 if (serialComm == NULL) {
144 gather<int, T> (sendBuf, sendCount, recvBuf, recvCount, root, comm);
147 std::copy (sendBuf, sendBuf + sendCount, recvBuf);
150 MPI_Comm rawMpiComm = * (mpiComm->getRawMpiComm ());
152 MPI_Datatype rawMpiType = MpiTypeTraits<T>::getType (t);
153 const int err = MPI_Gather (
const_cast<T*
> (sendBuf), sendCount, rawMpiType,
154 recvBuf, recvCount, rawMpiType,
159 "MPI_Gather failed with the following error: "
160 << ::Teuchos::Details::getMpiErrorString (err));
164 std::copy (sendBuf, sendBuf + sendCount, recvBuf);
178scatterImpl (
const T sendBuf[],
185#ifdef HAVE_TEUCHOS_MPI
186 using Teuchos::Details::MpiTypeTraits;
191 const MpiComm<int>* mpiComm =
dynamic_cast<const MpiComm<int>*
> (&comm);
192 if (mpiComm == NULL) {
195 if (serialComm == NULL) {
198 scatter<int, T> (sendBuf, sendCount, recvBuf, recvCount, root, comm);
201 std::copy (sendBuf, sendBuf + sendCount, recvBuf);
204 MPI_Comm rawMpiComm = * (mpiComm->getRawMpiComm ());
206 MPI_Datatype rawMpiType = MpiTypeTraits<T>::getType (t);
208 MPI_Scatter (
const_cast<T*
> (sendBuf), sendCount, rawMpiType,
209 recvBuf, recvCount, rawMpiType,
212 (err != MPI_SUCCESS, std::runtime_error,
213 "MPI_Scatter failed with the following error: "
214 << ::Teuchos::Details::getMpiErrorString (err));
219 std::copy (sendBuf, sendBuf + sendCount, recvBuf);
225scattervImpl (
const T sendBuf[],
226 const int sendCounts[],
233#ifdef HAVE_TEUCHOS_MPI
234 using Teuchos::Details::MpiTypeTraits;
239 const MpiComm<int>* mpiComm =
dynamic_cast<const MpiComm<int>*
> (&comm);
240 if (mpiComm == NULL) {
243 if (serialComm == NULL) {
246 scatterv<int, T> (sendBuf, sendCounts, displs, recvBuf, recvCount, root, comm);
249 std::copy (sendBuf, sendBuf + sendCounts[0], recvBuf);
252 MPI_Comm rawMpiComm = * (mpiComm->getRawMpiComm ());
254 MPI_Datatype rawMpiType = MpiTypeTraits<T>::getType (t);
256 MPI_Scatterv (
const_cast<T*
> (sendBuf), sendCounts, displs, rawMpiType,
257 recvBuf, recvCount, rawMpiType,
260 (err != MPI_SUCCESS, std::runtime_error,
261 "MPI_Scatter failed with the following error: "
262 << ::Teuchos::Details::getMpiErrorString (err));
267 std::copy (sendBuf, sendBuf + sendCounts[0], recvBuf);
281reduceImpl (
const T sendBuf[],
284 const EReductionType reductType,
288#ifdef HAVE_TEUCHOS_MPI
289 using Teuchos::Details::MpiTypeTraits;
294 const MpiComm<int>* mpiComm =
dynamic_cast<const MpiComm<int>*
> (&comm);
295 if (mpiComm == NULL) {
298 if (serialComm == NULL) {
304 std::copy (sendBuf, sendBuf + count, recvBuf);
307 MPI_Op rawMpiOp = ::Teuchos::Details::getMpiOpForEReductionType (reductType);
308 MPI_Comm rawMpiComm = * (mpiComm->getRawMpiComm ());
310 MPI_Datatype rawMpiType = MpiTypeTraits<T>::getType (t);
311 const int err = MPI_Reduce (
const_cast<T*
> (sendBuf), recvBuf, count,
312 rawMpiType, rawMpiOp, root, rawMpiComm);
314 (err != MPI_SUCCESS, std::runtime_error,
"MPI_Reduce failed with the "
315 "following error: " << ::Teuchos::Details::getMpiErrorString (err));
319 std::copy (sendBuf, sendBuf + count, recvBuf);
333gathervImpl (
const T sendBuf[],
336 const int recvCounts[],
341#ifdef HAVE_TEUCHOS_MPI
342 using Teuchos::Details::MpiTypeTraits;
347 const MpiComm<int>* mpiComm =
dynamic_cast<const MpiComm<int>*
> (&comm);
348 if (mpiComm == NULL) {
351 if (serialComm == NULL) {
354 gatherv<int, T> (sendBuf, sendCount, recvBuf, recvCounts, displs, root, comm);
358 recvCounts[0] > sendCount, std::invalid_argument,
359 "Teuchos::gatherv: If the input communicator contains only one "
360 "process, then you cannot receive more entries than you send. "
361 "You aim to receive " << recvCounts[0] <<
" entries, but to send "
362 << sendCount <<
" entries.");
366 std::copy (sendBuf, sendBuf + recvCounts[0], recvBuf + displs[0]);
369 MPI_Comm rawMpiComm = * (mpiComm->getRawMpiComm ());
371 MPI_Datatype rawMpiType = MpiTypeTraits<T>::getType (t);
372 const int err = MPI_Gatherv (
const_cast<T*
> (sendBuf),
376 const_cast<int*
> (recvCounts),
377 const_cast<int*
> (displs),
384 "MPI_Gatherv failed with the following error: "
385 << ::Teuchos::Details::getMpiErrorString (err));
390 recvCounts[0] > sendCount, std::invalid_argument,
391 "Teuchos::gatherv: If the input communicator contains only one "
392 "process, then you cannot receive more entries than you send. "
393 "You aim to receive " << recvCounts[0] <<
" entries, but to send "
394 << sendCount <<
" entries.");
398 std::copy (sendBuf, sendBuf + recvCounts[0], recvBuf + displs[0]);
407template<
typename Packet>
411 const int sourceRank)
413 TEUCHOS_COMM_TIME_MONITOR(
415 <<
"> ( value type )"
418 charRecvBuffer (recvBuffer.size (), recvBuffer.getRawPtr ());
420 comm.ireceive (charRecvBuffer.getCharBufferView (), sourceRank);
427template<
typename Packet>
430 const int sourceRank,
434 TEUCHOS_COMM_TIME_MONITOR(
436 <<
"> ( value type )"
439 charRecvBuffer (recvBuffer.size (), recvBuffer.getRawPtr ());
441 comm.ireceive (charRecvBuffer.getCharBufferView (), sourceRank, tag);
462 const int sourceRank)
464#ifdef HAVE_TEUCHOS_MPI
465 using Teuchos::Details::MpiTypeTraits;
470 const MpiComm<int>* mpiComm =
dynamic_cast<const MpiComm<int>*
> (&comm);
471 if (mpiComm == NULL) {
474 if (serialComm == NULL) {
477 return ireceiveGeneral<T> (comm, recvBuffer, sourceRank);
483 "ireceiveImpl: Not implemented for a serial communicator.");
487 MPI_Comm rawComm = * (mpiComm->getRawMpiComm ());
489 MPI_Datatype rawType = MpiTypeTraits<T>::getType (t);
490 T* rawRecvBuf = recvBuffer.getRawPtr ();
491 const int count =
as<int> (recvBuffer.size ());
492 const int tag = mpiComm->getTag ();
493 MPI_Request rawRequest = MPI_REQUEST_NULL;
494 const int err = MPI_Irecv (rawRecvBuf, count, rawType, sourceRank, tag,
495 rawComm, &rawRequest);
497 err != MPI_SUCCESS, std::runtime_error,
498 "MPI_Irecv failed with the following error: "
499 << ::Teuchos::Details::getMpiErrorString (err));
510 "ireceiveImpl: Not implemented for a serial communicator.");
529 const int sourceRank,
533#ifdef HAVE_TEUCHOS_MPI
534 using Teuchos::Details::MpiTypeTraits;
539 const MpiComm<int>* mpiComm =
dynamic_cast<const MpiComm<int>*
> (&comm);
540 if (mpiComm == NULL) {
543 if (serialComm == NULL) {
546 return ireceiveGeneral<T> (recvBuffer, sourceRank, tag, comm);
552 "ireceiveImpl: Not implemented for a serial communicator.");
556 MPI_Comm rawComm = * (mpiComm->getRawMpiComm ());
558 MPI_Datatype rawType = MpiTypeTraits<T>::getType (t);
559 T* rawRecvBuf = recvBuffer.getRawPtr ();
560 const int count =
as<int> (recvBuffer.size ());
561 MPI_Request rawRequest = MPI_REQUEST_NULL;
562 const int err = MPI_Irecv (rawRecvBuf, count, rawType, sourceRank, tag,
563 rawComm, &rawRequest);
565 err != MPI_SUCCESS, std::runtime_error,
566 "MPI_Irecv failed with the following error: "
567 << ::Teuchos::Details::getMpiErrorString (err));
578 "ireceiveImpl: Not implemented for a serial communicator.");
593 const T sendBuffer[],
596 TEUCHOS_COMM_TIME_MONITOR(
599 comm.send (charSendBuffer.getBytes (),
600 charSendBuffer.getCharBuffer (),
608sendGeneral (
const T sendBuffer[],
614 TEUCHOS_COMM_TIME_MONITOR(
617 comm.send (charSendBuffer.getBytes (),
618 charSendBuffer.getCharBuffer (),
638 const T sendBuffer[],
641#ifdef HAVE_TEUCHOS_MPI
642 using Teuchos::Details::MpiTypeTraits;
647 const MpiComm<int>* mpiComm =
dynamic_cast<const MpiComm<int>*
> (&comm);
648 if (mpiComm == NULL) {
651 if (serialComm == NULL) {
654 sendGeneral<T> (comm, count, sendBuffer, destRank);
660 "sendImpl: Not implemented for a serial communicator.");
664 MPI_Comm rawComm = * (mpiComm->getRawMpiComm ());
666 MPI_Datatype rawType = MpiTypeTraits<T>::getType (t);
667 T* rawBuf =
const_cast<T*
> (sendBuffer);
668 const int tag = mpiComm->getTag ();
669 const int err = MPI_Send (rawBuf, count, rawType, destRank, tag, rawComm);
673 "MPI_Send failed with the following error: "
674 << ::Teuchos::Details::getMpiErrorString (err));
680 "sendImpl: Not implemented for a serial communicator.");
688sendImpl (
const T sendBuffer[],
694#ifdef HAVE_TEUCHOS_MPI
695 using Teuchos::Details::MpiTypeTraits;
700 const MpiComm<int>* mpiComm =
dynamic_cast<const MpiComm<int>*
> (&comm);
701 if (mpiComm == NULL) {
704 if (serialComm == NULL) {
707 sendGeneral<T> (sendBuffer, count, destRank, tag, comm);
713 "sendImpl: Not implemented for a serial communicator.");
717 MPI_Comm rawComm = * (mpiComm->getRawMpiComm ());
719 MPI_Datatype rawType = MpiTypeTraits<T>::getType (t);
720 T* rawBuf =
const_cast<T*
> (sendBuffer);
721 const int err = MPI_Send (rawBuf, count, rawType, destRank, tag, rawComm);
725 "MPI_Send failed with the following error: "
726 << ::Teuchos::Details::getMpiErrorString (err));
732 "sendImpl: Not implemented for a serial communicator.");
747 TEUCHOS_COMM_TIME_MONITOR(
750 charSendBuffer (sendBuffer.size (), sendBuffer.getRawPtr ());
752 comm.isend (charSendBuffer.getCharBufferView (), destRank);
770 TEUCHOS_COMM_TIME_MONITOR(
773 charSendBuffer (sendBuffer.size (), sendBuffer.getRawPtr ());
775 comm.isend (charSendBuffer.getCharBufferView (), destRank, tag);
789#ifdef HAVE_TEUCHOS_MPI
790 using Teuchos::Details::MpiTypeTraits;
795 const MpiComm<int>* mpiComm =
dynamic_cast<const MpiComm<int>*
> (&comm);
796 if (mpiComm == NULL) {
799 if (serialComm == NULL) {
802 return isendGeneral<T> (sendBuffer, destRank, tag, comm);
806 true, std::logic_error,
807 "isendImpl: Not implemented for a serial communicator.");
811 MPI_Comm rawComm = * (mpiComm->getRawMpiComm ());
813 MPI_Datatype rawType = MpiTypeTraits<T>::getType (t);
817 T* rawSendBuf =
const_cast<T*
> (sendBuffer.getRawPtr ());
818 const int count =
as<int> (sendBuffer.size ());
819 MPI_Request rawRequest = MPI_REQUEST_NULL;
820 const int err = MPI_Isend (rawSendBuf, count, rawType, destRank, tag,
821 rawComm, &rawRequest);
825 "MPI_Isend failed with the following error: "
826 << ::Teuchos::Details::getMpiErrorString (err));
836 "isendImpl: Not implemented for a serial communicator.");
853#ifdef HAVE_TEUCHOS_COMPLEX
858 const EReductionType reductType,
860 const std::complex<double> sendBuffer[],
861 std::complex<double> globalReducts[])
863 TEUCHOS_COMM_TIME_MONITOR(
864 "Teuchos::reduceAll<int, std::complex<double> > (" << count <<
", "
865 << toString (reductType) <<
")"
867 reduceAllImpl<std::complex<double> > (comm, reductType, count, sendBuffer, globalReducts);
874 const int sourceRank)
876 TEUCHOS_COMM_TIME_MONITOR(
"ireceive<int, std::complex<double> >");
877 return ireceiveImpl<std::complex<double> > (comm, recvBuffer, sourceRank);
883 const int sourceRank,
887 TEUCHOS_COMM_TIME_MONITOR(
"ireceive<int, std::complex<double> >");
888 return ireceiveImpl<std::complex<double> > (recvBuffer, sourceRank, tag, comm);
895 const std::complex<double> sendBuffer[],
898 sendImpl<std::complex<double> > (comm, count, sendBuffer, destRank);
909 sendImpl<std::complex<double> > (sendBuffer, count, destRank, tag, comm);
914isend (
const ArrayRCP<
const std::complex<double> >& sendBuffer,
919 return isendImpl<std::complex<double> > (sendBuffer, destRank, tag, comm);
926 const EReductionType reductType,
928 const std::complex<float> sendBuffer[],
929 std::complex<float> globalReducts[])
931 TEUCHOS_COMM_TIME_MONITOR(
932 "Teuchos::reduceAll<int, std::complex<float> > (" << count <<
", "
933 << toString (reductType) <<
")"
935 reduceAllImpl<std::complex<float> > (comm, reductType, count, sendBuffer, globalReducts);
942 const int sourceRank)
944 TEUCHOS_COMM_TIME_MONITOR(
"ireceive<int, std::complex<float> >");
945 return ireceiveImpl<std::complex<float> > (comm, recvBuffer, sourceRank);
951 const int sourceRank,
955 TEUCHOS_COMM_TIME_MONITOR(
"ireceive<int, std::complex<float> >");
956 return ireceiveImpl<std::complex<float> > (recvBuffer, sourceRank, tag, comm);
963 const std::complex<float> sendBuffer[],
966 return sendImpl<std::complex<float> > (comm, count, sendBuffer, destRank);
977 return sendImpl<std::complex<float> > (sendBuffer, count, destRank, tag, comm);
982isend (
const ArrayRCP<
const std::complex<float> >& sendBuffer,
987 return isendImpl<std::complex<float> > (sendBuffer, destRank, tag, comm);
996 const EReductionType reductType,
998 const double sendBuffer[],
999 double globalReducts[])
1001 TEUCHOS_COMM_TIME_MONITOR(
1002 "Teuchos::reduceAll<int, double> (" << count <<
", "
1003 << toString (reductType) <<
")"
1005 reduceAllImpl<double> (comm, reductType, count, sendBuffer, globalReducts);
1012 const int sourceRank)
1014 TEUCHOS_COMM_TIME_MONITOR(
"ireceive<int, double>");
1015 return ireceiveImpl<double> (comm, recvBuffer, sourceRank);
1021 const int sourceRank,
1025 TEUCHOS_COMM_TIME_MONITOR(
"ireceive<int, double>");
1026 return ireceiveImpl<double> (recvBuffer, sourceRank, tag, comm);
1033 const double sendBuffer[],
1036 return sendImpl<double> (comm, count, sendBuffer, destRank);
1047 return sendImpl<double> (sendBuffer, count, destRank, tag, comm);
1057 return isendImpl<double> (sendBuffer, destRank, tag, comm);
1063 const int sendCount,
1065 const int recvCounts[],
1070 gathervImpl<double> (sendBuf, sendCount, recvBuf, recvCounts, displs, root, comm);
1078 const EReductionType reductType,
1080 const float sendBuffer[],
1081 float globalReducts[])
1083 TEUCHOS_COMM_TIME_MONITOR(
1084 "Teuchos::reduceAll<int, float> (" << count <<
", "
1085 << toString (reductType) <<
")"
1087 reduceAllImpl<float> (comm, reductType, count, sendBuffer, globalReducts);
1094 const int sourceRank)
1096 TEUCHOS_COMM_TIME_MONITOR(
"ireceive<int, float>");
1097 return ireceiveImpl<float> (comm, recvBuffer, sourceRank);
1103 const int sourceRank,
1107 TEUCHOS_COMM_TIME_MONITOR(
"ireceive<int, float>");
1108 return ireceiveImpl<float> (recvBuffer, sourceRank, tag, comm);
1115 const float sendBuffer[],
1118 return sendImpl<float> (comm, count, sendBuffer, destRank);
1129 return sendImpl<float> (sendBuffer, count, destRank, tag, comm);
1139 return isendImpl<float> (sendBuffer, destRank, tag, comm);
1145 const int sendCount,
1147 const int recvCounts[],
1152 gathervImpl<float> (sendBuf, sendCount, recvBuf, recvCounts, displs, root, comm);
1160 const int sendCount,
1161 long long recvBuf[],
1162 const int recvCount,
1166 gatherImpl<long long> (sendBuf, sendCount, recvBuf, recvCount, root, comm);
1172 const int sendCount,
1173 long long recvBuf[],
1174 const int recvCounts[],
1179 gathervImpl<long long> (sendBuf, sendCount, recvBuf, recvCounts, displs, root, comm);
1185 const EReductionType reductType,
1187 const long long sendBuffer[],
1188 long long globalReducts[])
1190 TEUCHOS_COMM_TIME_MONITOR(
1191 "Teuchos::reduceAll<int, long long> (" << count <<
", "
1192 << toString (reductType) <<
")"
1194 reduceAllImpl<long long> (comm, reductType, count, sendBuffer, globalReducts);
1201 const int sourceRank)
1203 TEUCHOS_COMM_TIME_MONITOR(
"ireceive<int, long long>");
1204 return ireceiveImpl<long long> (comm, recvBuffer, sourceRank);
1210 const int sourceRank,
1214 TEUCHOS_COMM_TIME_MONITOR(
"ireceive<int, long long>");
1215 return ireceiveImpl<long long> (recvBuffer, sourceRank, tag, comm);
1222 const long long sendBuffer[],
1225 return sendImpl<long long> (comm, count, sendBuffer, destRank);
1236 return sendImpl<long long> (sendBuffer, count, destRank, tag, comm);
1246 return isendImpl<long long> (sendBuffer, destRank, tag, comm);
1253 const int sendCount,
1254 unsigned long long recvBuf[],
1255 const int recvCount,
1259 gatherImpl<unsigned long long> (sendBuf, sendCount, recvBuf, recvCount, root, comm);
1265 const int sendCount,
1266 unsigned long long recvBuf[],
1267 const int recvCounts[],
1272 gathervImpl<unsigned long long> (sendBuf, sendCount, recvBuf, recvCounts, displs, root, comm);
1278 const EReductionType reductType,
1280 const unsigned long long sendBuffer[],
1281 unsigned long long globalReducts[])
1283 TEUCHOS_COMM_TIME_MONITOR(
1284 "Teuchos::reduceAll<int, unsigned long long> (" << count <<
", "
1285 << toString (reductType) <<
")"
1287 reduceAllImpl<unsigned long long> (comm, reductType, count, sendBuffer, globalReducts);
1294 const int sourceRank)
1296 TEUCHOS_COMM_TIME_MONITOR(
"ireceive<int, unsigned long long>");
1297 return ireceiveImpl<unsigned long long> (comm, recvBuffer, sourceRank);
1303 const int sourceRank,
1307 TEUCHOS_COMM_TIME_MONITOR(
"ireceive<int, unsigned long long>");
1308 return ireceiveImpl<unsigned long long> (recvBuffer, sourceRank, tag, comm);
1315 const unsigned long long sendBuffer[],
1318 return sendImpl<unsigned long long> (comm, count, sendBuffer, destRank);
1329 return sendImpl<unsigned long long> (sendBuffer, count, destRank, tag, comm);
1339 return isendImpl<unsigned long long> (sendBuffer, destRank, tag, comm);
1347 const int sendCount,
1349 const int recvCount,
1353 gatherImpl<long> (sendBuf, sendCount, recvBuf, recvCount, root, comm);
1359 const int sendCount,
1361 const int recvCounts[],
1366 gathervImpl<long> (sendBuf, sendCount, recvBuf, recvCounts, displs, root, comm);
1372 const EReductionType reductType,
1374 const long sendBuffer[],
1375 long globalReducts[])
1377 TEUCHOS_COMM_TIME_MONITOR(
1378 "Teuchos::reduceAll<int, long> (" << count <<
", "
1379 << toString (reductType) <<
")"
1381 reduceAllImpl<long> (comm, reductType, count, sendBuffer, globalReducts);
1388 const int sourceRank)
1390 TEUCHOS_COMM_TIME_MONITOR(
"ireceive<int, long>");
1391 return ireceiveImpl<long> (comm, recvBuffer, sourceRank);
1397 const int sourceRank,
1401 TEUCHOS_COMM_TIME_MONITOR(
"ireceive<int, long>");
1402 return ireceiveImpl<long> (recvBuffer, sourceRank, tag, comm);
1409 const long sendBuffer[],
1412 return sendImpl<long> (comm, count, sendBuffer, destRank);
1423 return sendImpl<long> (sendBuffer, count, destRank, tag, comm);
1433 return isendImpl<long> (sendBuffer, destRank, tag, comm);
1441 const int sendCount,
1442 unsigned long recvBuf[],
1443 const int recvCount,
1447 gatherImpl<unsigned long> (sendBuf, sendCount, recvBuf, recvCount, root, comm);
1453 const int sendCount,
1454 unsigned long recvBuf[],
1455 const int recvCounts[],
1460 gathervImpl<unsigned long> (sendBuf, sendCount, recvBuf, recvCounts, displs, root, comm);
1466 const EReductionType reductType,
1468 const unsigned long sendBuffer[],
1469 unsigned long globalReducts[])
1471 TEUCHOS_COMM_TIME_MONITOR(
1472 "Teuchos::reduceAll<int, unsigned long> (" << count <<
", "
1473 << toString (reductType) <<
")"
1475 reduceAllImpl<unsigned long> (comm, reductType, count, sendBuffer, globalReducts);
1482 const int sourceRank)
1484 TEUCHOS_COMM_TIME_MONITOR(
"ireceive<int, unsigned long>");
1485 return ireceiveImpl<unsigned long> (comm, recvBuffer, sourceRank);
1491 const int sourceRank,
1495 TEUCHOS_COMM_TIME_MONITOR(
"ireceive<int, unsigned long>");
1496 return ireceiveImpl<unsigned long> (recvBuffer, sourceRank, tag, comm);
1503 const unsigned long sendBuffer[],
1506 return sendImpl<unsigned long> (comm, count, sendBuffer, destRank);
1517 return sendImpl<unsigned long> (sendBuffer, count, destRank, tag, comm);
1527 return isendImpl<unsigned long> (sendBuffer, destRank, tag, comm);
1534 const int sendCount,
1536 const int recvCount,
1540 gatherImpl<int> (sendBuf, sendCount, recvBuf, recvCount, root, comm);
1546 const int sendCount,
1548 const int recvCounts[],
1553 gathervImpl<int> (sendBuf, sendCount, recvBuf, recvCounts, displs, root, comm);
1558scatter<int, int> (
const int sendBuf[],
1559 const int sendCount,
1561 const int recvCount,
1565 scatterImpl<int> (sendBuf, sendCount, recvBuf, recvCount, root, comm);
1570scatterv<int, double> (
const double sendBuf[],
1571 const int sendCount[],
1574 const int recvCount,
1578 scattervImpl<double> (sendBuf, sendCount, displs, recvBuf, recvCount, root, comm);
1583scatterv<int, float> (
const float sendBuf[],
1584 const int sendCounts[],
1587 const int recvCount,
1591 scattervImpl<float> (sendBuf, sendCounts, displs, recvBuf, recvCount, root, comm);
1599 const EReductionType reductType,
1603 TEUCHOS_COMM_TIME_MONITOR
1604 (
"Teuchos::reduce<int, int> (" << count <<
", " << toString (reductType)
1606 reduceImpl<int> (sendBuf, recvBuf, count, reductType, root, comm);
1613 const EReductionType reductType,
1617 TEUCHOS_COMM_TIME_MONITOR
1618 (
"Teuchos::reduce<int, int> (" << count <<
", " << toString (reductType)
1620 reduceImpl<long> (sendBuf, recvBuf, count, reductType, root, comm);
1626 unsigned long recvBuf[],
1628 const EReductionType reductType,
1632 TEUCHOS_COMM_TIME_MONITOR
1633 (
"Teuchos::reduce<int, int> (" << count <<
", " << toString (reductType)
1635 reduceImpl<unsigned long> (sendBuf, recvBuf, count, reductType, root, comm);
1641 unsigned long long recvBuf[],
1643 const EReductionType reductType,
1647 TEUCHOS_COMM_TIME_MONITOR
1648 (
"Teuchos::reduce<int, int> (" << count <<
", " << toString (reductType)
1650 reduceImpl<unsigned long long> (sendBuf, recvBuf, count, reductType, root, comm);
1658 const EReductionType reductType,
1662 TEUCHOS_COMM_TIME_MONITOR
1663 (
"Teuchos::reduce<int, int> (" << count <<
", " << toString (reductType)
1665 reduceImpl<double> (sendBuf, recvBuf, count, reductType, root, comm);
1670 const EReductionType reductType,
1672 const int sendBuffer[],
1673 int globalReducts[])
1675 TEUCHOS_COMM_TIME_MONITOR(
1676 "Teuchos::reduceAll<int, int> (" << count <<
", "
1677 << toString (reductType) <<
")"
1679 reduceAllImpl<int> (comm, reductType, count, sendBuffer, globalReducts);
1686 const int sourceRank)
1688 TEUCHOS_COMM_TIME_MONITOR(
"ireceive<int, int>");
1689 return ireceiveImpl<int> (comm, recvBuffer, sourceRank);
1695 const int sourceRank,
1699 TEUCHOS_COMM_TIME_MONITOR(
"ireceive<int, int>");
1700 return ireceiveImpl<int> (recvBuffer, sourceRank, tag, comm);
1707 const int sendBuffer[],
1710 return sendImpl<int> (comm, count, sendBuffer, destRank);
1721 return sendImpl<int> (sendBuffer, count, destRank, tag, comm);
1731 return isendImpl<int> (sendBuffer, destRank, tag, comm);
1738 const int sendCount,
1739 unsigned int recvBuf[],
1740 const int recvCount,
1744 gatherImpl<unsigned int> (sendBuf, sendCount, recvBuf, recvCount, root, comm);
1750 const int sendCount,
1751 unsigned int recvBuf[],
1752 const int recvCounts[],
1757 gathervImpl<unsigned int> (sendBuf, sendCount, recvBuf, recvCounts, displs, root, comm);
1763 const EReductionType reductType,
1765 const unsigned int sendBuffer[],
1766 unsigned int globalReducts[])
1768 TEUCHOS_COMM_TIME_MONITOR(
1769 "Teuchos::reduceAll<int, unsigned int> (" << count <<
", "
1770 << toString (reductType) <<
")"
1772 reduceAllImpl<unsigned int> (comm, reductType, count, sendBuffer, globalReducts);
1779 const int sourceRank)
1781 TEUCHOS_COMM_TIME_MONITOR(
"ireceive<int, unsigned int>");
1782 return ireceiveImpl<unsigned int> (comm, recvBuffer, sourceRank);
1788 const int sourceRank,
1792 TEUCHOS_COMM_TIME_MONITOR(
"ireceive<int, unsigned int>");
1793 return ireceiveImpl<unsigned int> (recvBuffer, sourceRank, tag, comm);
1800 const unsigned int sendBuffer[],
1803 return sendImpl<unsigned int> (comm, count, sendBuffer, destRank);
1814 return sendImpl<unsigned int> (sendBuffer, count, destRank, tag, comm);
1824 return isendImpl<unsigned int> (sendBuffer, destRank, tag, comm);
1832 const int sendCount,
1834 const int recvCount,
1838 gatherImpl<short> (sendBuf, sendCount, recvBuf, recvCount, root, comm);
1844 const int sendCount,
1846 const int recvCounts[],
1851 gathervImpl<short> (sendBuf, sendCount, recvBuf, recvCounts, displs, root, comm);
1857 const EReductionType reductType,
1859 const short sendBuffer[],
1860 short globalReducts[])
1862 TEUCHOS_COMM_TIME_MONITOR(
1863 "Teuchos::reduceAll<int, short> (" << count <<
", "
1864 << toString (reductType) <<
")"
1866 reduceAllImpl<short> (comm, reductType, count, sendBuffer, globalReducts);
1873 const int sourceRank)
1875 TEUCHOS_COMM_TIME_MONITOR(
"ireceive<int, short>");
1876 return ireceiveImpl<short> (comm, recvBuffer, sourceRank);
1882 const int sourceRank,
1886 TEUCHOS_COMM_TIME_MONITOR(
"ireceive<int, short>");
1887 return ireceiveImpl<short> (recvBuffer, sourceRank, tag, comm);
1894 const short sendBuffer[],
1897 return sendImpl<short> (comm, count, sendBuffer, destRank);
1908 return sendImpl<short> (sendBuffer, count, destRank, tag, comm);
1918 return isendImpl<short> (sendBuffer, destRank, tag, comm);
1934 const EReductionType reductType,
1936 const char sendBuffer[],
1937 char globalReducts[])
1939 TEUCHOS_COMM_TIME_MONITOR(
1940 "Teuchos::reduceAll<int, char> (" << count <<
", "
1941 << toString (reductType) <<
")"
1943 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 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>.
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).