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(
398 "Teuchos::ireceive<int, " <<
"," << TypeNameTraits<Packet>::name ()
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(
419 "Teuchos::ireceive<int, " <<
"," << TypeNameTraits<Packet>::name ()
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(
581 "Teuchos::send<int, " << TypeNameTraits<T>::name () <<
">");
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(
599 "Teuchos::send<int, " << TypeNameTraits<T>::name () <<
">");
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(
732 "Teuchos::isend<int," << TypeNameTraits<T>::name () <<
">");
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(
755 "Teuchos::isend<int," << TypeNameTraits<T>::name () <<
">");
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);
1117 gather<int, long long> (
const long long sendBuf[],
1118 const int sendCount,
1119 long long recvBuf[],
1120 const int recvCount,
1122 const Comm<int>& comm)
1124 gatherImpl<long long> (sendBuf, sendCount, recvBuf, recvCount, root, comm);
1129 gatherv<int, long long> (
const long long sendBuf[],
1130 const int sendCount,
1131 long long recvBuf[],
1132 const int recvCounts[],
1135 const Comm<int>& comm)
1137 gathervImpl<long long> (sendBuf, sendCount, recvBuf, recvCounts, displs, root, comm);
1142 reduceAll<int, long long> (
const Comm<int>& comm,
1143 const EReductionType reductType,
1145 const long long sendBuffer[],
1146 long long globalReducts[])
1148 TEUCHOS_COMM_TIME_MONITOR(
1149 "Teuchos::reduceAll<int, long long> (" << count <<
", "
1150 << toString (reductType) <<
")"
1152 reduceAllImpl<long long> (comm, reductType, count, sendBuffer, globalReducts);
1156 RCP<Teuchos::CommRequest<int> >
1157 ireceive<int, long long> (
const Comm<int>& comm,
1158 const ArrayRCP<long long>& recvBuffer,
1159 const int sourceRank)
1161 TEUCHOS_COMM_TIME_MONITOR(
"ireceive<int, long long>");
1162 return ireceiveImpl<long long> (comm, recvBuffer, sourceRank);
1166 RCP<Teuchos::CommRequest<int> >
1167 ireceive<int, long long> (
const ArrayRCP<long long>& recvBuffer,
1168 const int sourceRank,
1170 const Comm<int>& comm)
1172 TEUCHOS_COMM_TIME_MONITOR(
"ireceive<int, long long>");
1173 return ireceiveImpl<long long> (recvBuffer, sourceRank, tag, comm);
1178 send<int, long long> (
const Comm<int>& comm,
1180 const long long sendBuffer[],
1183 return sendImpl<long long> (comm, count, sendBuffer, destRank);
1188 send<int, long long> (
const long long sendBuffer[],
1192 const Comm<int>& comm)
1194 return sendImpl<long long> (sendBuffer, count, destRank, tag, comm);
1198 RCP<Teuchos::CommRequest<int> >
1199 isend (
const ArrayRCP<const long long>& sendBuffer,
1202 const Comm<int>& comm)
1204 return isendImpl<long long> (sendBuffer, destRank, tag, comm);
1210 gather<int, unsigned long long> (
const unsigned long long sendBuf[],
1211 const int sendCount,
1212 unsigned long long recvBuf[],
1213 const int recvCount,
1215 const Comm<int>& comm)
1217 gatherImpl<unsigned long long> (sendBuf, sendCount, recvBuf, recvCount, root, comm);
1222 gatherv<int, unsigned long long> (
const unsigned long long sendBuf[],
1223 const int sendCount,
1224 unsigned long long recvBuf[],
1225 const int recvCounts[],
1228 const Comm<int>& comm)
1230 gathervImpl<unsigned long long> (sendBuf, sendCount, recvBuf, recvCounts, displs, root, comm);
1235 reduceAll<int, unsigned long long> (
const Comm<int>& comm,
1236 const EReductionType reductType,
1238 const unsigned long long sendBuffer[],
1239 unsigned long long globalReducts[])
1241 TEUCHOS_COMM_TIME_MONITOR(
1242 "Teuchos::reduceAll<int, unsigned long long> (" << count <<
", "
1243 << toString (reductType) <<
")"
1245 reduceAllImpl<unsigned long long> (comm, reductType, count, sendBuffer, globalReducts);
1249 RCP<Teuchos::CommRequest<int> >
1250 ireceive<int, unsigned long long> (
const Comm<int>& comm,
1251 const ArrayRCP<unsigned long long>& recvBuffer,
1252 const int sourceRank)
1254 TEUCHOS_COMM_TIME_MONITOR(
"ireceive<int, unsigned long long>");
1255 return ireceiveImpl<unsigned long long> (comm, recvBuffer, sourceRank);
1259 RCP<Teuchos::CommRequest<int> >
1260 ireceive<int, unsigned long long> (
const ArrayRCP<unsigned long long>& recvBuffer,
1261 const int sourceRank,
1263 const Comm<int>& comm)
1265 TEUCHOS_COMM_TIME_MONITOR(
"ireceive<int, unsigned long long>");
1266 return ireceiveImpl<unsigned long long> (recvBuffer, sourceRank, tag, comm);
1271 send<int, unsigned long long> (
const Comm<int>& comm,
1273 const unsigned long long sendBuffer[],
1276 return sendImpl<unsigned long long> (comm, count, sendBuffer, destRank);
1281 send<int, unsigned long long> (
const unsigned long long sendBuffer[],
1285 const Comm<int>& comm)
1287 return sendImpl<unsigned long long> (sendBuffer, count, destRank, tag, comm);
1291 RCP<Teuchos::CommRequest<int> >
1292 isend (
const ArrayRCP<const unsigned long long>& sendBuffer,
1295 const Comm<int>& comm)
1297 return isendImpl<unsigned long long> (sendBuffer, destRank, tag, comm);
1304 gather<int, long> (
const long sendBuf[],
1305 const int sendCount,
1307 const int recvCount,
1309 const Comm<int>& comm)
1311 gatherImpl<long> (sendBuf, sendCount, recvBuf, recvCount, root, comm);
1316 gatherv<int, long> (
const long sendBuf[],
1317 const int sendCount,
1319 const int recvCounts[],
1322 const Comm<int>& comm)
1324 gathervImpl<long> (sendBuf, sendCount, recvBuf, recvCounts, displs, root, comm);
1329 reduceAll<int, long> (
const Comm<int>& comm,
1330 const EReductionType reductType,
1332 const long sendBuffer[],
1333 long globalReducts[])
1335 TEUCHOS_COMM_TIME_MONITOR(
1336 "Teuchos::reduceAll<int, long> (" << count <<
", "
1337 << toString (reductType) <<
")"
1339 reduceAllImpl<long> (comm, reductType, count, sendBuffer, globalReducts);
1343 RCP<Teuchos::CommRequest<int> >
1344 ireceive<int, long> (
const Comm<int>& comm,
1345 const ArrayRCP<long>& recvBuffer,
1346 const int sourceRank)
1348 TEUCHOS_COMM_TIME_MONITOR(
"ireceive<int, long>");
1349 return ireceiveImpl<long> (comm, recvBuffer, sourceRank);
1353 RCP<Teuchos::CommRequest<int> >
1354 ireceive<int, long> (
const ArrayRCP<long>& recvBuffer,
1355 const int sourceRank,
1357 const Comm<int>& comm)
1359 TEUCHOS_COMM_TIME_MONITOR(
"ireceive<int, long>");
1360 return ireceiveImpl<long> (recvBuffer, sourceRank, tag, comm);
1365 send<int, long> (
const Comm<int>& comm,
1367 const long sendBuffer[],
1370 return sendImpl<long> (comm, count, sendBuffer, destRank);
1375 send<int, long> (
const long sendBuffer[],
1379 const Comm<int>& comm)
1381 return sendImpl<long> (sendBuffer, count, destRank, tag, comm);
1385 RCP<Teuchos::CommRequest<int> >
1386 isend (
const ArrayRCP<const long>& sendBuffer,
1389 const Comm<int>& comm)
1391 return isendImpl<long> (sendBuffer, destRank, tag, comm);
1398 gather<int, unsigned long> (
const unsigned long sendBuf[],
1399 const int sendCount,
1400 unsigned long recvBuf[],
1401 const int recvCount,
1403 const Comm<int>& comm)
1405 gatherImpl<unsigned long> (sendBuf, sendCount, recvBuf, recvCount, root, comm);
1410 gatherv<int, unsigned long> (
const unsigned long sendBuf[],
1411 const int sendCount,
1412 unsigned long recvBuf[],
1413 const int recvCounts[],
1416 const Comm<int>& comm)
1418 gathervImpl<unsigned long> (sendBuf, sendCount, recvBuf, recvCounts, displs, root, comm);
1423 reduceAll<int, unsigned long> (
const Comm<int>& comm,
1424 const EReductionType reductType,
1426 const unsigned long sendBuffer[],
1427 unsigned long globalReducts[])
1429 TEUCHOS_COMM_TIME_MONITOR(
1430 "Teuchos::reduceAll<int, unsigned long> (" << count <<
", "
1431 << toString (reductType) <<
")"
1433 reduceAllImpl<unsigned long> (comm, reductType, count, sendBuffer, globalReducts);
1437 RCP<Teuchos::CommRequest<int> >
1438 ireceive<int, unsigned long> (
const Comm<int>& comm,
1439 const ArrayRCP<unsigned long>& recvBuffer,
1440 const int sourceRank)
1442 TEUCHOS_COMM_TIME_MONITOR(
"ireceive<int, unsigned long>");
1443 return ireceiveImpl<unsigned long> (comm, recvBuffer, sourceRank);
1447 RCP<Teuchos::CommRequest<int> >
1448 ireceive<int, unsigned long> (
const ArrayRCP<unsigned long>& recvBuffer,
1449 const int sourceRank,
1451 const Comm<int>& comm)
1453 TEUCHOS_COMM_TIME_MONITOR(
"ireceive<int, unsigned long>");
1454 return ireceiveImpl<unsigned long> (recvBuffer, sourceRank, tag, comm);
1459 send<int, unsigned long> (
const Comm<int>& comm,
1461 const unsigned long sendBuffer[],
1464 return sendImpl<unsigned long> (comm, count, sendBuffer, destRank);
1469 send<int, unsigned long> (
const unsigned long sendBuffer[],
1473 const Comm<int>& comm)
1475 return sendImpl<unsigned long> (sendBuffer, count, destRank, tag, comm);
1479 RCP<Teuchos::CommRequest<int> >
1480 isend (
const ArrayRCP<const unsigned long>& sendBuffer,
1483 const Comm<int>& comm)
1485 return isendImpl<unsigned long> (sendBuffer, destRank, tag, comm);
1491 gather<int, int> (
const int sendBuf[],
1492 const int sendCount,
1494 const int recvCount,
1496 const Comm<int>& comm)
1498 gatherImpl<int> (sendBuf, sendCount, recvBuf, recvCount, root, comm);
1503 gatherv<int, int> (
const int sendBuf[],
1504 const int sendCount,
1506 const int recvCounts[],
1509 const Comm<int>& comm)
1511 gathervImpl<int> (sendBuf, sendCount, recvBuf, recvCounts, displs, root, comm);
1516 scatter<int, int> (
const int sendBuf[],
1517 const int sendCount,
1519 const int recvCount,
1521 const Comm<int>& comm)
1523 scatterImpl<int> (sendBuf, sendCount, recvBuf, recvCount, root, comm);
1528 reduce<int, int> (
const int sendBuf[],
1531 const EReductionType reductType,
1533 const Comm<int>& comm)
1535 TEUCHOS_COMM_TIME_MONITOR
1536 (
"Teuchos::reduce<int, int> (" << count <<
", " << toString (reductType)
1538 reduceImpl<int> (sendBuf, recvBuf, count, reductType, root, comm);
1542 reduce<int, long> (
const long sendBuf[],
1545 const EReductionType reductType,
1547 const Comm<int>& comm)
1549 TEUCHOS_COMM_TIME_MONITOR
1550 (
"Teuchos::reduce<int, int> (" << count <<
", " << toString (reductType)
1552 reduceImpl<long> (sendBuf, recvBuf, count, reductType, root, comm);
1557 reduce<int, unsigned long> (
const unsigned long sendBuf[],
1558 unsigned long recvBuf[],
1560 const EReductionType reductType,
1562 const Comm<int>& comm)
1564 TEUCHOS_COMM_TIME_MONITOR
1565 (
"Teuchos::reduce<int, int> (" << count <<
", " << toString (reductType)
1567 reduceImpl<unsigned long> (sendBuf, recvBuf, count, reductType, root, comm);
1572 reduce<int, unsigned long long > (
const unsigned long long sendBuf[],
1573 unsigned long long recvBuf[],
1575 const EReductionType reductType,
1577 const Comm<int>& comm)
1579 TEUCHOS_COMM_TIME_MONITOR
1580 (
"Teuchos::reduce<int, int> (" << count <<
", " << toString (reductType)
1582 reduceImpl<unsigned long long> (sendBuf, recvBuf, count, reductType, root, comm);
1587 reduce<int, double> (
const double sendBuf[],
1590 const EReductionType reductType,
1592 const Comm<int>& comm)
1594 TEUCHOS_COMM_TIME_MONITOR
1595 (
"Teuchos::reduce<int, int> (" << count <<
", " << toString (reductType)
1597 reduceImpl<double> (sendBuf, recvBuf, count, reductType, root, comm);
1601 reduceAll<int, int> (
const Comm<int>& comm,
1602 const EReductionType reductType,
1604 const int sendBuffer[],
1605 int globalReducts[])
1607 TEUCHOS_COMM_TIME_MONITOR(
1608 "Teuchos::reduceAll<int, int> (" << count <<
", "
1609 << toString (reductType) <<
")"
1611 reduceAllImpl<int> (comm, reductType, count, sendBuffer, globalReducts);
1615 RCP<Teuchos::CommRequest<int> >
1616 ireceive<int, int> (
const Comm<int>& comm,
1617 const ArrayRCP<int>& recvBuffer,
1618 const int sourceRank)
1620 TEUCHOS_COMM_TIME_MONITOR(
"ireceive<int, int>");
1621 return ireceiveImpl<int> (comm, recvBuffer, sourceRank);
1625 RCP<Teuchos::CommRequest<int> >
1626 ireceive<int, int> (
const ArrayRCP<int>& recvBuffer,
1627 const int sourceRank,
1629 const Comm<int>& comm)
1631 TEUCHOS_COMM_TIME_MONITOR(
"ireceive<int, int>");
1632 return ireceiveImpl<int> (recvBuffer, sourceRank, tag, comm);
1637 send<int, int> (
const Comm<int>& comm,
1639 const int sendBuffer[],
1642 return sendImpl<int> (comm, count, sendBuffer, destRank);
1647 send<int, int> (
const int sendBuffer[],
1651 const Comm<int>& comm)
1653 return sendImpl<int> (sendBuffer, count, destRank, tag, comm);
1657 RCP<Teuchos::CommRequest<int> >
1658 isend (
const ArrayRCP<const int>& sendBuffer,
1661 const Comm<int>& comm)
1663 return isendImpl<int> (sendBuffer, destRank, tag, comm);
1669 gather<int, unsigned int> (
const unsigned int sendBuf[],
1670 const int sendCount,
1671 unsigned int recvBuf[],
1672 const int recvCount,
1674 const Comm<int>& comm)
1676 gatherImpl<unsigned int> (sendBuf, sendCount, recvBuf, recvCount, root, comm);
1681 gatherv<int, unsigned int> (
const unsigned int sendBuf[],
1682 const int sendCount,
1683 unsigned int recvBuf[],
1684 const int recvCounts[],
1687 const Comm<int>& comm)
1689 gathervImpl<unsigned int> (sendBuf, sendCount, recvBuf, recvCounts, displs, root, comm);
1694 reduceAll<int, unsigned int> (
const Comm<int>& comm,
1695 const EReductionType reductType,
1697 const unsigned int sendBuffer[],
1698 unsigned int globalReducts[])
1700 TEUCHOS_COMM_TIME_MONITOR(
1701 "Teuchos::reduceAll<int, unsigned int> (" << count <<
", "
1702 << toString (reductType) <<
")"
1704 reduceAllImpl<unsigned int> (comm, reductType, count, sendBuffer, globalReducts);
1708 RCP<Teuchos::CommRequest<int> >
1709 ireceive<int, unsigned int> (
const Comm<int>& comm,
1710 const ArrayRCP<unsigned int>& recvBuffer,
1711 const int sourceRank)
1713 TEUCHOS_COMM_TIME_MONITOR(
"ireceive<int, unsigned int>");
1714 return ireceiveImpl<unsigned int> (comm, recvBuffer, sourceRank);
1718 RCP<Teuchos::CommRequest<int> >
1719 ireceive<int, unsigned int> (
const ArrayRCP<unsigned int>& recvBuffer,
1720 const int sourceRank,
1722 const Comm<int>& comm)
1724 TEUCHOS_COMM_TIME_MONITOR(
"ireceive<int, unsigned int>");
1725 return ireceiveImpl<unsigned int> (recvBuffer, sourceRank, tag, comm);
1730 send<int, unsigned int> (
const Comm<int>& comm,
1732 const unsigned int sendBuffer[],
1735 return sendImpl<unsigned int> (comm, count, sendBuffer, destRank);
1740 send<int, unsigned int> (
const unsigned int sendBuffer[],
1744 const Comm<int>& comm)
1746 return sendImpl<unsigned int> (sendBuffer, count, destRank, tag, comm);
1750 RCP<Teuchos::CommRequest<int> >
1751 isend (
const ArrayRCP<const unsigned int>& sendBuffer,
1754 const Comm<int>& comm)
1756 return isendImpl<unsigned int> (sendBuffer, destRank, tag, comm);
1763 gather<int, short> (
const short sendBuf[],
1764 const int sendCount,
1766 const int recvCount,
1768 const Comm<int>& comm)
1770 gatherImpl<short> (sendBuf, sendCount, recvBuf, recvCount, root, comm);
1775 gatherv<int, short> (
const short sendBuf[],
1776 const int sendCount,
1778 const int recvCounts[],
1781 const Comm<int>& comm)
1783 gathervImpl<short> (sendBuf, sendCount, recvBuf, recvCounts, displs, root, comm);
1788 reduceAll<int, short> (
const Comm<int>& comm,
1789 const EReductionType reductType,
1791 const short sendBuffer[],
1792 short globalReducts[])
1794 TEUCHOS_COMM_TIME_MONITOR(
1795 "Teuchos::reduceAll<int, short> (" << count <<
", "
1796 << toString (reductType) <<
")"
1798 reduceAllImpl<short> (comm, reductType, count, sendBuffer, globalReducts);
1802 RCP<Teuchos::CommRequest<int> >
1803 ireceive<int, short> (
const Comm<int>& comm,
1804 const ArrayRCP<short>& recvBuffer,
1805 const int sourceRank)
1807 TEUCHOS_COMM_TIME_MONITOR(
"ireceive<int, short>");
1808 return ireceiveImpl<short> (comm, recvBuffer, sourceRank);
1812 RCP<Teuchos::CommRequest<int> >
1813 ireceive<int, short> (
const ArrayRCP<short>& recvBuffer,
1814 const int sourceRank,
1816 const Comm<int>& comm)
1818 TEUCHOS_COMM_TIME_MONITOR(
"ireceive<int, short>");
1819 return ireceiveImpl<short> (recvBuffer, sourceRank, tag, comm);
1824 send<int, short> (
const Comm<int>& comm,
1826 const short sendBuffer[],
1829 return sendImpl<short> (comm, count, sendBuffer, destRank);
1834 send<int, short> (
const short sendBuffer[],
1838 const Comm<int>& comm)
1840 return sendImpl<short> (sendBuffer, count, destRank, tag, comm);
1844 RCP<Teuchos::CommRequest<int> >
1845 isend (
const ArrayRCP<const short>& sendBuffer,
1848 const Comm<int>& comm)
1850 return isendImpl<short> (sendBuffer, destRank, tag, comm);
1865 reduceAll<int, char> (
const Comm<int>& comm,
1866 const EReductionType reductType,
1868 const char sendBuffer[],
1869 char globalReducts[])
1871 TEUCHOS_COMM_TIME_MONITOR(
1872 "Teuchos::reduceAll<int, char> (" << count <<
", "
1873 << toString (reductType) <<
")"
1875 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 .
Declaration of Teuchos::Details::MpiTypeTraits (only if building with MPI)