42 #include "Teuchos_CommHelpers.hpp" 43 #ifdef HAVE_TEUCHOS_MPI 44 # include "Teuchos_Details_MpiCommRequest.hpp" 46 #endif // HAVE_TEUCHOS_MPI 47 #ifdef HAVE_TEUCHOSCORE_CXX11 53 #ifdef HAVE_TEUCHOS_MPI 56 std::string getMpiErrorString (
const int errCode) {
59 char errString [MPI_MAX_ERROR_STRING+1];
60 int errStringLen = MPI_MAX_ERROR_STRING;
61 (void) MPI_Error_string (errCode, errString, &errStringLen);
66 if (errString[errStringLen-1] !=
'\0') {
67 errString[errStringLen] =
'\0';
69 return std::string (errString);
73 #endif // HAVE_TEUCHOS_MPI 86 reduceAllImpl (
const Comm<int>& comm,
87 const EReductionType reductType,
92 #ifdef HAVE_TEUCHOS_MPI 93 using Teuchos::Details::MpiTypeTraits;
98 const MpiComm<int>* mpiComm =
dynamic_cast<const MpiComm<int>*
> (&comm);
99 if (mpiComm == NULL) {
101 const SerialComm<int>* serialComm =
dynamic_cast<const SerialComm<int>*
> (&comm);
102 if (serialComm == NULL) {
105 #ifdef HAVE_TEUCHOSCORE_CXX11 106 std::unique_ptr<ValueTypeReductionOp<int, T> >
108 std::auto_ptr<ValueTypeReductionOp<int, T> >
110 reductOp (createOp<int, T> (reductType));
111 reduceAll (comm, *reductOp, count, sendBuffer, globalReducts);
114 std::copy (sendBuffer, sendBuffer + count, globalReducts);
117 MPI_Op rawMpiOp = ::Teuchos::Details::getMpiOpForEReductionType (reductType);
118 MPI_Comm rawMpiComm = * (mpiComm->getRawMpiComm ());
120 MPI_Datatype rawMpiType = MpiTypeTraits<T>::getType (t);
122 int err = MPI_SUCCESS;
123 if (sendBuffer == globalReducts) {
127 err = MPI_Allreduce (MPI_IN_PLACE, globalReducts,
128 count, rawMpiType, rawMpiOp, rawMpiComm);
131 err = MPI_Allreduce (const_cast<T*> (sendBuffer), globalReducts,
132 count, rawMpiType, rawMpiOp, rawMpiComm);
137 "MPI_Allreduce failed with the following error: " 138 << ::Teuchos::Details::getMpiErrorString (err));
142 std::copy (sendBuffer, sendBuffer + count, globalReducts);
143 #endif // HAVE_TEUCHOS_MPI 156 gatherImpl (
const T sendBuf[],
161 const Comm<int>& comm)
163 #ifdef HAVE_TEUCHOS_MPI 164 using Teuchos::Details::MpiTypeTraits;
169 const MpiComm<int>* mpiComm =
dynamic_cast<const MpiComm<int>*
> (&comm);
170 if (mpiComm == NULL) {
172 const SerialComm<int>* serialComm =
dynamic_cast<const SerialComm<int>*
> (&comm);
173 if (serialComm == NULL) {
176 gather<int, T> (sendBuf, sendCount, recvBuf, recvCount, root, comm);
179 std::copy (sendBuf, sendBuf + sendCount, recvBuf);
182 MPI_Comm rawMpiComm = * (mpiComm->getRawMpiComm ());
184 MPI_Datatype rawMpiType = MpiTypeTraits<T>::getType (t);
185 const int err = MPI_Gather (const_cast<T*> (sendBuf), sendCount, rawMpiType,
186 recvBuf, recvCount, rawMpiType,
191 "MPI_Gather failed with the following error: " 192 << ::Teuchos::Details::getMpiErrorString (err));
196 std::copy (sendBuf, sendBuf + sendCount, recvBuf);
197 #endif // HAVE_TEUCHOS_MPI 210 scatterImpl (
const T sendBuf[],
215 const Comm<int>& comm)
217 #ifdef HAVE_TEUCHOS_MPI 218 using Teuchos::Details::MpiTypeTraits;
223 const MpiComm<int>* mpiComm =
dynamic_cast<const MpiComm<int>*
> (&comm);
224 if (mpiComm == NULL) {
226 const SerialComm<int>* serialComm =
dynamic_cast<const SerialComm<int>*
> (&comm);
227 if (serialComm == NULL) {
230 scatter<int, T> (sendBuf, sendCount, recvBuf, recvCount, root, comm);
233 std::copy (sendBuf, sendBuf + sendCount, recvBuf);
236 MPI_Comm rawMpiComm = * (mpiComm->getRawMpiComm ());
238 MPI_Datatype rawMpiType = MpiTypeTraits<T>::getType (t);
240 MPI_Scatter (const_cast<T*> (sendBuf), sendCount, rawMpiType,
241 recvBuf, recvCount, rawMpiType,
244 (err != MPI_SUCCESS, std::runtime_error,
245 "MPI_Scatter failed with the following error: " 246 << ::Teuchos::Details::getMpiErrorString (err));
251 std::copy (sendBuf, sendBuf + sendCount, recvBuf);
252 #endif // HAVE_TEUCHOS_MPI 265 reduceImpl (
const T sendBuf[],
268 const EReductionType reductType,
270 const Comm<int>& comm)
272 #ifdef HAVE_TEUCHOS_MPI 273 using Teuchos::Details::MpiTypeTraits;
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 reduce<int, T> (sendBuf, recvBuf, count, reductType, root, comm);
288 std::copy (sendBuf, sendBuf + count, recvBuf);
291 MPI_Op rawMpiOp = ::Teuchos::Details::getMpiOpForEReductionType (reductType);
292 MPI_Comm rawMpiComm = * (mpiComm->getRawMpiComm ());
294 MPI_Datatype rawMpiType = MpiTypeTraits<T>::getType (t);
295 const int err = MPI_Reduce (const_cast<T*> (sendBuf), recvBuf, count,
296 rawMpiType, rawMpiOp, root, rawMpiComm);
298 (err != MPI_SUCCESS, std::runtime_error,
"MPI_Reduce failed with the " 299 "following error: " << ::Teuchos::Details::getMpiErrorString (err));
303 std::copy (sendBuf, sendBuf + count, recvBuf);
304 #endif // HAVE_TEUCHOS_MPI 317 gathervImpl (
const T sendBuf[],
320 const int recvCounts[],
323 const Comm<int>& comm)
325 #ifdef HAVE_TEUCHOS_MPI 326 using Teuchos::Details::MpiTypeTraits;
331 const MpiComm<int>* mpiComm =
dynamic_cast<const MpiComm<int>*
> (&comm);
332 if (mpiComm == NULL) {
334 const SerialComm<int>* serialComm =
dynamic_cast<const SerialComm<int>*
> (&comm);
335 if (serialComm == NULL) {
338 gatherv<int, T> (sendBuf, sendCount, recvBuf, recvCounts, displs, root, comm);
342 recvCounts[0] > sendCount, std::invalid_argument,
343 "Teuchos::gatherv: If the input communicator contains only one " 344 "process, then you cannot receive more entries than you send. " 345 "You aim to receive " << recvCounts[0] <<
" entries, but to send " 346 << sendCount <<
" entries.");
350 std::copy (sendBuf, sendBuf + recvCounts[0], recvBuf + displs[0]);
353 MPI_Comm rawMpiComm = * (mpiComm->getRawMpiComm ());
355 MPI_Datatype rawMpiType = MpiTypeTraits<T>::getType (t);
356 const int err = MPI_Gatherv (const_cast<T*> (sendBuf),
360 const_cast<int*> (recvCounts),
361 const_cast<int*> (displs),
368 "MPI_Gatherv failed with the following error: " 369 << ::Teuchos::Details::getMpiErrorString (err));
374 recvCounts[0] > sendCount, std::invalid_argument,
375 "Teuchos::gatherv: If the input communicator contains only one " 376 "process, then you cannot receive more entries than you send. " 377 "You aim to receive " << recvCounts[0] <<
" entries, but to send " 378 << sendCount <<
" entries.");
382 std::copy (sendBuf, sendBuf + recvCounts[0], recvBuf + displs[0]);
383 #endif // HAVE_TEUCHOS_MPI 391 template<
typename Packet>
392 RCP<Teuchos::CommRequest<int> >
393 ireceiveGeneral(
const Comm<int>& comm,
394 const ArrayRCP<Packet> &recvBuffer,
395 const int sourceRank)
397 TEUCHOS_COMM_TIME_MONITOR(
399 <<
"> ( value type )" 401 ValueTypeSerializationBuffer<int, Packet>
402 charRecvBuffer (recvBuffer.size (), recvBuffer.getRawPtr ());
403 RCP<CommRequest<int> > commRequest =
404 comm.ireceive (charRecvBuffer.getCharBufferView (), sourceRank);
405 set_extra_data (recvBuffer,
"buffer", inOutArg (commRequest));
411 template<
typename Packet>
412 RCP<Teuchos::CommRequest<int> >
413 ireceiveGeneral (
const ArrayRCP<Packet> &recvBuffer,
414 const int sourceRank,
416 const Comm<int>& comm)
418 TEUCHOS_COMM_TIME_MONITOR(
420 <<
"> ( value type )" 422 ValueTypeSerializationBuffer<int, Packet>
423 charRecvBuffer (recvBuffer.size (), recvBuffer.getRawPtr ());
424 RCP<CommRequest<int> > commRequest =
425 comm.ireceive (charRecvBuffer.getCharBufferView (), sourceRank, tag);
426 set_extra_data (recvBuffer,
"buffer", inOutArg (commRequest));
443 RCP<CommRequest<int> >
444 ireceiveImpl (
const Comm<int>& comm,
445 const ArrayRCP<T>& recvBuffer,
446 const int sourceRank)
448 #ifdef HAVE_TEUCHOS_MPI 449 using Teuchos::Details::MpiTypeTraits;
454 const MpiComm<int>* mpiComm =
dynamic_cast<const MpiComm<int>*
> (&comm);
455 if (mpiComm == NULL) {
457 const SerialComm<int>* serialComm =
dynamic_cast<const SerialComm<int>*
> (&comm);
458 if (serialComm == NULL) {
461 return ireceiveGeneral<T> (comm, recvBuffer, sourceRank);
467 "ireceiveImpl: Not implemented for a serial communicator.");
471 MPI_Comm rawComm = * (mpiComm->getRawMpiComm ());
473 MPI_Datatype rawType = MpiTypeTraits<T>::getType (t);
474 T* rawRecvBuf = recvBuffer.getRawPtr ();
475 const int count = as<int> (recvBuffer.size ());
476 const int tag = mpiComm->getTag ();
477 MPI_Request rawRequest = MPI_REQUEST_NULL;
478 const int err = MPI_Irecv (rawRecvBuf, count, rawType, sourceRank, tag,
479 rawComm, &rawRequest);
481 err != MPI_SUCCESS, std::runtime_error,
482 "MPI_Irecv failed with the following error: " 483 << ::Teuchos::Details::getMpiErrorString (err));
485 ArrayRCP<const char> buf =
486 arcp_const_cast<
const char> (arcp_reinterpret_cast<
char> (recvBuffer));
487 RCP<Details::MpiCommRequest> req (
new Details::MpiCommRequest (rawRequest, buf));
488 return rcp_implicit_cast<CommRequest<int> > (req);
494 "ireceiveImpl: Not implemented for a serial communicator.");
505 #endif // HAVE_TEUCHOS_MPI 511 RCP<CommRequest<int> >
512 ireceiveImpl (
const ArrayRCP<T>& recvBuffer,
513 const int sourceRank,
515 const Comm<int>& comm)
517 #ifdef HAVE_TEUCHOS_MPI 518 using Teuchos::Details::MpiTypeTraits;
523 const MpiComm<int>* mpiComm =
dynamic_cast<const MpiComm<int>*
> (&comm);
524 if (mpiComm == NULL) {
526 const SerialComm<int>* serialComm =
dynamic_cast<const SerialComm<int>*
> (&comm);
527 if (serialComm == NULL) {
530 return ireceiveGeneral<T> (recvBuffer, sourceRank, tag, comm);
536 "ireceiveImpl: Not implemented for a serial communicator.");
540 MPI_Comm rawComm = * (mpiComm->getRawMpiComm ());
542 MPI_Datatype rawType = MpiTypeTraits<T>::getType (t);
543 T* rawRecvBuf = recvBuffer.getRawPtr ();
544 const int count = as<int> (recvBuffer.size ());
545 MPI_Request rawRequest = MPI_REQUEST_NULL;
546 const int err = MPI_Irecv (rawRecvBuf, count, rawType, sourceRank, tag,
547 rawComm, &rawRequest);
549 err != MPI_SUCCESS, std::runtime_error,
550 "MPI_Irecv failed with the following error: " 551 << ::Teuchos::Details::getMpiErrorString (err));
553 ArrayRCP<const char> buf =
554 arcp_const_cast<
const char> (arcp_reinterpret_cast<
char> (recvBuffer));
555 RCP<Details::MpiCommRequest> req (
new Details::MpiCommRequest (rawRequest, buf));
556 return rcp_implicit_cast<CommRequest<int> > (req);
562 "ireceiveImpl: Not implemented for a serial communicator.");
565 #endif // HAVE_TEUCHOS_MPI 575 sendGeneral (
const Comm<int>& comm,
577 const T sendBuffer[],
580 TEUCHOS_COMM_TIME_MONITOR(
582 ConstValueTypeSerializationBuffer<int,T> charSendBuffer (count, sendBuffer);
583 comm.send (charSendBuffer.getBytes (),
584 charSendBuffer.getCharBuffer (),
592 sendGeneral (
const T sendBuffer[],
596 const Comm<int>& comm)
598 TEUCHOS_COMM_TIME_MONITOR(
600 ConstValueTypeSerializationBuffer<int,T> charSendBuffer (count, sendBuffer);
601 comm.send (charSendBuffer.getBytes (),
602 charSendBuffer.getCharBuffer (),
620 sendImpl (
const Comm<int>& comm,
622 const T sendBuffer[],
625 #ifdef HAVE_TEUCHOS_MPI 626 using Teuchos::Details::MpiTypeTraits;
631 const MpiComm<int>* mpiComm =
dynamic_cast<const MpiComm<int>*
> (&comm);
632 if (mpiComm == NULL) {
634 const SerialComm<int>* serialComm =
dynamic_cast<const SerialComm<int>*
> (&comm);
635 if (serialComm == NULL) {
638 sendGeneral<T> (comm, count, sendBuffer, destRank);
644 "sendImpl: Not implemented for a serial communicator.");
648 MPI_Comm rawComm = * (mpiComm->getRawMpiComm ());
650 MPI_Datatype rawType = MpiTypeTraits<T>::getType (t);
651 T* rawBuf =
const_cast<T*
> (sendBuffer);
652 const int tag = mpiComm->getTag ();
653 const int err = MPI_Send (rawBuf, count, rawType, destRank, tag, rawComm);
657 "MPI_Send failed with the following error: " 658 << ::Teuchos::Details::getMpiErrorString (err));
664 "sendImpl: Not implemented for a serial communicator.");
665 #endif // HAVE_TEUCHOS_MPI 672 sendImpl (
const T sendBuffer[],
676 const Comm<int>& comm)
678 #ifdef HAVE_TEUCHOS_MPI 679 using Teuchos::Details::MpiTypeTraits;
684 const MpiComm<int>* mpiComm =
dynamic_cast<const MpiComm<int>*
> (&comm);
685 if (mpiComm == NULL) {
687 const SerialComm<int>* serialComm =
dynamic_cast<const SerialComm<int>*
> (&comm);
688 if (serialComm == NULL) {
691 sendGeneral<T> (sendBuffer, count, destRank, tag, comm);
697 "sendImpl: Not implemented for a serial communicator.");
701 MPI_Comm rawComm = * (mpiComm->getRawMpiComm ());
703 MPI_Datatype rawType = MpiTypeTraits<T>::getType (t);
704 T* rawBuf =
const_cast<T*
> (sendBuffer);
705 const int err = MPI_Send (rawBuf, count, rawType, destRank, tag, rawComm);
709 "MPI_Send failed with the following error: " 710 << ::Teuchos::Details::getMpiErrorString (err));
716 "sendImpl: Not implemented for a serial communicator.");
717 #endif // HAVE_TEUCHOS_MPI 726 RCP<CommRequest<int> >
727 isendGeneral (
const Comm<int>& comm,
728 const ArrayRCP<const T>& sendBuffer,
731 TEUCHOS_COMM_TIME_MONITOR(
733 ConstValueTypeSerializationBuffer<int, T>
734 charSendBuffer (sendBuffer.size (), sendBuffer.getRawPtr ());
735 RCP<CommRequest<int> > commRequest =
736 comm.isend (charSendBuffer.getCharBufferView (), destRank);
737 set_extra_data (sendBuffer,
"buffer", inOutArg (commRequest));
748 RCP<CommRequest<int> >
749 isendGeneral (
const ArrayRCP<const T>& sendBuffer,
752 const Comm<int>& comm)
754 TEUCHOS_COMM_TIME_MONITOR(
756 ConstValueTypeSerializationBuffer<int, T>
757 charSendBuffer (sendBuffer.size (), sendBuffer.getRawPtr ());
758 RCP<CommRequest<int> > commRequest =
759 comm.isend (charSendBuffer.getCharBufferView (), destRank, tag);
760 set_extra_data (sendBuffer,
"buffer", inOutArg (commRequest));
767 RCP<Teuchos::CommRequest<int> >
768 isendImpl (
const ArrayRCP<const T>& sendBuffer,
771 const Comm<int>& comm)
773 #ifdef HAVE_TEUCHOS_MPI 774 using Teuchos::Details::MpiTypeTraits;
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 return isendGeneral<T> (sendBuffer, destRank, tag, comm);
790 true, std::logic_error,
791 "isendImpl: Not implemented for a serial communicator.");
795 MPI_Comm rawComm = * (mpiComm->getRawMpiComm ());
797 MPI_Datatype rawType = MpiTypeTraits<T>::getType (t);
801 T* rawSendBuf =
const_cast<T*
> (sendBuffer.getRawPtr ());
802 const int count = as<int> (sendBuffer.size ());
803 MPI_Request rawRequest = MPI_REQUEST_NULL;
804 const int err = MPI_Isend (rawSendBuf, count, rawType, destRank, tag,
805 rawComm, &rawRequest);
809 "MPI_Isend failed with the following error: " 810 << ::Teuchos::Details::getMpiErrorString (err));
812 ArrayRCP<const char> buf = arcp_reinterpret_cast<
const char> (sendBuffer);
813 RCP<Details::MpiCommRequest> req (
new Details::MpiCommRequest (rawRequest, buf));
814 return rcp_implicit_cast<CommRequest<int> > (req);
820 "isendImpl: Not implemented for a serial communicator.");
821 #endif // HAVE_TEUCHOS_MPI 837 #ifdef HAVE_TEUCHOS_COMPLEX 841 reduceAll<int, std::complex<double> > (
const Comm<int>& comm,
842 const EReductionType reductType,
844 const std::complex<double> sendBuffer[],
845 std::complex<double> globalReducts[])
847 TEUCHOS_COMM_TIME_MONITOR(
848 "Teuchos::reduceAll<int, std::complex<double> > (" << count <<
", " 849 << toString (reductType) <<
")" 851 reduceAllImpl<std::complex<double> > (comm, reductType, count, sendBuffer, globalReducts);
855 RCP<Teuchos::CommRequest<int> >
856 ireceive<int, std::complex<double> > (
const Comm<int>& comm,
857 const ArrayRCP<std::complex<double> >& recvBuffer,
858 const int sourceRank)
860 TEUCHOS_COMM_TIME_MONITOR(
"ireceive<int, std::complex<double> >");
861 return ireceiveImpl<std::complex<double> > (comm, recvBuffer, sourceRank);
865 RCP<Teuchos::CommRequest<int> >
866 ireceive<int, std::complex<double> > (
const ArrayRCP<std::complex<double> >& recvBuffer,
867 const int sourceRank,
869 const Comm<int>& comm)
871 TEUCHOS_COMM_TIME_MONITOR(
"ireceive<int, std::complex<double> >");
872 return ireceiveImpl<std::complex<double> > (recvBuffer, sourceRank, tag, comm);
877 send<int, std::complex<double> > (
const Comm<int>& comm,
879 const std::complex<double> sendBuffer[],
882 sendImpl<std::complex<double> > (comm, count, sendBuffer, destRank);
887 send<int, std::complex<double> > (
const std::complex<double> sendBuffer[],
891 const Comm<int>& comm)
893 sendImpl<std::complex<double> > (sendBuffer, count, destRank, tag, comm);
897 RCP<Teuchos::CommRequest<int> >
898 isend (
const ArrayRCP<
const std::complex<double> >& sendBuffer,
901 const Comm<int>& comm)
903 return isendImpl<std::complex<double> > (sendBuffer, destRank, tag, comm);
909 reduceAll<int, std::complex<float> > (
const Comm<int>& comm,
910 const EReductionType reductType,
912 const std::complex<float> sendBuffer[],
913 std::complex<float> globalReducts[])
915 TEUCHOS_COMM_TIME_MONITOR(
916 "Teuchos::reduceAll<int, std::complex<float> > (" << count <<
", " 917 << toString (reductType) <<
")" 919 reduceAllImpl<std::complex<float> > (comm, reductType, count, sendBuffer, globalReducts);
923 RCP<Teuchos::CommRequest<int> >
924 ireceive<int, std::complex<float> > (
const Comm<int>& comm,
925 const ArrayRCP<std::complex<float> >& recvBuffer,
926 const int sourceRank)
928 TEUCHOS_COMM_TIME_MONITOR(
"ireceive<int, std::complex<float> >");
929 return ireceiveImpl<std::complex<float> > (comm, recvBuffer, sourceRank);
933 RCP<Teuchos::CommRequest<int> >
934 ireceive<int, std::complex<float> > (
const ArrayRCP<std::complex<float> >& recvBuffer,
935 const int sourceRank,
937 const Comm<int>& comm)
939 TEUCHOS_COMM_TIME_MONITOR(
"ireceive<int, std::complex<float> >");
940 return ireceiveImpl<std::complex<float> > (recvBuffer, sourceRank, tag, comm);
945 send<int, std::complex<float> > (
const Comm<int>& comm,
947 const std::complex<float> sendBuffer[],
950 return sendImpl<std::complex<float> > (comm, count, sendBuffer, destRank);
955 send<int, std::complex<float> > (
const std::complex<float> sendBuffer[],
959 const Comm<int>& comm)
961 return sendImpl<std::complex<float> > (sendBuffer, count, destRank, tag, comm);
965 RCP<Teuchos::CommRequest<int> >
966 isend (
const ArrayRCP<
const std::complex<float> >& sendBuffer,
969 const Comm<int>& comm)
971 return isendImpl<std::complex<float> > (sendBuffer, destRank, tag, comm);
973 #endif // HAVE_TEUCHOS_COMPLEX 980 reduceAll<int, double> (
const Comm<int>& comm,
981 const EReductionType reductType,
983 const double sendBuffer[],
984 double globalReducts[])
986 TEUCHOS_COMM_TIME_MONITOR(
987 "Teuchos::reduceAll<int, double> (" << count <<
", " 988 << toString (reductType) <<
")" 990 reduceAllImpl<double> (comm, reductType, count, sendBuffer, globalReducts);
994 RCP<Teuchos::CommRequest<int> >
995 ireceive<int, double> (
const Comm<int>& comm,
996 const ArrayRCP<double>& recvBuffer,
997 const int sourceRank)
999 TEUCHOS_COMM_TIME_MONITOR(
"ireceive<int, double>");
1000 return ireceiveImpl<double> (comm, recvBuffer, sourceRank);
1004 RCP<Teuchos::CommRequest<int> >
1005 ireceive<int, double> (
const ArrayRCP<double>& recvBuffer,
1006 const int sourceRank,
1008 const Comm<int>& comm)
1010 TEUCHOS_COMM_TIME_MONITOR(
"ireceive<int, double>");
1011 return ireceiveImpl<double> (recvBuffer, sourceRank, tag, comm);
1016 send<int, double> (
const Comm<int>& comm,
1018 const double sendBuffer[],
1021 return sendImpl<double> (comm, count, sendBuffer, destRank);
1026 send<int, double> (
const double sendBuffer[],
1030 const Comm<int>& comm)
1032 return sendImpl<double> (sendBuffer, count, destRank, tag, comm);
1036 RCP<Teuchos::CommRequest<int> >
1037 isend (
const ArrayRCP<const double>& sendBuffer,
1040 const Comm<int>& comm)
1042 return isendImpl<double> (sendBuffer, destRank, tag, comm);
1048 reduceAll<int, float> (
const Comm<int>& comm,
1049 const EReductionType reductType,
1051 const float sendBuffer[],
1052 float globalReducts[])
1054 TEUCHOS_COMM_TIME_MONITOR(
1055 "Teuchos::reduceAll<int, float> (" << count <<
", " 1056 << toString (reductType) <<
")" 1058 reduceAllImpl<float> (comm, reductType, count, sendBuffer, globalReducts);
1062 RCP<Teuchos::CommRequest<int> >
1063 ireceive<int, float> (
const Comm<int>& comm,
1064 const ArrayRCP<float>& recvBuffer,
1065 const int sourceRank)
1067 TEUCHOS_COMM_TIME_MONITOR(
"ireceive<int, float>");
1068 return ireceiveImpl<float> (comm, recvBuffer, sourceRank);
1072 RCP<Teuchos::CommRequest<int> >
1073 ireceive<int, float> (
const ArrayRCP<float>& recvBuffer,
1074 const int sourceRank,
1076 const Comm<int>& comm)
1078 TEUCHOS_COMM_TIME_MONITOR(
"ireceive<int, float>");
1079 return ireceiveImpl<float> (recvBuffer, sourceRank, tag, comm);
1084 send<int, float> (
const Comm<int>& comm,
1086 const float sendBuffer[],
1089 return sendImpl<float> (comm, count, sendBuffer, destRank);
1094 send<int, float> (
const float sendBuffer[],
1098 const Comm<int>& comm)
1100 return sendImpl<float> (sendBuffer, count, destRank, tag, comm);
1104 RCP<Teuchos::CommRequest<int> >
1105 isend (
const ArrayRCP<const float>& sendBuffer,
1108 const Comm<int>& comm)
1110 return isendImpl<float> (sendBuffer, destRank, tag, comm);
1114 #ifdef HAVE_TEUCHOS_LONG_LONG_INT 1118 gather<int, long long> (
const long long sendBuf[],
1119 const int sendCount,
1120 long long recvBuf[],
1121 const int recvCount,
1123 const Comm<int>& comm)
1125 gatherImpl<long long> (sendBuf, sendCount, recvBuf, recvCount, root, comm);
1130 gatherv<int, long long> (
const long long sendBuf[],
1131 const int sendCount,
1132 long long recvBuf[],
1133 const int recvCounts[],
1136 const Comm<int>& comm)
1138 gathervImpl<long long> (sendBuf, sendCount, recvBuf, recvCounts, displs, root, comm);
1143 reduceAll<int, long long> (
const Comm<int>& comm,
1144 const EReductionType reductType,
1146 const long long sendBuffer[],
1147 long long globalReducts[])
1149 TEUCHOS_COMM_TIME_MONITOR(
1150 "Teuchos::reduceAll<int, long long> (" << count <<
", " 1151 << toString (reductType) <<
")" 1153 reduceAllImpl<long long> (comm, reductType, count, sendBuffer, globalReducts);
1157 RCP<Teuchos::CommRequest<int> >
1158 ireceive<int, long long> (
const Comm<int>& comm,
1159 const ArrayRCP<long long>& recvBuffer,
1160 const int sourceRank)
1162 TEUCHOS_COMM_TIME_MONITOR(
"ireceive<int, long long>");
1163 return ireceiveImpl<long long> (comm, recvBuffer, sourceRank);
1167 RCP<Teuchos::CommRequest<int> >
1168 ireceive<int, long long> (
const ArrayRCP<long long>& recvBuffer,
1169 const int sourceRank,
1171 const Comm<int>& comm)
1173 TEUCHOS_COMM_TIME_MONITOR(
"ireceive<int, long long>");
1174 return ireceiveImpl<long long> (recvBuffer, sourceRank, tag, comm);
1179 send<int, long long> (
const Comm<int>& comm,
1181 const long long sendBuffer[],
1184 return sendImpl<long long> (comm, count, sendBuffer, destRank);
1189 send<int, long long> (
const long long sendBuffer[],
1193 const Comm<int>& comm)
1195 return sendImpl<long long> (sendBuffer, count, destRank, tag, comm);
1199 RCP<Teuchos::CommRequest<int> >
1200 isend (
const ArrayRCP<const long long>& sendBuffer,
1203 const Comm<int>& comm)
1205 return isendImpl<long long> (sendBuffer, destRank, tag, comm);
1211 gather<int, unsigned long long> (
const unsigned long long sendBuf[],
1212 const int sendCount,
1213 unsigned long long recvBuf[],
1214 const int recvCount,
1216 const Comm<int>& comm)
1218 gatherImpl<unsigned long long> (sendBuf, sendCount, recvBuf, recvCount, root, comm);
1223 gatherv<int, unsigned long long> (
const unsigned long long sendBuf[],
1224 const int sendCount,
1225 unsigned long long recvBuf[],
1226 const int recvCounts[],
1229 const Comm<int>& comm)
1231 gathervImpl<unsigned long long> (sendBuf, sendCount, recvBuf, recvCounts, displs, root, comm);
1236 reduceAll<int, unsigned long long> (
const Comm<int>& comm,
1237 const EReductionType reductType,
1239 const unsigned long long sendBuffer[],
1240 unsigned long long globalReducts[])
1242 TEUCHOS_COMM_TIME_MONITOR(
1243 "Teuchos::reduceAll<int, unsigned long long> (" << count <<
", " 1244 << toString (reductType) <<
")" 1246 reduceAllImpl<unsigned long long> (comm, reductType, count, sendBuffer, globalReducts);
1250 RCP<Teuchos::CommRequest<int> >
1251 ireceive<int, unsigned long long> (
const Comm<int>& comm,
1252 const ArrayRCP<unsigned long long>& recvBuffer,
1253 const int sourceRank)
1255 TEUCHOS_COMM_TIME_MONITOR(
"ireceive<int, unsigned long long>");
1256 return ireceiveImpl<unsigned long long> (comm, recvBuffer, sourceRank);
1260 RCP<Teuchos::CommRequest<int> >
1261 ireceive<int, unsigned long long> (
const ArrayRCP<unsigned long long>& recvBuffer,
1262 const int sourceRank,
1264 const Comm<int>& comm)
1266 TEUCHOS_COMM_TIME_MONITOR(
"ireceive<int, unsigned long long>");
1267 return ireceiveImpl<unsigned long long> (recvBuffer, sourceRank, tag, comm);
1272 send<int, unsigned long long> (
const Comm<int>& comm,
1274 const unsigned long long sendBuffer[],
1277 return sendImpl<unsigned long long> (comm, count, sendBuffer, destRank);
1282 send<int, unsigned long long> (
const unsigned long long sendBuffer[],
1286 const Comm<int>& comm)
1288 return sendImpl<unsigned long long> (sendBuffer, count, destRank, tag, comm);
1292 RCP<Teuchos::CommRequest<int> >
1293 isend (
const ArrayRCP<const unsigned long long>& sendBuffer,
1296 const Comm<int>& comm)
1298 return isendImpl<unsigned long long> (sendBuffer, destRank, tag, comm);
1301 #endif // HAVE_TEUCHOS_LONG_LONG_INT 1307 gather<int, long> (
const long sendBuf[],
1308 const int sendCount,
1310 const int recvCount,
1312 const Comm<int>& comm)
1314 gatherImpl<long> (sendBuf, sendCount, recvBuf, recvCount, root, comm);
1319 gatherv<int, long> (
const long sendBuf[],
1320 const int sendCount,
1322 const int recvCounts[],
1325 const Comm<int>& comm)
1327 gathervImpl<long> (sendBuf, sendCount, recvBuf, recvCounts, displs, root, comm);
1332 reduceAll<int, long> (
const Comm<int>& comm,
1333 const EReductionType reductType,
1335 const long sendBuffer[],
1336 long globalReducts[])
1338 TEUCHOS_COMM_TIME_MONITOR(
1339 "Teuchos::reduceAll<int, long> (" << count <<
", " 1340 << toString (reductType) <<
")" 1342 reduceAllImpl<long> (comm, reductType, count, sendBuffer, globalReducts);
1346 RCP<Teuchos::CommRequest<int> >
1347 ireceive<int, long> (
const Comm<int>& comm,
1348 const ArrayRCP<long>& recvBuffer,
1349 const int sourceRank)
1351 TEUCHOS_COMM_TIME_MONITOR(
"ireceive<int, long>");
1352 return ireceiveImpl<long> (comm, recvBuffer, sourceRank);
1356 RCP<Teuchos::CommRequest<int> >
1357 ireceive<int, long> (
const ArrayRCP<long>& recvBuffer,
1358 const int sourceRank,
1360 const Comm<int>& comm)
1362 TEUCHOS_COMM_TIME_MONITOR(
"ireceive<int, long>");
1363 return ireceiveImpl<long> (recvBuffer, sourceRank, tag, comm);
1368 send<int, long> (
const Comm<int>& comm,
1370 const long sendBuffer[],
1373 return sendImpl<long> (comm, count, sendBuffer, destRank);
1378 send<int, long> (
const long sendBuffer[],
1382 const Comm<int>& comm)
1384 return sendImpl<long> (sendBuffer, count, destRank, tag, comm);
1388 RCP<Teuchos::CommRequest<int> >
1389 isend (
const ArrayRCP<const long>& sendBuffer,
1392 const Comm<int>& comm)
1394 return isendImpl<long> (sendBuffer, destRank, tag, comm);
1401 gather<int, unsigned long> (
const unsigned long sendBuf[],
1402 const int sendCount,
1403 unsigned long recvBuf[],
1404 const int recvCount,
1406 const Comm<int>& comm)
1408 gatherImpl<unsigned long> (sendBuf, sendCount, recvBuf, recvCount, root, comm);
1413 gatherv<int, unsigned long> (
const unsigned long sendBuf[],
1414 const int sendCount,
1415 unsigned long recvBuf[],
1416 const int recvCounts[],
1419 const Comm<int>& comm)
1421 gathervImpl<unsigned long> (sendBuf, sendCount, recvBuf, recvCounts, displs, root, comm);
1426 reduceAll<int, unsigned long> (
const Comm<int>& comm,
1427 const EReductionType reductType,
1429 const unsigned long sendBuffer[],
1430 unsigned long globalReducts[])
1432 TEUCHOS_COMM_TIME_MONITOR(
1433 "Teuchos::reduceAll<int, unsigned long> (" << count <<
", " 1434 << toString (reductType) <<
")" 1436 reduceAllImpl<unsigned long> (comm, reductType, count, sendBuffer, globalReducts);
1440 RCP<Teuchos::CommRequest<int> >
1441 ireceive<int, unsigned long> (
const Comm<int>& comm,
1442 const ArrayRCP<unsigned long>& recvBuffer,
1443 const int sourceRank)
1445 TEUCHOS_COMM_TIME_MONITOR(
"ireceive<int, unsigned long>");
1446 return ireceiveImpl<unsigned long> (comm, recvBuffer, sourceRank);
1450 RCP<Teuchos::CommRequest<int> >
1451 ireceive<int, unsigned long> (
const ArrayRCP<unsigned long>& recvBuffer,
1452 const int sourceRank,
1454 const Comm<int>& comm)
1456 TEUCHOS_COMM_TIME_MONITOR(
"ireceive<int, unsigned long>");
1457 return ireceiveImpl<unsigned long> (recvBuffer, sourceRank, tag, comm);
1462 send<int, unsigned long> (
const Comm<int>& comm,
1464 const unsigned long sendBuffer[],
1467 return sendImpl<unsigned long> (comm, count, sendBuffer, destRank);
1472 send<int, unsigned long> (
const unsigned long sendBuffer[],
1476 const Comm<int>& comm)
1478 return sendImpl<unsigned long> (sendBuffer, count, destRank, tag, comm);
1482 RCP<Teuchos::CommRequest<int> >
1483 isend (
const ArrayRCP<const unsigned long>& sendBuffer,
1486 const Comm<int>& comm)
1488 return isendImpl<unsigned long> (sendBuffer, destRank, tag, comm);
1494 gather<int, int> (
const int sendBuf[],
1495 const int sendCount,
1497 const int recvCount,
1499 const Comm<int>& comm)
1501 gatherImpl<int> (sendBuf, sendCount, recvBuf, recvCount, root, comm);
1506 gatherv<int, int> (
const int sendBuf[],
1507 const int sendCount,
1509 const int recvCounts[],
1512 const Comm<int>& comm)
1514 gathervImpl<int> (sendBuf, sendCount, recvBuf, recvCounts, displs, root, comm);
1519 scatter<int, int> (
const int sendBuf[],
1520 const int sendCount,
1522 const int recvCount,
1524 const Comm<int>& comm)
1526 scatterImpl<int> (sendBuf, sendCount, recvBuf, recvCount, root, comm);
1531 reduce<int, int> (
const int sendBuf[],
1534 const EReductionType reductType,
1536 const Comm<int>& comm)
1538 TEUCHOS_COMM_TIME_MONITOR
1539 (
"Teuchos::reduce<int, int> (" << count <<
", " << toString (reductType)
1541 reduceImpl<int> (sendBuf, recvBuf, count, reductType, root, comm);
1546 reduceAll<int, int> (
const Comm<int>& comm,
1547 const EReductionType reductType,
1549 const int sendBuffer[],
1550 int globalReducts[])
1552 TEUCHOS_COMM_TIME_MONITOR(
1553 "Teuchos::reduceAll<int, int> (" << count <<
", " 1554 << toString (reductType) <<
")" 1556 reduceAllImpl<int> (comm, reductType, count, sendBuffer, globalReducts);
1560 RCP<Teuchos::CommRequest<int> >
1561 ireceive<int, int> (
const Comm<int>& comm,
1562 const ArrayRCP<int>& recvBuffer,
1563 const int sourceRank)
1565 TEUCHOS_COMM_TIME_MONITOR(
"ireceive<int, int>");
1566 return ireceiveImpl<int> (comm, recvBuffer, sourceRank);
1570 RCP<Teuchos::CommRequest<int> >
1571 ireceive<int, int> (
const ArrayRCP<int>& recvBuffer,
1572 const int sourceRank,
1574 const Comm<int>& comm)
1576 TEUCHOS_COMM_TIME_MONITOR(
"ireceive<int, int>");
1577 return ireceiveImpl<int> (recvBuffer, sourceRank, tag, comm);
1582 send<int, int> (
const Comm<int>& comm,
1584 const int sendBuffer[],
1587 return sendImpl<int> (comm, count, sendBuffer, destRank);
1592 send<int, int> (
const int sendBuffer[],
1596 const Comm<int>& comm)
1598 return sendImpl<int> (sendBuffer, count, destRank, tag, comm);
1602 RCP<Teuchos::CommRequest<int> >
1603 isend (
const ArrayRCP<const int>& sendBuffer,
1606 const Comm<int>& comm)
1608 return isendImpl<int> (sendBuffer, destRank, tag, comm);
1614 gather<int, unsigned int> (
const unsigned int sendBuf[],
1615 const int sendCount,
1616 unsigned int recvBuf[],
1617 const int recvCount,
1619 const Comm<int>& comm)
1621 gatherImpl<unsigned int> (sendBuf, sendCount, recvBuf, recvCount, root, comm);
1626 gatherv<int, unsigned int> (
const unsigned int sendBuf[],
1627 const int sendCount,
1628 unsigned int recvBuf[],
1629 const int recvCounts[],
1632 const Comm<int>& comm)
1634 gathervImpl<unsigned int> (sendBuf, sendCount, recvBuf, recvCounts, displs, root, comm);
1639 reduceAll<int, unsigned int> (
const Comm<int>& comm,
1640 const EReductionType reductType,
1642 const unsigned int sendBuffer[],
1643 unsigned int globalReducts[])
1645 TEUCHOS_COMM_TIME_MONITOR(
1646 "Teuchos::reduceAll<int, unsigned int> (" << count <<
", " 1647 << toString (reductType) <<
")" 1649 reduceAllImpl<unsigned int> (comm, reductType, count, sendBuffer, globalReducts);
1653 RCP<Teuchos::CommRequest<int> >
1654 ireceive<int, unsigned int> (
const Comm<int>& comm,
1655 const ArrayRCP<unsigned int>& recvBuffer,
1656 const int sourceRank)
1658 TEUCHOS_COMM_TIME_MONITOR(
"ireceive<int, unsigned int>");
1659 return ireceiveImpl<unsigned int> (comm, recvBuffer, sourceRank);
1663 RCP<Teuchos::CommRequest<int> >
1664 ireceive<int, unsigned int> (
const ArrayRCP<unsigned int>& recvBuffer,
1665 const int sourceRank,
1667 const Comm<int>& comm)
1669 TEUCHOS_COMM_TIME_MONITOR(
"ireceive<int, unsigned int>");
1670 return ireceiveImpl<unsigned int> (recvBuffer, sourceRank, tag, comm);
1675 send<int, unsigned int> (
const Comm<int>& comm,
1677 const unsigned int sendBuffer[],
1680 return sendImpl<unsigned int> (comm, count, sendBuffer, destRank);
1685 send<int, unsigned int> (
const unsigned int sendBuffer[],
1689 const Comm<int>& comm)
1691 return sendImpl<unsigned int> (sendBuffer, count, destRank, tag, comm);
1695 RCP<Teuchos::CommRequest<int> >
1696 isend (
const ArrayRCP<const unsigned int>& sendBuffer,
1699 const Comm<int>& comm)
1701 return isendImpl<unsigned int> (sendBuffer, destRank, tag, comm);
1708 gather<int, short> (
const short sendBuf[],
1709 const int sendCount,
1711 const int recvCount,
1713 const Comm<int>& comm)
1715 gatherImpl<short> (sendBuf, sendCount, recvBuf, recvCount, root, comm);
1720 gatherv<int, short> (
const short sendBuf[],
1721 const int sendCount,
1723 const int recvCounts[],
1726 const Comm<int>& comm)
1728 gathervImpl<short> (sendBuf, sendCount, recvBuf, recvCounts, displs, root, comm);
1733 reduceAll<int, short> (
const Comm<int>& comm,
1734 const EReductionType reductType,
1736 const short sendBuffer[],
1737 short globalReducts[])
1739 TEUCHOS_COMM_TIME_MONITOR(
1740 "Teuchos::reduceAll<int, short> (" << count <<
", " 1741 << toString (reductType) <<
")" 1743 reduceAllImpl<short> (comm, reductType, count, sendBuffer, globalReducts);
1747 RCP<Teuchos::CommRequest<int> >
1748 ireceive<int, short> (
const Comm<int>& comm,
1749 const ArrayRCP<short>& recvBuffer,
1750 const int sourceRank)
1752 TEUCHOS_COMM_TIME_MONITOR(
"ireceive<int, short>");
1753 return ireceiveImpl<short> (comm, recvBuffer, sourceRank);
1757 RCP<Teuchos::CommRequest<int> >
1758 ireceive<int, short> (
const ArrayRCP<short>& recvBuffer,
1759 const int sourceRank,
1761 const Comm<int>& comm)
1763 TEUCHOS_COMM_TIME_MONITOR(
"ireceive<int, short>");
1764 return ireceiveImpl<short> (recvBuffer, sourceRank, tag, comm);
1769 send<int, short> (
const Comm<int>& comm,
1771 const short sendBuffer[],
1774 return sendImpl<short> (comm, count, sendBuffer, destRank);
1779 send<int, short> (
const short sendBuffer[],
1783 const Comm<int>& comm)
1785 return sendImpl<short> (sendBuffer, count, destRank, tag, comm);
1789 RCP<Teuchos::CommRequest<int> >
1790 isend (
const ArrayRCP<const short>& sendBuffer,
1793 const Comm<int>& comm)
1795 return isendImpl<short> (sendBuffer, destRank, tag, comm);
1810 reduceAll<int, char> (
const Comm<int>& comm,
1811 const EReductionType reductType,
1813 const char sendBuffer[],
1814 char globalReducts[])
1816 TEUCHOS_COMM_TIME_MONITOR(
1817 "Teuchos::reduceAll<int, char> (" << count <<
", " 1818 << toString (reductType) <<
")" 1820 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.
Namespace of implementation details.
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.
Declaration of Teuchos::Details::MpiTypeTraits (only if building with MPI)
static std::string name()