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]);
499 reduceAllAndScatterImpl (
const Comm<int>& comm,
500 const EReductionType reductType,
502 const T sendBuffer[],
503 const int recvCounts[],
510 const MpiComm<int>* mpiComm =
dynamic_cast<const MpiComm<int>*
> (&comm);
511 if (mpiComm == NULL) {
513 const SerialComm<int>* serialComm =
dynamic_cast<const SerialComm<int>*
> (&comm);
514 if (serialComm == NULL) {
516 "Not implemented for Comm not MpiComm or SerialComm.");
523 std::copy (sendBuffer, sendBuffer + sendCount, myGlobalReducts);
526 MPI_Op rawMpiOp = getMpiOpForEReductionType (reductType);
527 MPI_Comm rawMpiComm = * (mpiComm->getRawMpiComm ());
529 MPI_Datatype rawMpiType = MpiTypeTraits<T>::getType (t);
530 const int err = MPI_Reduce_scatter (const_cast<T*> (sendBuffer),
532 const_cast<int*> (recvCounts),
539 "MPI_Reduce_scatter failed with the following error: " 540 << getMpiErrorString (err));
547 std::copy (sendBuffer, sendBuffer + sendCount, myGlobalReducts);
557 template<
typename Packet>
558 RCP<Teuchos::CommRequest<int> >
559 ireceiveGeneral(
const Comm<int>& comm,
560 const ArrayRCP<Packet> &recvBuffer,
561 const int sourceRank)
563 TEUCHOS_COMM_TIME_MONITOR(
565 <<
"> ( value type )" 567 ValueTypeSerializationBuffer<int, Packet>
568 charRecvBuffer (recvBuffer.size (), recvBuffer.getRawPtr ());
569 RCP<CommRequest<int> > commRequest =
570 comm.ireceive (charRecvBuffer.getCharBufferView (), sourceRank);
571 set_extra_data (recvBuffer,
"buffer", inOutArg (commRequest));
577 template<
typename Packet>
578 RCP<Teuchos::CommRequest<int> >
579 ireceiveGeneral (
const ArrayRCP<Packet> &recvBuffer,
580 const int sourceRank,
582 const Comm<int>& comm)
584 TEUCHOS_COMM_TIME_MONITOR(
586 <<
"> ( value type )" 588 ValueTypeSerializationBuffer<int, Packet>
589 charRecvBuffer (recvBuffer.size (), recvBuffer.getRawPtr ());
590 RCP<CommRequest<int> > commRequest =
591 comm.ireceive (charRecvBuffer.getCharBufferView (), sourceRank, tag);
592 set_extra_data (recvBuffer,
"buffer", inOutArg (commRequest));
609 RCP<CommRequest<int> >
610 ireceiveImpl (
const Comm<int>& comm,
611 const ArrayRCP<T>& recvBuffer,
612 const int sourceRank)
618 const MpiComm<int>* mpiComm =
dynamic_cast<const MpiComm<int>*
> (&comm);
619 if (mpiComm == NULL) {
621 const SerialComm<int>* serialComm =
dynamic_cast<const SerialComm<int>*
> (&comm);
622 if (serialComm == NULL) {
625 return ireceiveGeneral<T> (comm, recvBuffer, sourceRank);
631 "ireceiveImpl: Not implemented for a serial communicator.");
635 MPI_Comm rawComm = * (mpiComm->getRawMpiComm ());
637 MPI_Datatype rawType = MpiTypeTraits<T>::getType (t);
638 T* rawRecvBuf = recvBuffer.getRawPtr ();
639 const int count = as<int> (recvBuffer.size ());
640 const int tag = mpiComm->getTag ();
641 MPI_Request rawRequest = MPI_REQUEST_NULL;
642 const int err = MPI_Irecv (rawRecvBuf, count, rawType, sourceRank, tag,
643 rawComm, &rawRequest);
645 err != MPI_SUCCESS, std::runtime_error,
646 "MPI_Irecv failed with the following error: " 647 << getMpiErrorString (err));
649 ArrayRCP<const char> buf =
650 arcp_const_cast<
const char> (arcp_reinterpret_cast<
char> (recvBuffer));
651 RCP<Details::MpiCommRequest> req (
new Details::MpiCommRequest (rawRequest, buf));
652 return rcp_implicit_cast<CommRequest<int> > (req);
658 "ireceiveImpl: Not implemented for a serial communicator.");
675 RCP<CommRequest<int> >
676 ireceiveImpl (
const ArrayRCP<T>& recvBuffer,
677 const int sourceRank,
679 const Comm<int>& comm)
685 const MpiComm<int>* mpiComm =
dynamic_cast<const MpiComm<int>*
> (&comm);
686 if (mpiComm == NULL) {
688 const SerialComm<int>* serialComm =
dynamic_cast<const SerialComm<int>*
> (&comm);
689 if (serialComm == NULL) {
692 return ireceiveGeneral<T> (recvBuffer, sourceRank, tag, comm);
698 "ireceiveImpl: Not implemented for a serial communicator.");
702 MPI_Comm rawComm = * (mpiComm->getRawMpiComm ());
704 MPI_Datatype rawType = MpiTypeTraits<T>::getType (t);
705 T* rawRecvBuf = recvBuffer.getRawPtr ();
706 const int count = as<int> (recvBuffer.size ());
707 MPI_Request rawRequest = MPI_REQUEST_NULL;
708 const int err = MPI_Irecv (rawRecvBuf, count, rawType, sourceRank, tag,
709 rawComm, &rawRequest);
711 err != MPI_SUCCESS, std::runtime_error,
712 "MPI_Irecv failed with the following error: " 713 << getMpiErrorString (err));
715 ArrayRCP<const char> buf =
716 arcp_const_cast<
const char> (arcp_reinterpret_cast<
char> (recvBuffer));
717 RCP<Details::MpiCommRequest> req (
new Details::MpiCommRequest (rawRequest, buf));
718 return rcp_implicit_cast<CommRequest<int> > (req);
724 "ireceiveImpl: Not implemented for a serial communicator.");
737 sendGeneral (
const Comm<int>& comm,
739 const T sendBuffer[],
742 TEUCHOS_COMM_TIME_MONITOR(
744 ConstValueTypeSerializationBuffer<int,T> charSendBuffer (count, sendBuffer);
745 comm.send (charSendBuffer.getBytes (),
746 charSendBuffer.getCharBuffer (),
754 sendGeneral (
const T sendBuffer[],
758 const Comm<int>& comm)
760 TEUCHOS_COMM_TIME_MONITOR(
762 ConstValueTypeSerializationBuffer<int,T> charSendBuffer (count, sendBuffer);
763 comm.send (charSendBuffer.getBytes (),
764 charSendBuffer.getCharBuffer (),
782 sendImpl (
const Comm<int>& comm,
784 const T sendBuffer[],
791 const MpiComm<int>* mpiComm =
dynamic_cast<const MpiComm<int>*
> (&comm);
792 if (mpiComm == NULL) {
794 const SerialComm<int>* serialComm =
dynamic_cast<const SerialComm<int>*
> (&comm);
795 if (serialComm == NULL) {
798 sendGeneral<T> (comm, count, sendBuffer, destRank);
804 "sendImpl: Not implemented for a serial communicator.");
808 MPI_Comm rawComm = * (mpiComm->getRawMpiComm ());
810 MPI_Datatype rawType = MpiTypeTraits<T>::getType (t);
811 T* rawBuf =
const_cast<T*
> (sendBuffer);
812 const int tag = mpiComm->getTag ();
813 const int err = MPI_Send (rawBuf, count, rawType, destRank, tag, rawComm);
817 "MPI_Send failed with the following error: " 818 << getMpiErrorString (err));
824 "sendImpl: Not implemented for a serial communicator.");
832 sendImpl (
const T sendBuffer[],
836 const Comm<int>& comm)
842 const MpiComm<int>* mpiComm =
dynamic_cast<const MpiComm<int>*
> (&comm);
843 if (mpiComm == NULL) {
845 const SerialComm<int>* serialComm =
dynamic_cast<const SerialComm<int>*
> (&comm);
846 if (serialComm == NULL) {
849 sendGeneral<T> (sendBuffer, count, destRank, tag, comm);
855 "sendImpl: Not implemented for a serial communicator.");
859 MPI_Comm rawComm = * (mpiComm->getRawMpiComm ());
861 MPI_Datatype rawType = MpiTypeTraits<T>::getType (t);
862 T* rawBuf =
const_cast<T*
> (sendBuffer);
863 const int err = MPI_Send (rawBuf, count, rawType, destRank, tag, rawComm);
867 "MPI_Send failed with the following error: " 868 << getMpiErrorString (err));
874 "sendImpl: Not implemented for a serial communicator.");
884 RCP<CommRequest<int> >
885 isendGeneral (
const Comm<int>& comm,
886 const ArrayRCP<const T>& sendBuffer,
889 TEUCHOS_COMM_TIME_MONITOR(
891 ConstValueTypeSerializationBuffer<int, T>
892 charSendBuffer (sendBuffer.size (), sendBuffer.getRawPtr ());
893 RCP<CommRequest<int> > commRequest =
894 comm.isend (charSendBuffer.getCharBufferView (), destRank);
895 set_extra_data (sendBuffer,
"buffer", inOutArg (commRequest));
906 RCP<CommRequest<int> >
907 isendGeneral (
const ArrayRCP<const T>& sendBuffer,
910 const Comm<int>& comm)
912 TEUCHOS_COMM_TIME_MONITOR(
914 ConstValueTypeSerializationBuffer<int, T>
915 charSendBuffer (sendBuffer.size (), sendBuffer.getRawPtr ());
916 RCP<CommRequest<int> > commRequest =
917 comm.isend (charSendBuffer.getCharBufferView (), destRank, tag);
918 set_extra_data (sendBuffer,
"buffer", inOutArg (commRequest));
925 RCP<Teuchos::CommRequest<int> >
926 isendImpl (
const ArrayRCP<const T>& sendBuffer,
929 const Comm<int>& comm)
935 const MpiComm<int>* mpiComm =
dynamic_cast<const MpiComm<int>*
> (&comm);
936 if (mpiComm == NULL) {
938 const SerialComm<int>* serialComm =
dynamic_cast<const SerialComm<int>*
> (&comm);
939 if (serialComm == NULL) {
942 return isendGeneral<T> (sendBuffer, destRank, tag, comm);
946 true, std::logic_error,
947 "isendImpl: Not implemented for a serial communicator.");
951 MPI_Comm rawComm = * (mpiComm->getRawMpiComm ());
953 MPI_Datatype rawType = MpiTypeTraits<T>::getType (t);
957 T* rawSendBuf =
const_cast<T*
> (sendBuffer.getRawPtr ());
958 const int count = as<int> (sendBuffer.size ());
959 MPI_Request rawRequest = MPI_REQUEST_NULL;
960 const int err = MPI_Isend (rawSendBuf, count, rawType, destRank, tag,
961 rawComm, &rawRequest);
965 "MPI_Isend failed with the following error: " 966 << getMpiErrorString (err));
968 ArrayRCP<const char> buf = arcp_reinterpret_cast<
const char> (sendBuffer);
969 RCP<Details::MpiCommRequest> req (
new Details::MpiCommRequest (rawRequest, buf));
970 return rcp_implicit_cast<CommRequest<int> > (req);
976 "isendImpl: Not implemented for a serial communicator.");
984 toString (
const EReductionType reductType)
986 switch (reductType) {
993 true, std::invalid_argument,
"Teuchos::toString(EReductionType): " 994 "Invalid EReductionType value " << reductType <<
". Valid values " 1012 #ifdef HAVE_TEUCHOS_COMPLEX 1016 reduceAll<int, std::complex<double> > (
const Comm<int>& comm,
1017 const EReductionType reductType,
1019 const std::complex<double> sendBuffer[],
1020 std::complex<double> globalReducts[])
1022 TEUCHOS_COMM_TIME_MONITOR(
1023 "Teuchos::reduceAll<int, std::complex<double> > (" << count <<
", " 1024 << toString (reductType) <<
")" 1026 reduceAllImpl<std::complex<double> > (comm, reductType, count, sendBuffer, globalReducts);
1030 RCP<Teuchos::CommRequest<int> >
1031 ireceive<int, std::complex<double> > (
const Comm<int>& comm,
1032 const ArrayRCP<std::complex<double> >& recvBuffer,
1033 const int sourceRank)
1035 TEUCHOS_COMM_TIME_MONITOR(
"ireceive<int, std::complex<double> >");
1036 return ireceiveImpl<std::complex<double> > (comm, recvBuffer, sourceRank);
1040 RCP<Teuchos::CommRequest<int> >
1041 ireceive<int, std::complex<double> > (
const ArrayRCP<std::complex<double> >& recvBuffer,
1042 const int sourceRank,
1044 const Comm<int>& comm)
1046 TEUCHOS_COMM_TIME_MONITOR(
"ireceive<int, std::complex<double> >");
1047 return ireceiveImpl<std::complex<double> > (recvBuffer, sourceRank, tag, comm);
1052 send<int, std::complex<double> > (
const Comm<int>& comm,
1054 const std::complex<double> sendBuffer[],
1057 sendImpl<std::complex<double> > (comm, count, sendBuffer, destRank);
1062 send<int, std::complex<double> > (
const std::complex<double> sendBuffer[],
1066 const Comm<int>& comm)
1068 sendImpl<std::complex<double> > (sendBuffer, count, destRank, tag, comm);
1072 RCP<Teuchos::CommRequest<int> >
1073 isend (
const ArrayRCP<
const std::complex<double> >& sendBuffer,
1076 const Comm<int>& comm)
1078 return isendImpl<std::complex<double> > (sendBuffer, destRank, tag, comm);
1084 reduceAll<int, std::complex<float> > (
const Comm<int>& comm,
1085 const EReductionType reductType,
1087 const std::complex<float> sendBuffer[],
1088 std::complex<float> globalReducts[])
1090 TEUCHOS_COMM_TIME_MONITOR(
1091 "Teuchos::reduceAll<int, std::complex<float> > (" << count <<
", " 1092 << toString (reductType) <<
")" 1094 reduceAllImpl<std::complex<float> > (comm, reductType, count, sendBuffer, globalReducts);
1098 RCP<Teuchos::CommRequest<int> >
1099 ireceive<int, std::complex<float> > (
const Comm<int>& comm,
1100 const ArrayRCP<std::complex<float> >& recvBuffer,
1101 const int sourceRank)
1103 TEUCHOS_COMM_TIME_MONITOR(
"ireceive<int, std::complex<float> >");
1104 return ireceiveImpl<std::complex<float> > (comm, recvBuffer, sourceRank);
1108 RCP<Teuchos::CommRequest<int> >
1109 ireceive<int, std::complex<float> > (
const ArrayRCP<std::complex<float> >& recvBuffer,
1110 const int sourceRank,
1112 const Comm<int>& comm)
1114 TEUCHOS_COMM_TIME_MONITOR(
"ireceive<int, std::complex<float> >");
1115 return ireceiveImpl<std::complex<float> > (recvBuffer, sourceRank, tag, comm);
1120 send<int, std::complex<float> > (
const Comm<int>& comm,
1122 const std::complex<float> sendBuffer[],
1125 return sendImpl<std::complex<float> > (comm, count, sendBuffer, destRank);
1130 send<int, std::complex<float> > (
const std::complex<float> sendBuffer[],
1134 const Comm<int>& comm)
1136 return sendImpl<std::complex<float> > (sendBuffer, count, destRank, tag, comm);
1140 RCP<Teuchos::CommRequest<int> >
1141 isend (
const ArrayRCP<
const std::complex<float> >& sendBuffer,
1144 const Comm<int>& comm)
1146 return isendImpl<std::complex<float> > (sendBuffer, destRank, tag, comm);
1148 #endif // HAVE_TEUCHOS_COMPLEX 1155 reduceAll<int, double> (
const Comm<int>& comm,
1156 const EReductionType reductType,
1158 const double sendBuffer[],
1159 double globalReducts[])
1161 TEUCHOS_COMM_TIME_MONITOR(
1162 "Teuchos::reduceAll<int, double> (" << count <<
", " 1163 << toString (reductType) <<
")" 1165 reduceAllImpl<double> (comm, reductType, count, sendBuffer, globalReducts);
1169 RCP<Teuchos::CommRequest<int> >
1170 ireceive<int, double> (
const Comm<int>& comm,
1171 const ArrayRCP<double>& recvBuffer,
1172 const int sourceRank)
1174 TEUCHOS_COMM_TIME_MONITOR(
"ireceive<int, double>");
1175 return ireceiveImpl<double> (comm, recvBuffer, sourceRank);
1179 RCP<Teuchos::CommRequest<int> >
1180 ireceive<int, double> (
const ArrayRCP<double>& recvBuffer,
1181 const int sourceRank,
1183 const Comm<int>& comm)
1185 TEUCHOS_COMM_TIME_MONITOR(
"ireceive<int, double>");
1186 return ireceiveImpl<double> (recvBuffer, sourceRank, tag, comm);
1191 send<int, double> (
const Comm<int>& comm,
1193 const double sendBuffer[],
1196 return sendImpl<double> (comm, count, sendBuffer, destRank);
1201 send<int, double> (
const double sendBuffer[],
1205 const Comm<int>& comm)
1207 return sendImpl<double> (sendBuffer, count, destRank, tag, comm);
1211 RCP<Teuchos::CommRequest<int> >
1212 isend (
const ArrayRCP<const double>& sendBuffer,
1215 const Comm<int>& comm)
1217 return isendImpl<double> (sendBuffer, destRank, tag, comm);
1223 reduceAll<int, float> (
const Comm<int>& comm,
1224 const EReductionType reductType,
1226 const float sendBuffer[],
1227 float globalReducts[])
1229 TEUCHOS_COMM_TIME_MONITOR(
1230 "Teuchos::reduceAll<int, float> (" << count <<
", " 1231 << toString (reductType) <<
")" 1233 reduceAllImpl<float> (comm, reductType, count, sendBuffer, globalReducts);
1237 RCP<Teuchos::CommRequest<int> >
1238 ireceive<int, float> (
const Comm<int>& comm,
1239 const ArrayRCP<float>& recvBuffer,
1240 const int sourceRank)
1242 TEUCHOS_COMM_TIME_MONITOR(
"ireceive<int, float>");
1243 return ireceiveImpl<float> (comm, recvBuffer, sourceRank);
1247 RCP<Teuchos::CommRequest<int> >
1248 ireceive<int, float> (
const ArrayRCP<float>& recvBuffer,
1249 const int sourceRank,
1251 const Comm<int>& comm)
1253 TEUCHOS_COMM_TIME_MONITOR(
"ireceive<int, float>");
1254 return ireceiveImpl<float> (recvBuffer, sourceRank, tag, comm);
1259 send<int, float> (
const Comm<int>& comm,
1261 const float sendBuffer[],
1264 return sendImpl<float> (comm, count, sendBuffer, destRank);
1269 send<int, float> (
const float sendBuffer[],
1273 const Comm<int>& comm)
1275 return sendImpl<float> (sendBuffer, count, destRank, tag, comm);
1279 RCP<Teuchos::CommRequest<int> >
1280 isend (
const ArrayRCP<const float>& sendBuffer,
1283 const Comm<int>& comm)
1285 return isendImpl<float> (sendBuffer, destRank, tag, comm);
1289 #ifdef HAVE_TEUCHOS_LONG_LONG_INT 1293 gather<int, long long> (
const long long sendBuf[],
1294 const int sendCount,
1295 long long recvBuf[],
1296 const int recvCount,
1298 const Comm<int>& comm)
1300 gatherImpl<long long> (sendBuf, sendCount, recvBuf, recvCount, root, comm);
1305 gatherv<int, long long> (
const long long sendBuf[],
1306 const int sendCount,
1307 long long recvBuf[],
1308 const int recvCounts[],
1311 const Comm<int>& comm)
1313 gathervImpl<long long> (sendBuf, sendCount, recvBuf, recvCounts, displs, root, comm);
1318 reduceAll<int, long long> (
const Comm<int>& comm,
1319 const EReductionType reductType,
1321 const long long sendBuffer[],
1322 long long globalReducts[])
1324 TEUCHOS_COMM_TIME_MONITOR(
1325 "Teuchos::reduceAll<int, long long> (" << count <<
", " 1326 << toString (reductType) <<
")" 1328 reduceAllImpl<long long> (comm, reductType, count, sendBuffer, globalReducts);
1332 RCP<Teuchos::CommRequest<int> >
1333 ireceive<int, long long> (
const Comm<int>& comm,
1334 const ArrayRCP<long long>& recvBuffer,
1335 const int sourceRank)
1337 TEUCHOS_COMM_TIME_MONITOR(
"ireceive<int, long long>");
1338 return ireceiveImpl<long long> (comm, recvBuffer, sourceRank);
1342 RCP<Teuchos::CommRequest<int> >
1343 ireceive<int, long long> (
const ArrayRCP<long long>& recvBuffer,
1344 const int sourceRank,
1346 const Comm<int>& comm)
1348 TEUCHOS_COMM_TIME_MONITOR(
"ireceive<int, long long>");
1349 return ireceiveImpl<long long> (recvBuffer, sourceRank, tag, comm);
1354 send<int, long long> (
const Comm<int>& comm,
1356 const long long sendBuffer[],
1359 return sendImpl<long long> (comm, count, sendBuffer, destRank);
1364 send<int, long long> (
const long long sendBuffer[],
1368 const Comm<int>& comm)
1370 return sendImpl<long long> (sendBuffer, count, destRank, tag, comm);
1374 RCP<Teuchos::CommRequest<int> >
1375 isend (
const ArrayRCP<const long long>& sendBuffer,
1378 const Comm<int>& comm)
1380 return isendImpl<long long> (sendBuffer, destRank, tag, comm);
1386 gather<int, unsigned long long> (
const unsigned long long sendBuf[],
1387 const int sendCount,
1388 unsigned long long recvBuf[],
1389 const int recvCount,
1391 const Comm<int>& comm)
1393 gatherImpl<unsigned long long> (sendBuf, sendCount, recvBuf, recvCount, root, comm);
1398 gatherv<int, unsigned long long> (
const unsigned long long sendBuf[],
1399 const int sendCount,
1400 unsigned long long recvBuf[],
1401 const int recvCounts[],
1404 const Comm<int>& comm)
1406 gathervImpl<unsigned long long> (sendBuf, sendCount, recvBuf, recvCounts, displs, root, comm);
1411 reduceAll<int, unsigned long long> (
const Comm<int>& comm,
1412 const EReductionType reductType,
1414 const unsigned long long sendBuffer[],
1415 unsigned long long globalReducts[])
1417 TEUCHOS_COMM_TIME_MONITOR(
1418 "Teuchos::reduceAll<int, unsigned long long> (" << count <<
", " 1419 << toString (reductType) <<
")" 1421 reduceAllImpl<unsigned long long> (comm, reductType, count, sendBuffer, globalReducts);
1425 RCP<Teuchos::CommRequest<int> >
1426 ireceive<int, unsigned long long> (
const Comm<int>& comm,
1427 const ArrayRCP<unsigned long long>& recvBuffer,
1428 const int sourceRank)
1430 TEUCHOS_COMM_TIME_MONITOR(
"ireceive<int, unsigned long long>");
1431 return ireceiveImpl<unsigned long long> (comm, recvBuffer, sourceRank);
1435 RCP<Teuchos::CommRequest<int> >
1436 ireceive<int, unsigned long long> (
const ArrayRCP<unsigned long long>& recvBuffer,
1437 const int sourceRank,
1439 const Comm<int>& comm)
1441 TEUCHOS_COMM_TIME_MONITOR(
"ireceive<int, unsigned long long>");
1442 return ireceiveImpl<unsigned long long> (recvBuffer, sourceRank, tag, comm);
1447 send<int, unsigned long long> (
const Comm<int>& comm,
1449 const unsigned long long sendBuffer[],
1452 return sendImpl<unsigned long long> (comm, count, sendBuffer, destRank);
1457 send<int, unsigned long long> (
const unsigned long long sendBuffer[],
1461 const Comm<int>& comm)
1463 return sendImpl<unsigned long long> (sendBuffer, count, destRank, tag, comm);
1467 RCP<Teuchos::CommRequest<int> >
1468 isend (
const ArrayRCP<const unsigned long long>& sendBuffer,
1471 const Comm<int>& comm)
1473 return isendImpl<unsigned long long> (sendBuffer, destRank, tag, comm);
1476 #endif // HAVE_TEUCHOS_LONG_LONG_INT 1482 gather<int, long> (
const long sendBuf[],
1483 const int sendCount,
1485 const int recvCount,
1487 const Comm<int>& comm)
1489 gatherImpl<long> (sendBuf, sendCount, recvBuf, recvCount, root, comm);
1494 gatherv<int, long> (
const long sendBuf[],
1495 const int sendCount,
1497 const int recvCounts[],
1500 const Comm<int>& comm)
1502 gathervImpl<long> (sendBuf, sendCount, recvBuf, recvCounts, displs, root, comm);
1507 reduceAll<int, long> (
const Comm<int>& comm,
1508 const EReductionType reductType,
1510 const long sendBuffer[],
1511 long globalReducts[])
1513 TEUCHOS_COMM_TIME_MONITOR(
1514 "Teuchos::reduceAll<int, long> (" << count <<
", " 1515 << toString (reductType) <<
")" 1517 reduceAllImpl<long> (comm, reductType, count, sendBuffer, globalReducts);
1521 RCP<Teuchos::CommRequest<int> >
1522 ireceive<int, long> (
const Comm<int>& comm,
1523 const ArrayRCP<long>& recvBuffer,
1524 const int sourceRank)
1526 TEUCHOS_COMM_TIME_MONITOR(
"ireceive<int, long>");
1527 return ireceiveImpl<long> (comm, recvBuffer, sourceRank);
1531 RCP<Teuchos::CommRequest<int> >
1532 ireceive<int, long> (
const ArrayRCP<long>& recvBuffer,
1533 const int sourceRank,
1535 const Comm<int>& comm)
1537 TEUCHOS_COMM_TIME_MONITOR(
"ireceive<int, long>");
1538 return ireceiveImpl<long> (recvBuffer, sourceRank, tag, comm);
1543 send<int, long> (
const Comm<int>& comm,
1545 const long sendBuffer[],
1548 return sendImpl<long> (comm, count, sendBuffer, destRank);
1553 send<int, long> (
const long sendBuffer[],
1557 const Comm<int>& comm)
1559 return sendImpl<long> (sendBuffer, count, destRank, tag, comm);
1563 RCP<Teuchos::CommRequest<int> >
1564 isend (
const ArrayRCP<const long>& sendBuffer,
1567 const Comm<int>& comm)
1569 return isendImpl<long> (sendBuffer, destRank, tag, comm);
1576 gather<int, unsigned long> (
const unsigned long sendBuf[],
1577 const int sendCount,
1578 unsigned long recvBuf[],
1579 const int recvCount,
1581 const Comm<int>& comm)
1583 gatherImpl<unsigned long> (sendBuf, sendCount, recvBuf, recvCount, root, comm);
1588 gatherv<int, unsigned long> (
const unsigned long sendBuf[],
1589 const int sendCount,
1590 unsigned long recvBuf[],
1591 const int recvCounts[],
1594 const Comm<int>& comm)
1596 gathervImpl<unsigned long> (sendBuf, sendCount, recvBuf, recvCounts, displs, root, comm);
1601 reduceAll<int, unsigned long> (
const Comm<int>& comm,
1602 const EReductionType reductType,
1604 const unsigned long sendBuffer[],
1605 unsigned long globalReducts[])
1607 TEUCHOS_COMM_TIME_MONITOR(
1608 "Teuchos::reduceAll<int, unsigned long> (" << count <<
", " 1609 << toString (reductType) <<
")" 1611 reduceAllImpl<unsigned long> (comm, reductType, count, sendBuffer, globalReducts);
1615 RCP<Teuchos::CommRequest<int> >
1616 ireceive<int, unsigned long> (
const Comm<int>& comm,
1617 const ArrayRCP<unsigned long>& recvBuffer,
1618 const int sourceRank)
1620 TEUCHOS_COMM_TIME_MONITOR(
"ireceive<int, unsigned long>");
1621 return ireceiveImpl<unsigned long> (comm, recvBuffer, sourceRank);
1625 RCP<Teuchos::CommRequest<int> >
1626 ireceive<int, unsigned long> (
const ArrayRCP<unsigned long>& recvBuffer,
1627 const int sourceRank,
1629 const Comm<int>& comm)
1631 TEUCHOS_COMM_TIME_MONITOR(
"ireceive<int, unsigned long>");
1632 return ireceiveImpl<unsigned long> (recvBuffer, sourceRank, tag, comm);
1637 send<int, unsigned long> (
const Comm<int>& comm,
1639 const unsigned long sendBuffer[],
1642 return sendImpl<unsigned long> (comm, count, sendBuffer, destRank);
1647 send<int, unsigned long> (
const unsigned long sendBuffer[],
1651 const Comm<int>& comm)
1653 return sendImpl<unsigned long> (sendBuffer, count, destRank, tag, comm);
1657 RCP<Teuchos::CommRequest<int> >
1658 isend (
const ArrayRCP<const unsigned long>& sendBuffer,
1661 const Comm<int>& comm)
1663 return isendImpl<unsigned long> (sendBuffer, destRank, tag, comm);
1669 gather<int, int> (
const int sendBuf[],
1670 const int sendCount,
1672 const int recvCount,
1674 const Comm<int>& comm)
1676 gatherImpl<int> (sendBuf, sendCount, recvBuf, recvCount, root, comm);
1681 gatherv<int, int> (
const int sendBuf[],
1682 const int sendCount,
1684 const int recvCounts[],
1687 const Comm<int>& comm)
1689 gathervImpl<int> (sendBuf, sendCount, recvBuf, recvCounts, displs, root, comm);
1694 scatter<int, int> (
const int sendBuf[],
1695 const int sendCount,
1697 const int recvCount,
1699 const Comm<int>& comm)
1701 scatterImpl<int> (sendBuf, sendCount, recvBuf, recvCount, root, comm);
1706 reduce<int, int> (
const int sendBuf[],
1709 const EReductionType reductType,
1711 const Comm<int>& comm)
1713 TEUCHOS_COMM_TIME_MONITOR
1714 (
"Teuchos::reduce<int, int> (" << count <<
", " << toString (reductType)
1716 reduceImpl<int> (sendBuf, recvBuf, count, reductType, root, comm);
1721 reduceAll<int, int> (
const Comm<int>& comm,
1722 const EReductionType reductType,
1724 const int sendBuffer[],
1725 int globalReducts[])
1727 TEUCHOS_COMM_TIME_MONITOR(
1728 "Teuchos::reduceAll<int, int> (" << count <<
", " 1729 << toString (reductType) <<
")" 1731 reduceAllImpl<int> (comm, reductType, count, sendBuffer, globalReducts);
1735 TEUCHOS_DEPRECATED
void 1736 reduceAllAndScatter<int, int> (
const Comm<int>& comm,
1737 const EReductionType reductType,
1738 const int sendCount,
1739 const int sendBuffer[],
1740 const int recvCounts[],
1741 int myGlobalReducts[])
1743 reduceAllAndScatterImpl<int> (comm, reductType, sendCount, sendBuffer,
1744 recvCounts, myGlobalReducts);
1748 RCP<Teuchos::CommRequest<int> >
1749 ireceive<int, int> (
const Comm<int>& comm,
1750 const ArrayRCP<int>& recvBuffer,
1751 const int sourceRank)
1753 TEUCHOS_COMM_TIME_MONITOR(
"ireceive<int, int>");
1754 return ireceiveImpl<int> (comm, recvBuffer, sourceRank);
1758 RCP<Teuchos::CommRequest<int> >
1759 ireceive<int, int> (
const ArrayRCP<int>& recvBuffer,
1760 const int sourceRank,
1762 const Comm<int>& comm)
1764 TEUCHOS_COMM_TIME_MONITOR(
"ireceive<int, int>");
1765 return ireceiveImpl<int> (recvBuffer, sourceRank, tag, comm);
1770 send<int, int> (
const Comm<int>& comm,
1772 const int sendBuffer[],
1775 return sendImpl<int> (comm, count, sendBuffer, destRank);
1780 send<int, int> (
const int sendBuffer[],
1784 const Comm<int>& comm)
1786 return sendImpl<int> (sendBuffer, count, destRank, tag, comm);
1790 RCP<Teuchos::CommRequest<int> >
1791 isend (
const ArrayRCP<const int>& sendBuffer,
1794 const Comm<int>& comm)
1796 return isendImpl<int> (sendBuffer, destRank, tag, comm);
1802 gather<int, unsigned int> (
const unsigned int sendBuf[],
1803 const int sendCount,
1804 unsigned int recvBuf[],
1805 const int recvCount,
1807 const Comm<int>& comm)
1809 gatherImpl<unsigned int> (sendBuf, sendCount, recvBuf, recvCount, root, comm);
1814 gatherv<int, unsigned int> (
const unsigned int sendBuf[],
1815 const int sendCount,
1816 unsigned int recvBuf[],
1817 const int recvCounts[],
1820 const Comm<int>& comm)
1822 gathervImpl<unsigned int> (sendBuf, sendCount, recvBuf, recvCounts, displs, root, comm);
1827 reduceAll<int, unsigned int> (
const Comm<int>& comm,
1828 const EReductionType reductType,
1830 const unsigned int sendBuffer[],
1831 unsigned int globalReducts[])
1833 TEUCHOS_COMM_TIME_MONITOR(
1834 "Teuchos::reduceAll<int, unsigned int> (" << count <<
", " 1835 << toString (reductType) <<
")" 1837 reduceAllImpl<unsigned int> (comm, reductType, count, sendBuffer, globalReducts);
1841 RCP<Teuchos::CommRequest<int> >
1842 ireceive<int, unsigned int> (
const Comm<int>& comm,
1843 const ArrayRCP<unsigned int>& recvBuffer,
1844 const int sourceRank)
1846 TEUCHOS_COMM_TIME_MONITOR(
"ireceive<int, unsigned int>");
1847 return ireceiveImpl<unsigned int> (comm, recvBuffer, sourceRank);
1851 RCP<Teuchos::CommRequest<int> >
1852 ireceive<int, unsigned int> (
const ArrayRCP<unsigned int>& recvBuffer,
1853 const int sourceRank,
1855 const Comm<int>& comm)
1857 TEUCHOS_COMM_TIME_MONITOR(
"ireceive<int, unsigned int>");
1858 return ireceiveImpl<unsigned int> (recvBuffer, sourceRank, tag, comm);
1863 send<int, unsigned int> (
const Comm<int>& comm,
1865 const unsigned int sendBuffer[],
1868 return sendImpl<unsigned int> (comm, count, sendBuffer, destRank);
1873 send<int, unsigned int> (
const unsigned int sendBuffer[],
1877 const Comm<int>& comm)
1879 return sendImpl<unsigned int> (sendBuffer, count, destRank, tag, comm);
1883 RCP<Teuchos::CommRequest<int> >
1884 isend (
const ArrayRCP<const unsigned int>& sendBuffer,
1887 const Comm<int>& comm)
1889 return isendImpl<unsigned int> (sendBuffer, destRank, tag, comm);
1896 gather<int, short> (
const short sendBuf[],
1897 const int sendCount,
1899 const int recvCount,
1901 const Comm<int>& comm)
1903 gatherImpl<short> (sendBuf, sendCount, recvBuf, recvCount, root, comm);
1908 gatherv<int, short> (
const short sendBuf[],
1909 const int sendCount,
1911 const int recvCounts[],
1914 const Comm<int>& comm)
1916 gathervImpl<short> (sendBuf, sendCount, recvBuf, recvCounts, displs, root, comm);
1921 reduceAll<int, short> (
const Comm<int>& comm,
1922 const EReductionType reductType,
1924 const short sendBuffer[],
1925 short globalReducts[])
1927 TEUCHOS_COMM_TIME_MONITOR(
1928 "Teuchos::reduceAll<int, short> (" << count <<
", " 1929 << toString (reductType) <<
")" 1931 reduceAllImpl<short> (comm, reductType, count, sendBuffer, globalReducts);
1935 RCP<Teuchos::CommRequest<int> >
1936 ireceive<int, short> (
const Comm<int>& comm,
1937 const ArrayRCP<short>& recvBuffer,
1938 const int sourceRank)
1940 TEUCHOS_COMM_TIME_MONITOR(
"ireceive<int, short>");
1941 return ireceiveImpl<short> (comm, recvBuffer, sourceRank);
1945 RCP<Teuchos::CommRequest<int> >
1946 ireceive<int, short> (
const ArrayRCP<short>& recvBuffer,
1947 const int sourceRank,
1949 const Comm<int>& comm)
1951 TEUCHOS_COMM_TIME_MONITOR(
"ireceive<int, short>");
1952 return ireceiveImpl<short> (recvBuffer, sourceRank, tag, comm);
1957 send<int, short> (
const Comm<int>& comm,
1959 const short sendBuffer[],
1962 return sendImpl<short> (comm, count, sendBuffer, destRank);
1967 send<int, short> (
const short sendBuffer[],
1971 const Comm<int>& comm)
1973 return sendImpl<short> (sendBuffer, count, destRank, tag, comm);
1977 RCP<Teuchos::CommRequest<int> >
1978 isend (
const ArrayRCP<const short>& sendBuffer,
1981 const Comm<int>& comm)
1983 return isendImpl<short> (sendBuffer, destRank, tag, comm);
1998 reduceAll<int, char> (
const Comm<int>& comm,
1999 const EReductionType reductType,
2001 const char sendBuffer[],
2002 char globalReducts[])
2004 TEUCHOS_COMM_TIME_MONITOR(
2005 "Teuchos::reduceAll<int, char> (" << count <<
", " 2006 << toString (reductType) <<
")" 2008 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()