42 #include "Teuchos_CommHelpers.hpp" 44 # include "Teuchos_Details_MpiCommRequest.hpp" 51 MPI_Op getMpiOpForEReductionType (
const enum EReductionType reductionType) {
53 switch (reductionType) {
60 "The given EReductionType value is invalid.");
67 std::string getMpiErrorString (
const int errCode) {
70 char errString [MPI_MAX_ERROR_STRING+1];
71 int errStringLen = MPI_MAX_ERROR_STRING;
72 (void) MPI_Error_string (errCode, errString, &errStringLen);
77 if (errString[errStringLen-1] !=
'\0') {
78 errString[errStringLen] =
'\0';
80 return std::string (errString);
98 static MPI_Datatype getType (
const T&);
103 #ifdef HAVE_TEUCHOS_COMPLEX 105 class MpiTypeTraits<std::complex<double> > {
107 static MPI_Datatype getType (
const std::complex<double>&) {
108 return MPI_C_DOUBLE_COMPLEX;
113 class MpiTypeTraits<std::complex<float> > {
115 static MPI_Datatype getType (
const std::complex<float>&) {
116 return MPI_C_FLOAT_COMPLEX;
119 #endif // HAVE_TEUCHOS_COMPLEX 123 class MpiTypeTraits<double> {
125 static MPI_Datatype getType (
const double&) {
131 class MpiTypeTraits<float> {
133 static MPI_Datatype getType (
const float&) {
138 #ifdef HAVE_TEUCHOS_LONG_LONG_INT 140 class MpiTypeTraits<long long> {
142 static MPI_Datatype getType (
const long long&) {
143 return MPI_LONG_LONG;
148 class MpiTypeTraits<unsigned long long> {
150 static MPI_Datatype getType (
const unsigned long long&) {
151 return MPI_UNSIGNED_LONG_LONG;
154 #endif // HAVE_TEUCHOS_LONG_LONG_INT 157 class MpiTypeTraits<long> {
159 static MPI_Datatype getType (
const long&) {
165 class MpiTypeTraits<unsigned long> {
167 static MPI_Datatype getType (
const unsigned long&) {
168 return MPI_UNSIGNED_LONG;
173 class MpiTypeTraits<int> {
175 static MPI_Datatype getType (
const int&) {
181 class MpiTypeTraits<unsigned int> {
183 static MPI_Datatype getType (
const unsigned int&) {
189 class MpiTypeTraits<short> {
191 static MPI_Datatype getType (
const short&) {
197 class MpiTypeTraits<unsigned short> {
199 static MPI_Datatype getType (
const unsigned short&) {
200 return MPI_UNSIGNED_SHORT;
215 reduceAllImpl (
const Comm<int>& comm,
216 const EReductionType reductType,
218 const T sendBuffer[],
225 const MpiComm<int>* mpiComm =
dynamic_cast<const MpiComm<int>*
> (&comm);
226 if (mpiComm == NULL) {
228 const SerialComm<int>* serialComm =
dynamic_cast<const SerialComm<int>*
> (&comm);
229 if (serialComm == NULL) {
232 std::auto_ptr<ValueTypeReductionOp<int, T> > reductOp (createOp<int, T> (reductType));
233 reduceAll (comm, *reductOp, count, sendBuffer, globalReducts);
236 std::copy (sendBuffer, sendBuffer + count, globalReducts);
239 MPI_Op rawMpiOp = getMpiOpForEReductionType (reductType);
240 MPI_Comm rawMpiComm = * (mpiComm->getRawMpiComm ());
242 MPI_Datatype rawMpiType = MpiTypeTraits<T>::getType (t);
243 const int err = MPI_Allreduce (const_cast<T*> (sendBuffer),
244 globalReducts, count, rawMpiType, rawMpiOp, rawMpiComm);
248 "MPI_Allreduce failed with the following error: " 249 << getMpiErrorString (err));
253 std::copy (sendBuffer, sendBuffer + count, globalReducts);
267 gatherImpl (
const T sendBuf[],
272 const Comm<int>& comm)
278 const MpiComm<int>* mpiComm =
dynamic_cast<const MpiComm<int>*
> (&comm);
279 if (mpiComm == NULL) {
281 const SerialComm<int>* serialComm =
dynamic_cast<const SerialComm<int>*
> (&comm);
282 if (serialComm == NULL) {
285 gather<int, T> (sendBuf, sendCount, recvBuf, recvCount, root, comm);
288 std::copy (sendBuf, sendBuf + sendCount, recvBuf);
291 MPI_Comm rawMpiComm = * (mpiComm->getRawMpiComm ());
293 MPI_Datatype rawMpiType = MpiTypeTraits<T>::getType (t);
294 const int err = MPI_Gather (const_cast<T*> (sendBuf), sendCount, rawMpiType,
295 recvBuf, recvCount, rawMpiType,
300 "MPI_Gather failed with the following error: " 301 << getMpiErrorString (err));
305 std::copy (sendBuf, sendBuf + sendCount, recvBuf);
319 scatterImpl (
const T sendBuf[],
324 const Comm<int>& comm)
330 const MpiComm<int>* mpiComm =
dynamic_cast<const MpiComm<int>*
> (&comm);
331 if (mpiComm == NULL) {
333 const SerialComm<int>* serialComm =
dynamic_cast<const SerialComm<int>*
> (&comm);
334 if (serialComm == NULL) {
337 scatter<int, T> (sendBuf, sendCount, recvBuf, recvCount, root, comm);
340 std::copy (sendBuf, sendBuf + sendCount, recvBuf);
343 MPI_Comm rawMpiComm = * (mpiComm->getRawMpiComm ());
345 MPI_Datatype rawMpiType = MpiTypeTraits<T>::getType (t);
347 MPI_Scatter (const_cast<T*> (sendBuf), sendCount, rawMpiType,
348 recvBuf, recvCount, rawMpiType,
351 (err != MPI_SUCCESS, std::runtime_error,
352 "MPI_Scatter failed with the following error: " 353 << getMpiErrorString (err));
358 std::copy (sendBuf, sendBuf + sendCount, recvBuf);
372 reduceImpl (
const T sendBuf[],
375 const EReductionType reductType,
377 const Comm<int>& comm)
383 const MpiComm<int>* mpiComm =
dynamic_cast<const MpiComm<int>*
> (&comm);
384 if (mpiComm == NULL) {
386 const SerialComm<int>* serialComm =
dynamic_cast<const SerialComm<int>*
> (&comm);
387 if (serialComm == NULL) {
390 reduce<int, T> (sendBuf, recvBuf, count, reductType, root, comm);
393 std::copy (sendBuf, sendBuf + count, recvBuf);
396 MPI_Op rawMpiOp = getMpiOpForEReductionType (reductType);
397 MPI_Comm rawMpiComm = * (mpiComm->getRawMpiComm ());
399 MPI_Datatype rawMpiType = MpiTypeTraits<T>::getType (t);
400 const int err = MPI_Reduce (const_cast<T*> (sendBuf), recvBuf, count,
401 rawMpiType, rawMpiOp, root, rawMpiComm);
403 (err != MPI_SUCCESS, std::runtime_error,
"MPI_Reduce failed with the " 404 "following error: " << getMpiErrorString (err));
408 std::copy (sendBuf, sendBuf + count, recvBuf);
422 gathervImpl (
const T sendBuf[],
425 const int recvCounts[],
428 const Comm<int>& comm)
434 const MpiComm<int>* mpiComm =
dynamic_cast<const MpiComm<int>*
> (&comm);
435 if (mpiComm == NULL) {
437 const SerialComm<int>* serialComm =
dynamic_cast<const SerialComm<int>*
> (&comm);
438 if (serialComm == NULL) {
441 gatherv<int, T> (sendBuf, sendCount, recvBuf, recvCounts, displs, root, comm);
445 recvCounts[0] > sendCount, std::invalid_argument,
446 "Teuchos::gatherv: If the input communicator contains only one " 447 "process, then you cannot receive more entries than you send. " 448 "You aim to receive " << recvCounts[0] <<
" entries, but to send " 449 << sendCount <<
" entries.");
453 std::copy (sendBuf, sendBuf + recvCounts[0], recvBuf + displs[0]);
456 MPI_Comm rawMpiComm = * (mpiComm->getRawMpiComm ());
458 MPI_Datatype rawMpiType = MpiTypeTraits<T>::getType (t);
459 const int err = MPI_Gatherv (const_cast<T*> (sendBuf),
463 const_cast<int*> (recvCounts),
464 const_cast<int*> (displs),
471 "MPI_Gatherv failed with the following error: " 472 << getMpiErrorString (err));
477 recvCounts[0] > sendCount, std::invalid_argument,
478 "Teuchos::gatherv: If the input communicator contains only one " 479 "process, then you cannot receive more entries than you send. " 480 "You aim to receive " << recvCounts[0] <<
" entries, but to send " 481 << sendCount <<
" entries.");
485 std::copy (sendBuf, sendBuf + recvCounts[0], recvBuf + displs[0]);
494 template<
typename Packet>
495 RCP<Teuchos::CommRequest<int> >
496 ireceiveGeneral(
const Comm<int>& comm,
497 const ArrayRCP<Packet> &recvBuffer,
498 const int sourceRank)
500 TEUCHOS_COMM_TIME_MONITOR(
502 <<
"> ( value type )" 504 ValueTypeSerializationBuffer<int, Packet>
505 charRecvBuffer (recvBuffer.size (), recvBuffer.getRawPtr ());
506 RCP<CommRequest<int> > commRequest =
507 comm.ireceive (charRecvBuffer.getCharBufferView (), sourceRank);
508 set_extra_data (recvBuffer,
"buffer", inOutArg (commRequest));
514 template<
typename Packet>
515 RCP<Teuchos::CommRequest<int> >
516 ireceiveGeneral (
const ArrayRCP<Packet> &recvBuffer,
517 const int sourceRank,
519 const Comm<int>& comm)
521 TEUCHOS_COMM_TIME_MONITOR(
523 <<
"> ( value type )" 525 ValueTypeSerializationBuffer<int, Packet>
526 charRecvBuffer (recvBuffer.size (), recvBuffer.getRawPtr ());
527 RCP<CommRequest<int> > commRequest =
528 comm.ireceive (charRecvBuffer.getCharBufferView (), sourceRank, tag);
529 set_extra_data (recvBuffer,
"buffer", inOutArg (commRequest));
546 RCP<CommRequest<int> >
547 ireceiveImpl (
const Comm<int>& comm,
548 const ArrayRCP<T>& recvBuffer,
549 const int sourceRank)
555 const MpiComm<int>* mpiComm =
dynamic_cast<const MpiComm<int>*
> (&comm);
556 if (mpiComm == NULL) {
558 const SerialComm<int>* serialComm =
dynamic_cast<const SerialComm<int>*
> (&comm);
559 if (serialComm == NULL) {
562 return ireceiveGeneral<T> (comm, recvBuffer, sourceRank);
568 "ireceiveImpl: Not implemented for a serial communicator.");
572 MPI_Comm rawComm = * (mpiComm->getRawMpiComm ());
574 MPI_Datatype rawType = MpiTypeTraits<T>::getType (t);
575 T* rawRecvBuf = recvBuffer.getRawPtr ();
576 const int count = as<int> (recvBuffer.size ());
577 const int tag = mpiComm->getTag ();
578 MPI_Request rawRequest = MPI_REQUEST_NULL;
579 const int err = MPI_Irecv (rawRecvBuf, count, rawType, sourceRank, tag,
580 rawComm, &rawRequest);
582 err != MPI_SUCCESS, std::runtime_error,
583 "MPI_Irecv failed with the following error: " 584 << getMpiErrorString (err));
586 ArrayRCP<const char> buf =
587 arcp_const_cast<
const char> (arcp_reinterpret_cast<
char> (recvBuffer));
588 RCP<Details::MpiCommRequest> req (
new Details::MpiCommRequest (rawRequest, buf));
589 return rcp_implicit_cast<CommRequest<int> > (req);
595 "ireceiveImpl: Not implemented for a serial communicator.");
612 RCP<CommRequest<int> >
613 ireceiveImpl (
const ArrayRCP<T>& recvBuffer,
614 const int sourceRank,
616 const Comm<int>& comm)
622 const MpiComm<int>* mpiComm =
dynamic_cast<const MpiComm<int>*
> (&comm);
623 if (mpiComm == NULL) {
625 const SerialComm<int>* serialComm =
dynamic_cast<const SerialComm<int>*
> (&comm);
626 if (serialComm == NULL) {
629 return ireceiveGeneral<T> (recvBuffer, sourceRank, tag, comm);
635 "ireceiveImpl: Not implemented for a serial communicator.");
639 MPI_Comm rawComm = * (mpiComm->getRawMpiComm ());
641 MPI_Datatype rawType = MpiTypeTraits<T>::getType (t);
642 T* rawRecvBuf = recvBuffer.getRawPtr ();
643 const int count = as<int> (recvBuffer.size ());
644 MPI_Request rawRequest = MPI_REQUEST_NULL;
645 const int err = MPI_Irecv (rawRecvBuf, count, rawType, sourceRank, tag,
646 rawComm, &rawRequest);
648 err != MPI_SUCCESS, std::runtime_error,
649 "MPI_Irecv failed with the following error: " 650 << getMpiErrorString (err));
652 ArrayRCP<const char> buf =
653 arcp_const_cast<
const char> (arcp_reinterpret_cast<
char> (recvBuffer));
654 RCP<Details::MpiCommRequest> req (
new Details::MpiCommRequest (rawRequest, buf));
655 return rcp_implicit_cast<CommRequest<int> > (req);
661 "ireceiveImpl: Not implemented for a serial communicator.");
674 sendGeneral (
const Comm<int>& comm,
676 const T sendBuffer[],
679 TEUCHOS_COMM_TIME_MONITOR(
681 ConstValueTypeSerializationBuffer<int,T> charSendBuffer (count, sendBuffer);
682 comm.send (charSendBuffer.getBytes (),
683 charSendBuffer.getCharBuffer (),
691 sendGeneral (
const T sendBuffer[],
695 const Comm<int>& comm)
697 TEUCHOS_COMM_TIME_MONITOR(
699 ConstValueTypeSerializationBuffer<int,T> charSendBuffer (count, sendBuffer);
700 comm.send (charSendBuffer.getBytes (),
701 charSendBuffer.getCharBuffer (),
719 sendImpl (
const Comm<int>& comm,
721 const T sendBuffer[],
728 const MpiComm<int>* mpiComm =
dynamic_cast<const MpiComm<int>*
> (&comm);
729 if (mpiComm == NULL) {
731 const SerialComm<int>* serialComm =
dynamic_cast<const SerialComm<int>*
> (&comm);
732 if (serialComm == NULL) {
735 sendGeneral<T> (comm, count, sendBuffer, destRank);
741 "sendImpl: Not implemented for a serial communicator.");
745 MPI_Comm rawComm = * (mpiComm->getRawMpiComm ());
747 MPI_Datatype rawType = MpiTypeTraits<T>::getType (t);
748 T* rawBuf =
const_cast<T*
> (sendBuffer);
749 const int tag = mpiComm->getTag ();
750 const int err = MPI_Send (rawBuf, count, rawType, destRank, tag, rawComm);
754 "MPI_Send failed with the following error: " 755 << getMpiErrorString (err));
761 "sendImpl: Not implemented for a serial communicator.");
769 sendImpl (
const T sendBuffer[],
773 const Comm<int>& comm)
779 const MpiComm<int>* mpiComm =
dynamic_cast<const MpiComm<int>*
> (&comm);
780 if (mpiComm == NULL) {
782 const SerialComm<int>* serialComm =
dynamic_cast<const SerialComm<int>*
> (&comm);
783 if (serialComm == NULL) {
786 sendGeneral<T> (sendBuffer, count, destRank, tag, comm);
792 "sendImpl: Not implemented for a serial communicator.");
796 MPI_Comm rawComm = * (mpiComm->getRawMpiComm ());
798 MPI_Datatype rawType = MpiTypeTraits<T>::getType (t);
799 T* rawBuf =
const_cast<T*
> (sendBuffer);
800 const int err = MPI_Send (rawBuf, count, rawType, destRank, tag, rawComm);
804 "MPI_Send failed with the following error: " 805 << getMpiErrorString (err));
811 "sendImpl: Not implemented for a serial communicator.");
821 RCP<CommRequest<int> >
822 isendGeneral (
const Comm<int>& comm,
823 const ArrayRCP<const T>& sendBuffer,
826 TEUCHOS_COMM_TIME_MONITOR(
828 ConstValueTypeSerializationBuffer<int, T>
829 charSendBuffer (sendBuffer.size (), sendBuffer.getRawPtr ());
830 RCP<CommRequest<int> > commRequest =
831 comm.isend (charSendBuffer.getCharBufferView (), destRank);
832 set_extra_data (sendBuffer,
"buffer", inOutArg (commRequest));
843 RCP<CommRequest<int> >
844 isendGeneral (
const ArrayRCP<const T>& sendBuffer,
847 const Comm<int>& comm)
849 TEUCHOS_COMM_TIME_MONITOR(
851 ConstValueTypeSerializationBuffer<int, T>
852 charSendBuffer (sendBuffer.size (), sendBuffer.getRawPtr ());
853 RCP<CommRequest<int> > commRequest =
854 comm.isend (charSendBuffer.getCharBufferView (), destRank, tag);
855 set_extra_data (sendBuffer,
"buffer", inOutArg (commRequest));
862 RCP<Teuchos::CommRequest<int> >
863 isendImpl (
const ArrayRCP<const T>& sendBuffer,
866 const Comm<int>& comm)
872 const MpiComm<int>* mpiComm =
dynamic_cast<const MpiComm<int>*
> (&comm);
873 if (mpiComm == NULL) {
875 const SerialComm<int>* serialComm =
dynamic_cast<const SerialComm<int>*
> (&comm);
876 if (serialComm == NULL) {
879 return isendGeneral<T> (sendBuffer, destRank, tag, comm);
883 true, std::logic_error,
884 "isendImpl: Not implemented for a serial communicator.");
888 MPI_Comm rawComm = * (mpiComm->getRawMpiComm ());
890 MPI_Datatype rawType = MpiTypeTraits<T>::getType (t);
894 T* rawSendBuf =
const_cast<T*
> (sendBuffer.getRawPtr ());
895 const int count = as<int> (sendBuffer.size ());
896 MPI_Request rawRequest = MPI_REQUEST_NULL;
897 const int err = MPI_Isend (rawSendBuf, count, rawType, destRank, tag,
898 rawComm, &rawRequest);
902 "MPI_Isend failed with the following error: " 903 << getMpiErrorString (err));
905 ArrayRCP<const char> buf = arcp_reinterpret_cast<
const char> (sendBuffer);
906 RCP<Details::MpiCommRequest> req (
new Details::MpiCommRequest (rawRequest, buf));
907 return rcp_implicit_cast<CommRequest<int> > (req);
913 "isendImpl: Not implemented for a serial communicator.");
921 toString (
const EReductionType reductType)
923 switch (reductType) {
930 true, std::invalid_argument,
"Teuchos::toString(EReductionType): " 931 "Invalid EReductionType value " << reductType <<
". Valid values " 949 #ifdef HAVE_TEUCHOS_COMPLEX 953 reduceAll<int, std::complex<double> > (
const Comm<int>& comm,
954 const EReductionType reductType,
956 const std::complex<double> sendBuffer[],
957 std::complex<double> globalReducts[])
959 TEUCHOS_COMM_TIME_MONITOR(
960 "Teuchos::reduceAll<int, std::complex<double> > (" << count <<
", " 961 << toString (reductType) <<
")" 963 reduceAllImpl<std::complex<double> > (comm, reductType, count, sendBuffer, globalReducts);
967 RCP<Teuchos::CommRequest<int> >
968 ireceive<int, std::complex<double> > (
const Comm<int>& comm,
969 const ArrayRCP<std::complex<double> >& recvBuffer,
970 const int sourceRank)
972 TEUCHOS_COMM_TIME_MONITOR(
"ireceive<int, std::complex<double> >");
973 return ireceiveImpl<std::complex<double> > (comm, recvBuffer, sourceRank);
977 RCP<Teuchos::CommRequest<int> >
978 ireceive<int, std::complex<double> > (
const ArrayRCP<std::complex<double> >& recvBuffer,
979 const int sourceRank,
981 const Comm<int>& comm)
983 TEUCHOS_COMM_TIME_MONITOR(
"ireceive<int, std::complex<double> >");
984 return ireceiveImpl<std::complex<double> > (recvBuffer, sourceRank, tag, comm);
989 send<int, std::complex<double> > (
const Comm<int>& comm,
991 const std::complex<double> sendBuffer[],
994 sendImpl<std::complex<double> > (comm, count, sendBuffer, destRank);
999 send<int, std::complex<double> > (
const std::complex<double> sendBuffer[],
1003 const Comm<int>& comm)
1005 sendImpl<std::complex<double> > (sendBuffer, count, destRank, tag, comm);
1009 RCP<Teuchos::CommRequest<int> >
1010 isend (
const ArrayRCP<
const std::complex<double> >& sendBuffer,
1013 const Comm<int>& comm)
1015 return isendImpl<std::complex<double> > (sendBuffer, destRank, tag, comm);
1021 reduceAll<int, std::complex<float> > (
const Comm<int>& comm,
1022 const EReductionType reductType,
1024 const std::complex<float> sendBuffer[],
1025 std::complex<float> globalReducts[])
1027 TEUCHOS_COMM_TIME_MONITOR(
1028 "Teuchos::reduceAll<int, std::complex<float> > (" << count <<
", " 1029 << toString (reductType) <<
")" 1031 reduceAllImpl<std::complex<float> > (comm, reductType, count, sendBuffer, globalReducts);
1035 RCP<Teuchos::CommRequest<int> >
1036 ireceive<int, std::complex<float> > (
const Comm<int>& comm,
1037 const ArrayRCP<std::complex<float> >& recvBuffer,
1038 const int sourceRank)
1040 TEUCHOS_COMM_TIME_MONITOR(
"ireceive<int, std::complex<float> >");
1041 return ireceiveImpl<std::complex<float> > (comm, recvBuffer, sourceRank);
1045 RCP<Teuchos::CommRequest<int> >
1046 ireceive<int, std::complex<float> > (
const ArrayRCP<std::complex<float> >& recvBuffer,
1047 const int sourceRank,
1049 const Comm<int>& comm)
1051 TEUCHOS_COMM_TIME_MONITOR(
"ireceive<int, std::complex<float> >");
1052 return ireceiveImpl<std::complex<float> > (recvBuffer, sourceRank, tag, comm);
1057 send<int, std::complex<float> > (
const Comm<int>& comm,
1059 const std::complex<float> sendBuffer[],
1062 return sendImpl<std::complex<float> > (comm, count, sendBuffer, destRank);
1067 send<int, std::complex<float> > (
const std::complex<float> sendBuffer[],
1071 const Comm<int>& comm)
1073 return sendImpl<std::complex<float> > (sendBuffer, count, destRank, tag, comm);
1077 RCP<Teuchos::CommRequest<int> >
1078 isend (
const ArrayRCP<
const std::complex<float> >& sendBuffer,
1081 const Comm<int>& comm)
1083 return isendImpl<std::complex<float> > (sendBuffer, destRank, tag, comm);
1085 #endif // HAVE_TEUCHOS_COMPLEX 1092 reduceAll<int, double> (
const Comm<int>& comm,
1093 const EReductionType reductType,
1095 const double sendBuffer[],
1096 double globalReducts[])
1098 TEUCHOS_COMM_TIME_MONITOR(
1099 "Teuchos::reduceAll<int, double> (" << count <<
", " 1100 << toString (reductType) <<
")" 1102 reduceAllImpl<double> (comm, reductType, count, sendBuffer, globalReducts);
1106 RCP<Teuchos::CommRequest<int> >
1107 ireceive<int, double> (
const Comm<int>& comm,
1108 const ArrayRCP<double>& recvBuffer,
1109 const int sourceRank)
1111 TEUCHOS_COMM_TIME_MONITOR(
"ireceive<int, double>");
1112 return ireceiveImpl<double> (comm, recvBuffer, sourceRank);
1116 RCP<Teuchos::CommRequest<int> >
1117 ireceive<int, double> (
const ArrayRCP<double>& recvBuffer,
1118 const int sourceRank,
1120 const Comm<int>& comm)
1122 TEUCHOS_COMM_TIME_MONITOR(
"ireceive<int, double>");
1123 return ireceiveImpl<double> (recvBuffer, sourceRank, tag, comm);
1128 send<int, double> (
const Comm<int>& comm,
1130 const double sendBuffer[],
1133 return sendImpl<double> (comm, count, sendBuffer, destRank);
1138 send<int, double> (
const double sendBuffer[],
1142 const Comm<int>& comm)
1144 return sendImpl<double> (sendBuffer, count, destRank, tag, comm);
1148 RCP<Teuchos::CommRequest<int> >
1149 isend (
const ArrayRCP<const double>& sendBuffer,
1152 const Comm<int>& comm)
1154 return isendImpl<double> (sendBuffer, destRank, tag, comm);
1160 reduceAll<int, float> (
const Comm<int>& comm,
1161 const EReductionType reductType,
1163 const float sendBuffer[],
1164 float globalReducts[])
1166 TEUCHOS_COMM_TIME_MONITOR(
1167 "Teuchos::reduceAll<int, float> (" << count <<
", " 1168 << toString (reductType) <<
")" 1170 reduceAllImpl<float> (comm, reductType, count, sendBuffer, globalReducts);
1174 RCP<Teuchos::CommRequest<int> >
1175 ireceive<int, float> (
const Comm<int>& comm,
1176 const ArrayRCP<float>& recvBuffer,
1177 const int sourceRank)
1179 TEUCHOS_COMM_TIME_MONITOR(
"ireceive<int, float>");
1180 return ireceiveImpl<float> (comm, recvBuffer, sourceRank);
1184 RCP<Teuchos::CommRequest<int> >
1185 ireceive<int, float> (
const ArrayRCP<float>& recvBuffer,
1186 const int sourceRank,
1188 const Comm<int>& comm)
1190 TEUCHOS_COMM_TIME_MONITOR(
"ireceive<int, float>");
1191 return ireceiveImpl<float> (recvBuffer, sourceRank, tag, comm);
1196 send<int, float> (
const Comm<int>& comm,
1198 const float sendBuffer[],
1201 return sendImpl<float> (comm, count, sendBuffer, destRank);
1206 send<int, float> (
const float sendBuffer[],
1210 const Comm<int>& comm)
1212 return sendImpl<float> (sendBuffer, count, destRank, tag, comm);
1216 RCP<Teuchos::CommRequest<int> >
1217 isend (
const ArrayRCP<const float>& sendBuffer,
1220 const Comm<int>& comm)
1222 return isendImpl<float> (sendBuffer, destRank, tag, comm);
1226 #ifdef HAVE_TEUCHOS_LONG_LONG_INT 1230 gather<int, long long> (
const long long sendBuf[],
1231 const int sendCount,
1232 long long recvBuf[],
1233 const int recvCount,
1235 const Comm<int>& comm)
1237 gatherImpl<long long> (sendBuf, sendCount, recvBuf, recvCount, root, comm);
1242 gatherv<int, long long> (
const long long sendBuf[],
1243 const int sendCount,
1244 long long recvBuf[],
1245 const int recvCounts[],
1248 const Comm<int>& comm)
1250 gathervImpl<long long> (sendBuf, sendCount, recvBuf, recvCounts, displs, root, comm);
1255 reduceAll<int, long long> (
const Comm<int>& comm,
1256 const EReductionType reductType,
1258 const long long sendBuffer[],
1259 long long globalReducts[])
1261 TEUCHOS_COMM_TIME_MONITOR(
1262 "Teuchos::reduceAll<int, long long> (" << count <<
", " 1263 << toString (reductType) <<
")" 1265 reduceAllImpl<long long> (comm, reductType, count, sendBuffer, globalReducts);
1269 RCP<Teuchos::CommRequest<int> >
1270 ireceive<int, long long> (
const Comm<int>& comm,
1271 const ArrayRCP<long long>& recvBuffer,
1272 const int sourceRank)
1274 TEUCHOS_COMM_TIME_MONITOR(
"ireceive<int, long long>");
1275 return ireceiveImpl<long long> (comm, recvBuffer, sourceRank);
1279 RCP<Teuchos::CommRequest<int> >
1280 ireceive<int, long long> (
const ArrayRCP<long long>& recvBuffer,
1281 const int sourceRank,
1283 const Comm<int>& comm)
1285 TEUCHOS_COMM_TIME_MONITOR(
"ireceive<int, long long>");
1286 return ireceiveImpl<long long> (recvBuffer, sourceRank, tag, comm);
1291 send<int, long long> (
const Comm<int>& comm,
1293 const long long sendBuffer[],
1296 return sendImpl<long long> (comm, count, sendBuffer, destRank);
1301 send<int, long long> (
const long long sendBuffer[],
1305 const Comm<int>& comm)
1307 return sendImpl<long long> (sendBuffer, count, destRank, tag, comm);
1311 RCP<Teuchos::CommRequest<int> >
1312 isend (
const ArrayRCP<const long long>& sendBuffer,
1315 const Comm<int>& comm)
1317 return isendImpl<long long> (sendBuffer, destRank, tag, comm);
1323 gather<int, unsigned long long> (
const unsigned long long sendBuf[],
1324 const int sendCount,
1325 unsigned long long recvBuf[],
1326 const int recvCount,
1328 const Comm<int>& comm)
1330 gatherImpl<unsigned long long> (sendBuf, sendCount, recvBuf, recvCount, root, comm);
1335 gatherv<int, unsigned long long> (
const unsigned long long sendBuf[],
1336 const int sendCount,
1337 unsigned long long recvBuf[],
1338 const int recvCounts[],
1341 const Comm<int>& comm)
1343 gathervImpl<unsigned long long> (sendBuf, sendCount, recvBuf, recvCounts, displs, root, comm);
1348 reduceAll<int, unsigned long long> (
const Comm<int>& comm,
1349 const EReductionType reductType,
1351 const unsigned long long sendBuffer[],
1352 unsigned long long globalReducts[])
1354 TEUCHOS_COMM_TIME_MONITOR(
1355 "Teuchos::reduceAll<int, unsigned long long> (" << count <<
", " 1356 << toString (reductType) <<
")" 1358 reduceAllImpl<unsigned long long> (comm, reductType, count, sendBuffer, globalReducts);
1362 RCP<Teuchos::CommRequest<int> >
1363 ireceive<int, unsigned long long> (
const Comm<int>& comm,
1364 const ArrayRCP<unsigned long long>& recvBuffer,
1365 const int sourceRank)
1367 TEUCHOS_COMM_TIME_MONITOR(
"ireceive<int, unsigned long long>");
1368 return ireceiveImpl<unsigned long long> (comm, recvBuffer, sourceRank);
1372 RCP<Teuchos::CommRequest<int> >
1373 ireceive<int, unsigned long long> (
const ArrayRCP<unsigned long long>& recvBuffer,
1374 const int sourceRank,
1376 const Comm<int>& comm)
1378 TEUCHOS_COMM_TIME_MONITOR(
"ireceive<int, unsigned long long>");
1379 return ireceiveImpl<unsigned long long> (recvBuffer, sourceRank, tag, comm);
1384 send<int, unsigned long long> (
const Comm<int>& comm,
1386 const unsigned long long sendBuffer[],
1389 return sendImpl<unsigned long long> (comm, count, sendBuffer, destRank);
1394 send<int, unsigned long long> (
const unsigned long long sendBuffer[],
1398 const Comm<int>& comm)
1400 return sendImpl<unsigned long long> (sendBuffer, count, destRank, tag, comm);
1404 RCP<Teuchos::CommRequest<int> >
1405 isend (
const ArrayRCP<const unsigned long long>& sendBuffer,
1408 const Comm<int>& comm)
1410 return isendImpl<unsigned long long> (sendBuffer, destRank, tag, comm);
1413 #endif // HAVE_TEUCHOS_LONG_LONG_INT 1419 gather<int, long> (
const long sendBuf[],
1420 const int sendCount,
1422 const int recvCount,
1424 const Comm<int>& comm)
1426 gatherImpl<long> (sendBuf, sendCount, recvBuf, recvCount, root, comm);
1431 gatherv<int, long> (
const long sendBuf[],
1432 const int sendCount,
1434 const int recvCounts[],
1437 const Comm<int>& comm)
1439 gathervImpl<long> (sendBuf, sendCount, recvBuf, recvCounts, displs, root, comm);
1444 reduceAll<int, long> (
const Comm<int>& comm,
1445 const EReductionType reductType,
1447 const long sendBuffer[],
1448 long globalReducts[])
1450 TEUCHOS_COMM_TIME_MONITOR(
1451 "Teuchos::reduceAll<int, long> (" << count <<
", " 1452 << toString (reductType) <<
")" 1454 reduceAllImpl<long> (comm, reductType, count, sendBuffer, globalReducts);
1458 RCP<Teuchos::CommRequest<int> >
1459 ireceive<int, long> (
const Comm<int>& comm,
1460 const ArrayRCP<long>& recvBuffer,
1461 const int sourceRank)
1463 TEUCHOS_COMM_TIME_MONITOR(
"ireceive<int, long>");
1464 return ireceiveImpl<long> (comm, recvBuffer, sourceRank);
1468 RCP<Teuchos::CommRequest<int> >
1469 ireceive<int, long> (
const ArrayRCP<long>& recvBuffer,
1470 const int sourceRank,
1472 const Comm<int>& comm)
1474 TEUCHOS_COMM_TIME_MONITOR(
"ireceive<int, long>");
1475 return ireceiveImpl<long> (recvBuffer, sourceRank, tag, comm);
1480 send<int, long> (
const Comm<int>& comm,
1482 const long sendBuffer[],
1485 return sendImpl<long> (comm, count, sendBuffer, destRank);
1490 send<int, long> (
const long sendBuffer[],
1494 const Comm<int>& comm)
1496 return sendImpl<long> (sendBuffer, count, destRank, tag, comm);
1500 RCP<Teuchos::CommRequest<int> >
1501 isend (
const ArrayRCP<const long>& sendBuffer,
1504 const Comm<int>& comm)
1506 return isendImpl<long> (sendBuffer, destRank, tag, comm);
1513 gather<int, unsigned long> (
const unsigned long sendBuf[],
1514 const int sendCount,
1515 unsigned long recvBuf[],
1516 const int recvCount,
1518 const Comm<int>& comm)
1520 gatherImpl<unsigned long> (sendBuf, sendCount, recvBuf, recvCount, root, comm);
1525 gatherv<int, unsigned long> (
const unsigned long sendBuf[],
1526 const int sendCount,
1527 unsigned long recvBuf[],
1528 const int recvCounts[],
1531 const Comm<int>& comm)
1533 gathervImpl<unsigned long> (sendBuf, sendCount, recvBuf, recvCounts, displs, root, comm);
1538 reduceAll<int, unsigned long> (
const Comm<int>& comm,
1539 const EReductionType reductType,
1541 const unsigned long sendBuffer[],
1542 unsigned long globalReducts[])
1544 TEUCHOS_COMM_TIME_MONITOR(
1545 "Teuchos::reduceAll<int, unsigned long> (" << count <<
", " 1546 << toString (reductType) <<
")" 1548 reduceAllImpl<unsigned long> (comm, reductType, count, sendBuffer, globalReducts);
1552 RCP<Teuchos::CommRequest<int> >
1553 ireceive<int, unsigned long> (
const Comm<int>& comm,
1554 const ArrayRCP<unsigned long>& recvBuffer,
1555 const int sourceRank)
1557 TEUCHOS_COMM_TIME_MONITOR(
"ireceive<int, unsigned long>");
1558 return ireceiveImpl<unsigned long> (comm, recvBuffer, sourceRank);
1562 RCP<Teuchos::CommRequest<int> >
1563 ireceive<int, unsigned long> (
const ArrayRCP<unsigned long>& recvBuffer,
1564 const int sourceRank,
1566 const Comm<int>& comm)
1568 TEUCHOS_COMM_TIME_MONITOR(
"ireceive<int, unsigned long>");
1569 return ireceiveImpl<unsigned long> (recvBuffer, sourceRank, tag, comm);
1574 send<int, unsigned long> (
const Comm<int>& comm,
1576 const unsigned long sendBuffer[],
1579 return sendImpl<unsigned long> (comm, count, sendBuffer, destRank);
1584 send<int, unsigned long> (
const unsigned long sendBuffer[],
1588 const Comm<int>& comm)
1590 return sendImpl<unsigned long> (sendBuffer, count, destRank, tag, comm);
1594 RCP<Teuchos::CommRequest<int> >
1595 isend (
const ArrayRCP<const unsigned long>& sendBuffer,
1598 const Comm<int>& comm)
1600 return isendImpl<unsigned long> (sendBuffer, destRank, tag, comm);
1606 gather<int, int> (
const int sendBuf[],
1607 const int sendCount,
1609 const int recvCount,
1611 const Comm<int>& comm)
1613 gatherImpl<int> (sendBuf, sendCount, recvBuf, recvCount, root, comm);
1618 gatherv<int, int> (
const int sendBuf[],
1619 const int sendCount,
1621 const int recvCounts[],
1624 const Comm<int>& comm)
1626 gathervImpl<int> (sendBuf, sendCount, recvBuf, recvCounts, displs, root, comm);
1631 scatter<int, int> (
const int sendBuf[],
1632 const int sendCount,
1634 const int recvCount,
1636 const Comm<int>& comm)
1638 scatterImpl<int> (sendBuf, sendCount, recvBuf, recvCount, root, comm);
1643 reduce<int, int> (
const int sendBuf[],
1646 const EReductionType reductType,
1648 const Comm<int>& comm)
1650 TEUCHOS_COMM_TIME_MONITOR
1651 (
"Teuchos::reduce<int, int> (" << count <<
", " << toString (reductType)
1653 reduceImpl<int> (sendBuf, recvBuf, count, reductType, root, comm);
1658 reduceAll<int, int> (
const Comm<int>& comm,
1659 const EReductionType reductType,
1661 const int sendBuffer[],
1662 int globalReducts[])
1664 TEUCHOS_COMM_TIME_MONITOR(
1665 "Teuchos::reduceAll<int, int> (" << count <<
", " 1666 << toString (reductType) <<
")" 1668 reduceAllImpl<int> (comm, reductType, count, sendBuffer, globalReducts);
1672 RCP<Teuchos::CommRequest<int> >
1673 ireceive<int, int> (
const Comm<int>& comm,
1674 const ArrayRCP<int>& recvBuffer,
1675 const int sourceRank)
1677 TEUCHOS_COMM_TIME_MONITOR(
"ireceive<int, int>");
1678 return ireceiveImpl<int> (comm, recvBuffer, sourceRank);
1682 RCP<Teuchos::CommRequest<int> >
1683 ireceive<int, int> (
const ArrayRCP<int>& recvBuffer,
1684 const int sourceRank,
1686 const Comm<int>& comm)
1688 TEUCHOS_COMM_TIME_MONITOR(
"ireceive<int, int>");
1689 return ireceiveImpl<int> (recvBuffer, sourceRank, tag, comm);
1694 send<int, int> (
const Comm<int>& comm,
1696 const int sendBuffer[],
1699 return sendImpl<int> (comm, count, sendBuffer, destRank);
1704 send<int, int> (
const int sendBuffer[],
1708 const Comm<int>& comm)
1710 return sendImpl<int> (sendBuffer, count, destRank, tag, comm);
1714 RCP<Teuchos::CommRequest<int> >
1715 isend (
const ArrayRCP<const int>& sendBuffer,
1718 const Comm<int>& comm)
1720 return isendImpl<int> (sendBuffer, destRank, tag, comm);
1726 gather<int, unsigned int> (
const unsigned int sendBuf[],
1727 const int sendCount,
1728 unsigned int recvBuf[],
1729 const int recvCount,
1731 const Comm<int>& comm)
1733 gatherImpl<unsigned int> (sendBuf, sendCount, recvBuf, recvCount, root, comm);
1738 gatherv<int, unsigned int> (
const unsigned int sendBuf[],
1739 const int sendCount,
1740 unsigned int recvBuf[],
1741 const int recvCounts[],
1744 const Comm<int>& comm)
1746 gathervImpl<unsigned int> (sendBuf, sendCount, recvBuf, recvCounts, displs, root, comm);
1751 reduceAll<int, unsigned int> (
const Comm<int>& comm,
1752 const EReductionType reductType,
1754 const unsigned int sendBuffer[],
1755 unsigned int globalReducts[])
1757 TEUCHOS_COMM_TIME_MONITOR(
1758 "Teuchos::reduceAll<int, unsigned int> (" << count <<
", " 1759 << toString (reductType) <<
")" 1761 reduceAllImpl<unsigned int> (comm, reductType, count, sendBuffer, globalReducts);
1765 RCP<Teuchos::CommRequest<int> >
1766 ireceive<int, unsigned int> (
const Comm<int>& comm,
1767 const ArrayRCP<unsigned int>& recvBuffer,
1768 const int sourceRank)
1770 TEUCHOS_COMM_TIME_MONITOR(
"ireceive<int, unsigned int>");
1771 return ireceiveImpl<unsigned int> (comm, recvBuffer, sourceRank);
1775 RCP<Teuchos::CommRequest<int> >
1776 ireceive<int, unsigned int> (
const ArrayRCP<unsigned int>& recvBuffer,
1777 const int sourceRank,
1779 const Comm<int>& comm)
1781 TEUCHOS_COMM_TIME_MONITOR(
"ireceive<int, unsigned int>");
1782 return ireceiveImpl<unsigned int> (recvBuffer, sourceRank, tag, comm);
1787 send<int, unsigned int> (
const Comm<int>& comm,
1789 const unsigned int sendBuffer[],
1792 return sendImpl<unsigned int> (comm, count, sendBuffer, destRank);
1797 send<int, unsigned int> (
const unsigned int sendBuffer[],
1801 const Comm<int>& comm)
1803 return sendImpl<unsigned int> (sendBuffer, count, destRank, tag, comm);
1807 RCP<Teuchos::CommRequest<int> >
1808 isend (
const ArrayRCP<const unsigned int>& sendBuffer,
1811 const Comm<int>& comm)
1813 return isendImpl<unsigned int> (sendBuffer, destRank, tag, comm);
1820 gather<int, short> (
const short sendBuf[],
1821 const int sendCount,
1823 const int recvCount,
1825 const Comm<int>& comm)
1827 gatherImpl<short> (sendBuf, sendCount, recvBuf, recvCount, root, comm);
1832 gatherv<int, short> (
const short sendBuf[],
1833 const int sendCount,
1835 const int recvCounts[],
1838 const Comm<int>& comm)
1840 gathervImpl<short> (sendBuf, sendCount, recvBuf, recvCounts, displs, root, comm);
1845 reduceAll<int, short> (
const Comm<int>& comm,
1846 const EReductionType reductType,
1848 const short sendBuffer[],
1849 short globalReducts[])
1851 TEUCHOS_COMM_TIME_MONITOR(
1852 "Teuchos::reduceAll<int, short> (" << count <<
", " 1853 << toString (reductType) <<
")" 1855 reduceAllImpl<short> (comm, reductType, count, sendBuffer, globalReducts);
1859 RCP<Teuchos::CommRequest<int> >
1860 ireceive<int, short> (
const Comm<int>& comm,
1861 const ArrayRCP<short>& recvBuffer,
1862 const int sourceRank)
1864 TEUCHOS_COMM_TIME_MONITOR(
"ireceive<int, short>");
1865 return ireceiveImpl<short> (comm, recvBuffer, sourceRank);
1869 RCP<Teuchos::CommRequest<int> >
1870 ireceive<int, short> (
const ArrayRCP<short>& recvBuffer,
1871 const int sourceRank,
1873 const Comm<int>& comm)
1875 TEUCHOS_COMM_TIME_MONITOR(
"ireceive<int, short>");
1876 return ireceiveImpl<short> (recvBuffer, sourceRank, tag, comm);
1881 send<int, short> (
const Comm<int>& comm,
1883 const short sendBuffer[],
1886 return sendImpl<short> (comm, count, sendBuffer, destRank);
1891 send<int, short> (
const short sendBuffer[],
1895 const Comm<int>& comm)
1897 return sendImpl<short> (sendBuffer, count, destRank, tag, comm);
1901 RCP<Teuchos::CommRequest<int> >
1902 isend (
const ArrayRCP<const short>& sendBuffer,
1905 const Comm<int>& comm)
1907 return isendImpl<short> (sendBuffer, destRank, tag, comm);
1922 reduceAll<int, char> (
const Comm<int>& comm,
1923 const EReductionType reductType,
1925 const char sendBuffer[],
1926 char globalReducts[])
1928 TEUCHOS_COMM_TIME_MONITOR(
1929 "Teuchos::reduceAll<int, char> (" << count <<
", " 1930 << toString (reductType) <<
")" 1932 reduceAllImpl<char> (comm, reductType, count, sendBuffer, globalReducts);
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
Macro for throwing an exception with breakpointing to ease debugging.
TEUCHOS_DEPRECATED void reduceAll(const Comm< Ordinal > &comm, const EReductionType reductType, const Packet &send, Packet *globalReduct)
Deprecated .
The Teuchos namespace contains all of the classes, structs and enums used by Teuchos, as well as a number of utility routines.
static std::string name()