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>
380 template<
typename Ordinal,
typename Packet>
384 const Ordinal count,
const Packet*
const sendBuffer[], Packet*
const globalReducts[]
392 template<
typename Ordinal,
typename Packet,
typename Serializer>
397 const Ordinal count,
const Packet sendBuffer[], Packet globalReducts[]
405 template<
typename Ordinal,
typename Packet,
typename Serializer>
410 const Ordinal count,
const Packet sendBuffer[], Packet globalReducts[]
418 template<
typename Ordinal,
typename Packet>
421 const Ordinal count,
const Packet sendBuffer[], Packet scanReducts[]
429 template<
typename Ordinal,
typename Packet>
432 const Ordinal count,
const Packet sendBuffer[], Packet scanReducts[]
440 template<
typename Ordinal,
typename Packet>
451 template<
typename Ordinal,
typename Packet>
455 const Ordinal count,
const Packet*
const sendBuffer[], Packet*
const scanReducts[]
463 template<
typename Ordinal,
typename Packet,
typename Serializer>
468 const Ordinal count,
const Packet sendBuffer[], Packet scanReducts[]
476 template<
typename Ordinal,
typename Packet,
typename Serializer>
481 const Ordinal count,
const Packet sendBuffer[], Packet scanReducts[]
488 template<
typename Ordinal,
typename Packet>
491 const Ordinal count,
const Packet sendBuffer[],
const int destRank
495 template<
typename Ordinal,
typename Packet>
497 send (
const Packet sendBuffer[],
507 template<
typename Ordinal,
typename Packet>
510 const Ordinal count,
const Packet sendBuffer[],
const int destRank
514 template<
typename Ordinal,
typename Packet>
516 ssend (
const Packet sendBuffer[],
526 template<
typename Ordinal,
typename Packet>
529 const Packet &
send,
const int destRank
536 template<
typename Ordinal,
typename Packet>
539 const Packet &
send,
const int destRank
548 template<
typename Ordinal,
typename Packet>
551 const Ordinal count,
const Packet*
const sendBuffer[],
const int destRank
559 template<
typename Ordinal,
typename Packet,
typename Serializer>
563 const Ordinal count,
const Packet sendBuffer[],
const int destRank
570 template<
typename Ordinal,
typename Packet>
573 const int sourceRank,
const Ordinal count, Packet recvBuffer[]
580 template<
typename Ordinal,
typename Packet>
583 const int sourceRank, Packet *recv
590 template<
typename Ordinal,
typename Packet>
593 const int sourceRank,
const Ordinal count, Packet*
const recvBuffer[]
601 template<
typename Ordinal,
typename Packet,
typename Serializer>
605 const int sourceRank,
const Ordinal count, Packet recvBuffer[]
613 template<
typename Ordinal,
typename Packet>
621 template<
typename Ordinal,
typename Packet>
633 template<
typename Ordinal,
typename Packet>
645 template<
typename Ordinal,
typename Packet,
typename Serializer>
657 template<
typename Ordinal,
typename Packet>
665 template<
typename Ordinal,
typename Packet>
676 template<
typename Ordinal,
typename Packet>
688 template<
typename Ordinal,
typename Packet,
typename Serializer>
709 template<
typename Ordinal,
typename Packet>
717 template<
typename Ordinal,
typename Packet>
720 const int sourceRank,
735 template<
typename Ordinal,
typename Packet>
747 template<
typename Ordinal,
typename Packet,
typename Serializer>
766 template<
typename Ordinal>
801 template<
typename Ordinal>
830 template<
typename Ordinal>
843 template<
typename Ordinal,
typename Packet>
850 const Packet inBuffer[],
864 template<
typename Ordinal,
typename Packet>
871 const Packet inBuffer[],
885 template<
typename Ordinal,
typename Packet>
892 const Packet inBuffer[],
902 template<
typename Ordinal,
typename Packet>
909 const Packet inBuffer[],
924 namespace MixMaxUtilities {
927 template<
bool isComparable,
typename Ordinal,
typename Packet>
931 template<
typename Ordinal,
typename Packet>
932 class Min<true,Ordinal,Packet> {
936 const Packet inBuffer[],
940 for(
int i = 0; i < count; ++i )
941 inoutBuffer[i] = TEUCHOS_MIN(inoutBuffer[i],inBuffer[i]);
946 template<
typename Ordinal,
typename Packet>
947 class Min<false,Ordinal,Packet> {
956 true,std::logic_error,
957 "Error, the type "<<TypeNameTraits<Packet>::name()
958 <<
" does not support comparison operations!"
964 template<
bool isComparable,
typename Ordinal,
typename Packet>
968 template<
typename Ordinal,
typename Packet>
969 class Max<true,Ordinal,Packet> {
973 const Packet inBuffer[],
977 for(
int i = 0; i < count; ++i )
978 inoutBuffer[i] = TEUCHOS_MAX(inoutBuffer[i],inBuffer[i]);
983 template<
typename Ordinal,
typename Packet>
984 class Max<false,Ordinal,Packet> {
993 true,std::logic_error,
994 "Error, the type "<<TypeNameTraits<Packet>::name()
995 <<
" does not support comparison operations!"
1001 template<
bool isComparable,
typename Ordinal,
typename Packet>
1005 template<
typename Ordinal,
typename Packet>
1006 class AND<true,Ordinal,Packet> {
1009 const Ordinal count,
1010 const Packet inBuffer[],
1011 Packet inoutBuffer[]
1014 for(
int i = 0; i < count; ++i )
1015 inoutBuffer[i] = inoutBuffer[i] && inBuffer[i];
1020 template<
typename Ordinal,
typename Packet>
1021 class AND<false,Ordinal,Packet> {
1030 true,std::logic_error,
1031 "Error, the type "<<TypeNameTraits<Packet>::name()
1032 <<
" does not support logical AND operations!"
1041 template<
typename Ordinal,
typename Packet>
1043 const Ordinal count,
1044 const Packet inBuffer[],
1045 Packet inoutBuffer[]
1048 for(
int i = 0; i < count; ++i )
1049 inoutBuffer[i] += inBuffer[i];
1053 template<
typename Ordinal,
typename Packet>
1055 const Ordinal count,
1056 const Packet inBuffer[],
1057 Packet inoutBuffer[]
1060 typedef MixMaxUtilities::Min<ScalarTraits<Packet>::isComparable, Ordinal, Packet> min_type;
1061 min_type::min (count, inBuffer, inoutBuffer);
1065 template<
typename Ordinal,
typename Packet>
1067 const Ordinal count,
1068 const Packet inBuffer[],
1069 Packet inoutBuffer[]
1072 typedef MixMaxUtilities::Max<ScalarTraits<Packet>::isComparable, Ordinal, Packet> max_type;
1073 max_type::max (count,inBuffer,inoutBuffer);
1077 template<
typename Ordinal,
typename Packet>
1079 const Ordinal count,
1080 const Packet inBuffer[],
1081 Packet inoutBuffer[]
1084 typedef MixMaxUtilities::AND<ScalarTraits<Packet>::isComparable, Ordinal, Packet> and_type;
1085 and_type::andOp (count, inBuffer, inoutBuffer);
1115 template<
typename Ordinal,
typename Packet>
1116 ValueTypeReductionOp<Ordinal,Packet>*
1117 createOp (
const EReductionType reductType)
1119 typedef ScalarTraits<Packet> ST;
1120 switch (reductType) {
1122 return new SumValueReductionOp<Ordinal,Packet> ();
1125 if (ST::isComparable) {
1126 return new MinValueReductionOp<Ordinal,Packet> ();
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.");
1137 if (ST::isComparable) {
1138 return new MaxValueReductionOp<Ordinal,Packet> ();
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.");
1149 return new ANDValueReductionOp<Ordinal, Packet> ();
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.");
1168 template<
typename Ordinal>
1169 int Teuchos::rank(
const Comm<Ordinal>& comm)
1171 return comm.getRank();
1175 template<
typename Ordinal>
1176 int Teuchos::size(
const Comm<Ordinal>& comm)
1178 return comm.getSize();
1182 template<
typename Ordinal>
1183 void Teuchos::barrier(
const Comm<Ordinal>& comm)
1185 TEUCHOS_COMM_TIME_MONITOR(
1186 "Teuchos::CommHelpers: barrier<"
1187 <<OrdinalTraits<Ordinal>::name()
1194 template<
typename Ordinal,
typename Packet>
1195 void Teuchos::broadcast(
1196 const Comm<Ordinal>& comm,
1197 const int rootRank,
const Ordinal count, Packet buffer[]
1200 TEUCHOS_COMM_TIME_MONITOR(
1201 "Teuchos::CommHelpers: broadcast<"
1202 <<OrdinalTraits<Ordinal>::name()<<
","<<TypeNameTraits<Packet>::name()
1205 ValueTypeSerializationBuffer<Ordinal,Packet>
1206 charBuffer(count,buffer);
1208 rootRank,charBuffer.getBytes(),charBuffer.getCharBuffer()
1213 template<
typename Ordinal,
typename Packet>
1214 void Teuchos::broadcast(
1215 const Comm<Ordinal>& comm,
1217 const ArrayView<Packet> &buffer
1220 broadcast<Ordinal, Packet>(comm, rootRank, buffer.size(), buffer.getRawPtr() );
1224 template<
typename Ordinal,
typename Packet>
1225 void Teuchos::broadcast(
1226 const Comm<Ordinal>& comm,
1227 const int rootRank, Packet *
object
1230 broadcast<Ordinal,Packet>(comm,rootRank,1,object);
1234 template<
typename Ordinal,
typename Packet>
1235 void Teuchos::broadcast(
1236 const Comm<Ordinal>& comm,
1237 const int rootRank,
const Ptr<Packet> &
object
1240 broadcast<Ordinal,Packet>(comm,rootRank,1,
object.getRawPtr());
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[]
1250 TEUCHOS_COMM_TIME_MONITOR(
1251 "Teuchos::CommHelpers: broadcast<"
1252 <<OrdinalTraits<Ordinal>::name()<<
","<<TypeNameTraits<Packet>::name()
1253 <<
">( reference type )"
1255 ReferenceTypeSerializationBuffer<Ordinal,Packet>
1256 charBuffer(serializer, count, buffer);
1258 rootRank,charBuffer.getBytes(),charBuffer.getCharBuffer()
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
1269 Array<Packet*> bufferPtrArray;
1270 for (
int i = 0; i < buffer.size(); ++i) {
1271 bufferPtrArray.push_back(buffer[i].getRawPtr());
1273 broadcast<Ordinal,Packet>(comm, serializer, rootRank,
1274 buffer.size(), bufferPtrArray.getRawPtr());
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[]
1284 TEUCHOS_COMM_TIME_MONITOR(
1285 "Teuchos::CommHelpers: broadcast<"
1286 <<OrdinalTraits<Ordinal>::name()<<
","<<TypeNameTraits<Packet>::name()
1289 ValueTypeSerializationBuffer<Ordinal,Packet,Serializer>
1290 charBuffer(count,buffer,
rcp(&serializer,
false));
1292 rootRank,charBuffer.getBytes(),charBuffer.getCharBuffer()
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[]
1304 TEUCHOS_COMM_TIME_MONITOR(
1305 "Teuchos::CommHelpers: gatherAll<"
1306 <<OrdinalTraits<Ordinal>::name()<<
","<<TypeNameTraits<Packet>::name()
1309 ConstValueTypeSerializationBuffer<Ordinal,Packet>
1310 charSendBuffer(sendCount,sendBuffer);
1311 ValueTypeSerializationBuffer<Ordinal,Packet>
1312 charRecvBuffer(recvCount,recvBuffer);
1314 charSendBuffer.getBytes(),charSendBuffer.getCharBuffer()
1315 ,charRecvBuffer.getBytes(),charRecvBuffer.getCharBuffer()
1319 template<
typename Ordinal,
typename Packet>
1321 Teuchos::gather (
const Packet sendBuf[],
1322 const Ordinal sendCount,
1324 const Ordinal recvCount,
1326 const Comm<Ordinal>& comm)
1328 TEUCHOS_COMM_TIME_MONITOR(
1329 "Teuchos::CommHelpers: gather<"
1330 <<OrdinalTraits<Ordinal>::name()<<
","<<TypeNameTraits<Packet>::name()
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 (),
1344 template<
typename Ordinal,
typename Packet>
1346 Teuchos::gatherv (
const Packet sendBuf[],
1347 const Ordinal sendCount,
1349 const Ordinal recvCounts[],
1350 const Ordinal displs[],
1352 const Comm<Ordinal>& comm)
1375 "Teuchos::gatherv: The general case is not implemented.");
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[]
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[]
1396 TEUCHOS_COMM_TIME_MONITOR(
1397 "Teuchos::CommHelpers: gatherAll<"
1398 <<OrdinalTraits<Ordinal>::name()<<
","<<TypeNameTraits<Packet>::name()
1401 ConstValueTypeSerializationBuffer<Ordinal,Packet,Serializer>
1402 charSendBuffer(sendCount,sendBuffer,
rcp(&serializer,
false));
1403 ValueTypeSerializationBuffer<Ordinal,Packet,Serializer>
1404 charRecvBuffer(recvCount,recvBuffer,
rcp(&serializer,
false));
1406 charSendBuffer.getBytes(),charSendBuffer.getCharBuffer()
1407 ,charRecvBuffer.getBytes(),charRecvBuffer.getCharBuffer()
1412 template<
typename Ordinal,
typename Packet>
1414 Teuchos::reduce (
const Packet sendBuf[],
1416 const Ordinal count,
1419 const Comm<Ordinal>& comm)
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.");
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[]
1438 TEUCHOS_COMM_TIME_MONITOR(
1439 "Teuchos::CommHelpers: reduceAll<"
1440 <<OrdinalTraits<Ordinal>::name()<<
","<<TypeNameTraits<Packet>::name()
1441 <<
">( value type, user-defined op )"
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));
1450 charReductOp,charSendBuffer.getBytes(),charSendBuffer.getCharBuffer()
1451 ,charGlobalReducts.getCharBuffer()
1456 template<
typename Ordinal,
typename Packet>
1457 void Teuchos::reduceAll(
1459 const Ordinal count,
const Packet sendBuffer[], Packet globalReducts[]
1462 TEUCHOS_COMM_TIME_MONITOR(
1463 "Teuchos::CommHelpers: reduceAll<"
1464 <<OrdinalTraits<Ordinal>::name()<<
","<<TypeNameTraits<Packet>::name()
1465 <<
">( value type, "<<
toString(reductType)<<
" )"
1468 ValueTypeReductionOp<Ordinal,Packet>* reductOp =
1469 createOp<Ordinal, Packet> (reductType);
1471 reduceAll(comm,*reductOp,count,sendBuffer,globalReducts);
1473 catch (std::exception& e) {
1489 #ifdef HAVE_TEUCHOS_COMPLEX
1492 TEUCHOSCOMM_LIB_DLL_EXPORT
void
1493 reduceAll<int, std::complex<double> > (
const Comm<int>& comm,
1494 const EReductionType reductType,
1496 const std::complex<double> sendBuffer[],
1497 std::complex<double> globalReducts[]);
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);
1504 TEUCHOSCOMM_LIB_DLL_EXPORT RCP<CommRequest<int> >
1505 ireceive<int, std::complex<double> > (
const ArrayRCP<std::complex<double> > &recvBuffer,
1506 const int sourceRank,
1508 const Comm<int>& comm);
1510 TEUCHOSCOMM_LIB_DLL_EXPORT
void
1511 send<int, std::complex<double> > (
const Comm<int>& comm,
1513 const std::complex<double> sendBuffer[],
1514 const int destRank);
1516 TEUCHOSCOMM_LIB_DLL_EXPORT
void
1517 send<int, std::complex<double> > (
const std::complex<double> sendBuffer[],
1521 const Comm<int>& comm);
1523 TEUCHOSCOMM_LIB_DLL_EXPORT RCP<CommRequest<int> >
1524 isend<int, std::complex<double> > (
const ArrayRCP<const std::complex<double> >& sendBuffer,
1527 const Comm<int>& comm);
1531 TEUCHOSCOMM_LIB_DLL_EXPORT
void
1532 reduceAll<int, std::complex<float> > (
const Comm<int>& comm,
1533 const EReductionType reductType,
1535 const std::complex<float> sendBuffer[],
1536 std::complex<float> globalReducts[]);
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);
1543 TEUCHOSCOMM_LIB_DLL_EXPORT RCP<CommRequest<int> >
1544 ireceive<int, std::complex<float> > (
const ArrayRCP<std::complex<float> > &recvBuffer,
1545 const int sourceRank,
1547 const Comm<int>& comm);
1549 TEUCHOSCOMM_LIB_DLL_EXPORT
void
1550 send<int, std::complex<float> > (
const Comm<int>& comm,
1552 const std::complex<float> sendBuffer[],
1553 const int destRank);
1555 TEUCHOSCOMM_LIB_DLL_EXPORT
void
1556 send<int, std::complex<float> > (
const std::complex<float> sendBuffer[],
1560 const Comm<int>& comm);
1562 TEUCHOSCOMM_LIB_DLL_EXPORT RCP<CommRequest<int> >
1563 isend<int, std::complex<float> > (
const ArrayRCP<const std::complex<float> >& sendBuffer,
1566 const Comm<int>& comm);
1567 #endif // HAVE_TEUCHOS_COMPLEX
1572 TEUCHOSCOMM_LIB_DLL_EXPORT
void
1573 reduceAll<int, double> (
const Comm<int>& comm,
1574 const EReductionType reductType,
1576 const double sendBuffer[],
1577 double globalReducts[]);
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);
1584 TEUCHOSCOMM_LIB_DLL_EXPORT RCP<CommRequest<int> >
1585 ireceive<int, double> (
const ArrayRCP<double> &recvBuffer,
1586 const int sourceRank,
1588 const Comm<int>& comm);
1590 TEUCHOSCOMM_LIB_DLL_EXPORT
void
1591 send<int, double> (
const Comm<int>& comm,
1593 const double sendBuffer[],
1594 const int destRank);
1596 TEUCHOSCOMM_LIB_DLL_EXPORT
void
1597 send<int, double> (
const double sendBuffer[],
1601 const Comm<int>& comm);
1603 TEUCHOSCOMM_LIB_DLL_EXPORT RCP<CommRequest<int> >
1604 isend<int, double> (
const ArrayRCP<const double>& sendBuffer,
1607 const Comm<int>& comm);
1611 TEUCHOSCOMM_LIB_DLL_EXPORT
void
1612 reduceAll<int, float> (
const Comm<int>& comm,
1613 const EReductionType reductType,
1615 const float sendBuffer[],
1616 float globalReducts[]);
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);
1623 TEUCHOSCOMM_LIB_DLL_EXPORT RCP<CommRequest<int> >
1624 ireceive<int, float> (
const ArrayRCP<float> &recvBuffer,
1625 const int sourceRank,
1627 const Comm<int>& comm);
1629 TEUCHOSCOMM_LIB_DLL_EXPORT
void
1630 send<int, float> (
const Comm<int>& comm,
1632 const float sendBuffer[],
1633 const int destRank);
1635 TEUCHOSCOMM_LIB_DLL_EXPORT
void
1636 send<int, float> (
const float sendBuffer[],
1640 const Comm<int>& comm);
1642 TEUCHOSCOMM_LIB_DLL_EXPORT RCP<CommRequest<int> >
1643 isend<int, float> (
const ArrayRCP<const float>& sendBuffer,
1646 const Comm<int>& comm);
1650 TEUCHOSCOMM_LIB_DLL_EXPORT
void
1651 gather<int, long long> (
const long long sendBuf[],
1652 const int sendCount,
1653 long long recvBuf[],
1654 const int recvCount,
1656 const Comm<int>& comm);
1658 TEUCHOSCOMM_LIB_DLL_EXPORT
void
1659 gatherv<int, long long> (
const long long sendBuf[],
1660 const int sendCount,
1661 long long recvBuf[],
1662 const int recvCounts[],
1665 const Comm<int>& comm);
1667 TEUCHOSCOMM_LIB_DLL_EXPORT
void
1668 reduceAll<int, long long> (
const Comm<int>& comm,
1669 const EReductionType reductType,
1671 const long long sendBuffer[],
1672 long long globalReducts[]);
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);
1679 TEUCHOSCOMM_LIB_DLL_EXPORT RCP<CommRequest<int> >
1680 ireceive<int, long long> (
const ArrayRCP<long long> &recvBuffer,
1681 const int sourceRank,
1683 const Comm<int>& comm);
1685 TEUCHOSCOMM_LIB_DLL_EXPORT
void
1686 send<int, long long> (
const Comm<int>& comm,
1688 const long long sendBuffer[],
1689 const int destRank);
1691 TEUCHOSCOMM_LIB_DLL_EXPORT
void
1692 send<int, long long> (
const long long sendBuffer[],
1696 const Comm<int>& comm);
1698 TEUCHOSCOMM_LIB_DLL_EXPORT RCP<CommRequest<int> >
1699 isend<int, long long> (
const ArrayRCP<const long long>& sendBuffer,
1702 const Comm<int>& comm);
1706 TEUCHOSCOMM_LIB_DLL_EXPORT
void
1707 gather<int, unsigned long long> (
const unsigned long long sendBuf[],
1708 const int sendCount,
1709 unsigned long long recvBuf[],
1710 const int recvCount,
1712 const Comm<int>& comm);
1714 TEUCHOSCOMM_LIB_DLL_EXPORT
void
1715 gatherv<int, unsigned long long> (
const unsigned long long sendBuf[],
1716 const int sendCount,
1717 unsigned long long recvBuf[],
1718 const int recvCounts[],
1721 const Comm<int>& comm);
1723 TEUCHOSCOMM_LIB_DLL_EXPORT
void
1724 reduceAll<int, unsigned long long> (
const Comm<int>& comm,
1725 const EReductionType reductType,
1727 const unsigned long long sendBuffer[],
1728 unsigned long long globalReducts[]);
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);
1735 TEUCHOSCOMM_LIB_DLL_EXPORT RCP<CommRequest<int> >
1736 ireceive<int, unsigned long long> (
const ArrayRCP<unsigned long long> &recvBuffer,
1737 const int sourceRank,
1739 const Comm<int>& comm);
1741 TEUCHOSCOMM_LIB_DLL_EXPORT
void
1742 send<int, unsigned long long> (
const Comm<int>& comm,
1744 const unsigned long long sendBuffer[],
1745 const int destRank);
1747 TEUCHOSCOMM_LIB_DLL_EXPORT
void
1748 send<int, unsigned long long> (
const unsigned long long sendBuffer[],
1752 const Comm<int>& comm);
1754 TEUCHOSCOMM_LIB_DLL_EXPORT RCP<CommRequest<int> >
1755 isend<int, unsigned long long> (
const ArrayRCP<const unsigned long long>& sendBuffer,
1758 const Comm<int>& comm);
1762 TEUCHOSCOMM_LIB_DLL_EXPORT
void
1763 gather<int, long> (
const long sendBuf[],
1764 const int sendCount,
1766 const int recvCount,
1768 const Comm<int>& comm);
1770 TEUCHOSCOMM_LIB_DLL_EXPORT
void
1771 gatherv<int, long> (
const long sendBuf[],
1772 const int sendCount,
1774 const int recvCounts[],
1777 const Comm<int>& comm);
1779 TEUCHOSCOMM_LIB_DLL_EXPORT
void
1780 reduceAll<int, long> (
const Comm<int>& comm,
1781 const EReductionType reductType,
1783 const long sendBuffer[],
1784 long globalReducts[]);
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);
1791 TEUCHOSCOMM_LIB_DLL_EXPORT RCP<CommRequest<int> >
1792 ireceive<int, long> (
const ArrayRCP<long> &recvBuffer,
1793 const int sourceRank,
1795 const Comm<int>& comm);
1797 TEUCHOSCOMM_LIB_DLL_EXPORT
void
1798 send<int, long> (
const Comm<int>& comm,
1800 const long sendBuffer[],
1801 const int destRank);
1803 TEUCHOSCOMM_LIB_DLL_EXPORT
void
1804 send<int, long> (
const long sendBuffer[],
1808 const Comm<int>& comm);
1810 TEUCHOSCOMM_LIB_DLL_EXPORT RCP<CommRequest<int> >
1811 isend<int, long> (
const ArrayRCP<const long>& sendBuffer,
1814 const Comm<int>& comm);
1818 TEUCHOSCOMM_LIB_DLL_EXPORT
void
1819 gather<int, unsigned long> (
const unsigned long sendBuf[],
1820 const int sendCount,
1821 unsigned long recvBuf[],
1822 const int recvCount,
1824 const Comm<int>& comm);
1826 TEUCHOSCOMM_LIB_DLL_EXPORT
void
1827 gatherv<int, unsigned long> (
const unsigned long sendBuf[],
1828 const int sendCount,
1829 unsigned long recvBuf[],
1830 const int recvCounts[],
1833 const Comm<int>& comm);
1835 TEUCHOSCOMM_LIB_DLL_EXPORT
void
1836 reduceAll<int, unsigned long> (
const Comm<int>& comm,
1837 const EReductionType reductType,
1839 const unsigned long sendBuffer[],
1840 unsigned long globalReducts[]);
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);
1847 TEUCHOSCOMM_LIB_DLL_EXPORT RCP<CommRequest<int> >
1848 ireceive<int, unsigned long> (
const ArrayRCP<unsigned long> &recvBuffer,
1849 const int sourceRank,
1851 const Comm<int>& comm);
1853 TEUCHOSCOMM_LIB_DLL_EXPORT
void
1854 send<int, unsigned long> (
const Comm<int>& comm,
1856 const unsigned long sendBuffer[],
1857 const int destRank);
1859 TEUCHOSCOMM_LIB_DLL_EXPORT
void
1860 send<int, unsigned long> (
const unsigned long sendBuffer[],
1864 const Comm<int>& comm);
1866 TEUCHOSCOMM_LIB_DLL_EXPORT RCP<CommRequest<int> >
1867 isend<int, unsigned long> (
const ArrayRCP<const unsigned long>& sendBuffer,
1870 const Comm<int>& comm);
1874 TEUCHOSCOMM_LIB_DLL_EXPORT
void
1875 gather<int, int> (
const int sendBuf[],
1876 const int sendCount,
1878 const int recvCount,
1880 const Comm<int>& comm);
1882 TEUCHOSCOMM_LIB_DLL_EXPORT
void
1883 gatherv<int, int> (
const int sendBuf[],
1884 const int sendCount,
1886 const int recvCounts[],
1889 const Comm<int>& comm);
1891 TEUCHOSCOMM_LIB_DLL_EXPORT
void
1892 scatter (
const int sendBuf[],
1893 const int sendCount,
1895 const int recvCount,
1897 const Comm<int>& comm);
1899 TEUCHOSCOMM_LIB_DLL_EXPORT
void
1900 reduce<int, int> (
const int sendBuf[],
1903 const EReductionType reductType,
1905 const Comm<int>& comm);
1907 TEUCHOSCOMM_LIB_DLL_EXPORT
void
1908 reduce<int, long> (
const long sendBuf[],
1911 const EReductionType reductType,
1913 const Comm<int>& comm);
1915 TEUCHOSCOMM_LIB_DLL_EXPORT
void
1916 reduce<int, unsigned long> (
const unsigned long sendBuf[],
1917 unsigned long recvBuf[],
1919 const EReductionType reductType,
1921 const Comm<int>& comm);
1923 TEUCHOSCOMM_LIB_DLL_EXPORT
void
1924 reduce<int, unsigned long long > (
const unsigned long long sendBuf[],
1925 unsigned long long recvBuf[],
1927 const EReductionType reductType,
1929 const Comm<int>& comm);
1931 TEUCHOSCOMM_LIB_DLL_EXPORT
void
1932 reduce<int, double> (
const double sendBuf[],
1935 const EReductionType reductType,
1937 const Comm<int>& comm);
1939 TEUCHOSCOMM_LIB_DLL_EXPORT
void
1940 reduceAll<int, int> (
const Comm<int>& comm,
1941 const EReductionType reductType,
1943 const int sendBuffer[],
1944 int globalReducts[]);
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);
1952 TEUCHOSCOMM_LIB_DLL_EXPORT RCP<CommRequest<int> >
1953 ireceive<int, int> (
const ArrayRCP<int> &recvBuffer,
1954 const int sourceRank,
1956 const Comm<int>& comm);
1958 TEUCHOSCOMM_LIB_DLL_EXPORT
void
1959 send<int, int> (
const Comm<int>& comm,
1961 const int sendBuffer[],
1962 const int destRank);
1964 TEUCHOSCOMM_LIB_DLL_EXPORT
void
1965 send<int, int> (
const int sendBuffer[],
1969 const Comm<int>& comm);
1971 TEUCHOSCOMM_LIB_DLL_EXPORT RCP<CommRequest<int> >
1972 isend<int, int> (
const ArrayRCP<const int>& sendBuffer,
1975 const Comm<int>& comm);
1979 TEUCHOSCOMM_LIB_DLL_EXPORT
void
1980 gather<int, unsigned int> (
const unsigned int sendBuf[],
1981 const int sendCount,
1982 unsigned int recvBuf[],
1983 const int recvCount,
1985 const Comm<int>& comm);
1987 TEUCHOSCOMM_LIB_DLL_EXPORT
void
1988 gatherv<int, unsigned int> (
const unsigned int sendBuf[],
1989 const int sendCount,
1990 unsigned int recvBuf[],
1991 const int recvCounts[],
1994 const Comm<int>& comm);
1996 TEUCHOSCOMM_LIB_DLL_EXPORT
void
1997 reduceAll<int, unsigned int> (
const Comm<int>& comm,
1998 const EReductionType reductType,
2000 const unsigned int sendBuffer[],
2001 unsigned int globalReducts[]);
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);
2008 TEUCHOSCOMM_LIB_DLL_EXPORT RCP<CommRequest<int> >
2009 ireceive<int, unsigned int> (
const ArrayRCP<unsigned int> &recvBuffer,
2010 const int sourceRank,
2012 const Comm<int>& comm);
2014 TEUCHOSCOMM_LIB_DLL_EXPORT
void
2015 send<int, unsigned int> (
const Comm<int>& comm,
2017 const unsigned int sendBuffer[],
2018 const int destRank);
2020 TEUCHOSCOMM_LIB_DLL_EXPORT
void
2021 send<int, unsigned int> (
const unsigned int sendBuffer[],
2025 const Comm<int>& comm);
2027 TEUCHOSCOMM_LIB_DLL_EXPORT RCP<CommRequest<int> >
2028 isend<int, unsigned int> (
const ArrayRCP<const unsigned int>& sendBuffer,
2031 const Comm<int>& comm);
2035 TEUCHOSCOMM_LIB_DLL_EXPORT
void
2036 gather<int, short> (
const short sendBuf[],
2037 const int sendCount,
2039 const int recvCount,
2041 const Comm<int>& comm);
2043 TEUCHOSCOMM_LIB_DLL_EXPORT
void
2044 gatherv<int, short> (
const short sendBuf[],
2045 const int sendCount,
2047 const int recvCounts[],
2050 const Comm<int>& comm);
2052 TEUCHOSCOMM_LIB_DLL_EXPORT
void
2053 reduceAll<int, short> (
const Comm<int>& comm,
2054 const EReductionType reductType,
2056 const short sendBuffer[],
2057 short globalReducts[]);
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);
2064 TEUCHOSCOMM_LIB_DLL_EXPORT RCP<CommRequest<int> >
2065 ireceive<int, short> (
const ArrayRCP<short> &recvBuffer,
2066 const int sourceRank,
2068 const Comm<int>& comm);
2070 TEUCHOSCOMM_LIB_DLL_EXPORT
void
2071 send<int, short> (
const Comm<int>& comm,
2073 const short sendBuffer[],
2074 const int destRank);
2076 TEUCHOSCOMM_LIB_DLL_EXPORT
void
2077 send<int, short> (
const short sendBuffer[],
2081 const Comm<int>& comm);
2083 TEUCHOSCOMM_LIB_DLL_EXPORT RCP<CommRequest<int> >
2084 isend<int, short> (
const ArrayRCP<const short>& sendBuffer,
2087 const Comm<int>& comm);
2100 TEUCHOSCOMM_LIB_DLL_EXPORT
void
2101 reduceAll<int, char> (
const Comm<int>& comm,
2102 const EReductionType reductType,
2104 const char sendBuffer[],
2105 char globalReducts[]);
2110 template<
typename Ordinal,
typename Packet>
2111 void Teuchos::reduceAll(
2113 ,
const Packet &
send,
const Ptr<Packet> &globalReduct
2118 reduceAll<Ordinal,Packet>(comm, reductType, 1, &
send, &*globalReduct);
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[]
2129 TEUCHOS_COMM_TIME_MONITOR(
2130 "Teuchos::CommHelpers: reduceAll<"
2131 <<OrdinalTraits<Ordinal>::name()<<
","<<TypeNameTraits<Packet>::name()
2132 <<
">( reference type )"
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));
2141 charReductOp,charSendBuffer.getBytes(),charSendBuffer.getCharBuffer()
2142 ,charGlobalReducts.getCharBuffer()
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[]
2154 TEUCHOS_COMM_TIME_MONITOR(
2155 "Teuchos::CommHelpers: reduceAll<"
2156 <<OrdinalTraits<Ordinal>::name()<<
","<<TypeNameTraits<Packet>::name()
2157 <<
">( value type, user-defined op )"
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));
2166 charReductOp,charSendBuffer.getBytes(),charSendBuffer.getCharBuffer()
2167 ,charGlobalReducts.getCharBuffer()
2172 template<
typename Ordinal,
typename Packet,
typename Serializer>
2173 void Teuchos::reduceAll(
2174 const Comm<Ordinal>& comm,
2175 const Serializer& serializer,
2177 const Ordinal count,
const Packet sendBuffer[], Packet globalReducts[]
2180 TEUCHOS_COMM_TIME_MONITOR(
2181 "Teuchos::CommHelpers: reduceAll<"
2182 <<OrdinalTraits<Ordinal>::name()<<
","<<TypeNameTraits<Packet>::name()
2183 <<
">( value type, "<<
toString(reductType)<<
" )"
2186 ValueTypeReductionOp<Ordinal,Packet>* reductOp =
2187 createOp<Ordinal, Packet> (reductType);
2189 reduceAll(comm,serializer,*reductOp,count,sendBuffer,globalReducts);
2191 catch (std::exception& e) {
2199 template<
typename Ordinal,
typename Packet>
2201 const Comm<Ordinal>& comm,
const ValueTypeReductionOp<Ordinal,Packet> &reductOp,
2202 const Ordinal count,
const Packet sendBuffer[], Packet scanReducts[]
2205 TEUCHOS_COMM_TIME_MONITOR(
2206 "Teuchos::CommHelpers: scan<"
2207 <<OrdinalTraits<Ordinal>::name()<<
","<<TypeNameTraits<Packet>::name()
2208 <<
">( value type, user-defined op )"
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));
2217 charReductOp,charSendBuffer.getBytes(),charSendBuffer.getCharBuffer()
2218 ,charScanReducts.getCharBuffer()
2223 template<
typename Ordinal,
typename Packet>
2226 const Ordinal count,
const Packet sendBuffer[], Packet scanReducts[]
2229 TEUCHOS_COMM_TIME_MONITOR(
2230 "Teuchos::CommHelpers: scan<"
2231 <<OrdinalTraits<Ordinal>::name()<<
","<<TypeNameTraits<Packet>::name()
2232 <<
">( value type, "<<
toString(reductType)<<
" )"
2235 ValueTypeReductionOp<Ordinal,Packet>* reductOp =
2236 createOp<Ordinal, Packet> (reductType);
2238 scan(comm,*reductOp,count,sendBuffer,scanReducts);
2240 catch (std::exception& e) {
2248 template<
typename Ordinal,
typename Packet>
2251 const Packet &
send,
const Ptr<Packet> &scanReduct
2254 scan<Ordinal,Packet>(comm, reductType, 1, &
send, &*scanReduct);
2258 template<
typename Ordinal,
typename Packet>
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[]
2268 template<
typename Ordinal,
typename Packet,
typename Serializer>
2270 const Comm<Ordinal>& comm,
2271 const Serializer& serializer,
2272 const ValueTypeReductionOp<Ordinal,Packet> &reductOp,
2273 const Ordinal count,
const Packet sendBuffer[], Packet scanReducts[]
2276 TEUCHOS_COMM_TIME_MONITOR(
2277 "Teuchos::CommHelpers: scan<"
2278 <<OrdinalTraits<Ordinal>::name()<<
","<<TypeNameTraits<Packet>::name()
2279 <<
">( value type, user-defined op )"
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));
2288 charReductOp,charSendBuffer.getBytes(),charSendBuffer.getCharBuffer()
2289 ,charScanReducts.getCharBuffer()
2294 template<
typename Ordinal,
typename Packet,
typename Serializer>
2296 const Comm<Ordinal>& comm,
2297 const Serializer& serializer,
2299 const Ordinal count,
const Packet sendBuffer[], Packet scanReducts[]
2302 TEUCHOS_COMM_TIME_MONITOR(
2303 "Teuchos::CommHelpers: scan<"
2304 <<OrdinalTraits<Ordinal>::name()<<
","<<TypeNameTraits<Packet>::name()
2305 <<
">( value type, "<<
toString(reductType)<<
" )"
2308 ValueTypeReductionOp<Ordinal,Packet>* reductOp =
2309 createOp<Ordinal, Packet> (reductType);
2311 scan(comm,serializer,*reductOp,count,sendBuffer,scanReducts);
2313 catch (std::exception& e) {
2320 template<
typename Ordinal,
typename Packet>
2322 const Comm<Ordinal>& comm,
2323 const Ordinal count,
const Packet sendBuffer[],
const int destRank
2326 TEUCHOS_COMM_TIME_MONITOR(
2327 "Teuchos::CommHelpers: send<"
2328 <<OrdinalTraits<Ordinal>::name()<<
","<<TypeNameTraits<Packet>::name()
2331 ConstValueTypeSerializationBuffer<Ordinal,Packet>
2332 charSendBuffer(count,sendBuffer);
2334 charSendBuffer.getBytes(),charSendBuffer.getCharBuffer()
2339 template<
typename Ordinal,
typename Packet>
2342 const Ordinal count,
2347 TEUCHOS_COMM_TIME_MONITOR(
2348 "Teuchos::CommHelpers: send<"
2353 comm.
send (charSendBuffer.getBytes (), charSendBuffer.getCharBuffer (), destRank, tag);
2356 template<
typename Ordinal,
typename Packet>
2358 const Comm<Ordinal>& comm,
2359 const Ordinal count,
const Packet sendBuffer[],
const int destRank
2362 TEUCHOS_COMM_TIME_MONITOR(
2363 "Teuchos::CommHelpers: ssend<"
2364 <<OrdinalTraits<Ordinal>::name()<<
","<<TypeNameTraits<Packet>::name()
2367 ConstValueTypeSerializationBuffer<Ordinal,Packet>
2368 charSendBuffer(count,sendBuffer);
2370 charSendBuffer.getBytes(),charSendBuffer.getCharBuffer()
2375 template<
typename Ordinal,
typename Packet>
2378 const Ordinal count,
2383 TEUCHOS_COMM_TIME_MONITOR(
2384 "Teuchos::CommHelpers: ssend<"
2389 buf_type charSendBuffer (count, sendBuffer);
2390 comm.
ssend (charSendBuffer.getBytes (),
2391 charSendBuffer.getCharBuffer (),
2395 template<
typename Ordinal,
typename Packet>
2397 const Comm<Ordinal>& comm,
2398 const Packet &
send,
const int destRank
2401 Teuchos::send<Ordinal,Packet>(comm,1,&
send,destRank);
2404 template<
typename Ordinal,
typename Packet>
2406 const Comm<Ordinal>& comm,
2407 const Packet &
send,
const int destRank
2410 Teuchos::ssend<Ordinal,Packet>(comm,1,&
send,destRank);
2413 template<
typename Ordinal,
typename Packet>
2415 const Comm<Ordinal>& comm,
const Serializer<Ordinal,Packet> &serializer,
2416 const Ordinal count,
const Packet*
const sendBuffer[],
const int destRank
2422 template<
typename Ordinal,
typename Packet,
typename Serializer>
2424 const Comm<Ordinal>& comm,
2425 const Serializer& serializer,
2426 const Ordinal count,
const Packet sendBuffer[],
const int destRank
2429 TEUCHOS_COMM_TIME_MONITOR(
2430 "Teuchos::CommHelpers: send<"
2431 <<OrdinalTraits<Ordinal>::name()<<
","<<TypeNameTraits<Packet>::name()
2434 ConstValueTypeSerializationBuffer<Ordinal,Packet,Serializer>
2435 charSendBuffer(count,sendBuffer,
rcp(&serializer,
false));
2437 charSendBuffer.getBytes(),charSendBuffer.getCharBuffer()
2442 template<
typename Ordinal,
typename Packet>
2443 int Teuchos::receive(
2444 const Comm<Ordinal>& comm,
2445 const int sourceRank,
const Ordinal count, Packet recvBuffer[]
2448 TEUCHOS_COMM_TIME_MONITOR(
2449 "Teuchos::CommHelpers: receive<"
2450 <<OrdinalTraits<Ordinal>::name()<<
","<<TypeNameTraits<Packet>::name()
2453 ValueTypeSerializationBuffer<Ordinal,Packet>
2454 charRecvBuffer(count,recvBuffer);
2455 return comm.receive(
2457 ,charRecvBuffer.getBytes(),charRecvBuffer.getCharBuffer()
2462 template<
typename Ordinal,
typename Packet>
2463 int Teuchos::receive(
2464 const Comm<Ordinal>& comm,
2465 const int sourceRank, Packet *recv
2468 return Teuchos::receive<Ordinal,Packet>(comm,sourceRank,1,recv);
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[]
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[]
2488 TEUCHOS_COMM_TIME_MONITOR(
2489 "Teuchos::CommHelpers: receive<"
2490 <<OrdinalTraits<Ordinal>::name()<<
","<<TypeNameTraits<Packet>::name()
2493 ValueTypeSerializationBuffer<Ordinal,Packet,Serializer>
2494 charRecvBuffer(count,recvBuffer,
rcp(&serializer,
false));
2495 return comm.receive(
2497 ,charRecvBuffer.getBytes(),charRecvBuffer.getCharBuffer()
2501 template<
typename Ordinal,
typename Packet>
2503 const Comm<Ordinal>& comm,
2504 const ArrayView<const Packet> &sendBuffer,
2508 TEUCHOS_COMM_TIME_MONITOR(
2509 "Teuchos::CommHelpers: readySend<"
2510 <<OrdinalTraits<Ordinal>::name()<<
","<<TypeNameTraits<Packet>::name()
2513 ConstValueTypeSerializationBuffer<Ordinal,Packet>
2514 charSendBuffer(sendBuffer.size(), sendBuffer.getRawPtr());
2515 comm.readySend( charSendBuffer.getCharBufferView(), destRank );
2518 template<
typename Ordinal,
typename Packet>
2521 const Ordinal count,
2526 TEUCHOS_COMM_TIME_MONITOR(
2527 "Teuchos::CommHelpers: readySend<"
2532 buf_type charSendBuffer (count, sendBuffer);
2533 comm.
readySend (charSendBuffer.getBytes (),
2534 charSendBuffer.getCharBuffer (),
2538 template<
typename Ordinal,
typename Packet>
2540 const Comm<Ordinal>& comm,
2545 readySend<Ordinal, Packet>( comm,
arrayView(&send,1), destRank );
2548 template<
typename Ordinal,
typename Packet,
typename Serializer>
2550 const Comm<Ordinal>& comm,
2551 const Serializer& serializer,
2552 const ArrayView<const Packet> &sendBuffer,
2556 TEUCHOS_COMM_TIME_MONITOR(
2557 "Teuchos::CommHelpers: readySend<"
2558 <<OrdinalTraits<Ordinal>::name()<<
","<<TypeNameTraits<Packet>::name()
2561 ConstValueTypeSerializationBuffer<Ordinal,Packet,Serializer>
2562 charSendBuffer(sendBuffer.size(), sendBuffer.getRawPtr(), serializer);
2563 comm.readySend( charSendBuffer.getCharBufferView(), destRank );
2566 template<
typename Ordinal,
typename Packet>
2569 const Comm<Ordinal>& comm,
2570 const ArrayRCP<const Packet> &sendBuffer,
2574 TEUCHOS_COMM_TIME_MONITOR(
2575 "Teuchos::CommHelpers: isend<"
2576 <<OrdinalTraits<Ordinal>::name()<<
","<<TypeNameTraits<Packet>::name()
2579 ConstValueTypeSerializationBuffer<Ordinal,Packet>
2580 charSendBuffer(sendBuffer.size(), sendBuffer.getRawPtr());
2581 RCP<CommRequest<Ordinal> > commRequest = comm.isend(
2582 charSendBuffer.getCharBufferView(), destRank );
2587 template<
typename Ordinal,
typename Packet>
2592 const Comm<Ordinal>& comm)
2594 TEUCHOS_COMM_TIME_MONITOR(
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);
2605 template<
typename Ordinal,
typename Packet>
2608 const Comm<Ordinal>& comm,
2609 const RCP<const Packet> &
send,
2613 const ArrayRCP<const Packet> sendBuffer =
2617 return isend<Ordinal, Packet>( comm, sendBuffer, destRank );
2620 template<
typename Ordinal,
typename Packet,
typename Serializer>
2623 const Comm<Ordinal>& comm,
2624 const Serializer& serializer,
2625 const ArrayRCP<const Packet> &sendBuffer,
2629 TEUCHOS_COMM_TIME_MONITOR(
2630 "Teuchos::CommHelpers: isend<"
2631 <<OrdinalTraits<Ordinal>::name()<<
","<<TypeNameTraits<Packet>::name()
2634 ConstValueTypeSerializationBuffer<Ordinal,Packet,Serializer>
2635 charSendBuffer(sendBuffer.size(), sendBuffer.getRawPtr(), serializer);
2636 RCP<CommRequest<Ordinal> > commRequest = comm.isend(
2637 charSendBuffer.getCharBufferView(), destRank );
2642 template<
typename Ordinal,
typename Packet>
2645 const Comm<Ordinal>& comm,
2646 const ArrayRCP<Packet> &recvBuffer,
2647 const int sourceRank
2650 TEUCHOS_COMM_TIME_MONITOR(
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 );
2660 template<
typename Ordinal,
typename Packet>
2663 const int sourceRank,
2667 TEUCHOS_COMM_TIME_MONITOR(
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);
2677 template<
typename Ordinal,
typename Packet>
2680 const Comm<Ordinal>& comm,
2681 const RCP<Packet> &recv,
2682 const int sourceRank
2685 const ArrayRCP<Packet> recvBuffer =
2689 return ireceive<Ordinal, Packet>( comm, recvBuffer, sourceRank );
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
2701 TEUCHOS_COMM_TIME_MONITOR(
2702 "Teuchos::CommHelpers: ireceive<"
2703 <<OrdinalTraits<Ordinal>::name()<<
","<<TypeNameTraits<Packet>::name()
2706 ValueTypeSerializationBuffer<Ordinal,Packet,Serializer>
2707 charRecvBuffer(recvBuffer.size(), recvBuffer.getRawPtr(), serializer);
2708 RCP<CommRequest<Ordinal> > commRequest = comm.ireceive(
2709 charRecvBuffer.getCharBufferView(), sourceRank );
2714 template<
typename Ordinal>
2715 void Teuchos::waitAll(
2716 const Comm<Ordinal>& comm,
2717 const ArrayView<RCP<CommRequest<Ordinal> > > &requests
2720 comm.waitAll(requests);
2724 template<
typename Ordinal>
2726 Teuchos::waitAll (
const Comm<Ordinal>& comm,
2727 const ArrayView<RCP<CommRequest<Ordinal> > >& requests,
2728 const ArrayView<RCP<CommStatus<Ordinal> > >& statuses)
2730 comm.waitAll (requests, statuses);
2734 template<
typename Ordinal>
2736 Teuchos::wait (
const Comm<Ordinal>& comm,
2737 const Ptr<RCP<CommRequest<Ordinal> > > &request)
2739 return comm.wait (request);
2743 #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...
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.
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.
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.
Encapsulation of the result of a receive (blocking or nonblocking).
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
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.
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).
Encapsulation of a pending nonblocking communication operation.
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.