42 #ifndef TEUCHOS_COMM_HELPERS_HPP
43 #define TEUCHOS_COMM_HELPERS_HPP
45 #include "Teuchos_Comm.hpp"
46 #include "Teuchos_CommUtilities.hpp"
47 #include "Teuchos_SerializationTraitsHelpers.hpp"
48 #include "Teuchos_ReductionOpHelpers.hpp"
49 #include "Teuchos_SerializerHelpers.hpp"
54 #include "Teuchos_Workspace.hpp"
57 #ifdef HAVE_TEUCHOS_MPI
59 #endif // HAVE_TEUCHOS_MPI
60 #include "Teuchos_DefaultSerialComm.hpp"
69 #ifdef HAVE_TEUCHOS_MPI
78 std::string getMpiErrorString (
const int errCode);
81 #endif // HAVE_TEUCHOS_MPI
87 template<
typename Ordinal>
88 int rank(
const Comm<Ordinal>& comm);
94 template<
typename Ordinal>
95 int size(
const Comm<Ordinal>& comm);
101 template<
typename Ordinal>
102 void barrier(
const Comm<Ordinal>& comm);
108 template<
typename Ordinal,
typename Packet>
110 const Comm<Ordinal>& comm,
112 const Ordinal count, Packet buffer[]
119 template<
typename Ordinal,
typename Packet>
121 const Comm<Ordinal>& comm,
123 const ArrayView<Packet> &buffer
130 template<
typename Ordinal,
typename Packet>
132 const Comm<Ordinal>& comm,
133 const int rootRank, Packet *
object
140 template<
typename Ordinal,
typename Packet>
142 const Comm<Ordinal>& comm,
143 const int rootRank,
const Ptr<Packet> &
object
150 template<
typename Ordinal,
typename Packet>
152 const Comm<Ordinal>& comm,
const Serializer<Ordinal,Packet> &serializer,
153 const int rootRank,
const Ordinal count, Packet*
const buffer[]
160 template<
typename Ordinal,
typename Packet>
162 const Comm<Ordinal>& comm,
const Serializer<Ordinal,Packet> &serializer,
163 const int rootRank,
const ArrayView<
const Ptr<Packet> > &buffer
171 template<
typename Ordinal,
typename Packet,
typename Serializer>
173 const Comm<Ordinal>& comm,
174 const Serializer& serializer,
176 const Ordinal count, Packet buffer[]
183 template<
typename Ordinal,
typename Packet>
185 gather (
const Packet sendBuf[],
186 const Ordinal sendCount,
188 const Ordinal recvCount,
190 const Comm<Ordinal>& comm);
196 template<
typename Ordinal,
typename Packet>
198 gatherv (
const Packet sendBuf[],
199 const Ordinal sendCount,
201 const Ordinal recvCounts[],
202 const Ordinal displs[],
204 const Comm<Ordinal>& comm);
211 template<
typename Ordinal,
typename Packet>
213 const Comm<Ordinal>& comm,
214 const Ordinal sendCount,
const Packet sendBuffer[],
215 const Ordinal recvCount, Packet recvBuffer[]
223 template<
typename Ordinal,
typename Packet>
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[]
235 template<
typename Ordinal,
typename Packet,
typename Serializer>
237 const Comm<Ordinal>& comm,
238 const Serializer& serializer,
239 const Ordinal sendCount,
const Packet sendBuffer[],
240 const Ordinal recvCount, Packet recvBuffer[]
269 template<
typename Ordinal,
typename Packet>
272 const Ordinal sendCount,
274 const Ordinal recvCount,
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.");
316 template<
typename Ordinal,
typename Packet>
318 reduce (
const Packet sendBuf[],
347 template<
typename Ordinal,
typename Packet>
350 const Ordinal count,
const Packet sendBuffer[], Packet globalReducts[]
358 template<
typename Ordinal,
typename Packet>
361 const Ordinal count,
const Packet sendBuffer[], Packet globalReducts[]
369 template<
typename Ordinal,
typename Packet>
376 template<
typename Ordinal,
typename Packet>
379 const Packet &
send, Packet *globalReduct
382 reduceAll<Ordinal,Packet>(comm, reductType,
send, ptr(globalReduct));
390 template<
typename Ordinal,
typename Packet>
392 const Comm<Ordinal>& comm,
const Serializer<Ordinal,Packet> &serializer,
393 const ReferenceTypeReductionOp<Ordinal,Packet> &reductOp,
394 const Ordinal count,
const Packet*
const sendBuffer[], Packet*
const globalReducts[]
402 template<
typename Ordinal,
typename Packet,
typename Serializer>
404 const Comm<Ordinal>& comm,
405 const Serializer& serializer,
406 const ValueTypeReductionOp<Ordinal,Packet> &reductOp,
407 const Ordinal count,
const Packet sendBuffer[], Packet globalReducts[]
415 template<
typename Ordinal,
typename Packet,
typename Serializer>
417 const Comm<Ordinal>& comm,
418 const Serializer& serializer,
419 const EReductionType reductType,
420 const Ordinal count,
const Packet sendBuffer[], Packet globalReducts[]
428 template<
typename Ordinal,
typename Packet>
430 const Comm<Ordinal>& comm,
const ValueTypeReductionOp<Ordinal,Packet> &reductOp,
431 const Ordinal count,
const Packet sendBuffer[], Packet scanReducts[]
439 template<
typename Ordinal,
typename Packet>
441 const Comm<Ordinal>& comm,
const EReductionType reductType,
442 const Ordinal count,
const Packet sendBuffer[], Packet scanReducts[]
450 template<
typename Ordinal,
typename Packet>
452 const Comm<Ordinal>& comm,
const EReductionType reductType,
453 const Packet &
send,
const Ptr<Packet> &scanReduct
457 template<
typename Ordinal,
typename Packet>
460 const Packet &
send, Packet *scanReduct
463 scan(comm, reductType, send, ptr(scanReduct));
471 template<
typename Ordinal,
typename Packet>
473 const Comm<Ordinal>& comm,
const Serializer<Ordinal,Packet> &serializer,
474 const ReferenceTypeReductionOp<Ordinal,Packet> &reductOp,
475 const Ordinal count,
const Packet*
const sendBuffer[], Packet*
const scanReducts[]
483 template<
typename Ordinal,
typename Packet,
typename Serializer>
485 const Comm<Ordinal>& comm,
486 const Serializer& serializer,
487 const ValueTypeReductionOp<Ordinal,Packet> &reductOp,
488 const Ordinal count,
const Packet sendBuffer[], Packet scanReducts[]
496 template<
typename Ordinal,
typename Packet,
typename Serializer>
498 const Comm<Ordinal>& comm,
499 const Serializer& serializer,
500 const EReductionType reductType,
501 const Ordinal count,
const Packet sendBuffer[], Packet scanReducts[]
508 template<
typename Ordinal,
typename Packet>
510 const Comm<Ordinal>& comm,
511 const Ordinal count,
const Packet sendBuffer[],
const int destRank
515 template<
typename Ordinal,
typename Packet>
517 send (
const Packet sendBuffer[],
521 const Comm<Ordinal>& comm);
527 template<
typename Ordinal,
typename Packet>
529 const Comm<Ordinal>& comm,
530 const Ordinal count,
const Packet sendBuffer[],
const int destRank
534 template<
typename Ordinal,
typename Packet>
536 ssend (
const Packet sendBuffer[],
540 const Comm<Ordinal>& comm);
546 template<
typename Ordinal,
typename Packet>
548 const Comm<Ordinal>& comm,
549 const Packet &
send,
const int destRank
556 template<
typename Ordinal,
typename Packet>
558 const Comm<Ordinal>& comm,
559 const Packet &
send,
const int destRank
568 template<
typename Ordinal,
typename Packet>
570 const Comm<Ordinal>& comm,
const Serializer<Ordinal,Packet> &serializer,
571 const Ordinal count,
const Packet*
const sendBuffer[],
const int destRank
579 template<
typename Ordinal,
typename Packet,
typename Serializer>
581 const Comm<Ordinal>& comm,
582 const Serializer& serializer,
583 const Ordinal count,
const Packet sendBuffer[],
const int destRank
590 template<
typename Ordinal,
typename Packet>
592 const Comm<Ordinal>& comm,
593 const int sourceRank,
const Ordinal count, Packet recvBuffer[]
600 template<
typename Ordinal,
typename Packet>
602 const Comm<Ordinal>& comm,
603 const int sourceRank, Packet *recv
610 template<
typename Ordinal,
typename Packet>
612 const Comm<Ordinal>& comm,
const Serializer<Ordinal,Packet> &serializer,
613 const int sourceRank,
const Ordinal count, Packet*
const recvBuffer[]
621 template<
typename Ordinal,
typename Packet,
typename Serializer>
623 const Comm<Ordinal>& comm,
624 const Serializer& serializer,
625 const int sourceRank,
const Ordinal count, Packet recvBuffer[]
633 template<
typename Ordinal,
typename Packet>
635 const Comm<Ordinal>& comm,
636 const ArrayView<const Packet> &sendBuffer,
641 template<
typename Ordinal,
typename Packet>
647 const Comm<Ordinal>& comm);
653 template<
typename Ordinal,
typename Packet>
655 const Comm<Ordinal>& comm,
665 template<
typename Ordinal,
typename Packet,
typename Serializer>
667 const Comm<Ordinal>& comm,
668 const Serializer& serializer,
669 const ArrayView<const Packet> &sendBuffer,
677 template<
typename Ordinal,
typename Packet>
678 RCP<CommRequest<Ordinal> > isend(
679 const Comm<Ordinal>& comm,
680 const ArrayRCP<const Packet> &sendBuffer,
685 template<
typename Ordinal,
typename Packet>
686 RCP<CommRequest<Ordinal> >
687 isend (
const ArrayRCP<const Packet>& sendBuffer,
690 const Comm<Ordinal>& comm);
696 template<
typename Ordinal,
typename Packet>
697 RCP<CommRequest<Ordinal> > isend(
698 const Comm<Ordinal>& comm,
699 const RCP<const Packet> &
send,
708 template<
typename Ordinal,
typename Packet,
typename Serializer>
709 RCP<CommRequest<Ordinal> > isend(
710 const Comm<Ordinal>& comm,
711 const Serializer& serializer,
712 const ArrayRCP<const Packet> &sendBuffer,
729 template<
typename Ordinal,
typename Packet>
730 RCP<CommRequest<Ordinal> >
ireceive(
731 const Comm<Ordinal>& comm,
732 const ArrayRCP<Packet> &recvBuffer,
737 template<
typename Ordinal,
typename Packet>
738 RCP<CommRequest<Ordinal> >
739 ireceive (
const ArrayRCP<Packet> &recvBuffer,
740 const int sourceRank,
742 const Comm<Ordinal>& comm);
755 template<
typename Ordinal,
typename Packet>
756 RCP<CommRequest<Ordinal> >
ireceive(
757 const Comm<Ordinal>& comm,
758 const RCP<Packet> &recv,
767 template<
typename Ordinal,
typename Packet,
typename Serializer>
768 RCP<CommRequest<Ordinal> >
ireceive(
769 const Comm<Ordinal>& comm,
770 const Serializer& serializer,
771 const ArrayRCP<Packet> &recvBuffer,
786 template<
typename Ordinal>
788 const Comm<Ordinal>& comm,
789 const ArrayView<RCP<CommRequest<Ordinal> > > &requests
821 template<
typename Ordinal>
823 waitAll (
const Comm<Ordinal>& comm,
824 const ArrayView<RCP<CommRequest<Ordinal> > >& requests,
825 const ArrayView<RCP<CommStatus<Ordinal> > >& statuses);
850 template<
typename Ordinal>
851 RCP<CommStatus<Ordinal> >
852 wait (
const Comm<Ordinal>& comm,
const Ptr<RCP<CommRequest<Ordinal> > >& request);
863 template<
typename Ordinal,
typename Packet>
870 const Packet inBuffer[],
884 template<
typename Ordinal,
typename Packet>
891 const Packet inBuffer[],
905 template<
typename Ordinal,
typename Packet>
912 const Packet inBuffer[],
922 template<
typename Ordinal,
typename Packet>
929 const Packet inBuffer[],
944 namespace MixMaxUtilities {
947 template<
bool isComparable,
typename Ordinal,
typename Packet>
951 template<
typename Ordinal,
typename Packet>
952 class Min<true,Ordinal,Packet> {
956 const Packet inBuffer[],
960 for(
int i = 0; i < count; ++i )
961 inoutBuffer[i] = TEUCHOS_MIN(inoutBuffer[i],inBuffer[i]);
966 template<
typename Ordinal,
typename Packet>
967 class Min<false,Ordinal,Packet> {
976 true,std::logic_error,
977 "Error, the type "<<TypeNameTraits<Packet>::name()
978 <<
" does not support comparison operations!"
984 template<
bool isComparable,
typename Ordinal,
typename Packet>
988 template<
typename Ordinal,
typename Packet>
989 class Max<true,Ordinal,Packet> {
993 const Packet inBuffer[],
997 for(
int i = 0; i < count; ++i )
998 inoutBuffer[i] = TEUCHOS_MAX(inoutBuffer[i],inBuffer[i]);
1003 template<
typename Ordinal,
typename Packet>
1004 class Max<false,Ordinal,Packet> {
1013 true,std::logic_error,
1014 "Error, the type "<<TypeNameTraits<Packet>::name()
1015 <<
" does not support comparison operations!"
1021 template<
bool isComparable,
typename Ordinal,
typename Packet>
1025 template<
typename Ordinal,
typename Packet>
1026 class AND<true,Ordinal,Packet> {
1029 const Ordinal count,
1030 const Packet inBuffer[],
1031 Packet inoutBuffer[]
1034 for(
int i = 0; i < count; ++i )
1035 inoutBuffer[i] = inoutBuffer[i] && inBuffer[i];
1040 template<
typename Ordinal,
typename Packet>
1041 class AND<false,Ordinal,Packet> {
1050 true,std::logic_error,
1051 "Error, the type "<<TypeNameTraits<Packet>::name()
1052 <<
" does not support logical AND operations!"
1061 template<
typename Ordinal,
typename Packet>
1063 const Ordinal count,
1064 const Packet inBuffer[],
1065 Packet inoutBuffer[]
1068 for(
int i = 0; i < count; ++i )
1069 inoutBuffer[i] += inBuffer[i];
1073 template<
typename Ordinal,
typename Packet>
1075 const Ordinal count,
1076 const Packet inBuffer[],
1077 Packet inoutBuffer[]
1080 typedef MixMaxUtilities::Min<ScalarTraits<Packet>::isComparable, Ordinal, Packet> min_type;
1081 min_type::min (count, inBuffer, inoutBuffer);
1085 template<
typename Ordinal,
typename Packet>
1087 const Ordinal count,
1088 const Packet inBuffer[],
1089 Packet inoutBuffer[]
1092 typedef MixMaxUtilities::Max<ScalarTraits<Packet>::isComparable, Ordinal, Packet> max_type;
1093 max_type::max (count,inBuffer,inoutBuffer);
1097 template<
typename Ordinal,
typename Packet>
1099 const Ordinal count,
1100 const Packet inBuffer[],
1101 Packet inoutBuffer[]
1104 typedef MixMaxUtilities::AND<ScalarTraits<Packet>::isComparable, Ordinal, Packet> and_type;
1105 and_type::andOp (count, inBuffer, inoutBuffer);
1135 template<
typename Ordinal,
typename Packet>
1136 ValueTypeReductionOp<Ordinal,Packet>*
1137 createOp (
const EReductionType reductType)
1139 typedef ScalarTraits<Packet> ST;
1140 switch (reductType) {
1142 return new SumValueReductionOp<Ordinal,Packet> ();
1145 if (ST::isComparable) {
1146 return new MinValueReductionOp<Ordinal,Packet> ();
1150 (! ST::isComparable, std::invalid_argument,
"Teuchos::createOp"
1151 "(EReductionType): The Packet type " << TypeNameTraits<Packet>::name ()
1152 <<
" is not less-than comparable, so it does not make sense to do a "
1153 "MIN reduction with it.");
1157 if (ST::isComparable) {
1158 return new MaxValueReductionOp<Ordinal,Packet> ();
1162 (! ST::isComparable, std::invalid_argument,
"Teuchos::createOp"
1163 "(EReductionType): The Packet type " << TypeNameTraits<Packet>::name ()
1164 <<
" is not less-than comparable, so it does not make sense to do a "
1165 "MAX reduction with it.");
1169 return new ANDValueReductionOp<Ordinal, Packet> ();
1173 true, std::invalid_argument,
"Teuchos::createOp(EReductionType): "
1174 "Invalid EReductionType value " << reductType <<
". Valid values "
1175 "include REDUCE_SUM, REDUCE_MIN, REDUCE_MAX, and REDUCE_AND.");
1188 template<
typename Ordinal>
1189 int Teuchos::rank(
const Comm<Ordinal>& comm)
1191 return comm.getRank();
1195 template<
typename Ordinal>
1196 int Teuchos::size(
const Comm<Ordinal>& comm)
1198 return comm.getSize();
1202 template<
typename Ordinal>
1203 void Teuchos::barrier(
const Comm<Ordinal>& comm)
1205 TEUCHOS_COMM_TIME_MONITOR(
1206 "Teuchos::CommHelpers: barrier<"
1207 <<OrdinalTraits<Ordinal>::name()
1214 template<
typename Ordinal,
typename Packet>
1215 void Teuchos::broadcast(
1216 const Comm<Ordinal>& comm,
1217 const int rootRank,
const Ordinal count, Packet buffer[]
1220 TEUCHOS_COMM_TIME_MONITOR(
1221 "Teuchos::CommHelpers: broadcast<"
1222 <<OrdinalTraits<Ordinal>::name()<<
","<<TypeNameTraits<Packet>::name()
1225 ValueTypeSerializationBuffer<Ordinal,Packet>
1226 charBuffer(count,buffer);
1228 rootRank,charBuffer.getBytes(),charBuffer.getCharBuffer()
1233 template<
typename Ordinal,
typename Packet>
1234 void Teuchos::broadcast(
1235 const Comm<Ordinal>& comm,
1237 const ArrayView<Packet> &buffer
1240 broadcast<Ordinal, Packet>(comm, rootRank, buffer.size(), buffer.getRawPtr() );
1244 template<
typename Ordinal,
typename Packet>
1245 void Teuchos::broadcast(
1246 const Comm<Ordinal>& comm,
1247 const int rootRank, Packet *
object
1250 broadcast<Ordinal,Packet>(comm,rootRank,1,object);
1254 template<
typename Ordinal,
typename Packet>
1255 void Teuchos::broadcast(
1256 const Comm<Ordinal>& comm,
1257 const int rootRank,
const Ptr<Packet> &
object
1260 broadcast<Ordinal,Packet>(comm,rootRank,1,
object.getRawPtr());
1264 template<
typename Ordinal,
typename Packet>
1265 void Teuchos::broadcast(
1266 const Comm<Ordinal>& comm,
const Serializer<Ordinal,Packet> &serializer,
1267 const int rootRank,
const Ordinal count, Packet*
const buffer[]
1270 TEUCHOS_COMM_TIME_MONITOR(
1271 "Teuchos::CommHelpers: broadcast<"
1272 <<OrdinalTraits<Ordinal>::name()<<
","<<TypeNameTraits<Packet>::name()
1273 <<
">( reference type )"
1275 ReferenceTypeSerializationBuffer<Ordinal,Packet>
1276 charBuffer(serializer, count, buffer);
1278 rootRank,charBuffer.getBytes(),charBuffer.getCharBuffer()
1283 template<
typename Ordinal,
typename Packet>
1284 void Teuchos::broadcast(
1285 const Comm<Ordinal>& comm,
const Serializer<Ordinal,Packet> &serializer,
1286 const int rootRank,
const ArrayView<
const Ptr<Packet> > &buffer
1289 Array<Packet*> bufferPtrArray;
1290 for (
int i = 0; i < buffer.size(); ++i) {
1291 bufferPtrArray.push_back(buffer[i].getRawPtr());
1293 broadcast<Ordinal,Packet>(comm, serializer, rootRank,
1294 buffer.size(), bufferPtrArray.getRawPtr());
1297 template<
typename Ordinal,
typename Packet,
typename Serializer>
1298 void Teuchos::broadcast(
1299 const Comm<Ordinal>& comm,
1300 const Serializer& serializer,
1301 const int rootRank,
const Ordinal count, Packet buffer[]
1304 TEUCHOS_COMM_TIME_MONITOR(
1305 "Teuchos::CommHelpers: broadcast<"
1306 <<OrdinalTraits<Ordinal>::name()<<
","<<TypeNameTraits<Packet>::name()
1309 ValueTypeSerializationBuffer<Ordinal,Packet,Serializer>
1310 charBuffer(count,buffer,
rcp(&serializer,
false));
1312 rootRank,charBuffer.getBytes(),charBuffer.getCharBuffer()
1317 template<
typename Ordinal,
typename Packet>
1318 void Teuchos::gatherAll(
1319 const Comm<Ordinal>& comm,
1320 const Ordinal sendCount,
const Packet sendBuffer[],
1321 const Ordinal recvCount, Packet recvBuffer[]
1324 TEUCHOS_COMM_TIME_MONITOR(
1325 "Teuchos::CommHelpers: gatherAll<"
1326 <<OrdinalTraits<Ordinal>::name()<<
","<<TypeNameTraits<Packet>::name()
1329 ConstValueTypeSerializationBuffer<Ordinal,Packet>
1330 charSendBuffer(sendCount,sendBuffer);
1331 ValueTypeSerializationBuffer<Ordinal,Packet>
1332 charRecvBuffer(recvCount,recvBuffer);
1334 charSendBuffer.getBytes(),charSendBuffer.getCharBuffer()
1335 ,charRecvBuffer.getBytes(),charRecvBuffer.getCharBuffer()
1339 template<
typename Ordinal,
typename Packet>
1341 Teuchos::gather (
const Packet sendBuf[],
1342 const Ordinal sendCount,
1344 const Ordinal recvCount,
1346 const Comm<Ordinal>& comm)
1348 TEUCHOS_COMM_TIME_MONITOR(
1349 "Teuchos::CommHelpers: gather<"
1350 <<OrdinalTraits<Ordinal>::name()<<
","<<TypeNameTraits<Packet>::name()
1353 ConstValueTypeSerializationBuffer<Ordinal,Packet>
1354 charSendBuffer (sendCount, sendBuf);
1355 ValueTypeSerializationBuffer<Ordinal,Packet>
1356 charRecvBuffer (recvCount, recvBuf);
1357 comm.gather (charSendBuffer.getBytes (),
1358 charSendBuffer.getCharBuffer (),
1359 charRecvBuffer.getBytes (),
1360 charRecvBuffer.getCharBuffer (),
1364 template<
typename Ordinal,
typename Packet>
1366 Teuchos::gatherv (
const Packet sendBuf[],
1367 const Ordinal sendCount,
1369 const Ordinal recvCounts[],
1370 const Ordinal displs[],
1372 const Comm<Ordinal>& comm)
1395 "Teuchos::gatherv: The general case is not implemented.");
1398 template<
typename Ordinal,
typename Packet>
1399 void Teuchos::gatherAll(
1400 const Comm<Ordinal>& comm,
const Serializer<Ordinal,Packet> &serializer,
1401 const Ordinal sendCount,
const Packet*
const sendBuffer[],
1402 const Ordinal recvCount, Packet*
const recvBuffer[]
1408 template<
typename Ordinal,
typename Packet,
typename Serializer>
1409 void Teuchos::gatherAll(
1410 const Comm<Ordinal>& comm,
1411 const Serializer& serializer,
1412 const Ordinal sendCount,
const Packet sendBuffer[],
1413 const Ordinal recvCount, Packet recvBuffer[]
1416 TEUCHOS_COMM_TIME_MONITOR(
1417 "Teuchos::CommHelpers: gatherAll<"
1418 <<OrdinalTraits<Ordinal>::name()<<
","<<TypeNameTraits<Packet>::name()
1421 ConstValueTypeSerializationBuffer<Ordinal,Packet,Serializer>
1422 charSendBuffer(sendCount,sendBuffer,
rcp(&serializer,
false));
1423 ValueTypeSerializationBuffer<Ordinal,Packet,Serializer>
1424 charRecvBuffer(recvCount,recvBuffer,
rcp(&serializer,
false));
1426 charSendBuffer.getBytes(),charSendBuffer.getCharBuffer()
1427 ,charRecvBuffer.getBytes(),charRecvBuffer.getCharBuffer()
1432 template<
typename Ordinal,
typename Packet>
1434 Teuchos::reduce (
const Packet sendBuf[],
1436 const Ordinal count,
1439 const Comm<Ordinal>& comm)
1445 (
true, std::logic_error,
"Teuchos::reduce<" <<
1446 TypeNameTraits<Ordinal>::name () <<
"," << TypeNameTraits<Packet>::name ()
1447 <<
">: Generic version not implemented. We only implement this function "
1448 "for Ordinal = int and Packet = specific types.");
1452 template<
typename Ordinal,
typename Packet>
1454 const Comm<Ordinal>& comm,
const ValueTypeReductionOp<Ordinal,Packet> &reductOp
1455 ,
const Ordinal count,
const Packet sendBuffer[], Packet globalReducts[]
1458 TEUCHOS_COMM_TIME_MONITOR(
1459 "Teuchos::CommHelpers: reduceAll<"
1460 <<OrdinalTraits<Ordinal>::name()<<
","<<TypeNameTraits<Packet>::name()
1461 <<
">( value type, user-defined op )"
1463 ConstValueTypeSerializationBuffer<Ordinal,Packet>
1464 charSendBuffer(count,sendBuffer);
1465 ValueTypeSerializationBuffer<Ordinal,Packet>
1466 charGlobalReducts(count,globalReducts);
1467 CharToValueTypeReductionOp<Ordinal,Packet>
1468 charReductOp(
rcp(&reductOp,
false));
1470 charReductOp,charSendBuffer.getBytes(),charSendBuffer.getCharBuffer()
1471 ,charGlobalReducts.getCharBuffer()
1476 template<
typename Ordinal,
typename Packet>
1479 const Ordinal count,
const Packet sendBuffer[], Packet globalReducts[]
1482 TEUCHOS_COMM_TIME_MONITOR(
1483 "Teuchos::CommHelpers: reduceAll<"
1484 <<OrdinalTraits<Ordinal>::name()<<
","<<TypeNameTraits<Packet>::name()
1485 <<
">( value type, "<<
toString(reductType)<<
" )"
1488 ValueTypeReductionOp<Ordinal,Packet>* reductOp =
1489 createOp<Ordinal, Packet> (reductType);
1491 reduceAll(comm,*reductOp,count,sendBuffer,globalReducts);
1493 catch (std::exception& e) {
1509 #ifdef HAVE_TEUCHOS_COMPLEX
1512 TEUCHOSCOMM_LIB_DLL_EXPORT
void
1513 reduceAll<int, std::complex<double> > (
const Comm<int>& comm,
1514 const EReductionType reductType,
1516 const std::complex<double> sendBuffer[],
1517 std::complex<double> globalReducts[]);
1519 TEUCHOSCOMM_LIB_DLL_EXPORT RCP<CommRequest<int> >
1520 ireceive<int, std::complex<double> > (
const Comm<int>& comm,
1521 const ArrayRCP<std::complex<double> >& recvBuffer,
1522 const int sourceRank);
1524 TEUCHOSCOMM_LIB_DLL_EXPORT RCP<CommRequest<int> >
1525 ireceive<int, std::complex<double> > (
const ArrayRCP<std::complex<double> > &recvBuffer,
1526 const int sourceRank,
1528 const Comm<int>& comm);
1530 TEUCHOSCOMM_LIB_DLL_EXPORT
void
1531 send<int, std::complex<double> > (
const Comm<int>& comm,
1533 const std::complex<double> sendBuffer[],
1534 const int destRank);
1536 TEUCHOSCOMM_LIB_DLL_EXPORT
void
1537 send<int, std::complex<double> > (
const std::complex<double> sendBuffer[],
1541 const Comm<int>& comm);
1543 TEUCHOSCOMM_LIB_DLL_EXPORT RCP<CommRequest<int> >
1544 isend<int, std::complex<double> > (
const ArrayRCP<const std::complex<double> >& sendBuffer,
1547 const Comm<int>& comm);
1551 TEUCHOSCOMM_LIB_DLL_EXPORT
void
1552 reduceAll<int, std::complex<float> > (
const Comm<int>& comm,
1553 const EReductionType reductType,
1555 const std::complex<float> sendBuffer[],
1556 std::complex<float> globalReducts[]);
1558 TEUCHOSCOMM_LIB_DLL_EXPORT RCP<CommRequest<int> >
1559 ireceive<int, std::complex<float> > (
const Comm<int>& comm,
1560 const ArrayRCP<std::complex<float> >& recvBuffer,
1561 const int sourceRank);
1563 TEUCHOSCOMM_LIB_DLL_EXPORT RCP<CommRequest<int> >
1564 ireceive<int, std::complex<float> > (
const ArrayRCP<std::complex<float> > &recvBuffer,
1565 const int sourceRank,
1567 const Comm<int>& comm);
1569 TEUCHOSCOMM_LIB_DLL_EXPORT
void
1570 send<int, std::complex<float> > (
const Comm<int>& comm,
1572 const std::complex<float> sendBuffer[],
1573 const int destRank);
1575 TEUCHOSCOMM_LIB_DLL_EXPORT
void
1576 send<int, std::complex<float> > (
const std::complex<float> sendBuffer[],
1580 const Comm<int>& comm);
1582 TEUCHOSCOMM_LIB_DLL_EXPORT RCP<CommRequest<int> >
1583 isend<int, std::complex<float> > (
const ArrayRCP<const std::complex<float> >& sendBuffer,
1586 const Comm<int>& comm);
1587 #endif // HAVE_TEUCHOS_COMPLEX
1592 TEUCHOSCOMM_LIB_DLL_EXPORT
void
1593 reduceAll<int, double> (
const Comm<int>& comm,
1594 const EReductionType reductType,
1596 const double sendBuffer[],
1597 double globalReducts[]);
1599 TEUCHOSCOMM_LIB_DLL_EXPORT RCP<CommRequest<int> >
1600 ireceive<int, double> (
const Comm<int>& comm,
1601 const ArrayRCP<double>& recvBuffer,
1602 const int sourceRank);
1604 TEUCHOSCOMM_LIB_DLL_EXPORT RCP<CommRequest<int> >
1605 ireceive<int, double> (
const ArrayRCP<double> &recvBuffer,
1606 const int sourceRank,
1608 const Comm<int>& comm);
1610 TEUCHOSCOMM_LIB_DLL_EXPORT
void
1611 send<int, double> (
const Comm<int>& comm,
1613 const double sendBuffer[],
1614 const int destRank);
1616 TEUCHOSCOMM_LIB_DLL_EXPORT
void
1617 send<int, double> (
const double sendBuffer[],
1621 const Comm<int>& comm);
1623 TEUCHOSCOMM_LIB_DLL_EXPORT RCP<CommRequest<int> >
1624 isend<int, double> (
const ArrayRCP<const double>& sendBuffer,
1627 const Comm<int>& comm);
1631 TEUCHOSCOMM_LIB_DLL_EXPORT
void
1632 reduceAll<int, float> (
const Comm<int>& comm,
1633 const EReductionType reductType,
1635 const float sendBuffer[],
1636 float globalReducts[]);
1638 TEUCHOSCOMM_LIB_DLL_EXPORT RCP<CommRequest<int> >
1639 ireceive<int, float> (
const Comm<int>& comm,
1640 const ArrayRCP<float>& recvBuffer,
1641 const int sourceRank);
1643 TEUCHOSCOMM_LIB_DLL_EXPORT RCP<CommRequest<int> >
1644 ireceive<int, float> (
const ArrayRCP<float> &recvBuffer,
1645 const int sourceRank,
1647 const Comm<int>& comm);
1649 TEUCHOSCOMM_LIB_DLL_EXPORT
void
1650 send<int, float> (
const Comm<int>& comm,
1652 const float sendBuffer[],
1653 const int destRank);
1655 TEUCHOSCOMM_LIB_DLL_EXPORT
void
1656 send<int, float> (
const float sendBuffer[],
1660 const Comm<int>& comm);
1662 TEUCHOSCOMM_LIB_DLL_EXPORT RCP<CommRequest<int> >
1663 isend<int, float> (
const ArrayRCP<const float>& sendBuffer,
1666 const Comm<int>& comm);
1670 TEUCHOSCOMM_LIB_DLL_EXPORT
void
1671 gather<int, long long> (
const long long sendBuf[],
1672 const int sendCount,
1673 long long recvBuf[],
1674 const int recvCount,
1676 const Comm<int>& comm);
1678 TEUCHOSCOMM_LIB_DLL_EXPORT
void
1679 gatherv<int, long long> (
const long long sendBuf[],
1680 const int sendCount,
1681 long long recvBuf[],
1682 const int recvCounts[],
1685 const Comm<int>& comm);
1687 TEUCHOSCOMM_LIB_DLL_EXPORT
void
1688 reduceAll<int, long long> (
const Comm<int>& comm,
1689 const EReductionType reductType,
1691 const long long sendBuffer[],
1692 long long globalReducts[]);
1694 TEUCHOSCOMM_LIB_DLL_EXPORT RCP<CommRequest<int> >
1695 ireceive<int, long long> (
const Comm<int>& comm,
1696 const ArrayRCP<long long>& recvBuffer,
1697 const int sourceRank);
1699 TEUCHOSCOMM_LIB_DLL_EXPORT RCP<CommRequest<int> >
1700 ireceive<int, long long> (
const ArrayRCP<long long> &recvBuffer,
1701 const int sourceRank,
1703 const Comm<int>& comm);
1705 TEUCHOSCOMM_LIB_DLL_EXPORT
void
1706 send<int, long long> (
const Comm<int>& comm,
1708 const long long sendBuffer[],
1709 const int destRank);
1711 TEUCHOSCOMM_LIB_DLL_EXPORT
void
1712 send<int, long long> (
const long long sendBuffer[],
1716 const Comm<int>& comm);
1718 TEUCHOSCOMM_LIB_DLL_EXPORT RCP<CommRequest<int> >
1719 isend<int, long long> (
const ArrayRCP<const long long>& sendBuffer,
1722 const Comm<int>& comm);
1726 TEUCHOSCOMM_LIB_DLL_EXPORT
void
1727 gather<int, unsigned long long> (
const unsigned long long sendBuf[],
1728 const int sendCount,
1729 unsigned long long recvBuf[],
1730 const int recvCount,
1732 const Comm<int>& comm);
1734 TEUCHOSCOMM_LIB_DLL_EXPORT
void
1735 gatherv<int, unsigned long long> (
const unsigned long long sendBuf[],
1736 const int sendCount,
1737 unsigned long long recvBuf[],
1738 const int recvCounts[],
1741 const Comm<int>& comm);
1743 TEUCHOSCOMM_LIB_DLL_EXPORT
void
1744 reduceAll<int, unsigned long long> (
const Comm<int>& comm,
1745 const EReductionType reductType,
1747 const unsigned long long sendBuffer[],
1748 unsigned long long globalReducts[]);
1750 TEUCHOSCOMM_LIB_DLL_EXPORT RCP<CommRequest<int> >
1751 ireceive<int, unsigned long long> (
const Comm<int>& comm,
1752 const ArrayRCP<unsigned long long>& recvBuffer,
1753 const int sourceRank);
1755 TEUCHOSCOMM_LIB_DLL_EXPORT RCP<CommRequest<int> >
1756 ireceive<int, unsigned long long> (
const ArrayRCP<unsigned long long> &recvBuffer,
1757 const int sourceRank,
1759 const Comm<int>& comm);
1761 TEUCHOSCOMM_LIB_DLL_EXPORT
void
1762 send<int, unsigned long long> (
const Comm<int>& comm,
1764 const unsigned long long sendBuffer[],
1765 const int destRank);
1767 TEUCHOSCOMM_LIB_DLL_EXPORT
void
1768 send<int, unsigned long long> (
const unsigned long long sendBuffer[],
1772 const Comm<int>& comm);
1774 TEUCHOSCOMM_LIB_DLL_EXPORT RCP<CommRequest<int> >
1775 isend<int, unsigned long long> (
const ArrayRCP<const unsigned long long>& sendBuffer,
1778 const Comm<int>& comm);
1782 TEUCHOSCOMM_LIB_DLL_EXPORT
void
1783 gather<int, long> (
const long sendBuf[],
1784 const int sendCount,
1786 const int recvCount,
1788 const Comm<int>& comm);
1790 TEUCHOSCOMM_LIB_DLL_EXPORT
void
1791 gatherv<int, long> (
const long sendBuf[],
1792 const int sendCount,
1794 const int recvCounts[],
1797 const Comm<int>& comm);
1799 TEUCHOSCOMM_LIB_DLL_EXPORT
void
1800 reduceAll<int, long> (
const Comm<int>& comm,
1801 const EReductionType reductType,
1803 const long sendBuffer[],
1804 long globalReducts[]);
1806 TEUCHOSCOMM_LIB_DLL_EXPORT RCP<CommRequest<int> >
1807 ireceive<int, long> (
const Comm<int>& comm,
1808 const ArrayRCP<long>& recvBuffer,
1809 const int sourceRank);
1811 TEUCHOSCOMM_LIB_DLL_EXPORT RCP<CommRequest<int> >
1812 ireceive<int, long> (
const ArrayRCP<long> &recvBuffer,
1813 const int sourceRank,
1815 const Comm<int>& comm);
1817 TEUCHOSCOMM_LIB_DLL_EXPORT
void
1818 send<int, long> (
const Comm<int>& comm,
1820 const long sendBuffer[],
1821 const int destRank);
1823 TEUCHOSCOMM_LIB_DLL_EXPORT
void
1824 send<int, long> (
const long sendBuffer[],
1828 const Comm<int>& comm);
1830 TEUCHOSCOMM_LIB_DLL_EXPORT RCP<CommRequest<int> >
1831 isend<int, long> (
const ArrayRCP<const long>& sendBuffer,
1834 const Comm<int>& comm);
1838 TEUCHOSCOMM_LIB_DLL_EXPORT
void
1839 gather<int, unsigned long> (
const unsigned long sendBuf[],
1840 const int sendCount,
1841 unsigned long recvBuf[],
1842 const int recvCount,
1844 const Comm<int>& comm);
1846 TEUCHOSCOMM_LIB_DLL_EXPORT
void
1847 gatherv<int, unsigned long> (
const unsigned long sendBuf[],
1848 const int sendCount,
1849 unsigned long recvBuf[],
1850 const int recvCounts[],
1853 const Comm<int>& comm);
1855 TEUCHOSCOMM_LIB_DLL_EXPORT
void
1856 reduceAll<int, unsigned long> (
const Comm<int>& comm,
1857 const EReductionType reductType,
1859 const unsigned long sendBuffer[],
1860 unsigned long globalReducts[]);
1862 TEUCHOSCOMM_LIB_DLL_EXPORT RCP<CommRequest<int> >
1863 ireceive<int, unsigned long> (
const Comm<int>& comm,
1864 const ArrayRCP<unsigned long>& recvBuffer,
1865 const int sourceRank);
1867 TEUCHOSCOMM_LIB_DLL_EXPORT RCP<CommRequest<int> >
1868 ireceive<int, unsigned long> (
const ArrayRCP<unsigned long> &recvBuffer,
1869 const int sourceRank,
1871 const Comm<int>& comm);
1873 TEUCHOSCOMM_LIB_DLL_EXPORT
void
1874 send<int, unsigned long> (
const Comm<int>& comm,
1876 const unsigned long sendBuffer[],
1877 const int destRank);
1879 TEUCHOSCOMM_LIB_DLL_EXPORT
void
1880 send<int, unsigned long> (
const unsigned long sendBuffer[],
1884 const Comm<int>& comm);
1886 TEUCHOSCOMM_LIB_DLL_EXPORT RCP<CommRequest<int> >
1887 isend<int, unsigned long> (
const ArrayRCP<const unsigned long>& sendBuffer,
1890 const Comm<int>& comm);
1894 TEUCHOSCOMM_LIB_DLL_EXPORT
void
1895 gather<int, int> (
const int sendBuf[],
1896 const int sendCount,
1898 const int recvCount,
1900 const Comm<int>& comm);
1902 TEUCHOSCOMM_LIB_DLL_EXPORT
void
1903 gatherv<int, int> (
const int sendBuf[],
1904 const int sendCount,
1906 const int recvCounts[],
1909 const Comm<int>& comm);
1911 TEUCHOSCOMM_LIB_DLL_EXPORT
void
1912 scatter (
const int sendBuf[],
1913 const int sendCount,
1915 const int recvCount,
1917 const Comm<int>& comm);
1919 TEUCHOSCOMM_LIB_DLL_EXPORT
void
1920 reduce<int, int> (
const int sendBuf[],
1923 const EReductionType reductType,
1925 const Comm<int>& comm);
1927 TEUCHOSCOMM_LIB_DLL_EXPORT
void
1928 reduce<int, long> (
const long sendBuf[],
1931 const EReductionType reductType,
1933 const Comm<int>& comm);
1935 TEUCHOSCOMM_LIB_DLL_EXPORT
void
1936 reduce<int, unsigned long> (
const unsigned long sendBuf[],
1937 unsigned long recvBuf[],
1939 const EReductionType reductType,
1941 const Comm<int>& comm);
1943 TEUCHOSCOMM_LIB_DLL_EXPORT
void
1944 reduce<int, unsigned long long > (
const unsigned long long sendBuf[],
1945 unsigned long long recvBuf[],
1947 const EReductionType reductType,
1949 const Comm<int>& comm);
1951 TEUCHOSCOMM_LIB_DLL_EXPORT
void
1952 reduce<int, double> (
const double sendBuf[],
1955 const EReductionType reductType,
1957 const Comm<int>& comm);
1959 TEUCHOSCOMM_LIB_DLL_EXPORT
void
1960 reduceAll<int, int> (
const Comm<int>& comm,
1961 const EReductionType reductType,
1963 const int sendBuffer[],
1964 int globalReducts[]);
1967 TEUCHOSCOMM_LIB_DLL_EXPORT RCP<CommRequest<int> >
1968 ireceive<int, int> (
const Comm<int>& comm,
1969 const ArrayRCP<int>& recvBuffer,
1970 const int sourceRank);
1972 TEUCHOSCOMM_LIB_DLL_EXPORT RCP<CommRequest<int> >
1973 ireceive<int, int> (
const ArrayRCP<int> &recvBuffer,
1974 const int sourceRank,
1976 const Comm<int>& comm);
1978 TEUCHOSCOMM_LIB_DLL_EXPORT
void
1979 send<int, int> (
const Comm<int>& comm,
1981 const int sendBuffer[],
1982 const int destRank);
1984 TEUCHOSCOMM_LIB_DLL_EXPORT
void
1985 send<int, int> (
const int sendBuffer[],
1989 const Comm<int>& comm);
1991 TEUCHOSCOMM_LIB_DLL_EXPORT RCP<CommRequest<int> >
1992 isend<int, int> (
const ArrayRCP<const int>& sendBuffer,
1995 const Comm<int>& comm);
1999 TEUCHOSCOMM_LIB_DLL_EXPORT
void
2000 gather<int, unsigned int> (
const unsigned int sendBuf[],
2001 const int sendCount,
2002 unsigned int recvBuf[],
2003 const int recvCount,
2005 const Comm<int>& comm);
2007 TEUCHOSCOMM_LIB_DLL_EXPORT
void
2008 gatherv<int, unsigned int> (
const unsigned int sendBuf[],
2009 const int sendCount,
2010 unsigned int recvBuf[],
2011 const int recvCounts[],
2014 const Comm<int>& comm);
2016 TEUCHOSCOMM_LIB_DLL_EXPORT
void
2017 reduceAll<int, unsigned int> (
const Comm<int>& comm,
2018 const EReductionType reductType,
2020 const unsigned int sendBuffer[],
2021 unsigned int globalReducts[]);
2023 TEUCHOSCOMM_LIB_DLL_EXPORT RCP<CommRequest<int> >
2024 ireceive<int, unsigned int> (
const Comm<int>& comm,
2025 const ArrayRCP<unsigned int>& recvBuffer,
2026 const int sourceRank);
2028 TEUCHOSCOMM_LIB_DLL_EXPORT RCP<CommRequest<int> >
2029 ireceive<int, unsigned int> (
const ArrayRCP<unsigned int> &recvBuffer,
2030 const int sourceRank,
2032 const Comm<int>& comm);
2034 TEUCHOSCOMM_LIB_DLL_EXPORT
void
2035 send<int, unsigned int> (
const Comm<int>& comm,
2037 const unsigned int sendBuffer[],
2038 const int destRank);
2040 TEUCHOSCOMM_LIB_DLL_EXPORT
void
2041 send<int, unsigned int> (
const unsigned int sendBuffer[],
2045 const Comm<int>& comm);
2047 TEUCHOSCOMM_LIB_DLL_EXPORT RCP<CommRequest<int> >
2048 isend<int, unsigned int> (
const ArrayRCP<const unsigned int>& sendBuffer,
2051 const Comm<int>& comm);
2055 TEUCHOSCOMM_LIB_DLL_EXPORT
void
2056 gather<int, short> (
const short sendBuf[],
2057 const int sendCount,
2059 const int recvCount,
2061 const Comm<int>& comm);
2063 TEUCHOSCOMM_LIB_DLL_EXPORT
void
2064 gatherv<int, short> (
const short sendBuf[],
2065 const int sendCount,
2067 const int recvCounts[],
2070 const Comm<int>& comm);
2072 TEUCHOSCOMM_LIB_DLL_EXPORT
void
2073 reduceAll<int, short> (
const Comm<int>& comm,
2074 const EReductionType reductType,
2076 const short sendBuffer[],
2077 short globalReducts[]);
2079 TEUCHOSCOMM_LIB_DLL_EXPORT RCP<CommRequest<int> >
2080 ireceive<int, short> (
const Comm<int>& comm,
2081 const ArrayRCP<short>& recvBuffer,
2082 const int sourceRank);
2084 TEUCHOSCOMM_LIB_DLL_EXPORT RCP<CommRequest<int> >
2085 ireceive<int, short> (
const ArrayRCP<short> &recvBuffer,
2086 const int sourceRank,
2088 const Comm<int>& comm);
2090 TEUCHOSCOMM_LIB_DLL_EXPORT
void
2091 send<int, short> (
const Comm<int>& comm,
2093 const short sendBuffer[],
2094 const int destRank);
2096 TEUCHOSCOMM_LIB_DLL_EXPORT
void
2097 send<int, short> (
const short sendBuffer[],
2101 const Comm<int>& comm);
2103 TEUCHOSCOMM_LIB_DLL_EXPORT RCP<CommRequest<int> >
2104 isend<int, short> (
const ArrayRCP<const short>& sendBuffer,
2107 const Comm<int>& comm);
2120 TEUCHOSCOMM_LIB_DLL_EXPORT
void
2121 reduceAll<int, char> (
const Comm<int>& comm,
2122 const EReductionType reductType,
2124 const char sendBuffer[],
2125 char globalReducts[]);
2130 template<
typename Ordinal,
typename Packet>
2133 ,
const Packet &
send,
const Ptr<Packet> &globalReduct
2138 reduceAll<Ordinal,Packet>(comm, reductType, 1, &
send, &*globalReduct);
2142 template<
typename Ordinal,
typename Packet>
2144 const Comm<Ordinal>& comm,
const Serializer<Ordinal,Packet> &serializer,
2145 const ReferenceTypeReductionOp<Ordinal,Packet> &reductOp,
2146 const Ordinal count,
const Packet*
const sendBuffer[], Packet*
const globalReducts[]
2149 TEUCHOS_COMM_TIME_MONITOR(
2150 "Teuchos::CommHelpers: reduceAll<"
2151 <<OrdinalTraits<Ordinal>::name()<<
","<<TypeNameTraits<Packet>::name()
2152 <<
">( reference type )"
2154 ConstReferenceTypeSerializationBuffer<Ordinal,Packet>
2155 charSendBuffer(serializer,count,sendBuffer);
2156 ReferenceTypeSerializationBuffer<Ordinal,Packet>
2157 charGlobalReducts(serializer,count,globalReducts);
2158 CharToReferenceTypeReductionOp<Ordinal,Packet>
2159 charReductOp(
rcp(&serializer,
false),
rcp(&reductOp,
false));
2161 charReductOp,charSendBuffer.getBytes(),charSendBuffer.getCharBuffer()
2162 ,charGlobalReducts.getCharBuffer()
2166 template<
typename Ordinal,
typename Packet,
typename Serializer>
2168 const Comm<Ordinal>& comm,
2169 const Serializer& serializer,
2170 const ValueTypeReductionOp<Ordinal,Packet> &reductOp,
2171 const Ordinal count,
const Packet sendBuffer[], Packet globalReducts[]
2174 TEUCHOS_COMM_TIME_MONITOR(
2175 "Teuchos::CommHelpers: reduceAll<"
2176 <<OrdinalTraits<Ordinal>::name()<<
","<<TypeNameTraits<Packet>::name()
2177 <<
">( value type, user-defined op )"
2179 ConstValueTypeSerializationBuffer<Ordinal,Packet,Serializer>
2180 charSendBuffer(count,sendBuffer,
rcp(&serializer,
false));
2181 ValueTypeSerializationBuffer<Ordinal,Packet,Serializer>
2182 charGlobalReducts(count,globalReducts,
rcp(&serializer,
false));
2183 CharToValueTypeReductionOp<Ordinal,Packet,Serializer>
2184 charReductOp(
rcp(&reductOp,
false),
rcp(&serializer,
false));
2186 charReductOp,charSendBuffer.getBytes(),charSendBuffer.getCharBuffer()
2187 ,charGlobalReducts.getCharBuffer()
2192 template<
typename Ordinal,
typename Packet,
typename Serializer>
2194 const Comm<Ordinal>& comm,
2195 const Serializer& serializer,
2197 const Ordinal count,
const Packet sendBuffer[], Packet globalReducts[]
2200 TEUCHOS_COMM_TIME_MONITOR(
2201 "Teuchos::CommHelpers: reduceAll<"
2202 <<OrdinalTraits<Ordinal>::name()<<
","<<TypeNameTraits<Packet>::name()
2203 <<
">( value type, "<<
toString(reductType)<<
" )"
2206 ValueTypeReductionOp<Ordinal,Packet>* reductOp =
2207 createOp<Ordinal, Packet> (reductType);
2209 reduceAll(comm,serializer,*reductOp,count,sendBuffer,globalReducts);
2211 catch (std::exception& e) {
2219 template<
typename Ordinal,
typename Packet>
2221 const Comm<Ordinal>& comm,
const ValueTypeReductionOp<Ordinal,Packet> &reductOp,
2222 const Ordinal count,
const Packet sendBuffer[], Packet scanReducts[]
2225 TEUCHOS_COMM_TIME_MONITOR(
2226 "Teuchos::CommHelpers: scan<"
2227 <<OrdinalTraits<Ordinal>::name()<<
","<<TypeNameTraits<Packet>::name()
2228 <<
">( value type, user-defined op )"
2230 ConstValueTypeSerializationBuffer<Ordinal,Packet>
2231 charSendBuffer(count,sendBuffer);
2232 ValueTypeSerializationBuffer<Ordinal,Packet>
2233 charScanReducts(count,scanReducts);
2234 CharToValueTypeReductionOp<Ordinal,Packet>
2235 charReductOp(
rcp(&reductOp,
false));
2237 charReductOp,charSendBuffer.getBytes(),charSendBuffer.getCharBuffer()
2238 ,charScanReducts.getCharBuffer()
2243 template<
typename Ordinal,
typename Packet>
2246 const Ordinal count,
const Packet sendBuffer[], Packet scanReducts[]
2249 TEUCHOS_COMM_TIME_MONITOR(
2250 "Teuchos::CommHelpers: scan<"
2251 <<OrdinalTraits<Ordinal>::name()<<
","<<TypeNameTraits<Packet>::name()
2252 <<
">( value type, "<<
toString(reductType)<<
" )"
2255 ValueTypeReductionOp<Ordinal,Packet>* reductOp =
2256 createOp<Ordinal, Packet> (reductType);
2258 scan(comm,*reductOp,count,sendBuffer,scanReducts);
2260 catch (std::exception& e) {
2268 template<
typename Ordinal,
typename Packet>
2271 const Packet &
send,
const Ptr<Packet> &scanReduct
2274 scan<Ordinal,Packet>(comm, reductType, 1, &
send, &*scanReduct);
2278 template<
typename Ordinal,
typename Packet>
2280 const Comm<Ordinal>& comm,
const Serializer<Ordinal,Packet> &serializer,
2281 const ReferenceTypeReductionOp<Ordinal,Packet> &reductOp,
2282 const Ordinal count,
const Packet*
const sendBuffer[], Packet*
const scanReducts[]
2288 template<
typename Ordinal,
typename Packet,
typename Serializer>
2290 const Comm<Ordinal>& comm,
2291 const Serializer& serializer,
2292 const ValueTypeReductionOp<Ordinal,Packet> &reductOp,
2293 const Ordinal count,
const Packet sendBuffer[], Packet scanReducts[]
2296 TEUCHOS_COMM_TIME_MONITOR(
2297 "Teuchos::CommHelpers: scan<"
2298 <<OrdinalTraits<Ordinal>::name()<<
","<<TypeNameTraits<Packet>::name()
2299 <<
">( value type, user-defined op )"
2301 ConstValueTypeSerializationBuffer<Ordinal,Packet,Serializer>
2302 charSendBuffer(count,sendBuffer,
rcp(&serializer,
false));
2303 ValueTypeSerializationBuffer<Ordinal,Packet,Serializer>
2304 charScanReducts(count,scanReducts,
rcp(&serializer,
false));
2305 CharToValueTypeReductionOp<Ordinal,Packet,Serializer>
2306 charReductOp(
rcp(&reductOp,
false),
rcp(&serializer,
false));
2308 charReductOp,charSendBuffer.getBytes(),charSendBuffer.getCharBuffer()
2309 ,charScanReducts.getCharBuffer()
2314 template<
typename Ordinal,
typename Packet,
typename Serializer>
2316 const Comm<Ordinal>& comm,
2317 const Serializer& serializer,
2319 const Ordinal count,
const Packet sendBuffer[], Packet scanReducts[]
2322 TEUCHOS_COMM_TIME_MONITOR(
2323 "Teuchos::CommHelpers: scan<"
2324 <<OrdinalTraits<Ordinal>::name()<<
","<<TypeNameTraits<Packet>::name()
2325 <<
">( value type, "<<
toString(reductType)<<
" )"
2328 ValueTypeReductionOp<Ordinal,Packet>* reductOp =
2329 createOp<Ordinal, Packet> (reductType);
2331 scan(comm,serializer,*reductOp,count,sendBuffer,scanReducts);
2333 catch (std::exception& e) {
2340 template<
typename Ordinal,
typename Packet>
2342 const Comm<Ordinal>& comm,
2343 const Ordinal count,
const Packet sendBuffer[],
const int destRank
2346 TEUCHOS_COMM_TIME_MONITOR(
2347 "Teuchos::CommHelpers: send<"
2348 <<OrdinalTraits<Ordinal>::name()<<
","<<TypeNameTraits<Packet>::name()
2351 ConstValueTypeSerializationBuffer<Ordinal,Packet>
2352 charSendBuffer(count,sendBuffer);
2354 charSendBuffer.getBytes(),charSendBuffer.getCharBuffer()
2359 template<
typename Ordinal,
typename Packet>
2362 const Ordinal count,
2367 TEUCHOS_COMM_TIME_MONITOR(
2368 "Teuchos::CommHelpers: send<"
2373 comm.
send (charSendBuffer.getBytes (), charSendBuffer.getCharBuffer (), destRank, tag);
2376 template<
typename Ordinal,
typename Packet>
2378 const Comm<Ordinal>& comm,
2379 const Ordinal count,
const Packet sendBuffer[],
const int destRank
2382 TEUCHOS_COMM_TIME_MONITOR(
2383 "Teuchos::CommHelpers: ssend<"
2384 <<OrdinalTraits<Ordinal>::name()<<
","<<TypeNameTraits<Packet>::name()
2387 ConstValueTypeSerializationBuffer<Ordinal,Packet>
2388 charSendBuffer(count,sendBuffer);
2390 charSendBuffer.getBytes(),charSendBuffer.getCharBuffer()
2395 template<
typename Ordinal,
typename Packet>
2398 const Ordinal count,
2403 TEUCHOS_COMM_TIME_MONITOR(
2404 "Teuchos::CommHelpers: ssend<"
2409 buf_type charSendBuffer (count, sendBuffer);
2410 comm.
ssend (charSendBuffer.getBytes (),
2411 charSendBuffer.getCharBuffer (),
2415 template<
typename Ordinal,
typename Packet>
2417 const Comm<Ordinal>& comm,
2418 const Packet &
send,
const int destRank
2421 Teuchos::send<Ordinal,Packet>(comm,1,&
send,destRank);
2424 template<
typename Ordinal,
typename Packet>
2426 const Comm<Ordinal>& comm,
2427 const Packet &
send,
const int destRank
2430 Teuchos::ssend<Ordinal,Packet>(comm,1,&
send,destRank);
2433 template<
typename Ordinal,
typename Packet>
2435 const Comm<Ordinal>& comm,
const Serializer<Ordinal,Packet> &serializer,
2436 const Ordinal count,
const Packet*
const sendBuffer[],
const int destRank
2442 template<
typename Ordinal,
typename Packet,
typename Serializer>
2444 const Comm<Ordinal>& comm,
2445 const Serializer& serializer,
2446 const Ordinal count,
const Packet sendBuffer[],
const int destRank
2449 TEUCHOS_COMM_TIME_MONITOR(
2450 "Teuchos::CommHelpers: send<"
2451 <<OrdinalTraits<Ordinal>::name()<<
","<<TypeNameTraits<Packet>::name()
2454 ConstValueTypeSerializationBuffer<Ordinal,Packet,Serializer>
2455 charSendBuffer(count,sendBuffer,
rcp(&serializer,
false));
2457 charSendBuffer.getBytes(),charSendBuffer.getCharBuffer()
2462 template<
typename Ordinal,
typename Packet>
2463 int Teuchos::receive(
2464 const Comm<Ordinal>& comm,
2465 const int sourceRank,
const Ordinal count, Packet recvBuffer[]
2468 TEUCHOS_COMM_TIME_MONITOR(
2469 "Teuchos::CommHelpers: receive<"
2470 <<OrdinalTraits<Ordinal>::name()<<
","<<TypeNameTraits<Packet>::name()
2473 ValueTypeSerializationBuffer<Ordinal,Packet>
2474 charRecvBuffer(count,recvBuffer);
2475 return comm.receive(
2477 ,charRecvBuffer.getBytes(),charRecvBuffer.getCharBuffer()
2482 template<
typename Ordinal,
typename Packet>
2483 int Teuchos::receive(
2484 const Comm<Ordinal>& comm,
2485 const int sourceRank, Packet *recv
2488 return Teuchos::receive<Ordinal,Packet>(comm,sourceRank,1,recv);
2492 template<
typename Ordinal,
typename Packet>
2493 int Teuchos::receive(
2494 const Comm<Ordinal>& comm,
const Serializer<Ordinal,Packet> &serializer,
2495 const int sourceRank,
const Ordinal count, Packet*
const recvBuffer[]
2501 template<
typename Ordinal,
typename Packet,
typename Serializer>
2502 int Teuchos::receive(
2503 const Comm<Ordinal>& comm,
2504 const Serializer& serializer,
2505 const int sourceRank,
const Ordinal count, Packet recvBuffer[]
2508 TEUCHOS_COMM_TIME_MONITOR(
2509 "Teuchos::CommHelpers: receive<"
2510 <<OrdinalTraits<Ordinal>::name()<<
","<<TypeNameTraits<Packet>::name()
2513 ValueTypeSerializationBuffer<Ordinal,Packet,Serializer>
2514 charRecvBuffer(count,recvBuffer,
rcp(&serializer,
false));
2515 return comm.receive(
2517 ,charRecvBuffer.getBytes(),charRecvBuffer.getCharBuffer()
2521 template<
typename Ordinal,
typename Packet>
2523 const Comm<Ordinal>& comm,
2524 const ArrayView<const Packet> &sendBuffer,
2528 TEUCHOS_COMM_TIME_MONITOR(
2529 "Teuchos::CommHelpers: readySend<"
2530 <<OrdinalTraits<Ordinal>::name()<<
","<<TypeNameTraits<Packet>::name()
2533 ConstValueTypeSerializationBuffer<Ordinal,Packet>
2534 charSendBuffer(sendBuffer.size(), sendBuffer.getRawPtr());
2535 comm.readySend( charSendBuffer.getCharBufferView(), destRank );
2538 template<
typename Ordinal,
typename Packet>
2541 const Ordinal count,
2546 TEUCHOS_COMM_TIME_MONITOR(
2547 "Teuchos::CommHelpers: readySend<"
2552 buf_type charSendBuffer (count, sendBuffer);
2553 comm.
readySend (charSendBuffer.getBytes (),
2554 charSendBuffer.getCharBuffer (),
2558 template<
typename Ordinal,
typename Packet>
2560 const Comm<Ordinal>& comm,
2565 readySend<Ordinal, Packet>( comm,
arrayView(&send,1), destRank );
2568 template<
typename Ordinal,
typename Packet,
typename Serializer>
2570 const Comm<Ordinal>& comm,
2571 const Serializer& serializer,
2572 const ArrayView<const Packet> &sendBuffer,
2576 TEUCHOS_COMM_TIME_MONITOR(
2577 "Teuchos::CommHelpers: readySend<"
2578 <<OrdinalTraits<Ordinal>::name()<<
","<<TypeNameTraits<Packet>::name()
2581 ConstValueTypeSerializationBuffer<Ordinal,Packet,Serializer>
2582 charSendBuffer(sendBuffer.size(), sendBuffer.getRawPtr(), serializer);
2583 comm.readySend( charSendBuffer.getCharBufferView(), destRank );
2586 template<
typename Ordinal,
typename Packet>
2589 const Comm<Ordinal>& comm,
2590 const ArrayRCP<const Packet> &sendBuffer,
2594 TEUCHOS_COMM_TIME_MONITOR(
2595 "Teuchos::CommHelpers: isend<"
2596 <<OrdinalTraits<Ordinal>::name()<<
","<<TypeNameTraits<Packet>::name()
2599 ConstValueTypeSerializationBuffer<Ordinal,Packet>
2600 charSendBuffer(sendBuffer.size(), sendBuffer.getRawPtr());
2601 RCP<CommRequest<Ordinal> > commRequest = comm.isend(
2602 charSendBuffer.getCharBufferView(), destRank );
2607 template<
typename Ordinal,
typename Packet>
2612 const Comm<Ordinal>& comm)
2614 TEUCHOS_COMM_TIME_MONITOR(
2615 "Teuchos::isend<" << OrdinalTraits<Ordinal>::name () <<
","
2616 << TypeNameTraits<Packet>::name () <<
">");
2617 ConstValueTypeSerializationBuffer<Ordinal,Packet>
2618 charSendBuffer (sendBuffer.size (), sendBuffer.getRawPtr ());
2619 RCP<CommRequest<Ordinal> > commRequest =
2620 comm.isend (charSendBuffer.getCharBufferView (), destRank, tag);
2625 template<
typename Ordinal,
typename Packet>
2628 const Comm<Ordinal>& comm,
2629 const RCP<const Packet> &
send,
2633 const ArrayRCP<const Packet> sendBuffer =
2637 return isend<Ordinal, Packet>( comm, sendBuffer, destRank );
2640 template<
typename Ordinal,
typename Packet,
typename Serializer>
2643 const Comm<Ordinal>& comm,
2644 const Serializer& serializer,
2645 const ArrayRCP<const Packet> &sendBuffer,
2649 TEUCHOS_COMM_TIME_MONITOR(
2650 "Teuchos::CommHelpers: isend<"
2651 <<OrdinalTraits<Ordinal>::name()<<
","<<TypeNameTraits<Packet>::name()
2654 ConstValueTypeSerializationBuffer<Ordinal,Packet,Serializer>
2655 charSendBuffer(sendBuffer.size(), sendBuffer.getRawPtr(), serializer);
2656 RCP<CommRequest<Ordinal> > commRequest = comm.isend(
2657 charSendBuffer.getCharBufferView(), destRank );
2662 template<
typename Ordinal,
typename Packet>
2665 const Comm<Ordinal>& comm,
2666 const ArrayRCP<Packet> &recvBuffer,
2667 const int sourceRank
2670 TEUCHOS_COMM_TIME_MONITOR(
2671 "Teuchos::ireceive<int, " <<
"," << TypeNameTraits<Packet>::name () <<
">");
2672 ValueTypeSerializationBuffer<Ordinal,Packet>
2673 charRecvBuffer(recvBuffer.size(), recvBuffer.getRawPtr());
2674 RCP<CommRequest<Ordinal> > commRequest = comm.ireceive(
2675 charRecvBuffer.getCharBufferView(), sourceRank );
2680 template<
typename Ordinal,
typename Packet>
2683 const int sourceRank,
2687 TEUCHOS_COMM_TIME_MONITOR(
2688 "Teuchos::ireceive<int, " <<
"," << TypeNameTraits<Packet>::name () <<
">");
2689 ValueTypeSerializationBuffer<int, Packet>
2690 charRecvBuffer (recvBuffer.
size (), recvBuffer.
getRawPtr ());
2691 RCP<CommRequest<int> > commRequest =
2692 comm.
ireceive (charRecvBuffer.getCharBufferView (), sourceRank, tag);
2697 template<
typename Ordinal,
typename Packet>
2700 const Comm<Ordinal>& comm,
2701 const RCP<Packet> &recv,
2702 const int sourceRank
2705 const ArrayRCP<Packet> recvBuffer =
2709 return ireceive<Ordinal, Packet>( comm, recvBuffer, sourceRank );
2712 template<
typename Ordinal,
typename Packet,
typename Serializer>
2715 const Comm<Ordinal>& comm,
2716 const Serializer& serializer,
2717 const ArrayRCP<Packet> &recvBuffer,
2718 const int sourceRank
2721 TEUCHOS_COMM_TIME_MONITOR(
2722 "Teuchos::CommHelpers: ireceive<"
2723 <<OrdinalTraits<Ordinal>::name()<<
","<<TypeNameTraits<Packet>::name()
2726 ValueTypeSerializationBuffer<Ordinal,Packet,Serializer>
2727 charRecvBuffer(recvBuffer.size(), recvBuffer.getRawPtr(), serializer);
2728 RCP<CommRequest<Ordinal> > commRequest = comm.ireceive(
2729 charRecvBuffer.getCharBufferView(), sourceRank );
2734 template<
typename Ordinal>
2735 void Teuchos::waitAll(
2736 const Comm<Ordinal>& comm,
2737 const ArrayView<RCP<CommRequest<Ordinal> > > &requests
2740 comm.waitAll(requests);
2744 template<
typename Ordinal>
2746 Teuchos::waitAll (
const Comm<Ordinal>& comm,
2747 const ArrayView<RCP<CommRequest<Ordinal> > >& requests,
2748 const ArrayView<RCP<CommStatus<Ordinal> > >& statuses)
2750 comm.waitAll (requests, statuses);
2754 template<
typename Ordinal>
2756 Teuchos::wait (
const Comm<Ordinal>& comm,
2757 const Ptr<RCP<CommRequest<Ordinal> > > &request)
2759 return comm.wait (request);
2763 #endif // TEUCHOS_COMM_HELPERS_HPP
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...
ArrayView< T > arrayView(T *p, typename ArrayView< T >::size_type size)
Construct a const or non-const view to const or non-const data.
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
EReductionType
Predefined reduction operations that Teuchos::Comm understands.
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
Macro for throwing an exception with breakpointing to ease debugging.
T * getRawPtr() const
Get the raw C++ pointer to the underlying object.
void reduce(const Ordinal count, const Packet inBuffer[], Packet inoutBuffer[]) const
size_type size() const
The total number of entries in the array.
Standard logical AND operator for booleans.
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.
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 reduce(const Ordinal count, const Packet inBuffer[], Packet inoutBuffer[]) const
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.
TEUCHOS_DEPRECATED void scan(const Comm< Ordinal > &comm, const EReductionType reductType, const Packet &send, Packet *scanReduct)
Deprecated.
Standard Max operator for types with value semantics.
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.
TEUCHOS_DEPRECATED void reduceAll(const Comm< Ordinal > &comm, const EReductionType reductType, const Packet &send, Packet *globalReduct)
Deprecated .
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). ...
virtual void readySend(const ArrayView< const char > &sendBuffer, const int destRank) const =0
Ready send of data from this process to another process.
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).
Templated array class derived from the STL std::vector.
Defines basic traits for the ordinal field type.
Default traits class that just returns typeid(T).name().
void reduce(const Ordinal count, const Packet inBuffer[], Packet inoutBuffer[]) const
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.
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.
Smart reference counting pointer class for automatic garbage collection.
RCP< CommRequest< Ordinal > > isend(const ArrayRCP< const Packet > &sendBuffer, const int destRank, const int tag, const Comm< Ordinal > &comm)
Variant of isend() that takes a tag (and restores the correct order of arguments).
Defines basic traits returning the name of a type in a portable and readable way. ...
Definition of Teuchos::as, for conversions between types.
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...
Encapsulate how an array of const objects with value sematics is serialized into a const char[] array...
Reference-counted smart pointer for managing arrays.