10 #include "Teuchos_CommHelpers.hpp"
11 #ifdef HAVE_TEUCHOS_MPI
12 # include "Teuchos_Details_MpiCommRequest.hpp"
14 #endif // HAVE_TEUCHOS_MPI
15 #ifdef HAVE_TEUCHOSCORE_CXX11
21 #ifdef HAVE_TEUCHOS_MPI
24 std::string getMpiErrorString (
const int errCode) {
27 char errString [MPI_MAX_ERROR_STRING+1];
28 int errStringLen = MPI_MAX_ERROR_STRING;
29 (void) MPI_Error_string (errCode, errString, &errStringLen);
34 if (errString[errStringLen-1] !=
'\0') {
35 errString[errStringLen] =
'\0';
37 return std::string (errString);
41 #endif // HAVE_TEUCHOS_MPI
54 reduceAllImpl (
const Comm<int>& comm,
55 const EReductionType reductType,
60 #ifdef HAVE_TEUCHOS_MPI
61 using Teuchos::Details::MpiTypeTraits;
66 const MpiComm<int>* mpiComm =
dynamic_cast<const MpiComm<int>*
> (&comm);
67 if (mpiComm == NULL) {
69 const SerialComm<int>* serialComm =
dynamic_cast<const SerialComm<int>*
> (&comm);
70 if (serialComm == NULL) {
73 #ifdef HAVE_TEUCHOSCORE_CXX11
74 std::unique_ptr<ValueTypeReductionOp<int, T> >
76 std::auto_ptr<ValueTypeReductionOp<int, T> >
78 reductOp (createOp<int, T> (reductType));
79 reduceAll (comm, *reductOp, count, sendBuffer, globalReducts);
82 std::copy (sendBuffer, sendBuffer + count, globalReducts);
85 MPI_Op rawMpiOp = ::Teuchos::Details::getMpiOpForEReductionType (reductType);
86 MPI_Comm rawMpiComm = * (mpiComm->getRawMpiComm ());
88 MPI_Datatype rawMpiType = MpiTypeTraits<T>::getType (t);
90 int err = MPI_SUCCESS;
91 if (sendBuffer == globalReducts) {
95 err = MPI_Allreduce (MPI_IN_PLACE, globalReducts,
96 count, rawMpiType, rawMpiOp, rawMpiComm);
99 err = MPI_Allreduce (const_cast<T*> (sendBuffer), globalReducts,
100 count, rawMpiType, rawMpiOp, rawMpiComm);
105 "MPI_Allreduce failed with the following error: "
106 << ::Teuchos::Details::getMpiErrorString (err));
110 std::copy (sendBuffer, sendBuffer + count, globalReducts);
111 #endif // HAVE_TEUCHOS_MPI
124 gatherImpl (
const T sendBuf[],
129 const Comm<int>& comm)
131 #ifdef HAVE_TEUCHOS_MPI
132 using Teuchos::Details::MpiTypeTraits;
137 const MpiComm<int>* mpiComm =
dynamic_cast<const MpiComm<int>*
> (&comm);
138 if (mpiComm == NULL) {
140 const SerialComm<int>* serialComm =
dynamic_cast<const SerialComm<int>*
> (&comm);
141 if (serialComm == NULL) {
144 gather<int, T> (sendBuf, sendCount, recvBuf, recvCount, root, comm);
147 std::copy (sendBuf, sendBuf + sendCount, recvBuf);
150 MPI_Comm rawMpiComm = * (mpiComm->getRawMpiComm ());
152 MPI_Datatype rawMpiType = MpiTypeTraits<T>::getType (t);
153 const int err = MPI_Gather (const_cast<T*> (sendBuf), sendCount, rawMpiType,
154 recvBuf, recvCount, rawMpiType,
159 "MPI_Gather failed with the following error: "
160 << ::Teuchos::Details::getMpiErrorString (err));
164 std::copy (sendBuf, sendBuf + sendCount, recvBuf);
165 #endif // HAVE_TEUCHOS_MPI
178 scatterImpl (
const T sendBuf[],
183 const Comm<int>& comm)
185 #ifdef HAVE_TEUCHOS_MPI
186 using Teuchos::Details::MpiTypeTraits;
191 const MpiComm<int>* mpiComm =
dynamic_cast<const MpiComm<int>*
> (&comm);
192 if (mpiComm == NULL) {
194 const SerialComm<int>* serialComm =
dynamic_cast<const SerialComm<int>*
> (&comm);
195 if (serialComm == NULL) {
198 scatter<int, T> (sendBuf, sendCount, recvBuf, recvCount, root, comm);
201 std::copy (sendBuf, sendBuf + sendCount, recvBuf);
204 MPI_Comm rawMpiComm = * (mpiComm->getRawMpiComm ());
206 MPI_Datatype rawMpiType = MpiTypeTraits<T>::getType (t);
208 MPI_Scatter (const_cast<T*> (sendBuf), sendCount, rawMpiType,
209 recvBuf, recvCount, rawMpiType,
212 (err != MPI_SUCCESS, std::runtime_error,
213 "MPI_Scatter failed with the following error: "
214 << ::Teuchos::Details::getMpiErrorString (err));
219 std::copy (sendBuf, sendBuf + sendCount, recvBuf);
220 #endif // HAVE_TEUCHOS_MPI
233 reduceImpl (
const T sendBuf[],
236 const EReductionType reductType,
238 const Comm<int>& comm)
240 #ifdef HAVE_TEUCHOS_MPI
241 using Teuchos::Details::MpiTypeTraits;
246 const MpiComm<int>* mpiComm =
dynamic_cast<const MpiComm<int>*
> (&comm);
247 if (mpiComm == NULL) {
249 const SerialComm<int>* serialComm =
dynamic_cast<const SerialComm<int>*
> (&comm);
250 if (serialComm == NULL) {
253 reduce<int, T> (sendBuf, recvBuf, count, reductType, root, comm);
256 std::copy (sendBuf, sendBuf + count, recvBuf);
259 MPI_Op rawMpiOp = ::Teuchos::Details::getMpiOpForEReductionType (reductType);
260 MPI_Comm rawMpiComm = * (mpiComm->getRawMpiComm ());
262 MPI_Datatype rawMpiType = MpiTypeTraits<T>::getType (t);
263 const int err = MPI_Reduce (const_cast<T*> (sendBuf), recvBuf, count,
264 rawMpiType, rawMpiOp, root, rawMpiComm);
266 (err != MPI_SUCCESS, std::runtime_error,
"MPI_Reduce failed with the "
267 "following error: " << ::Teuchos::Details::getMpiErrorString (err));
271 std::copy (sendBuf, sendBuf + count, recvBuf);
272 #endif // HAVE_TEUCHOS_MPI
285 gathervImpl (
const T sendBuf[],
288 const int recvCounts[],
291 const Comm<int>& comm)
293 #ifdef HAVE_TEUCHOS_MPI
294 using Teuchos::Details::MpiTypeTraits;
299 const MpiComm<int>* mpiComm =
dynamic_cast<const MpiComm<int>*
> (&comm);
300 if (mpiComm == NULL) {
302 const SerialComm<int>* serialComm =
dynamic_cast<const SerialComm<int>*
> (&comm);
303 if (serialComm == NULL) {
306 gatherv<int, T> (sendBuf, sendCount, recvBuf, recvCounts, displs, root, comm);
310 recvCounts[0] > sendCount, std::invalid_argument,
311 "Teuchos::gatherv: If the input communicator contains only one "
312 "process, then you cannot receive more entries than you send. "
313 "You aim to receive " << recvCounts[0] <<
" entries, but to send "
314 << sendCount <<
" entries.");
318 std::copy (sendBuf, sendBuf + recvCounts[0], recvBuf + displs[0]);
321 MPI_Comm rawMpiComm = * (mpiComm->getRawMpiComm ());
323 MPI_Datatype rawMpiType = MpiTypeTraits<T>::getType (t);
324 const int err = MPI_Gatherv (const_cast<T*> (sendBuf),
328 const_cast<int*> (recvCounts),
329 const_cast<int*> (displs),
336 "MPI_Gatherv failed with the following error: "
337 << ::Teuchos::Details::getMpiErrorString (err));
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]);
351 #endif // HAVE_TEUCHOS_MPI
359 template<
typename Packet>
360 RCP<Teuchos::CommRequest<int> >
361 ireceiveGeneral(
const Comm<int>& comm,
362 const ArrayRCP<Packet> &recvBuffer,
363 const int sourceRank)
365 TEUCHOS_COMM_TIME_MONITOR(
366 "Teuchos::ireceive<int, " <<
"," << TypeNameTraits<Packet>::name ()
367 <<
"> ( value type )"
369 ValueTypeSerializationBuffer<int, Packet>
370 charRecvBuffer (recvBuffer.size (), recvBuffer.getRawPtr ());
371 RCP<CommRequest<int> > commRequest =
372 comm.ireceive (charRecvBuffer.getCharBufferView (), sourceRank);
373 set_extra_data (recvBuffer,
"buffer", inOutArg (commRequest));
379 template<
typename Packet>
380 RCP<Teuchos::CommRequest<int> >
381 ireceiveGeneral (
const ArrayRCP<Packet> &recvBuffer,
382 const int sourceRank,
384 const Comm<int>& comm)
386 TEUCHOS_COMM_TIME_MONITOR(
387 "Teuchos::ireceive<int, " <<
"," << TypeNameTraits<Packet>::name ()
388 <<
"> ( value type )"
390 ValueTypeSerializationBuffer<int, Packet>
391 charRecvBuffer (recvBuffer.size (), recvBuffer.getRawPtr ());
392 RCP<CommRequest<int> > commRequest =
393 comm.ireceive (charRecvBuffer.getCharBufferView (), sourceRank, tag);
394 set_extra_data (recvBuffer,
"buffer", inOutArg (commRequest));
411 RCP<CommRequest<int> >
412 ireceiveImpl (
const Comm<int>& comm,
413 const ArrayRCP<T>& recvBuffer,
414 const int sourceRank)
416 #ifdef HAVE_TEUCHOS_MPI
417 using Teuchos::Details::MpiTypeTraits;
422 const MpiComm<int>* mpiComm =
dynamic_cast<const MpiComm<int>*
> (&comm);
423 if (mpiComm == NULL) {
425 const SerialComm<int>* serialComm =
dynamic_cast<const SerialComm<int>*
> (&comm);
426 if (serialComm == NULL) {
429 return ireceiveGeneral<T> (comm, recvBuffer, sourceRank);
435 "ireceiveImpl: Not implemented for a serial communicator.");
439 MPI_Comm rawComm = * (mpiComm->getRawMpiComm ());
441 MPI_Datatype rawType = MpiTypeTraits<T>::getType (t);
442 T* rawRecvBuf = recvBuffer.getRawPtr ();
443 const int count = as<int> (recvBuffer.size ());
444 const int tag = mpiComm->getTag ();
445 MPI_Request rawRequest = MPI_REQUEST_NULL;
446 const int err = MPI_Irecv (rawRecvBuf, count, rawType, sourceRank, tag,
447 rawComm, &rawRequest);
449 err != MPI_SUCCESS, std::runtime_error,
450 "MPI_Irecv failed with the following error: "
451 << ::Teuchos::Details::getMpiErrorString (err));
453 ArrayRCP<const char> buf =
454 arcp_const_cast<
const char> (arcp_reinterpret_cast<
char> (recvBuffer));
455 RCP<Details::MpiCommRequest> req (
new Details::MpiCommRequest (rawRequest, buf));
456 return rcp_implicit_cast<CommRequest<int> > (req);
462 "ireceiveImpl: Not implemented for a serial communicator.");
473 #endif // HAVE_TEUCHOS_MPI
479 RCP<CommRequest<int> >
480 ireceiveImpl (
const ArrayRCP<T>& recvBuffer,
481 const int sourceRank,
483 const Comm<int>& comm)
485 #ifdef HAVE_TEUCHOS_MPI
486 using Teuchos::Details::MpiTypeTraits;
491 const MpiComm<int>* mpiComm =
dynamic_cast<const MpiComm<int>*
> (&comm);
492 if (mpiComm == NULL) {
494 const SerialComm<int>* serialComm =
dynamic_cast<const SerialComm<int>*
> (&comm);
495 if (serialComm == NULL) {
498 return ireceiveGeneral<T> (recvBuffer, sourceRank, tag, comm);
504 "ireceiveImpl: Not implemented for a serial communicator.");
508 MPI_Comm rawComm = * (mpiComm->getRawMpiComm ());
510 MPI_Datatype rawType = MpiTypeTraits<T>::getType (t);
511 T* rawRecvBuf = recvBuffer.getRawPtr ();
512 const int count = as<int> (recvBuffer.size ());
513 MPI_Request rawRequest = MPI_REQUEST_NULL;
514 const int err = MPI_Irecv (rawRecvBuf, count, rawType, sourceRank, tag,
515 rawComm, &rawRequest);
517 err != MPI_SUCCESS, std::runtime_error,
518 "MPI_Irecv failed with the following error: "
519 << ::Teuchos::Details::getMpiErrorString (err));
521 ArrayRCP<const char> buf =
522 arcp_const_cast<
const char> (arcp_reinterpret_cast<
char> (recvBuffer));
523 RCP<Details::MpiCommRequest> req (
new Details::MpiCommRequest (rawRequest, buf));
524 return rcp_implicit_cast<CommRequest<int> > (req);
530 "ireceiveImpl: Not implemented for a serial communicator.");
533 #endif // HAVE_TEUCHOS_MPI
543 sendGeneral (
const Comm<int>& comm,
545 const T sendBuffer[],
548 TEUCHOS_COMM_TIME_MONITOR(
549 "Teuchos::send<int, " << TypeNameTraits<T>::name () <<
">");
550 ConstValueTypeSerializationBuffer<int,T> charSendBuffer (count, sendBuffer);
551 comm.send (charSendBuffer.getBytes (),
552 charSendBuffer.getCharBuffer (),
560 sendGeneral (
const T sendBuffer[],
564 const Comm<int>& comm)
566 TEUCHOS_COMM_TIME_MONITOR(
567 "Teuchos::send<int, " << TypeNameTraits<T>::name () <<
">");
568 ConstValueTypeSerializationBuffer<int,T> charSendBuffer (count, sendBuffer);
569 comm.send (charSendBuffer.getBytes (),
570 charSendBuffer.getCharBuffer (),
588 sendImpl (
const Comm<int>& comm,
590 const T sendBuffer[],
593 #ifdef HAVE_TEUCHOS_MPI
594 using Teuchos::Details::MpiTypeTraits;
599 const MpiComm<int>* mpiComm =
dynamic_cast<const MpiComm<int>*
> (&comm);
600 if (mpiComm == NULL) {
602 const SerialComm<int>* serialComm =
dynamic_cast<const SerialComm<int>*
> (&comm);
603 if (serialComm == NULL) {
606 sendGeneral<T> (comm, count, sendBuffer, destRank);
612 "sendImpl: Not implemented for a serial communicator.");
616 MPI_Comm rawComm = * (mpiComm->getRawMpiComm ());
618 MPI_Datatype rawType = MpiTypeTraits<T>::getType (t);
619 T* rawBuf =
const_cast<T*
> (sendBuffer);
620 const int tag = mpiComm->getTag ();
621 const int err = MPI_Send (rawBuf, count, rawType, destRank, tag, rawComm);
625 "MPI_Send failed with the following error: "
626 << ::Teuchos::Details::getMpiErrorString (err));
632 "sendImpl: Not implemented for a serial communicator.");
633 #endif // HAVE_TEUCHOS_MPI
640 sendImpl (
const T sendBuffer[],
644 const Comm<int>& comm)
646 #ifdef HAVE_TEUCHOS_MPI
647 using Teuchos::Details::MpiTypeTraits;
652 const MpiComm<int>* mpiComm =
dynamic_cast<const MpiComm<int>*
> (&comm);
653 if (mpiComm == NULL) {
655 const SerialComm<int>* serialComm =
dynamic_cast<const SerialComm<int>*
> (&comm);
656 if (serialComm == NULL) {
659 sendGeneral<T> (sendBuffer, count, destRank, tag, comm);
665 "sendImpl: Not implemented for a serial communicator.");
669 MPI_Comm rawComm = * (mpiComm->getRawMpiComm ());
671 MPI_Datatype rawType = MpiTypeTraits<T>::getType (t);
672 T* rawBuf =
const_cast<T*
> (sendBuffer);
673 const int err = MPI_Send (rawBuf, count, rawType, destRank, tag, rawComm);
677 "MPI_Send failed with the following error: "
678 << ::Teuchos::Details::getMpiErrorString (err));
684 "sendImpl: Not implemented for a serial communicator.");
685 #endif // HAVE_TEUCHOS_MPI
694 RCP<CommRequest<int> >
695 isendGeneral (
const Comm<int>& comm,
696 const ArrayRCP<const T>& sendBuffer,
699 TEUCHOS_COMM_TIME_MONITOR(
700 "Teuchos::isend<int," << TypeNameTraits<T>::name () <<
">");
701 ConstValueTypeSerializationBuffer<int, T>
702 charSendBuffer (sendBuffer.size (), sendBuffer.getRawPtr ());
703 RCP<CommRequest<int> > commRequest =
704 comm.isend (charSendBuffer.getCharBufferView (), destRank);
705 set_extra_data (sendBuffer,
"buffer", inOutArg (commRequest));
716 RCP<CommRequest<int> >
717 isendGeneral (
const ArrayRCP<const T>& sendBuffer,
720 const Comm<int>& comm)
722 TEUCHOS_COMM_TIME_MONITOR(
723 "Teuchos::isend<int," << TypeNameTraits<T>::name () <<
">");
724 ConstValueTypeSerializationBuffer<int, T>
725 charSendBuffer (sendBuffer.size (), sendBuffer.getRawPtr ());
726 RCP<CommRequest<int> > commRequest =
727 comm.isend (charSendBuffer.getCharBufferView (), destRank, tag);
728 set_extra_data (sendBuffer,
"buffer", inOutArg (commRequest));
735 RCP<Teuchos::CommRequest<int> >
736 isendImpl (
const ArrayRCP<const T>& sendBuffer,
739 const Comm<int>& comm)
741 #ifdef HAVE_TEUCHOS_MPI
742 using Teuchos::Details::MpiTypeTraits;
747 const MpiComm<int>* mpiComm =
dynamic_cast<const MpiComm<int>*
> (&comm);
748 if (mpiComm == NULL) {
750 const SerialComm<int>* serialComm =
dynamic_cast<const SerialComm<int>*
> (&comm);
751 if (serialComm == NULL) {
754 return isendGeneral<T> (sendBuffer, destRank, tag, comm);
758 true, std::logic_error,
759 "isendImpl: Not implemented for a serial communicator.");
763 MPI_Comm rawComm = * (mpiComm->getRawMpiComm ());
765 MPI_Datatype rawType = MpiTypeTraits<T>::getType (t);
769 T* rawSendBuf =
const_cast<T*
> (sendBuffer.getRawPtr ());
770 const int count = as<int> (sendBuffer.size ());
771 MPI_Request rawRequest = MPI_REQUEST_NULL;
772 const int err = MPI_Isend (rawSendBuf, count, rawType, destRank, tag,
773 rawComm, &rawRequest);
777 "MPI_Isend failed with the following error: "
778 << ::Teuchos::Details::getMpiErrorString (err));
780 ArrayRCP<const char> buf = arcp_reinterpret_cast<
const char> (sendBuffer);
781 RCP<Details::MpiCommRequest> req (
new Details::MpiCommRequest (rawRequest, buf));
782 return rcp_implicit_cast<CommRequest<int> > (req);
788 "isendImpl: Not implemented for a serial communicator.");
789 #endif // HAVE_TEUCHOS_MPI
805 #ifdef HAVE_TEUCHOS_COMPLEX
809 reduceAll<int, std::complex<double> > (
const Comm<int>& comm,
810 const EReductionType reductType,
812 const std::complex<double> sendBuffer[],
813 std::complex<double> globalReducts[])
815 TEUCHOS_COMM_TIME_MONITOR(
816 "Teuchos::reduceAll<int, std::complex<double> > (" << count <<
", "
817 << toString (reductType) <<
")"
819 reduceAllImpl<std::complex<double> > (comm, reductType, count, sendBuffer, globalReducts);
823 RCP<Teuchos::CommRequest<int> >
824 ireceive<int, std::complex<double> > (
const Comm<int>& comm,
825 const ArrayRCP<std::complex<double> >& recvBuffer,
826 const int sourceRank)
828 TEUCHOS_COMM_TIME_MONITOR(
"ireceive<int, std::complex<double> >");
829 return ireceiveImpl<std::complex<double> > (comm, recvBuffer, sourceRank);
833 RCP<Teuchos::CommRequest<int> >
834 ireceive<int, std::complex<double> > (
const ArrayRCP<std::complex<double> >& recvBuffer,
835 const int sourceRank,
837 const Comm<int>& comm)
839 TEUCHOS_COMM_TIME_MONITOR(
"ireceive<int, std::complex<double> >");
840 return ireceiveImpl<std::complex<double> > (recvBuffer, sourceRank, tag, comm);
845 send<int, std::complex<double> > (
const Comm<int>& comm,
847 const std::complex<double> sendBuffer[],
850 sendImpl<std::complex<double> > (comm, count, sendBuffer, destRank);
855 send<int, std::complex<double> > (
const std::complex<double> sendBuffer[],
859 const Comm<int>& comm)
861 sendImpl<std::complex<double> > (sendBuffer, count, destRank, tag, comm);
865 RCP<Teuchos::CommRequest<int> >
866 isend (
const ArrayRCP<
const std::complex<double> >& sendBuffer,
869 const Comm<int>& comm)
871 return isendImpl<std::complex<double> > (sendBuffer, destRank, tag, comm);
877 reduceAll<int, std::complex<float> > (
const Comm<int>& comm,
878 const EReductionType reductType,
880 const std::complex<float> sendBuffer[],
881 std::complex<float> globalReducts[])
883 TEUCHOS_COMM_TIME_MONITOR(
884 "Teuchos::reduceAll<int, std::complex<float> > (" << count <<
", "
885 << toString (reductType) <<
")"
887 reduceAllImpl<std::complex<float> > (comm, reductType, count, sendBuffer, globalReducts);
891 RCP<Teuchos::CommRequest<int> >
892 ireceive<int, std::complex<float> > (
const Comm<int>& comm,
893 const ArrayRCP<std::complex<float> >& recvBuffer,
894 const int sourceRank)
896 TEUCHOS_COMM_TIME_MONITOR(
"ireceive<int, std::complex<float> >");
897 return ireceiveImpl<std::complex<float> > (comm, recvBuffer, sourceRank);
901 RCP<Teuchos::CommRequest<int> >
902 ireceive<int, std::complex<float> > (
const ArrayRCP<std::complex<float> >& recvBuffer,
903 const int sourceRank,
905 const Comm<int>& comm)
907 TEUCHOS_COMM_TIME_MONITOR(
"ireceive<int, std::complex<float> >");
908 return ireceiveImpl<std::complex<float> > (recvBuffer, sourceRank, tag, comm);
913 send<int, std::complex<float> > (
const Comm<int>& comm,
915 const std::complex<float> sendBuffer[],
918 return sendImpl<std::complex<float> > (comm, count, sendBuffer, destRank);
923 send<int, std::complex<float> > (
const std::complex<float> sendBuffer[],
927 const Comm<int>& comm)
929 return sendImpl<std::complex<float> > (sendBuffer, count, destRank, tag, comm);
933 RCP<Teuchos::CommRequest<int> >
934 isend (
const ArrayRCP<
const std::complex<float> >& sendBuffer,
937 const Comm<int>& comm)
939 return isendImpl<std::complex<float> > (sendBuffer, destRank, tag, comm);
941 #endif // HAVE_TEUCHOS_COMPLEX
947 reduceAll<int, double> (
const Comm<int>& comm,
948 const EReductionType reductType,
950 const double sendBuffer[],
951 double globalReducts[])
953 TEUCHOS_COMM_TIME_MONITOR(
954 "Teuchos::reduceAll<int, double> (" << count <<
", "
955 << toString (reductType) <<
")"
957 reduceAllImpl<double> (comm, reductType, count, sendBuffer, globalReducts);
961 RCP<Teuchos::CommRequest<int> >
962 ireceive<int, double> (
const Comm<int>& comm,
963 const ArrayRCP<double>& recvBuffer,
964 const int sourceRank)
966 TEUCHOS_COMM_TIME_MONITOR(
"ireceive<int, double>");
967 return ireceiveImpl<double> (comm, recvBuffer, sourceRank);
971 RCP<Teuchos::CommRequest<int> >
972 ireceive<int, double> (
const ArrayRCP<double>& recvBuffer,
973 const int sourceRank,
975 const Comm<int>& comm)
977 TEUCHOS_COMM_TIME_MONITOR(
"ireceive<int, double>");
978 return ireceiveImpl<double> (recvBuffer, sourceRank, tag, comm);
983 send<int, double> (
const Comm<int>& comm,
985 const double sendBuffer[],
988 return sendImpl<double> (comm, count, sendBuffer, destRank);
993 send<int, double> (
const double sendBuffer[],
997 const Comm<int>& comm)
999 return sendImpl<double> (sendBuffer, count, destRank, tag, comm);
1003 RCP<Teuchos::CommRequest<int> >
1004 isend (
const ArrayRCP<const double>& sendBuffer,
1007 const Comm<int>& comm)
1009 return isendImpl<double> (sendBuffer, destRank, tag, comm);
1014 gatherv<int, double> (
const double sendBuf[],
1015 const int sendCount,
1017 const int recvCounts[],
1020 const Comm<int>& comm)
1022 gathervImpl<double> (sendBuf, sendCount, recvBuf, recvCounts, displs, root, comm);
1029 reduceAll<int, float> (
const Comm<int>& comm,
1030 const EReductionType reductType,
1032 const float sendBuffer[],
1033 float globalReducts[])
1035 TEUCHOS_COMM_TIME_MONITOR(
1036 "Teuchos::reduceAll<int, float> (" << count <<
", "
1037 << toString (reductType) <<
")"
1039 reduceAllImpl<float> (comm, reductType, count, sendBuffer, globalReducts);
1043 RCP<Teuchos::CommRequest<int> >
1044 ireceive<int, float> (
const Comm<int>& comm,
1045 const ArrayRCP<float>& recvBuffer,
1046 const int sourceRank)
1048 TEUCHOS_COMM_TIME_MONITOR(
"ireceive<int, float>");
1049 return ireceiveImpl<float> (comm, recvBuffer, sourceRank);
1053 RCP<Teuchos::CommRequest<int> >
1054 ireceive<int, float> (
const ArrayRCP<float>& recvBuffer,
1055 const int sourceRank,
1057 const Comm<int>& comm)
1059 TEUCHOS_COMM_TIME_MONITOR(
"ireceive<int, float>");
1060 return ireceiveImpl<float> (recvBuffer, sourceRank, tag, comm);
1065 send<int, float> (
const Comm<int>& comm,
1067 const float sendBuffer[],
1070 return sendImpl<float> (comm, count, sendBuffer, destRank);
1075 send<int, float> (
const float sendBuffer[],
1079 const Comm<int>& comm)
1081 return sendImpl<float> (sendBuffer, count, destRank, tag, comm);
1085 RCP<Teuchos::CommRequest<int> >
1086 isend (
const ArrayRCP<const float>& sendBuffer,
1089 const Comm<int>& comm)
1091 return isendImpl<float> (sendBuffer, destRank, tag, comm);
1096 gatherv<int,float > (
const float sendBuf[],
1097 const int sendCount,
1099 const int recvCounts[],
1102 const Comm<int>& comm)
1104 gathervImpl<float> (sendBuf, sendCount, recvBuf, recvCounts, displs, root, comm);
1111 gather<int, long long> (
const long long sendBuf[],
1112 const int sendCount,
1113 long long recvBuf[],
1114 const int recvCount,
1116 const Comm<int>& comm)
1118 gatherImpl<long long> (sendBuf, sendCount, recvBuf, recvCount, root, comm);
1123 gatherv<int, long long> (
const long long sendBuf[],
1124 const int sendCount,
1125 long long recvBuf[],
1126 const int recvCounts[],
1129 const Comm<int>& comm)
1131 gathervImpl<long long> (sendBuf, sendCount, recvBuf, recvCounts, displs, root, comm);
1136 reduceAll<int, long long> (
const Comm<int>& comm,
1137 const EReductionType reductType,
1139 const long long sendBuffer[],
1140 long long globalReducts[])
1142 TEUCHOS_COMM_TIME_MONITOR(
1143 "Teuchos::reduceAll<int, long long> (" << count <<
", "
1144 << toString (reductType) <<
")"
1146 reduceAllImpl<long long> (comm, reductType, count, sendBuffer, globalReducts);
1150 RCP<Teuchos::CommRequest<int> >
1151 ireceive<int, long long> (
const Comm<int>& comm,
1152 const ArrayRCP<long long>& recvBuffer,
1153 const int sourceRank)
1155 TEUCHOS_COMM_TIME_MONITOR(
"ireceive<int, long long>");
1156 return ireceiveImpl<long long> (comm, recvBuffer, sourceRank);
1160 RCP<Teuchos::CommRequest<int> >
1161 ireceive<int, long long> (
const ArrayRCP<long long>& recvBuffer,
1162 const int sourceRank,
1164 const Comm<int>& comm)
1166 TEUCHOS_COMM_TIME_MONITOR(
"ireceive<int, long long>");
1167 return ireceiveImpl<long long> (recvBuffer, sourceRank, tag, comm);
1172 send<int, long long> (
const Comm<int>& comm,
1174 const long long sendBuffer[],
1177 return sendImpl<long long> (comm, count, sendBuffer, destRank);
1182 send<int, long long> (
const long long sendBuffer[],
1186 const Comm<int>& comm)
1188 return sendImpl<long long> (sendBuffer, count, destRank, tag, comm);
1192 RCP<Teuchos::CommRequest<int> >
1193 isend (
const ArrayRCP<const long long>& sendBuffer,
1196 const Comm<int>& comm)
1198 return isendImpl<long long> (sendBuffer, destRank, tag, comm);
1204 gather<int, unsigned long long> (
const unsigned long long sendBuf[],
1205 const int sendCount,
1206 unsigned long long recvBuf[],
1207 const int recvCount,
1209 const Comm<int>& comm)
1211 gatherImpl<unsigned long long> (sendBuf, sendCount, recvBuf, recvCount, root, comm);
1216 gatherv<int, unsigned long long> (
const unsigned long long sendBuf[],
1217 const int sendCount,
1218 unsigned long long recvBuf[],
1219 const int recvCounts[],
1222 const Comm<int>& comm)
1224 gathervImpl<unsigned long long> (sendBuf, sendCount, recvBuf, recvCounts, displs, root, comm);
1229 reduceAll<int, unsigned long long> (
const Comm<int>& comm,
1230 const EReductionType reductType,
1232 const unsigned long long sendBuffer[],
1233 unsigned long long globalReducts[])
1235 TEUCHOS_COMM_TIME_MONITOR(
1236 "Teuchos::reduceAll<int, unsigned long long> (" << count <<
", "
1237 << toString (reductType) <<
")"
1239 reduceAllImpl<unsigned long long> (comm, reductType, count, sendBuffer, globalReducts);
1243 RCP<Teuchos::CommRequest<int> >
1244 ireceive<int, unsigned long long> (
const Comm<int>& comm,
1245 const ArrayRCP<unsigned long long>& recvBuffer,
1246 const int sourceRank)
1248 TEUCHOS_COMM_TIME_MONITOR(
"ireceive<int, unsigned long long>");
1249 return ireceiveImpl<unsigned long long> (comm, recvBuffer, sourceRank);
1253 RCP<Teuchos::CommRequest<int> >
1254 ireceive<int, unsigned long long> (
const ArrayRCP<unsigned long long>& recvBuffer,
1255 const int sourceRank,
1257 const Comm<int>& comm)
1259 TEUCHOS_COMM_TIME_MONITOR(
"ireceive<int, unsigned long long>");
1260 return ireceiveImpl<unsigned long long> (recvBuffer, sourceRank, tag, comm);
1265 send<int, unsigned long long> (
const Comm<int>& comm,
1267 const unsigned long long sendBuffer[],
1270 return sendImpl<unsigned long long> (comm, count, sendBuffer, destRank);
1275 send<int, unsigned long long> (
const unsigned long long sendBuffer[],
1279 const Comm<int>& comm)
1281 return sendImpl<unsigned long long> (sendBuffer, count, destRank, tag, comm);
1285 RCP<Teuchos::CommRequest<int> >
1286 isend (
const ArrayRCP<const unsigned long long>& sendBuffer,
1289 const Comm<int>& comm)
1291 return isendImpl<unsigned long long> (sendBuffer, destRank, tag, comm);
1298 gather<int, long> (
const long sendBuf[],
1299 const int sendCount,
1301 const int recvCount,
1303 const Comm<int>& comm)
1305 gatherImpl<long> (sendBuf, sendCount, recvBuf, recvCount, root, comm);
1310 gatherv<int, long> (
const long sendBuf[],
1311 const int sendCount,
1313 const int recvCounts[],
1316 const Comm<int>& comm)
1318 gathervImpl<long> (sendBuf, sendCount, recvBuf, recvCounts, displs, root, comm);
1323 reduceAll<int, long> (
const Comm<int>& comm,
1324 const EReductionType reductType,
1326 const long sendBuffer[],
1327 long globalReducts[])
1329 TEUCHOS_COMM_TIME_MONITOR(
1330 "Teuchos::reduceAll<int, long> (" << count <<
", "
1331 << toString (reductType) <<
")"
1333 reduceAllImpl<long> (comm, reductType, count, sendBuffer, globalReducts);
1337 RCP<Teuchos::CommRequest<int> >
1338 ireceive<int, long> (
const Comm<int>& comm,
1339 const ArrayRCP<long>& recvBuffer,
1340 const int sourceRank)
1342 TEUCHOS_COMM_TIME_MONITOR(
"ireceive<int, long>");
1343 return ireceiveImpl<long> (comm, recvBuffer, sourceRank);
1347 RCP<Teuchos::CommRequest<int> >
1348 ireceive<int, long> (
const ArrayRCP<long>& recvBuffer,
1349 const int sourceRank,
1351 const Comm<int>& comm)
1353 TEUCHOS_COMM_TIME_MONITOR(
"ireceive<int, long>");
1354 return ireceiveImpl<long> (recvBuffer, sourceRank, tag, comm);
1359 send<int, long> (
const Comm<int>& comm,
1361 const long sendBuffer[],
1364 return sendImpl<long> (comm, count, sendBuffer, destRank);
1369 send<int, long> (
const long sendBuffer[],
1373 const Comm<int>& comm)
1375 return sendImpl<long> (sendBuffer, count, destRank, tag, comm);
1379 RCP<Teuchos::CommRequest<int> >
1380 isend (
const ArrayRCP<const long>& sendBuffer,
1383 const Comm<int>& comm)
1385 return isendImpl<long> (sendBuffer, destRank, tag, comm);
1392 gather<int, unsigned long> (
const unsigned long sendBuf[],
1393 const int sendCount,
1394 unsigned long recvBuf[],
1395 const int recvCount,
1397 const Comm<int>& comm)
1399 gatherImpl<unsigned long> (sendBuf, sendCount, recvBuf, recvCount, root, comm);
1404 gatherv<int, unsigned long> (
const unsigned long sendBuf[],
1405 const int sendCount,
1406 unsigned long recvBuf[],
1407 const int recvCounts[],
1410 const Comm<int>& comm)
1412 gathervImpl<unsigned long> (sendBuf, sendCount, recvBuf, recvCounts, displs, root, comm);
1417 reduceAll<int, unsigned long> (
const Comm<int>& comm,
1418 const EReductionType reductType,
1420 const unsigned long sendBuffer[],
1421 unsigned long globalReducts[])
1423 TEUCHOS_COMM_TIME_MONITOR(
1424 "Teuchos::reduceAll<int, unsigned long> (" << count <<
", "
1425 << toString (reductType) <<
")"
1427 reduceAllImpl<unsigned long> (comm, reductType, count, sendBuffer, globalReducts);
1431 RCP<Teuchos::CommRequest<int> >
1432 ireceive<int, unsigned long> (
const Comm<int>& comm,
1433 const ArrayRCP<unsigned long>& recvBuffer,
1434 const int sourceRank)
1436 TEUCHOS_COMM_TIME_MONITOR(
"ireceive<int, unsigned long>");
1437 return ireceiveImpl<unsigned long> (comm, recvBuffer, sourceRank);
1441 RCP<Teuchos::CommRequest<int> >
1442 ireceive<int, unsigned long> (
const ArrayRCP<unsigned long>& recvBuffer,
1443 const int sourceRank,
1445 const Comm<int>& comm)
1447 TEUCHOS_COMM_TIME_MONITOR(
"ireceive<int, unsigned long>");
1448 return ireceiveImpl<unsigned long> (recvBuffer, sourceRank, tag, comm);
1453 send<int, unsigned long> (
const Comm<int>& comm,
1455 const unsigned long sendBuffer[],
1458 return sendImpl<unsigned long> (comm, count, sendBuffer, destRank);
1463 send<int, unsigned long> (
const unsigned long sendBuffer[],
1467 const Comm<int>& comm)
1469 return sendImpl<unsigned long> (sendBuffer, count, destRank, tag, comm);
1473 RCP<Teuchos::CommRequest<int> >
1474 isend (
const ArrayRCP<const unsigned long>& sendBuffer,
1477 const Comm<int>& comm)
1479 return isendImpl<unsigned long> (sendBuffer, destRank, tag, comm);
1485 gather<int, int> (
const int sendBuf[],
1486 const int sendCount,
1488 const int recvCount,
1490 const Comm<int>& comm)
1492 gatherImpl<int> (sendBuf, sendCount, recvBuf, recvCount, root, comm);
1497 gatherv<int, int> (
const int sendBuf[],
1498 const int sendCount,
1500 const int recvCounts[],
1503 const Comm<int>& comm)
1505 gathervImpl<int> (sendBuf, sendCount, recvBuf, recvCounts, displs, root, comm);
1510 scatter<int, int> (
const int sendBuf[],
1511 const int sendCount,
1513 const int recvCount,
1515 const Comm<int>& comm)
1517 scatterImpl<int> (sendBuf, sendCount, recvBuf, recvCount, root, comm);
1522 reduce<int, int> (
const int sendBuf[],
1525 const EReductionType reductType,
1527 const Comm<int>& comm)
1529 TEUCHOS_COMM_TIME_MONITOR
1530 (
"Teuchos::reduce<int, int> (" << count <<
", " << toString (reductType)
1532 reduceImpl<int> (sendBuf, recvBuf, count, reductType, root, comm);
1536 reduce<int, long> (
const long sendBuf[],
1539 const EReductionType reductType,
1541 const Comm<int>& comm)
1543 TEUCHOS_COMM_TIME_MONITOR
1544 (
"Teuchos::reduce<int, int> (" << count <<
", " << toString (reductType)
1546 reduceImpl<long> (sendBuf, recvBuf, count, reductType, root, comm);
1551 reduce<int, unsigned long> (
const unsigned long sendBuf[],
1552 unsigned long recvBuf[],
1554 const EReductionType reductType,
1556 const Comm<int>& comm)
1558 TEUCHOS_COMM_TIME_MONITOR
1559 (
"Teuchos::reduce<int, int> (" << count <<
", " << toString (reductType)
1561 reduceImpl<unsigned long> (sendBuf, recvBuf, count, reductType, root, comm);
1566 reduce<int, unsigned long long > (
const unsigned long long sendBuf[],
1567 unsigned long long recvBuf[],
1569 const EReductionType reductType,
1571 const Comm<int>& comm)
1573 TEUCHOS_COMM_TIME_MONITOR
1574 (
"Teuchos::reduce<int, int> (" << count <<
", " << toString (reductType)
1576 reduceImpl<unsigned long long> (sendBuf, recvBuf, count, reductType, root, comm);
1581 reduce<int, double> (
const double sendBuf[],
1584 const EReductionType reductType,
1586 const Comm<int>& comm)
1588 TEUCHOS_COMM_TIME_MONITOR
1589 (
"Teuchos::reduce<int, int> (" << count <<
", " << toString (reductType)
1591 reduceImpl<double> (sendBuf, recvBuf, count, reductType, root, comm);
1595 reduceAll<int, int> (
const Comm<int>& comm,
1596 const EReductionType reductType,
1598 const int sendBuffer[],
1599 int globalReducts[])
1601 TEUCHOS_COMM_TIME_MONITOR(
1602 "Teuchos::reduceAll<int, int> (" << count <<
", "
1603 << toString (reductType) <<
")"
1605 reduceAllImpl<int> (comm, reductType, count, sendBuffer, globalReducts);
1609 RCP<Teuchos::CommRequest<int> >
1610 ireceive<int, int> (
const Comm<int>& comm,
1611 const ArrayRCP<int>& recvBuffer,
1612 const int sourceRank)
1614 TEUCHOS_COMM_TIME_MONITOR(
"ireceive<int, int>");
1615 return ireceiveImpl<int> (comm, recvBuffer, sourceRank);
1619 RCP<Teuchos::CommRequest<int> >
1620 ireceive<int, int> (
const ArrayRCP<int>& recvBuffer,
1621 const int sourceRank,
1623 const Comm<int>& comm)
1625 TEUCHOS_COMM_TIME_MONITOR(
"ireceive<int, int>");
1626 return ireceiveImpl<int> (recvBuffer, sourceRank, tag, comm);
1631 send<int, int> (
const Comm<int>& comm,
1633 const int sendBuffer[],
1636 return sendImpl<int> (comm, count, sendBuffer, destRank);
1641 send<int, int> (
const int sendBuffer[],
1645 const Comm<int>& comm)
1647 return sendImpl<int> (sendBuffer, count, destRank, tag, comm);
1651 RCP<Teuchos::CommRequest<int> >
1652 isend (
const ArrayRCP<const int>& sendBuffer,
1655 const Comm<int>& comm)
1657 return isendImpl<int> (sendBuffer, destRank, tag, comm);
1663 gather<int, unsigned int> (
const unsigned int sendBuf[],
1664 const int sendCount,
1665 unsigned int recvBuf[],
1666 const int recvCount,
1668 const Comm<int>& comm)
1670 gatherImpl<unsigned int> (sendBuf, sendCount, recvBuf, recvCount, root, comm);
1675 gatherv<int, unsigned int> (
const unsigned int sendBuf[],
1676 const int sendCount,
1677 unsigned int recvBuf[],
1678 const int recvCounts[],
1681 const Comm<int>& comm)
1683 gathervImpl<unsigned int> (sendBuf, sendCount, recvBuf, recvCounts, displs, root, comm);
1688 reduceAll<int, unsigned int> (
const Comm<int>& comm,
1689 const EReductionType reductType,
1691 const unsigned int sendBuffer[],
1692 unsigned int globalReducts[])
1694 TEUCHOS_COMM_TIME_MONITOR(
1695 "Teuchos::reduceAll<int, unsigned int> (" << count <<
", "
1696 << toString (reductType) <<
")"
1698 reduceAllImpl<unsigned int> (comm, reductType, count, sendBuffer, globalReducts);
1702 RCP<Teuchos::CommRequest<int> >
1703 ireceive<int, unsigned int> (
const Comm<int>& comm,
1704 const ArrayRCP<unsigned int>& recvBuffer,
1705 const int sourceRank)
1707 TEUCHOS_COMM_TIME_MONITOR(
"ireceive<int, unsigned int>");
1708 return ireceiveImpl<unsigned int> (comm, recvBuffer, sourceRank);
1712 RCP<Teuchos::CommRequest<int> >
1713 ireceive<int, unsigned int> (
const ArrayRCP<unsigned int>& recvBuffer,
1714 const int sourceRank,
1716 const Comm<int>& comm)
1718 TEUCHOS_COMM_TIME_MONITOR(
"ireceive<int, unsigned int>");
1719 return ireceiveImpl<unsigned int> (recvBuffer, sourceRank, tag, comm);
1724 send<int, unsigned int> (
const Comm<int>& comm,
1726 const unsigned int sendBuffer[],
1729 return sendImpl<unsigned int> (comm, count, sendBuffer, destRank);
1734 send<int, unsigned int> (
const unsigned int sendBuffer[],
1738 const Comm<int>& comm)
1740 return sendImpl<unsigned int> (sendBuffer, count, destRank, tag, comm);
1744 RCP<Teuchos::CommRequest<int> >
1745 isend (
const ArrayRCP<const unsigned int>& sendBuffer,
1748 const Comm<int>& comm)
1750 return isendImpl<unsigned int> (sendBuffer, destRank, tag, comm);
1757 gather<int, short> (
const short sendBuf[],
1758 const int sendCount,
1760 const int recvCount,
1762 const Comm<int>& comm)
1764 gatherImpl<short> (sendBuf, sendCount, recvBuf, recvCount, root, comm);
1769 gatherv<int, short> (
const short sendBuf[],
1770 const int sendCount,
1772 const int recvCounts[],
1775 const Comm<int>& comm)
1777 gathervImpl<short> (sendBuf, sendCount, recvBuf, recvCounts, displs, root, comm);
1782 reduceAll<int, short> (
const Comm<int>& comm,
1783 const EReductionType reductType,
1785 const short sendBuffer[],
1786 short globalReducts[])
1788 TEUCHOS_COMM_TIME_MONITOR(
1789 "Teuchos::reduceAll<int, short> (" << count <<
", "
1790 << toString (reductType) <<
")"
1792 reduceAllImpl<short> (comm, reductType, count, sendBuffer, globalReducts);
1796 RCP<Teuchos::CommRequest<int> >
1797 ireceive<int, short> (
const Comm<int>& comm,
1798 const ArrayRCP<short>& recvBuffer,
1799 const int sourceRank)
1801 TEUCHOS_COMM_TIME_MONITOR(
"ireceive<int, short>");
1802 return ireceiveImpl<short> (comm, recvBuffer, sourceRank);
1806 RCP<Teuchos::CommRequest<int> >
1807 ireceive<int, short> (
const ArrayRCP<short>& recvBuffer,
1808 const int sourceRank,
1810 const Comm<int>& comm)
1812 TEUCHOS_COMM_TIME_MONITOR(
"ireceive<int, short>");
1813 return ireceiveImpl<short> (recvBuffer, sourceRank, tag, comm);
1818 send<int, short> (
const Comm<int>& comm,
1820 const short sendBuffer[],
1823 return sendImpl<short> (comm, count, sendBuffer, destRank);
1828 send<int, short> (
const short sendBuffer[],
1832 const Comm<int>& comm)
1834 return sendImpl<short> (sendBuffer, count, destRank, tag, comm);
1838 RCP<Teuchos::CommRequest<int> >
1839 isend (
const ArrayRCP<const short>& sendBuffer,
1842 const Comm<int>& comm)
1844 return isendImpl<short> (sendBuffer, destRank, tag, comm);
1859 reduceAll<int, char> (
const Comm<int>& comm,
1860 const EReductionType reductType,
1862 const char sendBuffer[],
1863 char globalReducts[])
1865 TEUCHOS_COMM_TIME_MONITOR(
1866 "Teuchos::reduceAll<int, char> (" << count <<
", "
1867 << toString (reductType) <<
")"
1869 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.
Declaration of Teuchos::Details::MpiTypeTraits (only if building with MPI)