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
948 reduceAll<int, double> (
const Comm<int>& comm,
949 const EReductionType reductType,
951 const double sendBuffer[],
952 double globalReducts[])
954 TEUCHOS_COMM_TIME_MONITOR(
955 "Teuchos::reduceAll<int, double> (" << count <<
", "
956 << toString (reductType) <<
")"
958 reduceAllImpl<double> (comm, reductType, count, sendBuffer, globalReducts);
962 RCP<Teuchos::CommRequest<int> >
963 ireceive<int, double> (
const Comm<int>& comm,
964 const ArrayRCP<double>& recvBuffer,
965 const int sourceRank)
967 TEUCHOS_COMM_TIME_MONITOR(
"ireceive<int, double>");
968 return ireceiveImpl<double> (comm, recvBuffer, sourceRank);
972 RCP<Teuchos::CommRequest<int> >
973 ireceive<int, double> (
const ArrayRCP<double>& recvBuffer,
974 const int sourceRank,
976 const Comm<int>& comm)
978 TEUCHOS_COMM_TIME_MONITOR(
"ireceive<int, double>");
979 return ireceiveImpl<double> (recvBuffer, sourceRank, tag, comm);
984 send<int, double> (
const Comm<int>& comm,
986 const double sendBuffer[],
989 return sendImpl<double> (comm, count, sendBuffer, destRank);
994 send<int, double> (
const double sendBuffer[],
998 const Comm<int>& comm)
1000 return sendImpl<double> (sendBuffer, count, destRank, tag, comm);
1004 RCP<Teuchos::CommRequest<int> >
1005 isend (
const ArrayRCP<const double>& sendBuffer,
1008 const Comm<int>& comm)
1010 return isendImpl<double> (sendBuffer, destRank, tag, comm);
1016 reduceAll<int, float> (
const Comm<int>& comm,
1017 const EReductionType reductType,
1019 const float sendBuffer[],
1020 float globalReducts[])
1022 TEUCHOS_COMM_TIME_MONITOR(
1023 "Teuchos::reduceAll<int, float> (" << count <<
", "
1024 << toString (reductType) <<
")"
1026 reduceAllImpl<float> (comm, reductType, count, sendBuffer, globalReducts);
1030 RCP<Teuchos::CommRequest<int> >
1031 ireceive<int, float> (
const Comm<int>& comm,
1032 const ArrayRCP<float>& recvBuffer,
1033 const int sourceRank)
1035 TEUCHOS_COMM_TIME_MONITOR(
"ireceive<int, float>");
1036 return ireceiveImpl<float> (comm, recvBuffer, sourceRank);
1040 RCP<Teuchos::CommRequest<int> >
1041 ireceive<int, float> (
const ArrayRCP<float>& recvBuffer,
1042 const int sourceRank,
1044 const Comm<int>& comm)
1046 TEUCHOS_COMM_TIME_MONITOR(
"ireceive<int, float>");
1047 return ireceiveImpl<float> (recvBuffer, sourceRank, tag, comm);
1052 send<int, float> (
const Comm<int>& comm,
1054 const float sendBuffer[],
1057 return sendImpl<float> (comm, count, sendBuffer, destRank);
1062 send<int, float> (
const float sendBuffer[],
1066 const Comm<int>& comm)
1068 return sendImpl<float> (sendBuffer, count, destRank, tag, comm);
1072 RCP<Teuchos::CommRequest<int> >
1073 isend (
const ArrayRCP<const float>& sendBuffer,
1076 const Comm<int>& comm)
1078 return isendImpl<float> (sendBuffer, destRank, tag, comm);
1085 gather<int, long long> (
const long long sendBuf[],
1086 const int sendCount,
1087 long long recvBuf[],
1088 const int recvCount,
1090 const Comm<int>& comm)
1092 gatherImpl<long long> (sendBuf, sendCount, recvBuf, recvCount, root, comm);
1097 gatherv<int, long long> (
const long long sendBuf[],
1098 const int sendCount,
1099 long long recvBuf[],
1100 const int recvCounts[],
1103 const Comm<int>& comm)
1105 gathervImpl<long long> (sendBuf, sendCount, recvBuf, recvCounts, displs, root, comm);
1110 reduceAll<int, long long> (
const Comm<int>& comm,
1111 const EReductionType reductType,
1113 const long long sendBuffer[],
1114 long long globalReducts[])
1116 TEUCHOS_COMM_TIME_MONITOR(
1117 "Teuchos::reduceAll<int, long long> (" << count <<
", "
1118 << toString (reductType) <<
")"
1120 reduceAllImpl<long long> (comm, reductType, count, sendBuffer, globalReducts);
1124 RCP<Teuchos::CommRequest<int> >
1125 ireceive<int, long long> (
const Comm<int>& comm,
1126 const ArrayRCP<long long>& recvBuffer,
1127 const int sourceRank)
1129 TEUCHOS_COMM_TIME_MONITOR(
"ireceive<int, long long>");
1130 return ireceiveImpl<long long> (comm, recvBuffer, sourceRank);
1134 RCP<Teuchos::CommRequest<int> >
1135 ireceive<int, long long> (
const ArrayRCP<long long>& recvBuffer,
1136 const int sourceRank,
1138 const Comm<int>& comm)
1140 TEUCHOS_COMM_TIME_MONITOR(
"ireceive<int, long long>");
1141 return ireceiveImpl<long long> (recvBuffer, sourceRank, tag, comm);
1146 send<int, long long> (
const Comm<int>& comm,
1148 const long long sendBuffer[],
1151 return sendImpl<long long> (comm, count, sendBuffer, destRank);
1156 send<int, long long> (
const long long sendBuffer[],
1160 const Comm<int>& comm)
1162 return sendImpl<long long> (sendBuffer, count, destRank, tag, comm);
1166 RCP<Teuchos::CommRequest<int> >
1167 isend (
const ArrayRCP<const long long>& sendBuffer,
1170 const Comm<int>& comm)
1172 return isendImpl<long long> (sendBuffer, destRank, tag, comm);
1178 gather<int, unsigned long long> (
const unsigned long long sendBuf[],
1179 const int sendCount,
1180 unsigned long long recvBuf[],
1181 const int recvCount,
1183 const Comm<int>& comm)
1185 gatherImpl<unsigned long long> (sendBuf, sendCount, recvBuf, recvCount, root, comm);
1190 gatherv<int, unsigned long long> (
const unsigned long long sendBuf[],
1191 const int sendCount,
1192 unsigned long long recvBuf[],
1193 const int recvCounts[],
1196 const Comm<int>& comm)
1198 gathervImpl<unsigned long long> (sendBuf, sendCount, recvBuf, recvCounts, displs, root, comm);
1203 reduceAll<int, unsigned long long> (
const Comm<int>& comm,
1204 const EReductionType reductType,
1206 const unsigned long long sendBuffer[],
1207 unsigned long long globalReducts[])
1209 TEUCHOS_COMM_TIME_MONITOR(
1210 "Teuchos::reduceAll<int, unsigned long long> (" << count <<
", "
1211 << toString (reductType) <<
")"
1213 reduceAllImpl<unsigned long long> (comm, reductType, count, sendBuffer, globalReducts);
1217 RCP<Teuchos::CommRequest<int> >
1218 ireceive<int, unsigned long long> (
const Comm<int>& comm,
1219 const ArrayRCP<unsigned long long>& recvBuffer,
1220 const int sourceRank)
1222 TEUCHOS_COMM_TIME_MONITOR(
"ireceive<int, unsigned long long>");
1223 return ireceiveImpl<unsigned long long> (comm, recvBuffer, sourceRank);
1227 RCP<Teuchos::CommRequest<int> >
1228 ireceive<int, unsigned long long> (
const ArrayRCP<unsigned long long>& recvBuffer,
1229 const int sourceRank,
1231 const Comm<int>& comm)
1233 TEUCHOS_COMM_TIME_MONITOR(
"ireceive<int, unsigned long long>");
1234 return ireceiveImpl<unsigned long long> (recvBuffer, sourceRank, tag, comm);
1239 send<int, unsigned long long> (
const Comm<int>& comm,
1241 const unsigned long long sendBuffer[],
1244 return sendImpl<unsigned long long> (comm, count, sendBuffer, destRank);
1249 send<int, unsigned long long> (
const unsigned long long sendBuffer[],
1253 const Comm<int>& comm)
1255 return sendImpl<unsigned long long> (sendBuffer, count, destRank, tag, comm);
1259 RCP<Teuchos::CommRequest<int> >
1260 isend (
const ArrayRCP<const unsigned long long>& sendBuffer,
1263 const Comm<int>& comm)
1265 return isendImpl<unsigned long long> (sendBuffer, destRank, tag, comm);
1272 gather<int, long> (
const long sendBuf[],
1273 const int sendCount,
1275 const int recvCount,
1277 const Comm<int>& comm)
1279 gatherImpl<long> (sendBuf, sendCount, recvBuf, recvCount, root, comm);
1284 gatherv<int, long> (
const long sendBuf[],
1285 const int sendCount,
1287 const int recvCounts[],
1290 const Comm<int>& comm)
1292 gathervImpl<long> (sendBuf, sendCount, recvBuf, recvCounts, displs, root, comm);
1297 reduceAll<int, long> (
const Comm<int>& comm,
1298 const EReductionType reductType,
1300 const long sendBuffer[],
1301 long globalReducts[])
1303 TEUCHOS_COMM_TIME_MONITOR(
1304 "Teuchos::reduceAll<int, long> (" << count <<
", "
1305 << toString (reductType) <<
")"
1307 reduceAllImpl<long> (comm, reductType, count, sendBuffer, globalReducts);
1311 RCP<Teuchos::CommRequest<int> >
1312 ireceive<int, long> (
const Comm<int>& comm,
1313 const ArrayRCP<long>& recvBuffer,
1314 const int sourceRank)
1316 TEUCHOS_COMM_TIME_MONITOR(
"ireceive<int, long>");
1317 return ireceiveImpl<long> (comm, recvBuffer, sourceRank);
1321 RCP<Teuchos::CommRequest<int> >
1322 ireceive<int, long> (
const ArrayRCP<long>& recvBuffer,
1323 const int sourceRank,
1325 const Comm<int>& comm)
1327 TEUCHOS_COMM_TIME_MONITOR(
"ireceive<int, long>");
1328 return ireceiveImpl<long> (recvBuffer, sourceRank, tag, comm);
1333 send<int, long> (
const Comm<int>& comm,
1335 const long sendBuffer[],
1338 return sendImpl<long> (comm, count, sendBuffer, destRank);
1343 send<int, long> (
const long sendBuffer[],
1347 const Comm<int>& comm)
1349 return sendImpl<long> (sendBuffer, count, destRank, tag, comm);
1353 RCP<Teuchos::CommRequest<int> >
1354 isend (
const ArrayRCP<const long>& sendBuffer,
1357 const Comm<int>& comm)
1359 return isendImpl<long> (sendBuffer, destRank, tag, comm);
1366 gather<int, unsigned long> (
const unsigned long sendBuf[],
1367 const int sendCount,
1368 unsigned long recvBuf[],
1369 const int recvCount,
1371 const Comm<int>& comm)
1373 gatherImpl<unsigned long> (sendBuf, sendCount, recvBuf, recvCount, root, comm);
1378 gatherv<int, unsigned long> (
const unsigned long sendBuf[],
1379 const int sendCount,
1380 unsigned long recvBuf[],
1381 const int recvCounts[],
1384 const Comm<int>& comm)
1386 gathervImpl<unsigned long> (sendBuf, sendCount, recvBuf, recvCounts, displs, root, comm);
1391 reduceAll<int, unsigned long> (
const Comm<int>& comm,
1392 const EReductionType reductType,
1394 const unsigned long sendBuffer[],
1395 unsigned long globalReducts[])
1397 TEUCHOS_COMM_TIME_MONITOR(
1398 "Teuchos::reduceAll<int, unsigned long> (" << count <<
", "
1399 << toString (reductType) <<
")"
1401 reduceAllImpl<unsigned long> (comm, reductType, count, sendBuffer, globalReducts);
1405 RCP<Teuchos::CommRequest<int> >
1406 ireceive<int, unsigned long> (
const Comm<int>& comm,
1407 const ArrayRCP<unsigned long>& recvBuffer,
1408 const int sourceRank)
1410 TEUCHOS_COMM_TIME_MONITOR(
"ireceive<int, unsigned long>");
1411 return ireceiveImpl<unsigned long> (comm, recvBuffer, sourceRank);
1415 RCP<Teuchos::CommRequest<int> >
1416 ireceive<int, unsigned long> (
const ArrayRCP<unsigned long>& recvBuffer,
1417 const int sourceRank,
1419 const Comm<int>& comm)
1421 TEUCHOS_COMM_TIME_MONITOR(
"ireceive<int, unsigned long>");
1422 return ireceiveImpl<unsigned long> (recvBuffer, sourceRank, tag, comm);
1427 send<int, unsigned long> (
const Comm<int>& comm,
1429 const unsigned long sendBuffer[],
1432 return sendImpl<unsigned long> (comm, count, sendBuffer, destRank);
1437 send<int, unsigned long> (
const unsigned long sendBuffer[],
1441 const Comm<int>& comm)
1443 return sendImpl<unsigned long> (sendBuffer, count, destRank, tag, comm);
1447 RCP<Teuchos::CommRequest<int> >
1448 isend (
const ArrayRCP<const unsigned long>& sendBuffer,
1451 const Comm<int>& comm)
1453 return isendImpl<unsigned long> (sendBuffer, destRank, tag, comm);
1459 gather<int, int> (
const int sendBuf[],
1460 const int sendCount,
1462 const int recvCount,
1464 const Comm<int>& comm)
1466 gatherImpl<int> (sendBuf, sendCount, recvBuf, recvCount, root, comm);
1471 gatherv<int, int> (
const int sendBuf[],
1472 const int sendCount,
1474 const int recvCounts[],
1477 const Comm<int>& comm)
1479 gathervImpl<int> (sendBuf, sendCount, recvBuf, recvCounts, displs, root, comm);
1484 scatter<int, int> (
const int sendBuf[],
1485 const int sendCount,
1487 const int recvCount,
1489 const Comm<int>& comm)
1491 scatterImpl<int> (sendBuf, sendCount, recvBuf, recvCount, root, comm);
1496 reduce<int, int> (
const int sendBuf[],
1499 const EReductionType reductType,
1501 const Comm<int>& comm)
1503 TEUCHOS_COMM_TIME_MONITOR
1504 (
"Teuchos::reduce<int, int> (" << count <<
", " << toString (reductType)
1506 reduceImpl<int> (sendBuf, recvBuf, count, reductType, root, comm);
1510 reduce<int, long> (
const long sendBuf[],
1513 const EReductionType reductType,
1515 const Comm<int>& comm)
1517 TEUCHOS_COMM_TIME_MONITOR
1518 (
"Teuchos::reduce<int, int> (" << count <<
", " << toString (reductType)
1520 reduceImpl<long> (sendBuf, recvBuf, count, reductType, root, comm);
1525 reduce<int, unsigned long> (
const unsigned long sendBuf[],
1526 unsigned long recvBuf[],
1528 const EReductionType reductType,
1530 const Comm<int>& comm)
1532 TEUCHOS_COMM_TIME_MONITOR
1533 (
"Teuchos::reduce<int, int> (" << count <<
", " << toString (reductType)
1535 reduceImpl<unsigned long> (sendBuf, recvBuf, count, reductType, root, comm);
1540 reduce<int, unsigned long long > (
const unsigned long long sendBuf[],
1541 unsigned long long recvBuf[],
1543 const EReductionType reductType,
1545 const Comm<int>& comm)
1547 TEUCHOS_COMM_TIME_MONITOR
1548 (
"Teuchos::reduce<int, int> (" << count <<
", " << toString (reductType)
1550 reduceImpl<unsigned long long> (sendBuf, recvBuf, count, reductType, root, comm);
1555 reduce<int, double> (
const double sendBuf[],
1558 const EReductionType reductType,
1560 const Comm<int>& comm)
1562 TEUCHOS_COMM_TIME_MONITOR
1563 (
"Teuchos::reduce<int, int> (" << count <<
", " << toString (reductType)
1565 reduceImpl<double> (sendBuf, recvBuf, count, reductType, root, comm);
1569 reduceAll<int, int> (
const Comm<int>& comm,
1570 const EReductionType reductType,
1572 const int sendBuffer[],
1573 int globalReducts[])
1575 TEUCHOS_COMM_TIME_MONITOR(
1576 "Teuchos::reduceAll<int, int> (" << count <<
", "
1577 << toString (reductType) <<
")"
1579 reduceAllImpl<int> (comm, reductType, count, sendBuffer, globalReducts);
1583 RCP<Teuchos::CommRequest<int> >
1584 ireceive<int, int> (
const Comm<int>& comm,
1585 const ArrayRCP<int>& recvBuffer,
1586 const int sourceRank)
1588 TEUCHOS_COMM_TIME_MONITOR(
"ireceive<int, int>");
1589 return ireceiveImpl<int> (comm, recvBuffer, sourceRank);
1593 RCP<Teuchos::CommRequest<int> >
1594 ireceive<int, int> (
const ArrayRCP<int>& recvBuffer,
1595 const int sourceRank,
1597 const Comm<int>& comm)
1599 TEUCHOS_COMM_TIME_MONITOR(
"ireceive<int, int>");
1600 return ireceiveImpl<int> (recvBuffer, sourceRank, tag, comm);
1605 send<int, int> (
const Comm<int>& comm,
1607 const int sendBuffer[],
1610 return sendImpl<int> (comm, count, sendBuffer, destRank);
1615 send<int, int> (
const int sendBuffer[],
1619 const Comm<int>& comm)
1621 return sendImpl<int> (sendBuffer, count, destRank, tag, comm);
1625 RCP<Teuchos::CommRequest<int> >
1626 isend (
const ArrayRCP<const int>& sendBuffer,
1629 const Comm<int>& comm)
1631 return isendImpl<int> (sendBuffer, destRank, tag, comm);
1637 gather<int, unsigned int> (
const unsigned int sendBuf[],
1638 const int sendCount,
1639 unsigned int recvBuf[],
1640 const int recvCount,
1642 const Comm<int>& comm)
1644 gatherImpl<unsigned int> (sendBuf, sendCount, recvBuf, recvCount, root, comm);
1649 gatherv<int, unsigned int> (
const unsigned int sendBuf[],
1650 const int sendCount,
1651 unsigned int recvBuf[],
1652 const int recvCounts[],
1655 const Comm<int>& comm)
1657 gathervImpl<unsigned int> (sendBuf, sendCount, recvBuf, recvCounts, displs, root, comm);
1662 reduceAll<int, unsigned int> (
const Comm<int>& comm,
1663 const EReductionType reductType,
1665 const unsigned int sendBuffer[],
1666 unsigned int globalReducts[])
1668 TEUCHOS_COMM_TIME_MONITOR(
1669 "Teuchos::reduceAll<int, unsigned int> (" << count <<
", "
1670 << toString (reductType) <<
")"
1672 reduceAllImpl<unsigned int> (comm, reductType, count, sendBuffer, globalReducts);
1676 RCP<Teuchos::CommRequest<int> >
1677 ireceive<int, unsigned int> (
const Comm<int>& comm,
1678 const ArrayRCP<unsigned int>& recvBuffer,
1679 const int sourceRank)
1681 TEUCHOS_COMM_TIME_MONITOR(
"ireceive<int, unsigned int>");
1682 return ireceiveImpl<unsigned int> (comm, recvBuffer, sourceRank);
1686 RCP<Teuchos::CommRequest<int> >
1687 ireceive<int, unsigned int> (
const ArrayRCP<unsigned int>& recvBuffer,
1688 const int sourceRank,
1690 const Comm<int>& comm)
1692 TEUCHOS_COMM_TIME_MONITOR(
"ireceive<int, unsigned int>");
1693 return ireceiveImpl<unsigned int> (recvBuffer, sourceRank, tag, comm);
1698 send<int, unsigned int> (
const Comm<int>& comm,
1700 const unsigned int sendBuffer[],
1703 return sendImpl<unsigned int> (comm, count, sendBuffer, destRank);
1708 send<int, unsigned int> (
const unsigned int sendBuffer[],
1712 const Comm<int>& comm)
1714 return sendImpl<unsigned int> (sendBuffer, count, destRank, tag, comm);
1718 RCP<Teuchos::CommRequest<int> >
1719 isend (
const ArrayRCP<const unsigned int>& sendBuffer,
1722 const Comm<int>& comm)
1724 return isendImpl<unsigned int> (sendBuffer, destRank, tag, comm);
1731 gather<int, short> (
const short sendBuf[],
1732 const int sendCount,
1734 const int recvCount,
1736 const Comm<int>& comm)
1738 gatherImpl<short> (sendBuf, sendCount, recvBuf, recvCount, root, comm);
1743 gatherv<int, short> (
const short sendBuf[],
1744 const int sendCount,
1746 const int recvCounts[],
1749 const Comm<int>& comm)
1751 gathervImpl<short> (sendBuf, sendCount, recvBuf, recvCounts, displs, root, comm);
1756 reduceAll<int, short> (
const Comm<int>& comm,
1757 const EReductionType reductType,
1759 const short sendBuffer[],
1760 short globalReducts[])
1762 TEUCHOS_COMM_TIME_MONITOR(
1763 "Teuchos::reduceAll<int, short> (" << count <<
", "
1764 << toString (reductType) <<
")"
1766 reduceAllImpl<short> (comm, reductType, count, sendBuffer, globalReducts);
1770 RCP<Teuchos::CommRequest<int> >
1771 ireceive<int, short> (
const Comm<int>& comm,
1772 const ArrayRCP<short>& recvBuffer,
1773 const int sourceRank)
1775 TEUCHOS_COMM_TIME_MONITOR(
"ireceive<int, short>");
1776 return ireceiveImpl<short> (comm, recvBuffer, sourceRank);
1780 RCP<Teuchos::CommRequest<int> >
1781 ireceive<int, short> (
const ArrayRCP<short>& recvBuffer,
1782 const int sourceRank,
1784 const Comm<int>& comm)
1786 TEUCHOS_COMM_TIME_MONITOR(
"ireceive<int, short>");
1787 return ireceiveImpl<short> (recvBuffer, sourceRank, tag, comm);
1792 send<int, short> (
const Comm<int>& comm,
1794 const short sendBuffer[],
1797 return sendImpl<short> (comm, count, sendBuffer, destRank);
1802 send<int, short> (
const short sendBuffer[],
1806 const Comm<int>& comm)
1808 return sendImpl<short> (sendBuffer, count, destRank, tag, comm);
1812 RCP<Teuchos::CommRequest<int> >
1813 isend (
const ArrayRCP<const short>& sendBuffer,
1816 const Comm<int>& comm)
1818 return isendImpl<short> (sendBuffer, destRank, tag, comm);
1833 reduceAll<int, char> (
const Comm<int>& comm,
1834 const EReductionType reductType,
1836 const char sendBuffer[],
1837 char globalReducts[])
1839 TEUCHOS_COMM_TIME_MONITOR(
1840 "Teuchos::reduceAll<int, char> (" << count <<
", "
1841 << toString (reductType) <<
")"
1843 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)