Teuchos Package Browser (Single Doxygen Collection)  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Teuchos_CommHelpers.hpp
Go to the documentation of this file.
1 // @HEADER
2 // ***********************************************************************
3 //
4 // Teuchos: Common Tools Package
5 // Copyright (2004) Sandia Corporation
6 //
7 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
8 // license for use of this work by or on behalf of the U.S. Government.
9 //
10 // Redistribution and use in source and binary forms, with or without
11 // modification, are permitted provided that the following conditions are
12 // met:
13 //
14 // 1. Redistributions of source code must retain the above copyright
15 // notice, this list of conditions and the following disclaimer.
16 //
17 // 2. Redistributions in binary form must reproduce the above copyright
18 // notice, this list of conditions and the following disclaimer in the
19 // documentation and/or other materials provided with the distribution.
20 //
21 // 3. Neither the name of the Corporation nor the names of the
22 // contributors may be used to endorse or promote products derived from
23 // this software without specific prior written permission.
24 //
25 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
26 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
29 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
30 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
31 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
32 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
33 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
34 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
35 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 //
37 // Questions? Contact Michael A. Heroux (maherou@sandia.gov)
38 //
39 // ***********************************************************************
40 // @HEADER
41 
42 #ifndef TEUCHOS_COMM_HELPERS_HPP
43 #define TEUCHOS_COMM_HELPERS_HPP
44 
45 #include "Teuchos_Comm.hpp"
50 #include "Teuchos_ScalarTraits.hpp"
52 #include "Teuchos_Array.hpp"
54 #include "Teuchos_Workspace.hpp"
55 #include "Teuchos_as.hpp"
56 
57 #ifdef HAVE_TEUCHOS_MPI
59 #endif // HAVE_TEUCHOS_MPI
62 
63 namespace Teuchos {
64 
65 //
66 // Teuchos::Comm Helper Functions
67 //
68 
69 #ifdef HAVE_TEUCHOS_MPI
70 namespace Details {
71 
78 std::string getMpiErrorString (const int errCode);
79 
80 } // namespace Details
81 #endif // HAVE_TEUCHOS_MPI
82 
87 template<typename Ordinal>
88 int rank(const Comm<Ordinal>& comm);
89 
94 template<typename Ordinal>
95 int size(const Comm<Ordinal>& comm);
96 
101 template<typename Ordinal>
102 void barrier(const Comm<Ordinal>& comm);
103 
108 template<typename Ordinal, typename Packet>
109 void broadcast(
110  const Comm<Ordinal>& comm,
111  const int rootRank,
112  const Ordinal count, Packet buffer[]
113  );
114 
119 template<typename Ordinal, typename Packet>
120 void broadcast(
121  const Comm<Ordinal>& comm,
122  const int rootRank,
123  const ArrayView<Packet> &buffer
124  );
125 
130 template<typename Ordinal, typename Packet>
131 void broadcast(
132  const Comm<Ordinal>& comm,
133  const int rootRank, Packet *object
134  );
135 
140 template<typename Ordinal, typename Packet>
141 void broadcast(
142  const Comm<Ordinal>& comm,
143  const int rootRank, const Ptr<Packet> &object
144  );
145 
150 template<typename Ordinal, typename Packet>
151 void broadcast(
152  const Comm<Ordinal>& comm, const Serializer<Ordinal,Packet> &serializer,
153  const int rootRank, const Ordinal count, Packet*const buffer[]
154  );
155 
160 template<typename Ordinal, typename Packet>
161 void broadcast(
162  const Comm<Ordinal>& comm, const Serializer<Ordinal,Packet> &serializer,
163  const int rootRank, const ArrayView<const Ptr<Packet> > &buffer
164  );
165 
171 template<typename Ordinal, typename Packet, typename Serializer>
172 void broadcast(
173  const Comm<Ordinal>& comm,
174  const Serializer& serializer,
175  const int rootRank,
176  const Ordinal count, Packet buffer[]
177  );
178 
183 template<typename Ordinal, typename Packet>
184 void
185 gather (const Packet sendBuf[],
186  const Ordinal sendCount,
187  Packet recvBuf[],
188  const Ordinal recvCount,
189  const int root,
190  const Comm<Ordinal>& comm);
191 
196 template<typename Ordinal, typename Packet>
197 void
198 gatherv (const Packet sendBuf[],
199  const Ordinal sendCount,
200  Packet recvBuf[],
201  const Ordinal recvCounts[],
202  const Ordinal displs[],
203  const int root,
204  const Comm<Ordinal>& comm);
205 
211 template<typename Ordinal, typename Packet>
212 void gatherAll(
213  const Comm<Ordinal>& comm,
214  const Ordinal sendCount, const Packet sendBuffer[],
215  const Ordinal recvCount, Packet recvBuffer[]
216  );
217 
223 template<typename Ordinal, typename Packet>
224 void gatherAll(
225  const Comm<Ordinal>& comm, const Serializer<Ordinal,Packet> &serializer,
226  const Ordinal sendCount, const Packet*const sendBuffer[],
227  const Ordinal recvCount, Packet*const recvBuffer[]
228  );
229 
235 template<typename Ordinal, typename Packet, typename Serializer>
236 void gatherAll(
237  const Comm<Ordinal>& comm,
238  const Serializer& serializer,
239  const Ordinal sendCount, const Packet sendBuffer[],
240  const Ordinal recvCount, Packet recvBuffer[]
241  );
242 
269 template<typename Ordinal, typename Packet>
270 void
271 scatter (const Packet sendBuf[],
272  const Ordinal sendCount,
273  Packet recvBuf[],
274  const Ordinal recvCount,
275  const Ordinal root,
276  const Comm<Ordinal>& comm)
277 {
278  // See Bug 6375; Tpetra does not actually need any specializations
279  // other than Ordinal = int and Packet = int. We may add them later
280  // if there is interest.
282  (true, std::logic_error, "Teuchos::scatter<" <<
284  << ">: Generic version is not yet implemented. This function currently "
285  "only has an implementtion for Ordinal = int and Packet = int. "
286  "See Bug 6375 and Bug 6336.");
287 }
288 
316 template<typename Ordinal, typename Packet>
317 void
318 reduce (const Packet sendBuf[],
319  Packet recvBuf[],
320  const Ordinal count,
321  const EReductionType reductType,
322  const Ordinal root,
323  const Comm<Ordinal>& comm);
324 
347 template<typename Ordinal, typename Packet>
348 void reduceAll(
349  const Comm<Ordinal>& comm, const ValueTypeReductionOp<Ordinal,Packet> &reductOp,
350  const Ordinal count, const Packet sendBuffer[], Packet globalReducts[]
351  );
352 
358 template<typename Ordinal, typename Packet>
359 void reduceAll(
360  const Comm<Ordinal>& comm, const EReductionType reductType,
361  const Ordinal count, const Packet sendBuffer[], Packet globalReducts[]
362  );
363 
369 template<typename Ordinal, typename Packet>
370 void reduceAll(
371  const Comm<Ordinal>& comm, const EReductionType reductType,
372  const Packet &send, const Ptr<Packet> &globalReduct
373  );
374 
380 template<typename Ordinal, typename Packet>
381 void reduceAll(
382  const Comm<Ordinal>& comm, const Serializer<Ordinal,Packet> &serializer,
384  const Ordinal count, const Packet*const sendBuffer[], Packet*const globalReducts[]
385  );
386 
392 template<typename Ordinal, typename Packet, typename Serializer>
393 void reduceAll(
394  const Comm<Ordinal>& comm,
395  const Serializer& serializer,
396  const ValueTypeReductionOp<Ordinal,Packet> &reductOp,
397  const Ordinal count, const Packet sendBuffer[], Packet globalReducts[]
398  );
399 
405 template<typename Ordinal, typename Packet, typename Serializer>
406 void reduceAll(
407  const Comm<Ordinal>& comm,
408  const Serializer& serializer,
409  const EReductionType reductType,
410  const Ordinal count, const Packet sendBuffer[], Packet globalReducts[]
411  );
412 
418 template<typename Ordinal, typename Packet>
419 void scan(
420  const Comm<Ordinal>& comm, const ValueTypeReductionOp<Ordinal,Packet> &reductOp,
421  const Ordinal count, const Packet sendBuffer[], Packet scanReducts[]
422  );
423 
429 template<typename Ordinal, typename Packet>
430 void scan(
431  const Comm<Ordinal>& comm, const EReductionType reductType,
432  const Ordinal count, const Packet sendBuffer[], Packet scanReducts[]
433  );
434 
440 template<typename Ordinal, typename Packet>
441 void scan(
442  const Comm<Ordinal>& comm, const EReductionType reductType,
443  const Packet &send, const Ptr<Packet> &scanReduct
444  );
445 
451 template<typename Ordinal, typename Packet>
452 void scan(
453  const Comm<Ordinal>& comm, const Serializer<Ordinal,Packet> &serializer,
455  const Ordinal count, const Packet*const sendBuffer[], Packet*const scanReducts[]
456  );
457 
463 template<typename Ordinal, typename Packet, typename Serializer>
464 void scan(
465  const Comm<Ordinal>& comm,
466  const Serializer& serializer,
467  const ValueTypeReductionOp<Ordinal,Packet> &reductOp,
468  const Ordinal count, const Packet sendBuffer[], Packet scanReducts[]
469  );
470 
476 template<typename Ordinal, typename Packet, typename Serializer>
477 void scan(
478  const Comm<Ordinal>& comm,
479  const Serializer& serializer,
480  const EReductionType reductType,
481  const Ordinal count, const Packet sendBuffer[], Packet scanReducts[]
482  );
483 
488 template<typename Ordinal, typename Packet>
489 void send(
490  const Comm<Ordinal>& comm,
491  const Ordinal count, const Packet sendBuffer[], const int destRank
492  );
493 
495 template<typename Ordinal, typename Packet>
496 void
497 send (const Packet sendBuffer[],
498  const Ordinal count,
499  const int destRank,
500  const int tag,
501  const Comm<Ordinal>& comm);
502 
507 template<typename Ordinal, typename Packet>
508 void ssend(
509  const Comm<Ordinal>& comm,
510  const Ordinal count, const Packet sendBuffer[], const int destRank
511  );
512 
514 template<typename Ordinal, typename Packet>
515 void
516 ssend (const Packet sendBuffer[],
517  const Ordinal count,
518  const int destRank,
519  const int tag,
520  const Comm<Ordinal>& comm);
521 
526 template<typename Ordinal, typename Packet>
527 void send(
528  const Comm<Ordinal>& comm,
529  const Packet &send, const int destRank
530  );
531 
536 template<typename Ordinal, typename Packet>
537 void ssend(
538  const Comm<Ordinal>& comm,
539  const Packet &send, const int destRank
540  );
541 
548 template<typename Ordinal, typename Packet>
549 void send(
550  const Comm<Ordinal>& comm, const Serializer<Ordinal,Packet> &serializer,
551  const Ordinal count, const Packet*const sendBuffer[], const int destRank
552  );
553 
559 template<typename Ordinal, typename Packet, typename Serializer>
560 void send(
561  const Comm<Ordinal>& comm,
562  const Serializer& serializer,
563  const Ordinal count, const Packet sendBuffer[], const int destRank
564  );
565 
570 template<typename Ordinal, typename Packet>
571 int receive(
572  const Comm<Ordinal>& comm,
573  const int sourceRank, const Ordinal count, Packet recvBuffer[]
574  );
575 
580 template<typename Ordinal, typename Packet>
581 int receive(
582  const Comm<Ordinal>& comm,
583  const int sourceRank, Packet *recv
584  );
585 
590 template<typename Ordinal, typename Packet>
591 int receive(
592  const Comm<Ordinal>& comm, const Serializer<Ordinal,Packet> &serializer,
593  const int sourceRank, const Ordinal count, Packet*const recvBuffer[]
594  );
595 
601 template<typename Ordinal, typename Packet, typename Serializer>
602 int receive(
603  const Comm<Ordinal>& comm,
604  const Serializer& serializer,
605  const int sourceRank, const Ordinal count, Packet recvBuffer[]
606  );
607 
613 template<typename Ordinal, typename Packet>
614 void readySend(
615  const Comm<Ordinal>& comm,
616  const ArrayView<const Packet> &sendBuffer,
617  const int destRank
618  );
619 
621 template<typename Ordinal, typename Packet>
622 void
623 readySend (const Packet sendBuffer[],
624  const Ordinal count,
625  const int destRank,
626  const int tag,
627  const Comm<Ordinal>& comm);
628 
633 template<typename Ordinal, typename Packet>
634 void readySend(
635  const Comm<Ordinal>& comm,
636  const Packet &send,
637  const int destRank
638  );
639 
645 template<typename Ordinal, typename Packet, typename Serializer>
646 void readySend(
647  const Comm<Ordinal>& comm,
648  const Serializer& serializer,
649  const ArrayView<const Packet> &sendBuffer,
650  const int destRank
651  );
652 
657 template<typename Ordinal, typename Packet>
659  const Comm<Ordinal>& comm,
660  const ArrayRCP<const Packet> &sendBuffer,
661  const int destRank
662  );
663 
665 template<typename Ordinal, typename Packet>
667 isend (const ArrayRCP<const Packet>& sendBuffer,
668  const int destRank,
669  const int tag,
670  const Comm<Ordinal>& comm);
671 
676 template<typename Ordinal, typename Packet>
678  const Comm<Ordinal>& comm,
679  const RCP<const Packet> &send,
680  const int destRank
681  );
682 
688 template<typename Ordinal, typename Packet, typename Serializer>
690  const Comm<Ordinal>& comm,
691  const Serializer& serializer,
692  const ArrayRCP<const Packet> &sendBuffer,
693  const int destRank
694  );
695 
696 
697 // 2008/07/29: rabartl: ToDo: Add reference semantics version of isend!
698 
699 
709 template<typename Ordinal, typename Packet>
711  const Comm<Ordinal>& comm,
712  const ArrayRCP<Packet> &recvBuffer,
713  const int sourceRank
714  );
715 
717 template<typename Ordinal, typename Packet>
719 ireceive (const ArrayRCP<Packet> &recvBuffer,
720  const int sourceRank,
721  const int tag,
722  const Comm<Ordinal>& comm);
723 
735 template<typename Ordinal, typename Packet>
737  const Comm<Ordinal>& comm,
738  const RCP<Packet> &recv,
739  const int sourceRank
740  );
741 
747 template<typename Ordinal, typename Packet, typename Serializer>
749  const Comm<Ordinal>& comm,
750  const Serializer& serializer,
751  const ArrayRCP<Packet> &recvBuffer,
752  const int sourceRank
753  );
754 
755 
756 // 2008/07/29: rabartl: ToDo: Add reference semantics version of ireceive!
757 
758 
766 template<typename Ordinal>
767 void waitAll(
768  const Comm<Ordinal>& comm,
769  const ArrayView<RCP<CommRequest<Ordinal> > > &requests
770  );
771 
801 template<typename Ordinal>
802 void
803 waitAll (const Comm<Ordinal>& comm,
804  const ArrayView<RCP<CommRequest<Ordinal> > >& requests,
805  const ArrayView<RCP<CommStatus<Ordinal> > >& statuses);
806 
830 template<typename Ordinal>
832 wait (const Comm<Ordinal>& comm, const Ptr<RCP<CommRequest<Ordinal> > >& request);
833 
834 //
835 // Standard reduction subclasses for objects that use value semantics
836 //
837 
838 
843 template<typename Ordinal, typename Packet>
844 class SumValueReductionOp : public ValueTypeReductionOp<Ordinal,Packet>
845 {
846 public:
848  void reduce(
849  const Ordinal count,
850  const Packet inBuffer[],
851  Packet inoutBuffer[]
852  ) const;
853 };
854 
855 
864 template<typename Ordinal, typename Packet>
865 class MinValueReductionOp : public ValueTypeReductionOp<Ordinal,Packet>
866 {
867 public:
869  void reduce(
870  const Ordinal count,
871  const Packet inBuffer[],
872  Packet inoutBuffer[]
873  ) const;
874 };
875 
876 
885 template<typename Ordinal, typename Packet>
886 class MaxValueReductionOp : public ValueTypeReductionOp<Ordinal,Packet>
887 {
888 public:
890  void reduce(
891  const Ordinal count,
892  const Packet inBuffer[],
893  Packet inoutBuffer[]
894  ) const;
895 };
896 
897 
902 template<typename Ordinal, typename Packet>
903 class ANDValueReductionOp : public ValueTypeReductionOp<Ordinal,Packet>
904 {
905 public:
907  void reduce(
908  const Ordinal count,
909  const Packet inBuffer[],
910  Packet inoutBuffer[]
911  ) const;
912 };
913 
914 
915 // ////////////////////////////////////////////////////////////
916 // Implementation details (not for geneal users to mess with)
917 
918 
919 //
920 // ReductionOp Utilities
921 //
922 
923 
924 namespace MixMaxUtilities {
925 
926 
927 template<bool isComparable, typename Ordinal, typename Packet>
928 class Min {};
929 
930 
931 template<typename Ordinal, typename Packet>
932 class Min<true,Ordinal,Packet> {
933 public:
934  static void min(
935  const Ordinal count,
936  const Packet inBuffer[],
937  Packet inoutBuffer[]
938  )
939  {
940  for( int i = 0; i < count; ++i )
941  inoutBuffer[i] = TEUCHOS_MIN(inoutBuffer[i],inBuffer[i]);
942  }
943 };
944 
945 
946 template<typename Ordinal, typename Packet>
947 class Min<false,Ordinal,Packet> {
948 public:
949  static void min(
950  const Ordinal,
951  const Packet[],
952  Packet[]
953  )
954  {
956  true,std::logic_error,
957  "Error, the type "<<TypeNameTraits<Packet>::name()
958  <<" does not support comparison operations!"
959  );
960  }
961 };
962 
963 
964 template<bool isComparable, typename Ordinal, typename Packet>
965 class Max {};
966 
967 
968 template<typename Ordinal, typename Packet>
969 class Max<true,Ordinal,Packet> {
970 public:
971  static void max(
972  const Ordinal count,
973  const Packet inBuffer[],
974  Packet inoutBuffer[]
975  )
976  {
977  for( int i = 0; i < count; ++i )
978  inoutBuffer[i] = TEUCHOS_MAX(inoutBuffer[i],inBuffer[i]);
979  }
980 };
981 
982 
983 template<typename Ordinal, typename Packet>
984 class Max<false,Ordinal,Packet> {
985 public:
986  static void max(
987  const Ordinal,
988  const Packet[],
989  Packet[]
990  )
991  {
993  true,std::logic_error,
994  "Error, the type "<<TypeNameTraits<Packet>::name()
995  <<" does not support comparison operations!"
996  );
997  }
998 };
999 
1000 
1001 template<bool isComparable, typename Ordinal, typename Packet>
1002 class AND {};
1003 
1004 
1005 template<typename Ordinal, typename Packet>
1006 class AND<true,Ordinal,Packet> {
1007 public:
1008  static void andOp(
1009  const Ordinal count,
1010  const Packet inBuffer[],
1011  Packet inoutBuffer[]
1012  )
1013  {
1014  for( int i = 0; i < count; ++i )
1015  inoutBuffer[i] = inoutBuffer[i] && inBuffer[i];
1016  }
1017 };
1018 
1019 
1020 template<typename Ordinal, typename Packet>
1021 class AND<false,Ordinal,Packet> {
1022 public:
1023  static void andOp(
1024  const Ordinal,
1025  const Packet[],
1026  Packet[]
1027  )
1028  {
1030  true,std::logic_error,
1031  "Error, the type "<<TypeNameTraits<Packet>::name()
1032  <<" does not support logical AND operations!"
1033  );
1034  }
1035 };
1036 
1037 
1038 } // namespace MixMaxUtilities
1039 
1040 
1041 template<typename Ordinal, typename Packet>
1043  const Ordinal count,
1044  const Packet inBuffer[],
1045  Packet inoutBuffer[]
1046  ) const
1047 {
1048  for( int i = 0; i < count; ++i )
1049  inoutBuffer[i] += inBuffer[i];
1050 }
1051 
1052 
1053 template<typename Ordinal, typename Packet>
1055  const Ordinal count,
1056  const Packet inBuffer[],
1057  Packet inoutBuffer[]
1058  ) const
1059 {
1060  typedef MixMaxUtilities::Min<ScalarTraits<Packet>::isComparable, Ordinal, Packet> min_type;
1061  min_type::min (count, inBuffer, inoutBuffer);
1062 }
1063 
1064 
1065 template<typename Ordinal, typename Packet>
1067  const Ordinal count,
1068  const Packet inBuffer[],
1069  Packet inoutBuffer[]
1070  ) const
1071 {
1072  typedef MixMaxUtilities::Max<ScalarTraits<Packet>::isComparable, Ordinal, Packet> max_type;
1073  max_type::max (count,inBuffer,inoutBuffer);
1074 }
1075 
1076 
1077 template<typename Ordinal, typename Packet>
1079  const Ordinal count,
1080  const Packet inBuffer[],
1081  Packet inoutBuffer[]
1082  ) const
1083 {
1084  typedef MixMaxUtilities::AND<ScalarTraits<Packet>::isComparable, Ordinal, Packet> and_type;
1085  and_type::andOp (count, inBuffer, inoutBuffer);
1086 }
1087 
1088 
1089 } // namespace Teuchos
1090 
1091 
1092 // //////////////////////////
1093 // Template implemenations
1094 
1095 
1096 //
1097 // ReductionOp utilities
1098 //
1099 
1100 
1101 namespace Teuchos {
1102 
1103 
1104 // Not for the general user to use! I am returning a raw ReductionOp* pointer
1105 // to avoid the overhead of using RCP. However, given the use case
1106 // this is just fine since I can just use std::auto_ptr to make sure things
1107 // are deleted correctly.
1108 //
1109 // NOTE (mfh 08 Feb 2015) std::auto_ptr has been deprecated in C++11.
1110 // I could either replace it with std::unique_ptr, or just call 'new'
1111 // and 'delete' manually. The former is less error prone, but
1112 // requires checking a macro for whether C++11 is actually enabled.
1113 // Thus, I've chosen (for now) to rewrite all the code that uses
1114 // std::auto_ptr, so that it allocates and deletes manually.
1115 template<typename Ordinal, typename Packet>
1116 ValueTypeReductionOp<Ordinal,Packet>*
1117 createOp (const EReductionType reductType)
1118 {
1119  typedef ScalarTraits<Packet> ST;
1120  switch (reductType) {
1121  case REDUCE_SUM: {
1123  }
1124  case REDUCE_MIN: {
1125  if (ST::isComparable) {
1127  }
1128  else {
1130  (! ST::isComparable, std::invalid_argument, "Teuchos::createOp"
1131  "(EReductionType): The Packet type " << TypeNameTraits<Packet>::name ()
1132  << " is not less-than comparable, so it does not make sense to do a "
1133  "MIN reduction with it.");
1134  }
1135  }
1136  case REDUCE_MAX: {
1137  if (ST::isComparable) {
1139  }
1140  else {
1142  (! ST::isComparable, std::invalid_argument, "Teuchos::createOp"
1143  "(EReductionType): The Packet type " << TypeNameTraits<Packet>::name ()
1144  << " is not less-than comparable, so it does not make sense to do a "
1145  "MAX reduction with it.");
1146  }
1147  }
1148  case REDUCE_AND: {
1150  }
1151  default:
1153  true, std::invalid_argument, "Teuchos::createOp(EReductionType): "
1154  "Invalid EReductionType value " << reductType << ". Valid values "
1155  "include REDUCE_SUM, REDUCE_MIN, REDUCE_MAX, and REDUCE_AND.");
1156  }
1157 }
1158 
1159 
1160 } // namespace Teuchos
1161 
1162 
1163 //
1164 // Teuchos::Comm wrapper functions
1165 //
1166 
1167 
1168 template<typename Ordinal>
1169 int Teuchos::rank(const Comm<Ordinal>& comm)
1170 {
1171  return comm.getRank();
1172 }
1173 
1174 
1175 template<typename Ordinal>
1176 int Teuchos::size(const Comm<Ordinal>& comm)
1177 {
1178  return comm.getSize();
1179 }
1180 
1181 
1182 template<typename Ordinal>
1183 void Teuchos::barrier(const Comm<Ordinal>& comm)
1184 {
1186  "Teuchos::CommHelpers: barrier<"
1187  <<OrdinalTraits<Ordinal>::name()
1188  <<">()"
1189  );
1190  comm.barrier();
1191 }
1192 
1193 
1194 template<typename Ordinal, typename Packet>
1195 void Teuchos::broadcast(
1196  const Comm<Ordinal>& comm,
1197  const int rootRank, const Ordinal count, Packet buffer[]
1198  )
1199 {
1201  "Teuchos::CommHelpers: broadcast<"
1202  <<OrdinalTraits<Ordinal>::name()<<","<<TypeNameTraits<Packet>::name()
1203  <<">( value type )"
1204  );
1205  ValueTypeSerializationBuffer<Ordinal,Packet>
1206  charBuffer(count,buffer);
1207  comm.broadcast(
1208  rootRank,charBuffer.getBytes(),charBuffer.getCharBuffer()
1209  );
1210 }
1211 
1212 
1213 template<typename Ordinal, typename Packet>
1214 void Teuchos::broadcast(
1215  const Comm<Ordinal>& comm,
1216  const int rootRank,
1217  const ArrayView<Packet> &buffer
1218  )
1219 {
1220  broadcast<Ordinal, Packet>(comm, rootRank, buffer.size(), buffer.getRawPtr() );
1221 }
1222 
1223 
1224 template<typename Ordinal, typename Packet>
1225 void Teuchos::broadcast(
1226  const Comm<Ordinal>& comm,
1227  const int rootRank, Packet *object
1228  )
1229 {
1230  broadcast<Ordinal,Packet>(comm,rootRank,1,object);
1231 }
1232 
1233 
1234 template<typename Ordinal, typename Packet>
1235 void Teuchos::broadcast(
1236  const Comm<Ordinal>& comm,
1237  const int rootRank, const Ptr<Packet> &object
1238  )
1239 {
1240  broadcast<Ordinal,Packet>(comm,rootRank,1,object.getRawPtr());
1241 }
1242 
1243 
1244 template<typename Ordinal, typename Packet>
1245 void Teuchos::broadcast(
1246  const Comm<Ordinal>& comm, const Serializer<Ordinal,Packet> &serializer,
1247  const int rootRank, const Ordinal count, Packet*const buffer[]
1248  )
1249 {
1251  "Teuchos::CommHelpers: broadcast<"
1252  <<OrdinalTraits<Ordinal>::name()<<","<<TypeNameTraits<Packet>::name()
1253  <<">( reference type )"
1254  );
1255  ReferenceTypeSerializationBuffer<Ordinal,Packet>
1256  charBuffer(serializer, count, buffer);
1257  comm.broadcast(
1258  rootRank,charBuffer.getBytes(),charBuffer.getCharBuffer()
1259  );
1260 }
1261 
1262 
1263 template<typename Ordinal, typename Packet>
1264 void Teuchos::broadcast(
1265  const Comm<Ordinal>& comm, const Serializer<Ordinal,Packet> &serializer,
1266  const int rootRank, const ArrayView<const Ptr<Packet> > &buffer
1267  )
1268 {
1269  Array<Packet*> bufferPtrArray;
1270  for (int i = 0; i < buffer.size(); ++i) {
1271  bufferPtrArray.push_back(buffer[i].getRawPtr());
1272  }
1273  broadcast<Ordinal,Packet>(comm, serializer, rootRank,
1274  buffer.size(), bufferPtrArray.getRawPtr());
1275 }
1276 
1277 template<typename Ordinal, typename Packet, typename Serializer>
1278 void Teuchos::broadcast(
1279  const Comm<Ordinal>& comm,
1280  const Serializer& serializer,
1281  const int rootRank, const Ordinal count, Packet buffer[]
1282  )
1283 {
1285  "Teuchos::CommHelpers: broadcast<"
1286  <<OrdinalTraits<Ordinal>::name()<<","<<TypeNameTraits<Packet>::name()
1287  <<">( value type )"
1288  );
1289  ValueTypeSerializationBuffer<Ordinal,Packet,Serializer>
1290  charBuffer(count,buffer,rcp(&serializer,false));
1291  comm.broadcast(
1292  rootRank,charBuffer.getBytes(),charBuffer.getCharBuffer()
1293  );
1294 }
1295 
1296 
1297 template<typename Ordinal, typename Packet>
1298 void Teuchos::gatherAll(
1299  const Comm<Ordinal>& comm,
1300  const Ordinal sendCount, const Packet sendBuffer[],
1301  const Ordinal recvCount, Packet recvBuffer[]
1302  )
1303 {
1305  "Teuchos::CommHelpers: gatherAll<"
1306  <<OrdinalTraits<Ordinal>::name()<<","<<TypeNameTraits<Packet>::name()
1307  <<">( value type )"
1308  );
1309  ConstValueTypeSerializationBuffer<Ordinal,Packet>
1310  charSendBuffer(sendCount,sendBuffer);
1311  ValueTypeSerializationBuffer<Ordinal,Packet>
1312  charRecvBuffer(recvCount,recvBuffer);
1313  comm.gatherAll(
1314  charSendBuffer.getBytes(),charSendBuffer.getCharBuffer()
1315  ,charRecvBuffer.getBytes(),charRecvBuffer.getCharBuffer()
1316  );
1317 }
1318 
1319 template<typename Ordinal, typename Packet>
1320 void
1321 Teuchos::gather (const Packet sendBuf[],
1322  const Ordinal sendCount,
1323  Packet recvBuf[],
1324  const Ordinal recvCount,
1325  const int root,
1326  const Comm<Ordinal>& comm)
1327 {
1329  "Teuchos::CommHelpers: gather<"
1330  <<OrdinalTraits<Ordinal>::name()<<","<<TypeNameTraits<Packet>::name()
1331  <<">( value type )"
1332  );
1333  ConstValueTypeSerializationBuffer<Ordinal,Packet>
1334  charSendBuffer (sendCount, sendBuf);
1335  ValueTypeSerializationBuffer<Ordinal,Packet>
1336  charRecvBuffer (recvCount, recvBuf);
1337  comm.gather (charSendBuffer.getBytes (),
1338  charSendBuffer.getCharBuffer (),
1339  charRecvBuffer.getBytes (),
1340  charRecvBuffer.getCharBuffer (),
1341  root);
1342 }
1343 
1344 template<typename Ordinal, typename Packet>
1345 void
1346 Teuchos::gatherv (const Packet sendBuf[],
1347  const Ordinal sendCount,
1348  Packet recvBuf[],
1349  const Ordinal recvCounts[],
1350  const Ordinal displs[],
1351  const int root,
1352  const Comm<Ordinal>& comm)
1353 {
1354  // Ordinal totalRecvCount = 0;
1355 
1356  // // In order to get the right output buffer length, we have to sum
1357  // // the receive counts from all the processes in the communicator.
1358  // const Ordinal numProcs = as<Ordinal> (comm->getSize ());
1359  // for (Ordinal k = 0; k < as<Ordinal> (numProcs); ++k) {
1360  // totalRecvCount += recvCounts[k];
1361  // }
1362 
1363  // // FIXME (mfh 16 Apr 2013) We also have to redo the displacements.
1364 
1365  // ConstValueTypeSerializationBuffer<Ordinal,Packet>
1366  // charSendBuffer (sendCount, sendBuf);
1367  // ValueTypeSerializationBuffer<Ordinal,Packet>
1368  // charRecvBuffer (totalRecvCount, recvBuf);
1369  // comm.gatherv (charSendBuffer.getBytes (),
1370  // charSendBuffer.getCharBuffer (),
1371  // charRecvBuffer.getBytes (),
1372  // charRecvBuffer.getCharBuffer (),
1373  // root);
1374  TEUCHOS_TEST_FOR_EXCEPTION(true, std::logic_error,
1375  "Teuchos::gatherv: The general case is not implemented.");
1376 }
1377 
1378 template<typename Ordinal, typename Packet>
1379 void Teuchos::gatherAll(
1380  const Comm<Ordinal>& comm, const Serializer<Ordinal,Packet> &serializer,
1381  const Ordinal sendCount, const Packet*const sendBuffer[],
1382  const Ordinal recvCount, Packet*const recvBuffer[]
1383  )
1384 {
1385  TEUCHOS_TEST_FOR_EXCEPT(true); // ToDo: Implement and test when needed!
1386 }
1387 
1388 template<typename Ordinal, typename Packet, typename Serializer>
1389 void Teuchos::gatherAll(
1390  const Comm<Ordinal>& comm,
1391  const Serializer& serializer,
1392  const Ordinal sendCount, const Packet sendBuffer[],
1393  const Ordinal recvCount, Packet recvBuffer[]
1394  )
1395 {
1397  "Teuchos::CommHelpers: gatherAll<"
1398  <<OrdinalTraits<Ordinal>::name()<<","<<TypeNameTraits<Packet>::name()
1399  <<">( value type )"
1400  );
1401  ConstValueTypeSerializationBuffer<Ordinal,Packet,Serializer>
1402  charSendBuffer(sendCount,sendBuffer,rcp(&serializer,false));
1403  ValueTypeSerializationBuffer<Ordinal,Packet,Serializer>
1404  charRecvBuffer(recvCount,recvBuffer,rcp(&serializer,false));
1405  comm.gatherAll(
1406  charSendBuffer.getBytes(),charSendBuffer.getCharBuffer()
1407  ,charRecvBuffer.getBytes(),charRecvBuffer.getCharBuffer()
1408  );
1409 }
1410 
1411 
1412 template<typename Ordinal, typename Packet>
1413 void
1414 Teuchos::reduce (const Packet sendBuf[],
1415  Packet recvBuf[],
1416  const Ordinal count,
1417  const EReductionType reductType,
1418  const Ordinal root,
1419  const Comm<Ordinal>& comm)
1420 {
1421  // See Bug 6375; Tpetra does not actually need any specializations
1422  // other than Ordinal = int and Packet = int. We may add them later
1423  // if there is interest.
1425  (true, std::logic_error, "Teuchos::reduce<" <<
1426  TypeNameTraits<Ordinal>::name () << "," << TypeNameTraits<Packet>::name ()
1427  << ">: Generic version not implemented. We only implement this function "
1428  "for Ordinal = int and Packet = specific types.");
1429 }
1430 
1431 
1432 template<typename Ordinal, typename Packet>
1433 void Teuchos::reduceAll(
1434  const Comm<Ordinal>& comm, const ValueTypeReductionOp<Ordinal,Packet> &reductOp
1435  ,const Ordinal count, const Packet sendBuffer[], Packet globalReducts[]
1436  )
1437 {
1439  "Teuchos::CommHelpers: reduceAll<"
1440  <<OrdinalTraits<Ordinal>::name()<<","<<TypeNameTraits<Packet>::name()
1441  <<">( value type, user-defined op )"
1442  );
1443  ConstValueTypeSerializationBuffer<Ordinal,Packet>
1444  charSendBuffer(count,sendBuffer);
1445  ValueTypeSerializationBuffer<Ordinal,Packet>
1446  charGlobalReducts(count,globalReducts);
1447  CharToValueTypeReductionOp<Ordinal,Packet>
1448  charReductOp(rcp(&reductOp,false));
1449  comm.reduceAll(
1450  charReductOp,charSendBuffer.getBytes(),charSendBuffer.getCharBuffer()
1451  ,charGlobalReducts.getCharBuffer()
1452  );
1453 }
1454 
1455 
1456 template<typename Ordinal, typename Packet>
1457 void Teuchos::reduceAll(
1458  const Comm<Ordinal>& comm, const EReductionType reductType,
1459  const Ordinal count, const Packet sendBuffer[], Packet globalReducts[]
1460  )
1461 {
1463  "Teuchos::CommHelpers: reduceAll<"
1464  <<OrdinalTraits<Ordinal>::name()<<","<<TypeNameTraits<Packet>::name()
1465  <<">( value type, "<<toString(reductType)<<" )"
1466  );
1467 
1468  ValueTypeReductionOp<Ordinal,Packet>* reductOp =
1469  createOp<Ordinal, Packet> (reductType);
1470  try {
1471  reduceAll(comm,*reductOp,count,sendBuffer,globalReducts);
1472  }
1473  catch (std::exception& e) {
1474  delete reductOp;
1475  throw e;
1476  }
1477  delete reductOp;
1478 }
1479 
1480 
1481 namespace Teuchos {
1482 
1483 // amb 11 Nov 2014. I am disabling these specializations for
1484 // now. MPI_C_DOUBLE_COMPLEX is causing a problem in some builds. This code was
1485 // effectively turned on only yesterday (10 Nov 2014) when TEUCHOS_HAVE_COMPLEX
1486 // was corrected to be HAVE_TEUCHOS_COMPLEX, so evidently there are no users of
1487 // these specializations.
1488 #if 0
1489 #ifdef HAVE_TEUCHOS_COMPLEX
1490 // Specialization for Ordinal=int and Packet=std::complex<double>.
1491 template<>
1493 reduceAll<int, std::complex<double> > (const Comm<int>& comm,
1494  const EReductionType reductType,
1495  const int count,
1496  const std::complex<double> sendBuffer[],
1497  std::complex<double> globalReducts[]);
1498 template<>
1499 TEUCHOSCOMM_LIB_DLL_EXPORT RCP<CommRequest<int> >
1500 ireceive<int, std::complex<double> > (const Comm<int>& comm,
1501  const ArrayRCP<std::complex<double> >& recvBuffer,
1502  const int sourceRank);
1503 template<>
1504 TEUCHOSCOMM_LIB_DLL_EXPORT RCP<CommRequest<int> >
1505 ireceive<int, std::complex<double> > (const ArrayRCP<std::complex<double> > &recvBuffer,
1506  const int sourceRank,
1507  const int tag,
1508  const Comm<int>& comm);
1509 template<>
1511 send<int, std::complex<double> > (const Comm<int>& comm,
1512  const int count,
1513  const std::complex<double> sendBuffer[],
1514  const int destRank);
1515 template<>
1517 send<int, std::complex<double> > (const std::complex<double> sendBuffer[],
1518  const int count,
1519  const int destRank,
1520  const int tag,
1521  const Comm<int>& comm);
1522 template<>
1523 TEUCHOSCOMM_LIB_DLL_EXPORT RCP<CommRequest<int> >
1524 isend<int, std::complex<double> > (const ArrayRCP<const std::complex<double> >& sendBuffer,
1525  const int destRank,
1526  const int tag,
1527  const Comm<int>& comm);
1528 
1529 // Specialization for Ordinal=int and Packet=std::complex<float>.
1530 template<>
1532 reduceAll<int, std::complex<float> > (const Comm<int>& comm,
1533  const EReductionType reductType,
1534  const int count,
1535  const std::complex<float> sendBuffer[],
1536  std::complex<float> globalReducts[]);
1537 template<>
1538 TEUCHOSCOMM_LIB_DLL_EXPORT RCP<CommRequest<int> >
1539 ireceive<int, std::complex<float> > (const Comm<int>& comm,
1540  const ArrayRCP<std::complex<float> >& recvBuffer,
1541  const int sourceRank);
1542 template<>
1543 TEUCHOSCOMM_LIB_DLL_EXPORT RCP<CommRequest<int> >
1544 ireceive<int, std::complex<float> > (const ArrayRCP<std::complex<float> > &recvBuffer,
1545  const int sourceRank,
1546  const int tag,
1547  const Comm<int>& comm);
1548 template<>
1550 send<int, std::complex<float> > (const Comm<int>& comm,
1551  const int count,
1552  const std::complex<float> sendBuffer[],
1553  const int destRank);
1554 template<>
1556 send<int, std::complex<float> > (const std::complex<float> sendBuffer[],
1557  const int count,
1558  const int destRank,
1559  const int tag,
1560  const Comm<int>& comm);
1561 template<>
1562 TEUCHOSCOMM_LIB_DLL_EXPORT RCP<CommRequest<int> >
1563 isend<int, std::complex<float> > (const ArrayRCP<const std::complex<float> >& sendBuffer,
1564  const int destRank,
1565  const int tag,
1566  const Comm<int>& comm);
1567 #endif // HAVE_TEUCHOS_COMPLEX
1568 #endif // if 0
1569 
1570 // Specialization for Ordinal=int and Packet=double.
1571 template<>
1573 reduceAll<int, double> (const Comm<int>& comm,
1574  const EReductionType reductType,
1575  const int count,
1576  const double sendBuffer[],
1577  double globalReducts[]);
1578 template<>
1579 TEUCHOSCOMM_LIB_DLL_EXPORT RCP<CommRequest<int> >
1580 ireceive<int, double> (const Comm<int>& comm,
1581  const ArrayRCP<double>& recvBuffer,
1582  const int sourceRank);
1583 template<>
1584 TEUCHOSCOMM_LIB_DLL_EXPORT RCP<CommRequest<int> >
1585 ireceive<int, double> (const ArrayRCP<double> &recvBuffer,
1586  const int sourceRank,
1587  const int tag,
1588  const Comm<int>& comm);
1589 template<>
1591 send<int, double> (const Comm<int>& comm,
1592  const int count,
1593  const double sendBuffer[],
1594  const int destRank);
1595 template<>
1597 send<int, double> (const double sendBuffer[],
1598  const int count,
1599  const int destRank,
1600  const int tag,
1601  const Comm<int>& comm);
1602 template<>
1603 TEUCHOSCOMM_LIB_DLL_EXPORT RCP<CommRequest<int> >
1604 isend<int, double> (const ArrayRCP<const double>& sendBuffer,
1605  const int destRank,
1606  const int tag,
1607  const Comm<int>& comm);
1608 
1609 // Specialization for Ordinal=int and Packet=float.
1610 template<>
1612 reduceAll<int, float> (const Comm<int>& comm,
1613  const EReductionType reductType,
1614  const int count,
1615  const float sendBuffer[],
1616  float globalReducts[]);
1617 template<>
1618 TEUCHOSCOMM_LIB_DLL_EXPORT RCP<CommRequest<int> >
1619 ireceive<int, float> (const Comm<int>& comm,
1620  const ArrayRCP<float>& recvBuffer,
1621  const int sourceRank);
1622 template<>
1623 TEUCHOSCOMM_LIB_DLL_EXPORT RCP<CommRequest<int> >
1624 ireceive<int, float> (const ArrayRCP<float> &recvBuffer,
1625  const int sourceRank,
1626  const int tag,
1627  const Comm<int>& comm);
1628 template<>
1630 send<int, float> (const Comm<int>& comm,
1631  const int count,
1632  const float sendBuffer[],
1633  const int destRank);
1634 template<>
1636 send<int, float> (const float sendBuffer[],
1637  const int count,
1638  const int destRank,
1639  const int tag,
1640  const Comm<int>& comm);
1641 template<>
1642 TEUCHOSCOMM_LIB_DLL_EXPORT RCP<CommRequest<int> >
1643 isend<int, float> (const ArrayRCP<const float>& sendBuffer,
1644  const int destRank,
1645  const int tag,
1646  const Comm<int>& comm);
1647 
1648 // Specialization for Ordinal=int and Packet=long long.
1649 template<>
1651 gather<int, long long> (const long long sendBuf[],
1652  const int sendCount,
1653  long long recvBuf[],
1654  const int recvCount,
1655  const int root,
1656  const Comm<int>& comm);
1657 template<>
1659 gatherv<int, long long> (const long long sendBuf[],
1660  const int sendCount,
1661  long long recvBuf[],
1662  const int recvCounts[],
1663  const int displs[],
1664  const int root,
1665  const Comm<int>& comm);
1666 template<>
1668 reduceAll<int, long long> (const Comm<int>& comm,
1669  const EReductionType reductType,
1670  const int count,
1671  const long long sendBuffer[],
1672  long long globalReducts[]);
1673 template<>
1674 TEUCHOSCOMM_LIB_DLL_EXPORT RCP<CommRequest<int> >
1675 ireceive<int, long long> (const Comm<int>& comm,
1676  const ArrayRCP<long long>& recvBuffer,
1677  const int sourceRank);
1678 template<>
1679 TEUCHOSCOMM_LIB_DLL_EXPORT RCP<CommRequest<int> >
1680 ireceive<int, long long> (const ArrayRCP<long long> &recvBuffer,
1681  const int sourceRank,
1682  const int tag,
1683  const Comm<int>& comm);
1684 template<>
1686 send<int, long long> (const Comm<int>& comm,
1687  const int count,
1688  const long long sendBuffer[],
1689  const int destRank);
1690 template<>
1692 send<int, long long> (const long long sendBuffer[],
1693  const int count,
1694  const int destRank,
1695  const int tag,
1696  const Comm<int>& comm);
1697 template<>
1698 TEUCHOSCOMM_LIB_DLL_EXPORT RCP<CommRequest<int> >
1699 isend<int, long long> (const ArrayRCP<const long long>& sendBuffer,
1700  const int destRank,
1701  const int tag,
1702  const Comm<int>& comm);
1703 
1704 // Specialization for Ordinal=int and Packet=unsigned long long.
1705 template<>
1707 gather<int, unsigned long long> (const unsigned long long sendBuf[],
1708  const int sendCount,
1709  unsigned long long recvBuf[],
1710  const int recvCount,
1711  const int root,
1712  const Comm<int>& comm);
1713 template<>
1715 gatherv<int, unsigned long long> (const unsigned long long sendBuf[],
1716  const int sendCount,
1717  unsigned long long recvBuf[],
1718  const int recvCounts[],
1719  const int displs[],
1720  const int root,
1721  const Comm<int>& comm);
1722 template<>
1724 reduceAll<int, unsigned long long> (const Comm<int>& comm,
1725  const EReductionType reductType,
1726  const int count,
1727  const unsigned long long sendBuffer[],
1728  unsigned long long globalReducts[]);
1729 template<>
1730 TEUCHOSCOMM_LIB_DLL_EXPORT RCP<CommRequest<int> >
1731 ireceive<int, unsigned long long> (const Comm<int>& comm,
1732  const ArrayRCP<unsigned long long>& recvBuffer,
1733  const int sourceRank);
1734 template<>
1735 TEUCHOSCOMM_LIB_DLL_EXPORT RCP<CommRequest<int> >
1736 ireceive<int, unsigned long long> (const ArrayRCP<unsigned long long> &recvBuffer,
1737  const int sourceRank,
1738  const int tag,
1739  const Comm<int>& comm);
1740 template<>
1742 send<int, unsigned long long> (const Comm<int>& comm,
1743  const int count,
1744  const unsigned long long sendBuffer[],
1745  const int destRank);
1746 template<>
1748 send<int, unsigned long long> (const unsigned long long sendBuffer[],
1749  const int count,
1750  const int destRank,
1751  const int tag,
1752  const Comm<int>& comm);
1753 template<>
1754 TEUCHOSCOMM_LIB_DLL_EXPORT RCP<CommRequest<int> >
1755 isend<int, unsigned long long> (const ArrayRCP<const unsigned long long>& sendBuffer,
1756  const int destRank,
1757  const int tag,
1758  const Comm<int>& comm);
1759 
1760 // Specialization for Ordinal=int and Packet=long.
1761 template<>
1763 gather<int, long> (const long sendBuf[],
1764  const int sendCount,
1765  long recvBuf[],
1766  const int recvCount,
1767  const int root,
1768  const Comm<int>& comm);
1769 template<>
1771 gatherv<int, long> (const long sendBuf[],
1772  const int sendCount,
1773  long recvBuf[],
1774  const int recvCounts[],
1775  const int displs[],
1776  const int root,
1777  const Comm<int>& comm);
1778 template<>
1780 reduceAll<int, long> (const Comm<int>& comm,
1781  const EReductionType reductType,
1782  const int count,
1783  const long sendBuffer[],
1784  long globalReducts[]);
1785 template<>
1786 TEUCHOSCOMM_LIB_DLL_EXPORT RCP<CommRequest<int> >
1787 ireceive<int, long> (const Comm<int>& comm,
1788  const ArrayRCP<long>& recvBuffer,
1789  const int sourceRank);
1790 template<>
1791 TEUCHOSCOMM_LIB_DLL_EXPORT RCP<CommRequest<int> >
1792 ireceive<int, long> (const ArrayRCP<long> &recvBuffer,
1793  const int sourceRank,
1794  const int tag,
1795  const Comm<int>& comm);
1796 template<>
1798 send<int, long> (const Comm<int>& comm,
1799  const int count,
1800  const long sendBuffer[],
1801  const int destRank);
1802 template<>
1804 send<int, long> (const long sendBuffer[],
1805  const int count,
1806  const int destRank,
1807  const int tag,
1808  const Comm<int>& comm);
1809 template<>
1810 TEUCHOSCOMM_LIB_DLL_EXPORT RCP<CommRequest<int> >
1811 isend<int, long> (const ArrayRCP<const long>& sendBuffer,
1812  const int destRank,
1813  const int tag,
1814  const Comm<int>& comm);
1815 
1816 // Specialization for Ordinal=int and Packet=unsigned long.
1817 template<>
1819 gather<int, unsigned long> (const unsigned long sendBuf[],
1820  const int sendCount,
1821  unsigned long recvBuf[],
1822  const int recvCount,
1823  const int root,
1824  const Comm<int>& comm);
1825 template<>
1827 gatherv<int, unsigned long> (const unsigned long sendBuf[],
1828  const int sendCount,
1829  unsigned long recvBuf[],
1830  const int recvCounts[],
1831  const int displs[],
1832  const int root,
1833  const Comm<int>& comm);
1834 template<>
1836 reduceAll<int, unsigned long> (const Comm<int>& comm,
1837  const EReductionType reductType,
1838  const int count,
1839  const unsigned long sendBuffer[],
1840  unsigned long globalReducts[]);
1841 template<>
1842 TEUCHOSCOMM_LIB_DLL_EXPORT RCP<CommRequest<int> >
1843 ireceive<int, unsigned long> (const Comm<int>& comm,
1844  const ArrayRCP<unsigned long>& recvBuffer,
1845  const int sourceRank);
1846 template<>
1847 TEUCHOSCOMM_LIB_DLL_EXPORT RCP<CommRequest<int> >
1848 ireceive<int, unsigned long> (const ArrayRCP<unsigned long> &recvBuffer,
1849  const int sourceRank,
1850  const int tag,
1851  const Comm<int>& comm);
1852 template<>
1854 send<int, unsigned long> (const Comm<int>& comm,
1855  const int count,
1856  const unsigned long sendBuffer[],
1857  const int destRank);
1858 template<>
1860 send<int, unsigned long> (const unsigned long sendBuffer[],
1861  const int count,
1862  const int destRank,
1863  const int tag,
1864  const Comm<int>& comm);
1865 template<>
1866 TEUCHOSCOMM_LIB_DLL_EXPORT RCP<CommRequest<int> >
1867 isend<int, unsigned long> (const ArrayRCP<const unsigned long>& sendBuffer,
1868  const int destRank,
1869  const int tag,
1870  const Comm<int>& comm);
1871 
1872 // Specialization for Ordinal=int and Packet=int.
1873 template<>
1875 gather<int, int> (const int sendBuf[],
1876  const int sendCount,
1877  int recvBuf[],
1878  const int recvCount,
1879  const int root,
1880  const Comm<int>& comm);
1881 template<>
1883 gatherv<int, int> (const int sendBuf[],
1884  const int sendCount,
1885  int recvBuf[],
1886  const int recvCounts[],
1887  const int displs[],
1888  const int root,
1889  const Comm<int>& comm);
1890 template<>
1892 scatter (const int sendBuf[],
1893  const int sendCount,
1894  int recvBuf[],
1895  const int recvCount,
1896  const int root,
1897  const Comm<int>& comm);
1898 template<>
1900 reduce<int, int> (const int sendBuf[],
1901  int recvBuf[],
1902  const int count,
1903  const EReductionType reductType,
1904  const int root,
1905  const Comm<int>& comm);
1906 template<>
1908 reduce<int, long> (const long sendBuf[],
1909  long recvBuf[],
1910  const int count,
1911  const EReductionType reductType,
1912  const int root,
1913  const Comm<int>& comm);
1914 template<>
1916 reduce<int, unsigned long> (const unsigned long sendBuf[],
1917  unsigned long recvBuf[],
1918  const int count,
1919  const EReductionType reductType,
1920  const int root,
1921  const Comm<int>& comm);
1922 template<>
1924 reduce<int, unsigned long long > (const unsigned long long sendBuf[],
1925  unsigned long long recvBuf[],
1926  const int count,
1927  const EReductionType reductType,
1928  const int root,
1929  const Comm<int>& comm);
1930 template<>
1932 reduce<int, double> (const double sendBuf[],
1933  double recvBuf[],
1934  const int count,
1935  const EReductionType reductType,
1936  const int root,
1937  const Comm<int>& comm);
1938 template<>
1940 reduceAll<int, int> (const Comm<int>& comm,
1941  const EReductionType reductType,
1942  const int count,
1943  const int sendBuffer[],
1944  int globalReducts[]);
1945 
1946 template<>
1947 TEUCHOSCOMM_LIB_DLL_EXPORT RCP<CommRequest<int> >
1948 ireceive<int, int> (const Comm<int>& comm,
1949  const ArrayRCP<int>& recvBuffer,
1950  const int sourceRank);
1951 template<>
1952 TEUCHOSCOMM_LIB_DLL_EXPORT RCP<CommRequest<int> >
1953 ireceive<int, int> (const ArrayRCP<int> &recvBuffer,
1954  const int sourceRank,
1955  const int tag,
1956  const Comm<int>& comm);
1957 template<>
1959 send<int, int> (const Comm<int>& comm,
1960  const int count,
1961  const int sendBuffer[],
1962  const int destRank);
1963 template<>
1965 send<int, int> (const int sendBuffer[],
1966  const int count,
1967  const int destRank,
1968  const int tag,
1969  const Comm<int>& comm);
1970 template<>
1971 TEUCHOSCOMM_LIB_DLL_EXPORT RCP<CommRequest<int> >
1972 isend<int, int> (const ArrayRCP<const int>& sendBuffer,
1973  const int destRank,
1974  const int tag,
1975  const Comm<int>& comm);
1976 
1977 // Specialization for Ordinal=int and Packet=unsigned int.
1978 template<>
1980 gather<int, unsigned int> (const unsigned int sendBuf[],
1981  const int sendCount,
1982  unsigned int recvBuf[],
1983  const int recvCount,
1984  const int root,
1985  const Comm<int>& comm);
1986 template<>
1988 gatherv<int, unsigned int> (const unsigned int sendBuf[],
1989  const int sendCount,
1990  unsigned int recvBuf[],
1991  const int recvCounts[],
1992  const int displs[],
1993  const int root,
1994  const Comm<int>& comm);
1995 template<>
1997 reduceAll<int, unsigned int> (const Comm<int>& comm,
1998  const EReductionType reductType,
1999  const int count,
2000  const unsigned int sendBuffer[],
2001  unsigned int globalReducts[]);
2002 template<>
2003 TEUCHOSCOMM_LIB_DLL_EXPORT RCP<CommRequest<int> >
2004 ireceive<int, unsigned int> (const Comm<int>& comm,
2005  const ArrayRCP<unsigned int>& recvBuffer,
2006  const int sourceRank);
2007 template<>
2008 TEUCHOSCOMM_LIB_DLL_EXPORT RCP<CommRequest<int> >
2009 ireceive<int, unsigned int> (const ArrayRCP<unsigned int> &recvBuffer,
2010  const int sourceRank,
2011  const int tag,
2012  const Comm<int>& comm);
2013 template<>
2015 send<int, unsigned int> (const Comm<int>& comm,
2016  const int count,
2017  const unsigned int sendBuffer[],
2018  const int destRank);
2019 template<>
2021 send<int, unsigned int> (const unsigned int sendBuffer[],
2022  const int count,
2023  const int destRank,
2024  const int tag,
2025  const Comm<int>& comm);
2026 template<>
2027 TEUCHOSCOMM_LIB_DLL_EXPORT RCP<CommRequest<int> >
2028 isend<int, unsigned int> (const ArrayRCP<const unsigned int>& sendBuffer,
2029  const int destRank,
2030  const int tag,
2031  const Comm<int>& comm);
2032 
2033 // Specialization for Ordinal=int and Packet=short.
2034 template<>
2036 gather<int, short> (const short sendBuf[],
2037  const int sendCount,
2038  short recvBuf[],
2039  const int recvCount,
2040  const int root,
2041  const Comm<int>& comm);
2042 template<>
2044 gatherv<int, short> (const short sendBuf[],
2045  const int sendCount,
2046  short recvBuf[],
2047  const int recvCounts[],
2048  const int displs[],
2049  const int root,
2050  const Comm<int>& comm);
2051 template<>
2053 reduceAll<int, short> (const Comm<int>& comm,
2054  const EReductionType reductType,
2055  const int count,
2056  const short sendBuffer[],
2057  short globalReducts[]);
2058 template<>
2059 TEUCHOSCOMM_LIB_DLL_EXPORT RCP<CommRequest<int> >
2060 ireceive<int, short> (const Comm<int>& comm,
2061  const ArrayRCP<short>& recvBuffer,
2062  const int sourceRank);
2063 template<>
2064 TEUCHOSCOMM_LIB_DLL_EXPORT RCP<CommRequest<int> >
2065 ireceive<int, short> (const ArrayRCP<short> &recvBuffer,
2066  const int sourceRank,
2067  const int tag,
2068  const Comm<int>& comm);
2069 template<>
2071 send<int, short> (const Comm<int>& comm,
2072  const int count,
2073  const short sendBuffer[],
2074  const int destRank);
2075 template<>
2077 send<int, short> (const short sendBuffer[],
2078  const int count,
2079  const int destRank,
2080  const int tag,
2081  const Comm<int>& comm);
2082 template<>
2083 TEUCHOSCOMM_LIB_DLL_EXPORT RCP<CommRequest<int> >
2084 isend<int, short> (const ArrayRCP<const short>& sendBuffer,
2085  const int destRank,
2086  const int tag,
2087  const Comm<int>& comm);
2088 
2089 // mfh 18 Oct 2012: The specialization for Packet=char seems to be
2090 // causing problems such as the following:
2091 //
2092 // http://testing.sandia.gov/cdash/testDetails.php?test=9909246&build=747699
2093 //
2094 // I am disabling it for now. This should revert back to the old
2095 // behavior for Packet=char. That should fix the Tpetra errors, since
2096 // many Tpetra objects inherit from DistObject<char, ...>.
2097 #if 0
2098 // Specialization for Ordinal=int and Packet=char.
2099 template<>
2101 reduceAll<int, char> (const Comm<int>& comm,
2102  const EReductionType reductType,
2103  const int count,
2104  const char sendBuffer[],
2105  char globalReducts[]);
2106 #endif // 0
2107 } // namespace Teuchos
2108 
2109 
2110 template<typename Ordinal, typename Packet>
2111 void Teuchos::reduceAll(
2112  const Comm<Ordinal>& comm, const EReductionType reductType
2113  ,const Packet &send, const Ptr<Packet> &globalReduct
2114  )
2115 {
2116  // mfh 17 Oct 2012: This will invoke the above specializations for
2117  // general count, so we don't need to specialize this function.
2118  reduceAll<Ordinal,Packet>(comm, reductType, 1, &send, &*globalReduct);
2119 }
2120 
2121 
2122 template<typename Ordinal, typename Packet>
2123 void Teuchos::reduceAll(
2124  const Comm<Ordinal>& comm, const Serializer<Ordinal,Packet> &serializer,
2125  const ReferenceTypeReductionOp<Ordinal,Packet> &reductOp,
2126  const Ordinal count, const Packet*const sendBuffer[], Packet*const globalReducts[]
2127  )
2128 {
2130  "Teuchos::CommHelpers: reduceAll<"
2131  <<OrdinalTraits<Ordinal>::name()<<","<<TypeNameTraits<Packet>::name()
2132  <<">( reference type )"
2133  );
2134  ConstReferenceTypeSerializationBuffer<Ordinal,Packet>
2135  charSendBuffer(serializer,count,sendBuffer);
2136  ReferenceTypeSerializationBuffer<Ordinal,Packet>
2137  charGlobalReducts(serializer,count,globalReducts);
2138  CharToReferenceTypeReductionOp<Ordinal,Packet>
2139  charReductOp(rcp(&serializer,false),rcp(&reductOp,false));
2140  comm.reduceAll(
2141  charReductOp,charSendBuffer.getBytes(),charSendBuffer.getCharBuffer()
2142  ,charGlobalReducts.getCharBuffer()
2143  );
2144 }
2145 
2146 template<typename Ordinal, typename Packet, typename Serializer>
2147 void Teuchos::reduceAll(
2148  const Comm<Ordinal>& comm,
2149  const Serializer& serializer,
2150  const ValueTypeReductionOp<Ordinal,Packet> &reductOp,
2151  const Ordinal count, const Packet sendBuffer[], Packet globalReducts[]
2152  )
2153 {
2155  "Teuchos::CommHelpers: reduceAll<"
2156  <<OrdinalTraits<Ordinal>::name()<<","<<TypeNameTraits<Packet>::name()
2157  <<">( value type, user-defined op )"
2158  );
2159  ConstValueTypeSerializationBuffer<Ordinal,Packet,Serializer>
2160  charSendBuffer(count,sendBuffer,rcp(&serializer,false));
2161  ValueTypeSerializationBuffer<Ordinal,Packet,Serializer>
2162  charGlobalReducts(count,globalReducts,rcp(&serializer,false));
2163  CharToValueTypeReductionOp<Ordinal,Packet,Serializer>
2164  charReductOp(rcp(&reductOp,false),rcp(&serializer,false));
2165  comm.reduceAll(
2166  charReductOp,charSendBuffer.getBytes(),charSendBuffer.getCharBuffer()
2167  ,charGlobalReducts.getCharBuffer()
2168  );
2169 }
2170 
2171 
2172 template<typename Ordinal, typename Packet, typename Serializer>
2173 void Teuchos::reduceAll(
2174  const Comm<Ordinal>& comm,
2175  const Serializer& serializer,
2176  const EReductionType reductType,
2177  const Ordinal count, const Packet sendBuffer[], Packet globalReducts[]
2178  )
2179 {
2181  "Teuchos::CommHelpers: reduceAll<"
2182  <<OrdinalTraits<Ordinal>::name()<<","<<TypeNameTraits<Packet>::name()
2183  <<">( value type, "<<toString(reductType)<<" )"
2184  );
2185 
2186  ValueTypeReductionOp<Ordinal,Packet>* reductOp =
2187  createOp<Ordinal, Packet> (reductType);
2188  try {
2189  reduceAll(comm,serializer,*reductOp,count,sendBuffer,globalReducts);
2190  }
2191  catch (std::exception& e) {
2192  delete reductOp;
2193  throw e;
2194  }
2195  delete reductOp;
2196 }
2197 
2198 
2199 template<typename Ordinal, typename Packet>
2200 void Teuchos::scan(
2201  const Comm<Ordinal>& comm, const ValueTypeReductionOp<Ordinal,Packet> &reductOp,
2202  const Ordinal count, const Packet sendBuffer[], Packet scanReducts[]
2203  )
2204 {
2206  "Teuchos::CommHelpers: scan<"
2207  <<OrdinalTraits<Ordinal>::name()<<","<<TypeNameTraits<Packet>::name()
2208  <<">( value type, user-defined op )"
2209  );
2210  ConstValueTypeSerializationBuffer<Ordinal,Packet>
2211  charSendBuffer(count,sendBuffer);
2212  ValueTypeSerializationBuffer<Ordinal,Packet>
2213  charScanReducts(count,scanReducts);
2214  CharToValueTypeReductionOp<Ordinal,Packet>
2215  charReductOp(rcp(&reductOp,false));
2216  comm.scan(
2217  charReductOp,charSendBuffer.getBytes(),charSendBuffer.getCharBuffer()
2218  ,charScanReducts.getCharBuffer()
2219  );
2220 }
2221 
2222 
2223 template<typename Ordinal, typename Packet>
2224 void Teuchos::scan(
2225  const Comm<Ordinal>& comm, const EReductionType reductType,
2226  const Ordinal count, const Packet sendBuffer[], Packet scanReducts[]
2227  )
2228 {
2230  "Teuchos::CommHelpers: scan<"
2231  <<OrdinalTraits<Ordinal>::name()<<","<<TypeNameTraits<Packet>::name()
2232  <<">( value type, "<<toString(reductType)<<" )"
2233  );
2234 
2235  ValueTypeReductionOp<Ordinal,Packet>* reductOp =
2236  createOp<Ordinal, Packet> (reductType);
2237  try {
2238  scan(comm,*reductOp,count,sendBuffer,scanReducts);
2239  }
2240  catch (std::exception& e) {
2241  delete reductOp;
2242  throw e;
2243  }
2244  delete reductOp;
2245 }
2246 
2247 
2248 template<typename Ordinal, typename Packet>
2249 void Teuchos::scan(
2250  const Comm<Ordinal>& comm, const EReductionType reductType,
2251  const Packet &send, const Ptr<Packet> &scanReduct
2252  )
2253 {
2254  scan<Ordinal,Packet>(comm, reductType, 1, &send, &*scanReduct);
2255 }
2256 
2257 
2258 template<typename Ordinal, typename Packet>
2259 void Teuchos::scan(
2260  const Comm<Ordinal>& comm, const Serializer<Ordinal,Packet> &serializer,
2261  const ReferenceTypeReductionOp<Ordinal,Packet> &reductOp,
2262  const Ordinal count, const Packet*const sendBuffer[], Packet*const scanReducts[]
2263  )
2264 {
2265  TEUCHOS_TEST_FOR_EXCEPT(true); // ToDo: Implement and test when needed!
2266 }
2267 
2268 template<typename Ordinal, typename Packet, typename Serializer>
2269 void Teuchos::scan(
2270  const Comm<Ordinal>& comm,
2271  const Serializer& serializer,
2272  const ValueTypeReductionOp<Ordinal,Packet> &reductOp,
2273  const Ordinal count, const Packet sendBuffer[], Packet scanReducts[]
2274  )
2275 {
2277  "Teuchos::CommHelpers: scan<"
2278  <<OrdinalTraits<Ordinal>::name()<<","<<TypeNameTraits<Packet>::name()
2279  <<">( value type, user-defined op )"
2280  );
2281  ConstValueTypeSerializationBuffer<Ordinal,Packet,Serializer>
2282  charSendBuffer(count,sendBuffer,rcp(&serializer,false));
2283  ValueTypeSerializationBuffer<Ordinal,Packet,Serializer>
2284  charScanReducts(count,scanReducts,rcp(&serializer,false));
2285  CharToValueTypeReductionOp<Ordinal,Packet,Serializer>
2286  charReductOp(rcp(&reductOp,false),rcp(&serializer,false));
2287  comm.scan(
2288  charReductOp,charSendBuffer.getBytes(),charSendBuffer.getCharBuffer()
2289  ,charScanReducts.getCharBuffer()
2290  );
2291 }
2292 
2293 
2294 template<typename Ordinal, typename Packet, typename Serializer>
2295 void Teuchos::scan(
2296  const Comm<Ordinal>& comm,
2297  const Serializer& serializer,
2298  const EReductionType reductType,
2299  const Ordinal count, const Packet sendBuffer[], Packet scanReducts[]
2300  )
2301 {
2303  "Teuchos::CommHelpers: scan<"
2304  <<OrdinalTraits<Ordinal>::name()<<","<<TypeNameTraits<Packet>::name()
2305  <<">( value type, "<<toString(reductType)<<" )"
2306  );
2307 
2308  ValueTypeReductionOp<Ordinal,Packet>* reductOp =
2309  createOp<Ordinal, Packet> (reductType);
2310  try {
2311  scan(comm,serializer,*reductOp,count,sendBuffer,scanReducts);
2312  }
2313  catch (std::exception& e) {
2314  delete reductOp;
2315  throw e;
2316  }
2317  delete reductOp;
2318 }
2319 
2320 template<typename Ordinal, typename Packet>
2321 void Teuchos::send(
2322  const Comm<Ordinal>& comm,
2323  const Ordinal count, const Packet sendBuffer[], const int destRank
2324  )
2325 {
2327  "Teuchos::CommHelpers: send<"
2328  <<OrdinalTraits<Ordinal>::name()<<","<<TypeNameTraits<Packet>::name()
2329  <<">( value type )"
2330  );
2331  ConstValueTypeSerializationBuffer<Ordinal,Packet>
2332  charSendBuffer(count,sendBuffer);
2333  comm.send(
2334  charSendBuffer.getBytes(),charSendBuffer.getCharBuffer()
2335  ,destRank
2336  );
2337 }
2338 
2339 template<typename Ordinal, typename Packet>
2340 void
2341 Teuchos::send (const Packet sendBuffer[],
2342  const Ordinal count,
2343  const int destRank,
2344  const int tag,
2345  const Comm<Ordinal>& comm)
2346 {
2348  "Teuchos::CommHelpers: send<"
2350  <<">( value type )"
2351  );
2352  ConstValueTypeSerializationBuffer<Ordinal,Packet> charSendBuffer (count, sendBuffer);
2353  comm.send (charSendBuffer.getBytes (), charSendBuffer.getCharBuffer (), destRank, tag);
2354 }
2355 
2356 template<typename Ordinal, typename Packet>
2357 void Teuchos::ssend(
2358  const Comm<Ordinal>& comm,
2359  const Ordinal count, const Packet sendBuffer[], const int destRank
2360  )
2361 {
2363  "Teuchos::CommHelpers: ssend<"
2364  <<OrdinalTraits<Ordinal>::name()<<","<<TypeNameTraits<Packet>::name()
2365  <<">( value type )"
2366  );
2367  ConstValueTypeSerializationBuffer<Ordinal,Packet>
2368  charSendBuffer(count,sendBuffer);
2369  comm.ssend(
2370  charSendBuffer.getBytes(),charSendBuffer.getCharBuffer()
2371  ,destRank
2372  );
2373 }
2374 
2375 template<typename Ordinal, typename Packet>
2376 void
2377 Teuchos::ssend (const Packet sendBuffer[],
2378  const Ordinal count,
2379  const int destRank,
2380  const int tag,
2381  const Comm<Ordinal>& comm)
2382 {
2384  "Teuchos::CommHelpers: ssend<"
2386  <<">( value type )"
2387  );
2389  buf_type charSendBuffer (count, sendBuffer);
2390  comm.ssend (charSendBuffer.getBytes (),
2391  charSendBuffer.getCharBuffer (),
2392  destRank, tag);
2393 }
2394 
2395 template<typename Ordinal, typename Packet>
2396 void Teuchos::send(
2397  const Comm<Ordinal>& comm,
2398  const Packet &send, const int destRank
2399  )
2400 {
2401  Teuchos::send<Ordinal,Packet>(comm,1,&send,destRank);
2402 }
2403 
2404 template<typename Ordinal, typename Packet>
2405 void Teuchos::ssend(
2406  const Comm<Ordinal>& comm,
2407  const Packet &send, const int destRank
2408  )
2409 {
2410  Teuchos::ssend<Ordinal,Packet>(comm,1,&send,destRank);
2411 }
2412 
2413 template<typename Ordinal, typename Packet>
2414 void Teuchos::send(
2415  const Comm<Ordinal>& comm, const Serializer<Ordinal,Packet> &serializer,
2416  const Ordinal count, const Packet*const sendBuffer[], const int destRank
2417  )
2418 {
2419  TEUCHOS_TEST_FOR_EXCEPT(true); // ToDo: Implement and test when needed!
2420 }
2421 
2422 template<typename Ordinal, typename Packet, typename Serializer>
2423 void Teuchos::send(
2424  const Comm<Ordinal>& comm,
2425  const Serializer& serializer,
2426  const Ordinal count, const Packet sendBuffer[], const int destRank
2427  )
2428 {
2430  "Teuchos::CommHelpers: send<"
2431  <<OrdinalTraits<Ordinal>::name()<<","<<TypeNameTraits<Packet>::name()
2432  <<">( value type )"
2433  );
2434  ConstValueTypeSerializationBuffer<Ordinal,Packet,Serializer>
2435  charSendBuffer(count,sendBuffer,rcp(&serializer,false));
2436  comm.send(
2437  charSendBuffer.getBytes(),charSendBuffer.getCharBuffer()
2438  ,destRank
2439  );
2440 }
2441 
2442 template<typename Ordinal, typename Packet>
2443 int Teuchos::receive(
2444  const Comm<Ordinal>& comm,
2445  const int sourceRank, const Ordinal count, Packet recvBuffer[]
2446  )
2447 {
2449  "Teuchos::CommHelpers: receive<"
2450  <<OrdinalTraits<Ordinal>::name()<<","<<TypeNameTraits<Packet>::name()
2451  <<">( value type )"
2452  );
2453  ValueTypeSerializationBuffer<Ordinal,Packet>
2454  charRecvBuffer(count,recvBuffer);
2455  return comm.receive(
2456  sourceRank
2457  ,charRecvBuffer.getBytes(),charRecvBuffer.getCharBuffer()
2458  );
2459 }
2460 
2461 
2462 template<typename Ordinal, typename Packet>
2463 int Teuchos::receive(
2464  const Comm<Ordinal>& comm,
2465  const int sourceRank, Packet *recv
2466  )
2467 {
2468  return Teuchos::receive<Ordinal,Packet>(comm,sourceRank,1,recv);
2469 }
2470 
2471 
2472 template<typename Ordinal, typename Packet>
2473 int Teuchos::receive(
2474  const Comm<Ordinal>& comm, const Serializer<Ordinal,Packet> &serializer,
2475  const int sourceRank, const Ordinal count, Packet*const recvBuffer[]
2476  )
2477 {
2478  TEUCHOS_TEST_FOR_EXCEPT(true); // ToDo: Implement and test when needed!
2479 }
2480 
2481 template<typename Ordinal, typename Packet, typename Serializer>
2482 int Teuchos::receive(
2483  const Comm<Ordinal>& comm,
2484  const Serializer& serializer,
2485  const int sourceRank, const Ordinal count, Packet recvBuffer[]
2486  )
2487 {
2489  "Teuchos::CommHelpers: receive<"
2490  <<OrdinalTraits<Ordinal>::name()<<","<<TypeNameTraits<Packet>::name()
2491  <<">( value type )"
2492  );
2493  ValueTypeSerializationBuffer<Ordinal,Packet,Serializer>
2494  charRecvBuffer(count,recvBuffer,rcp(&serializer,false));
2495  return comm.receive(
2496  sourceRank
2497  ,charRecvBuffer.getBytes(),charRecvBuffer.getCharBuffer()
2498  );
2499 }
2500 
2501 template<typename Ordinal, typename Packet>
2502 void Teuchos::readySend(
2503  const Comm<Ordinal>& comm,
2504  const ArrayView<const Packet> &sendBuffer,
2505  const int destRank
2506  )
2507 {
2509  "Teuchos::CommHelpers: readySend<"
2510  <<OrdinalTraits<Ordinal>::name()<<","<<TypeNameTraits<Packet>::name()
2511  <<">( value type )"
2512  );
2513  ConstValueTypeSerializationBuffer<Ordinal,Packet>
2514  charSendBuffer(sendBuffer.size(), sendBuffer.getRawPtr());
2515  comm.readySend( charSendBuffer.getCharBufferView(), destRank );
2516 }
2517 
2518 template<typename Ordinal, typename Packet>
2519 void
2520 Teuchos::readySend (const Packet sendBuffer[],
2521  const Ordinal count,
2522  const int destRank,
2523  const int tag,
2524  const Comm<Ordinal>& comm)
2525 {
2527  "Teuchos::CommHelpers: readySend<"
2529  <<">( value type )"
2530  );
2532  buf_type charSendBuffer (count, sendBuffer);
2533  comm.readySend (charSendBuffer.getBytes (),
2534  charSendBuffer.getCharBuffer (),
2535  destRank, tag);
2536 }
2537 
2538 template<typename Ordinal, typename Packet>
2539 void Teuchos::readySend(
2540  const Comm<Ordinal>& comm,
2541  const Packet &send,
2542  const int destRank
2543  )
2544 {
2545  readySend<Ordinal, Packet>( comm, arrayView(&send,1), destRank );
2546 }
2547 
2548 template<typename Ordinal, typename Packet, typename Serializer>
2549 void Teuchos::readySend(
2550  const Comm<Ordinal>& comm,
2551  const Serializer& serializer,
2552  const ArrayView<const Packet> &sendBuffer,
2553  const int destRank
2554  )
2555 {
2557  "Teuchos::CommHelpers: readySend<"
2558  <<OrdinalTraits<Ordinal>::name()<<","<<TypeNameTraits<Packet>::name()
2559  <<">( value type )"
2560  );
2561  ConstValueTypeSerializationBuffer<Ordinal,Packet,Serializer>
2562  charSendBuffer(sendBuffer.size(), sendBuffer.getRawPtr(), serializer);
2563  comm.readySend( charSendBuffer.getCharBufferView(), destRank );
2564 }
2565 
2566 template<typename Ordinal, typename Packet>
2569  const Comm<Ordinal>& comm,
2570  const ArrayRCP<const Packet> &sendBuffer,
2571  const int destRank
2572  )
2573 {
2575  "Teuchos::CommHelpers: isend<"
2576  <<OrdinalTraits<Ordinal>::name()<<","<<TypeNameTraits<Packet>::name()
2577  <<">( value type )"
2578  );
2579  ConstValueTypeSerializationBuffer<Ordinal,Packet>
2580  charSendBuffer(sendBuffer.size(), sendBuffer.getRawPtr());
2581  RCP<CommRequest<Ordinal> > commRequest = comm.isend(
2582  charSendBuffer.getCharBufferView(), destRank );
2583  set_extra_data( sendBuffer, "buffer", inOutArg(commRequest) );
2584  return commRequest;
2585 }
2586 
2587 template<typename Ordinal, typename Packet>
2589 Teuchos::isend (const ArrayRCP<const Packet> &sendBuffer,
2590  const int destRank,
2591  const int tag,
2592  const Comm<Ordinal>& comm)
2593 {
2595  "Teuchos::isend<" << OrdinalTraits<Ordinal>::name () << ","
2596  << TypeNameTraits<Packet>::name () << ">");
2597  ConstValueTypeSerializationBuffer<Ordinal,Packet>
2598  charSendBuffer (sendBuffer.size (), sendBuffer.getRawPtr ());
2599  RCP<CommRequest<Ordinal> > commRequest =
2600  comm.isend (charSendBuffer.getCharBufferView (), destRank, tag);
2601  set_extra_data (sendBuffer, "buffer", inOutArg (commRequest));
2602  return commRequest;
2603 }
2604 
2605 template<typename Ordinal, typename Packet>
2608  const Comm<Ordinal>& comm,
2609  const RCP<const Packet> &send,
2610  const int destRank
2611  )
2612 {
2613  const ArrayRCP<const Packet> sendBuffer =
2614  arcpWithEmbeddedObj( send.get(), 0, 1, send, false );
2615  // 2008/07/29: rabartl: Above: I need to write a helper function to create
2616  // new ArrayRCP object given a single object to copy.
2617  return isend<Ordinal, Packet>( comm, sendBuffer, destRank );
2618 }
2619 
2620 template<typename Ordinal, typename Packet, typename Serializer>
2623  const Comm<Ordinal>& comm,
2624  const Serializer& serializer,
2625  const ArrayRCP<const Packet> &sendBuffer,
2626  const int destRank
2627  )
2628 {
2630  "Teuchos::CommHelpers: isend<"
2631  <<OrdinalTraits<Ordinal>::name()<<","<<TypeNameTraits<Packet>::name()
2632  <<">( value type )"
2633  );
2634  ConstValueTypeSerializationBuffer<Ordinal,Packet,Serializer>
2635  charSendBuffer(sendBuffer.size(), sendBuffer.getRawPtr(), serializer);
2636  RCP<CommRequest<Ordinal> > commRequest = comm.isend(
2637  charSendBuffer.getCharBufferView(), destRank );
2638  set_extra_data( sendBuffer, "buffer", inOutArg(commRequest) );
2639  return commRequest;
2640 }
2641 
2642 template<typename Ordinal, typename Packet>
2645  const Comm<Ordinal>& comm,
2646  const ArrayRCP<Packet> &recvBuffer,
2647  const int sourceRank
2648  )
2649 {
2651  "Teuchos::ireceive<int, " << "," << TypeNameTraits<Packet>::name () << ">");
2652  ValueTypeSerializationBuffer<Ordinal,Packet>
2653  charRecvBuffer(recvBuffer.size(), recvBuffer.getRawPtr());
2654  RCP<CommRequest<Ordinal> > commRequest = comm.ireceive(
2655  charRecvBuffer.getCharBufferView(), sourceRank );
2656  set_extra_data( recvBuffer, "buffer", inOutArg(commRequest) );
2657  return commRequest;
2658 }
2659 
2660 template<typename Ordinal, typename Packet>
2662 Teuchos::ireceive (const Teuchos::ArrayRCP<Packet> &recvBuffer,
2663  const int sourceRank,
2664  const int tag,
2665  const Teuchos::Comm<Ordinal>& comm)
2666 {
2668  "Teuchos::ireceive<int, " << "," << TypeNameTraits<Packet>::name () << ">");
2669  ValueTypeSerializationBuffer<int, Packet>
2670  charRecvBuffer (recvBuffer.size (), recvBuffer.getRawPtr ());
2671  RCP<CommRequest<int> > commRequest =
2672  comm.ireceive (charRecvBuffer.getCharBufferView (), sourceRank, tag);
2673  set_extra_data (recvBuffer, "buffer", inOutArg (commRequest));
2674  return commRequest;
2675 }
2676 
2677 template<typename Ordinal, typename Packet>
2680  const Comm<Ordinal>& comm,
2681  const RCP<Packet> &recv,
2682  const int sourceRank
2683  )
2684 {
2685  const ArrayRCP<Packet> recvBuffer =
2686  arcpWithEmbeddedObj( recv.get(), 0, 1, recv, false );
2687  // 2008/07/29: rabartl: Above: I need to write a helper function to create
2688  // new ArrayRCP object given a single object to copy.
2689  return ireceive<Ordinal, Packet>( comm, recvBuffer, sourceRank );
2690 }
2691 
2692 template<typename Ordinal, typename Packet, typename Serializer>
2695  const Comm<Ordinal>& comm,
2696  const Serializer& serializer,
2697  const ArrayRCP<Packet> &recvBuffer,
2698  const int sourceRank
2699  )
2700 {
2702  "Teuchos::CommHelpers: ireceive<"
2703  <<OrdinalTraits<Ordinal>::name()<<","<<TypeNameTraits<Packet>::name()
2704  <<">( value type )"
2705  );
2706  ValueTypeSerializationBuffer<Ordinal,Packet,Serializer>
2707  charRecvBuffer(recvBuffer.size(), recvBuffer.getRawPtr(), serializer);
2708  RCP<CommRequest<Ordinal> > commRequest = comm.ireceive(
2709  charRecvBuffer.getCharBufferView(), sourceRank );
2710  set_extra_data( recvBuffer, "buffer", inOutArg(commRequest) );
2711  return commRequest;
2712 }
2713 
2714 template<typename Ordinal>
2715 void Teuchos::waitAll(
2716  const Comm<Ordinal>& comm,
2717  const ArrayView<RCP<CommRequest<Ordinal> > > &requests
2718  )
2719 {
2720  comm.waitAll(requests);
2721 }
2722 
2723 
2724 template<typename Ordinal>
2725 void
2726 Teuchos::waitAll (const Comm<Ordinal>& comm,
2727  const ArrayView<RCP<CommRequest<Ordinal> > >& requests,
2728  const ArrayView<RCP<CommStatus<Ordinal> > >& statuses)
2729 {
2730  comm.waitAll (requests, statuses);
2731 }
2732 
2733 
2734 template<typename Ordinal>
2736 Teuchos::wait (const Comm<Ordinal>& comm,
2737  const Ptr<RCP<CommRequest<Ordinal> > > &request)
2738 {
2739  return comm.wait (request);
2740 }
2741 
2742 
2743 #endif // TEUCHOS_COMM_HELPERS_HPP
void reduce< int, unsigned long >(const unsigned long sendBuf[], unsigned long recvBuf[], const int count, const EReductionType reductType, const int root, const Comm< int > &comm)
void reduce< int, long >(const long sendBuf[], long recvBuf[], const int count, const EReductionType reductType, const int root, const Comm< int > &comm)
RCP< T > rcp(const boost::shared_ptr< T > &sptr)
Conversion function that takes in a boost::shared_ptr object and spits out a Teuchos::RCP object...
Strategy interface for the indirect serializing and deserializing objects of a given type handled usi...
ArrayView< T > arrayView(T *p, typename ArrayView< T >::size_type size)
Construct a const or non-const view to const or non-const data.
RCP< Teuchos::CommRequest< int > > ireceive< int, unsigned long long >(const Comm< int > &comm, const ArrayRCP< unsigned long long > &recvBuffer, const int sourceRank)
void set_extra_data(const T1 &extra_data, const std::string &name, const Ptr< ArrayRCP< T2 > > &p, EPrePostDestruction destroy_when=POST_DESTROY, bool force_unique=true)
Set extra data associated with a ArrayRCP object.
Ptr< T > inOutArg(T &arg)
create a non-persisting (required or optional) input/output argument for a function call...
void reduce(const Ordinal count, const Packet inBuffer[], Packet inoutBuffer[]) const
TEUCHOSCOMM_LIB_DLL_EXPORT RCP< CommRequest< int > > isend< int, unsigned long >(const ArrayRCP< const unsigned long > &sendBuffer, const int destRank, const int tag, const Comm< int > &comm)
void send< int, float >(const Comm< int > &comm, const int count, const float sendBuffer[], const int destRank)
EReductionType
Predefined reduction operations that Teuchos::Comm understands.
TEUCHOSCOMM_LIB_DLL_EXPORT RCP< CommRequest< int > > isend< int, float >(const ArrayRCP< const float > &sendBuffer, const int destRank, const int tag, const Comm< int > &comm)
RCP< Teuchos::CommRequest< int > > ireceive< int, float >(const Comm< int > &comm, const ArrayRCP< float > &recvBuffer, const int sourceRank)
static void max(const Ordinal count, const Packet inBuffer[], Packet inoutBuffer[])
TEUCHOSCOMM_LIB_DLL_EXPORT RCP< CommRequest< int > > isend< int, long long >(const ArrayRCP< const long long > &sendBuffer, const int destRank, const int tag, const Comm< int > &comm)
void gatherv< int, short >(const short sendBuf[], const int sendCount, short recvBuf[], const int recvCounts[], const int displs[], const int root, const Comm< int > &comm)
void gather< int, unsigned long long >(const unsigned long long sendBuf[], const int sendCount, unsigned long long recvBuf[], const int recvCount, const int root, const Comm< int > &comm)
TEUCHOSCOMM_LIB_DLL_EXPORT RCP< CommRequest< int > > isend< int, short >(const ArrayRCP< const short > &sendBuffer, const int destRank, const int tag, const Comm< int > &comm)
void reduceAll< int, long >(const Comm< int > &comm, const EReductionType reductType, const int count, const long sendBuffer[], long globalReducts[])
void send< int, unsigned long long >(const Comm< int > &comm, const int count, const unsigned long long sendBuffer[], const int destRank)
RCP< Teuchos::CommRequest< int > > ireceive< int, double >(const Comm< int > &comm, const ArrayRCP< double > &recvBuffer, const int sourceRank)
RCP< Teuchos::CommRequest< int > > ireceive< int, short >(const Comm< int > &comm, const ArrayRCP< short > &recvBuffer, const int sourceRank)
void send< int, long >(const Comm< int > &comm, const int count, const long sendBuffer[], const int destRank)
void gather< int, unsigned int >(const unsigned int sendBuf[], const int sendCount, unsigned int recvBuf[], const int recvCount, const int root, const Comm< int > &comm)
static void andOp(const Ordinal, const Packet[], Packet[])
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
Macro for throwing an exception with breakpointing to ease debugging.
void reduce< int, double >(const double sendBuf[], double recvBuf[], const int count, const EReductionType reductType, const int root, const Comm< int > &comm)
T * getRawPtr() const
Get the raw C++ pointer to the underlying object.
RawPointerConversionTraits< Container >::Ptr_t getRawPtr(const Container &c)
void gatherv< int, int >(const int sendBuf[], const int sendCount, int recvBuf[], const int recvCounts[], const int displs[], const int root, const Comm< int > &comm)
TEUCHOSCOMM_LIB_DLL_EXPORT RCP< CommRequest< int > > isend< int, double >(const ArrayRCP< const double > &sendBuffer, const int destRank, const int tag, const Comm< int > &comm)
void gatherv< int, long long >(const long long sendBuf[], const int sendCount, long long recvBuf[], const int recvCounts[], const int displs[], const int root, const Comm< int > &comm)
void gather< int, long >(const long sendBuf[], const int sendCount, long recvBuf[], const int recvCount, const int root, const Comm< int > &comm)
RCP< Teuchos::CommRequest< int > > ireceive< int, long long >(const Comm< int > &comm, const ArrayRCP< long long > &recvBuffer, const int sourceRank)
void send< int, int >(const Comm< int > &comm, const int count, const int sendBuffer[], const int destRank)
void reduce(const Ordinal count, const Packet inBuffer[], Packet inoutBuffer[]) const
TEUCHOSCOMM_LIB_DLL_EXPORT RCP< CommRequest< int > > isend< int, unsigned int >(const ArrayRCP< const unsigned int > &sendBuffer, const int destRank, const int tag, const Comm< int > &comm)
void send< int, double >(const Comm< int > &comm, const int count, const double sendBuffer[], const int destRank)
void gather< int, int >(const int sendBuf[], const int sendCount, int recvBuf[], const int recvCount, const int root, const Comm< int > &comm)
size_type size() const
The total number of entries in the array.
void gather< int, long long >(const long long sendBuf[], const int sendCount, long long recvBuf[], const int recvCount, const int root, const Comm< int > &comm)
Standard logical AND operator for booleans.
#define TEUCHOS_COMM_TIME_MONITOR(FUNCNAME)
void reduceAll(const Comm< Ordinal > &comm, const ValueTypeReductionOp< Ordinal, Packet > &reductOp, const Ordinal count, const Packet sendBuffer[], Packet globalReducts[])
Wrapper for MPI_Allreduce that takes a custom reduction operator.
Standard min operator for types with value semantics.
This structure defines some basic traits for a scalar field type.
void scatter(const Packet sendBuf[], const Ordinal sendCount, Packet recvBuf[], const Ordinal recvCount, const Ordinal root, const Comm< Ordinal > &comm)
Wrapper for MPI_Scatter; scatter collective.
std::string toString(const any &rhs)
Converts the value in any to a std::string.
Standard summation operator for types with value semantics.
void gatherv< int, unsigned long >(const unsigned long sendBuf[], const int sendCount, unsigned long recvBuf[], const int recvCounts[], const int displs[], const int root, const Comm< int > &comm)
static void andOp(const Ordinal count, const Packet inBuffer[], Packet inoutBuffer[])
void reduce(const Ordinal count, const Packet inBuffer[], Packet inoutBuffer[]) const
void reduceAll< int, unsigned int >(const Comm< int > &comm, const EReductionType reductType, const int count, const unsigned int sendBuffer[], unsigned int globalReducts[])
void send< int, long long >(const Comm< int > &comm, const int count, const long long sendBuffer[], const int destRank)
void reduceAll< int, short >(const Comm< int > &comm, const EReductionType reductType, const int count, const short sendBuffer[], short globalReducts[])
void reduce< int, unsigned long long >(const unsigned long long sendBuf[], unsigned long long recvBuf[], const int count, const EReductionType reductType, const int root, const Comm< int > &comm)
static void min(const Ordinal, const Packet[], Packet[])
void reduce< int, int >(const int sendBuf[], int recvBuf[], const int count, const EReductionType reductType, const int root, const Comm< int > &comm)
virtual RCP< CommRequest< Ordinal > > ireceive(const ArrayView< char > &recvBuffer, const int sourceRank) const =0
Non-blocking receive.
void send(const Comm< Ordinal > &comm, const Ordinal count, const Packet sendBuffer[], const int destRank)
Send objects that use values semantics to another process.
TEUCHOSCOMM_LIB_DLL_EXPORT RCP< CommRequest< int > > isend< int, unsigned long long >(const ArrayRCP< const unsigned long long > &sendBuffer, const int destRank, const int tag, const Comm< int > &comm)
void reduceAll< int, double >(const Comm< int > &comm, const EReductionType reductType, const int count, const double sendBuffer[], double globalReducts[])
TEUCHOSCOMM_LIB_DLL_EXPORT RCP< CommRequest< int > > isend< int, long >(const ArrayRCP< const long > &sendBuffer, const int destRank, const int tag, const Comm< int > &comm)
void gatherv< int, unsigned long long >(const unsigned long long sendBuf[], const int sendCount, unsigned long long recvBuf[], const int recvCounts[], const int displs[], const int root, const Comm< int > &comm)
Standard Max operator for types with value semantics.
void gatherv< int, long >(const long sendBuf[], const int sendCount, long recvBuf[], const int recvCounts[], const int displs[], const int root, const Comm< int > &comm)
Implementation of Teuchos wrappers for MPI.
Declaration of Teuchos::EReductionType enum, and related functions.
This structure defines some basic traits for the ordinal field type.
Encapsulation of the result of a receive (blocking or nonblocking).
#define TEUCHOS_MAX(x, y)
void send(const Packet sendBuffer[], const Ordinal count, const int destRank, const int tag, const Comm< Ordinal > &comm)
Variant of send() that takes a tag (and restores the correct order of arguments). ...
void reduceAll< int, int >(const Comm< int > &comm, const EReductionType reductType, const int count, const int sendBuffer[], int globalReducts[])
void reduceAll< int, unsigned long long >(const Comm< int > &comm, const EReductionType reductType, const int count, const unsigned long long sendBuffer[], unsigned long long globalReducts[])
void gatherv< int, unsigned int >(const unsigned int sendBuf[], const int sendCount, unsigned int recvBuf[], const int recvCounts[], const int displs[], const int root, const Comm< int > &comm)
virtual void readySend(const ArrayView< const char > &sendBuffer, const int destRank) const =0
Ready send of data from this process to another process.
RCP< Teuchos::CommRequest< int > > ireceive< int, unsigned int >(const Comm< int > &comm, const ArrayRCP< unsigned int > &recvBuffer, const int sourceRank)
TEUCHOSCOMM_LIB_DLL_EXPORT RCP< CommRequest< int > > isend< int, int >(const ArrayRCP< const int > &sendBuffer, const int destRank, const int tag, const Comm< int > &comm)
void reduceAll< int, unsigned long >(const Comm< int > &comm, const EReductionType reductType, const int count, const unsigned long sendBuffer[], unsigned long globalReducts[])
RCP< CommRequest< Ordinal > > ireceive(const ArrayRCP< Packet > &recvBuffer, const int sourceRank, const int tag, const Comm< Ordinal > &comm)
Variant of ireceive that takes a tag argument (and restores the correct order of arguments).
RCP< Teuchos::CommRequest< int > > ireceive< int, int >(const Comm< int > &comm, const ArrayRCP< int > &recvBuffer, const int sourceRank)
Templated array class derived from the STL std::vector.
RCP< Teuchos::CommRequest< int > > ireceive< int, unsigned long >(const Comm< int > &comm, const ArrayRCP< unsigned long > &recvBuffer, const int sourceRank)
Nonowning array view.
Defines basic traits for the ordinal field type.
Default traits class that just returns typeid(T).name().
RCP< Teuchos::CommRequest< int > > isend(const ArrayRCP< const double > &sendBuffer, const int destRank, const int tag, const Comm< int > &comm)
void reduceAll< int, float >(const Comm< int > &comm, const EReductionType reductType, const int count, const float sendBuffer[], float globalReducts[])
void reduce(const Ordinal count, const Packet inBuffer[], Packet inoutBuffer[]) const
Base interface class for user-defined reduction operations for objects that use reference semantics...
virtual void send(const Ordinal bytes, const char sendBuffer[], const int destRank) const =0
Possibly blocking send of data from this process to another process.
virtual void ssend(const Ordinal bytes, const char sendBuffer[], const int destRank) const =0
Always blocking send of data from this process to another process.
void ssend(const Packet sendBuffer[], const Ordinal count, const int destRank, const int tag, const Comm< Ordinal > &comm)
Variant of ssend() that takes a tag (and restores the correct order of arguments).
Defines basic traits for the scalar field type.
#define TEUCHOSCOMM_LIB_DLL_EXPORT
TEUCHOSCOMM_LIB_DLL_EXPORT void scatter(const int sendBuf[], const int sendCount, int recvBuf[], const int recvCount, const int root, const Comm< int > &comm)
ArrayRCP< T > arcpWithEmbeddedObj(T *p, typename ArrayRCP< T >::size_type lowerOffset, typename ArrayRCP< T >::size_type size, const Embedded &embedded, bool owns_mem=true)
Create an ArrayRCP with and also put in an embedded object.
static void max(const Ordinal, const Packet[], Packet[])
Smart reference counting pointer class for automatic garbage collection.
RCP< Teuchos::CommRequest< int > > ireceive< int, long >(const Comm< int > &comm, const ArrayRCP< long > &recvBuffer, const int sourceRank)
Encapsulation of a pending nonblocking communication operation.
void gather< int, short >(const short sendBuf[], const int sendCount, short recvBuf[], const int recvCount, const int root, const Comm< int > &comm)
#define TEUCHOS_MIN(x, y)
void send< int, short >(const Comm< int > &comm, const int count, const short sendBuffer[], const int destRank)
Defines basic traits returning the name of a type in a portable and readable way. ...
Definition of Teuchos::as, for conversions between types.
ValueTypeReductionOp< Ordinal, Packet > * createOp(const EReductionType reductType)
void readySend(const Packet sendBuffer[], const Ordinal count, const int destRank, const int tag, const Comm< Ordinal > &comm)
Variant of readySend() that accepts a message tag.
#define TEUCHOS_TEST_FOR_EXCEPT(throw_exception_test)
This macro is designed to be a short version of TEUCHOS_TEST_FOR_EXCEPTION() that is easier to call...
Simple wrapper class for raw pointers to single objects where no persisting relationship exists...
void scan(const Comm< Ordinal > &comm, const ValueTypeReductionOp< Ordinal, Packet > &reductOp, const Ordinal count, const Packet sendBuffer[], Packet scanReducts[])
Scan/Reduce array of objects that use value semantics using a user-defined reduction operator...
void gather< int, unsigned long >(const unsigned long sendBuf[], const int sendCount, unsigned long recvBuf[], const int recvCount, const int root, const Comm< int > &comm)
void reduceAll< int, long long >(const Comm< int > &comm, const EReductionType reductType, const int count, const long long sendBuffer[], long long globalReducts[])
Encapsulate how an array of const objects with value sematics is serialized into a const char[] array...
void send< int, unsigned long >(const Comm< int > &comm, const int count, const unsigned long sendBuffer[], const int destRank)
static void min(const Ordinal count, const Packet inBuffer[], Packet inoutBuffer[])
Reference-counted smart pointer for managing arrays.
void send< int, unsigned int >(const Comm< int > &comm, const int count, const unsigned int sendBuffer[], const int destRank)