54 #ifdef HAVE_TEUCHOS_QD
55 #include <qd/dd_real.h>
61 template <
typename Packet>
62 ostream & operator<< ( ostream& os, const pair<Packet, Packet>& arg)
64 os <<
"(" << arg.first <<
"," << arg.second <<
")";
75 template<
typename Packet>
79 typedef std::pair<typename PST::magnitudeType, typename PST::magnitudeType>
magnitudeType;
84 static inline magnitudeType magnitude(std::pair<Packet,Packet> a) {
return std::pair<Packet,Packet>( PST::magnitude(a.first), PST::magnitude(a.second) ); }
85 static inline std::pair<Packet,Packet>
zero() {
return std::pair<Packet,Packet>(PST::zero(),PST::zero()); }
86 static inline std::pair<Packet,Packet>
one() {
return std::pair<Packet,Packet>(PST::one(), PST::one()); }
87 static inline std::pair<Packet,Packet>
conjugate(std::pair<Packet,Packet> x) {
return std::pair<Packet,Packet>(PST::conjugate(x.first), PST::conjugate(x.second) ); }
88 static inline std::pair<Packet,Packet>
real(std::pair<Packet,Packet> x) {
return std::pair<Packet,Packet>(PST::real(x.first), PST::real(x.second) ); }
89 static inline std::pair<Packet,Packet>
imag(std::pair<Packet,Packet> x) {
return std::pair<Packet,Packet>(PST::imag(x.first), PST::imag(x.second) ); }
90 static inline bool isnaninf(std::pair<Packet,Packet> x) {
return PST::isnaninf(x.first) || PST::isnaninf(x.second); }
91 static inline void seedrandom(
unsigned int s) { PST::seedrandom(s); }
92 static inline std::pair<Packet,Packet>
random() {
return std::pair<Packet,Packet>( PST::random(), PST::random() ); }
94 static inline std::pair<Packet,Packet>
squareroot(std::pair<Packet,Packet> x) {
return std::pair<Packet,Packet>(PST::squareroot(x.first), PST::squareroot(x.second)); }
95 static inline std::pair<Packet,Packet>
pow(std::pair<Packet,Packet> x, std::pair<Packet,Packet> y) {
return std::pair<Packet,Packet>( PST::pow(x.first,y.first), PST::pow(x.second,y.second) ); }
98 template<
class Packet,
class ConvertToPacket>
101 static std::pair<Packet,Packet>
convert(
const ConvertToPacket t )
103 return std::pair<Packet,Packet>(t,t);
105 static std::pair<Packet,Packet>
safeConvert(
const ConvertToPacket t )
107 return std::pair<Packet,Packet>(t,t);
126 using Teuchos::outArg;
132 double errorTolSlack = 1e+1;
144 "test-mpi",
"test-serial", &testMpi,
145 "Test MPI (if available) or force test of serial. In a serial build,"
146 " this option is ignored and a serial comm is always used." );
149 "error-tol-slack", &errorTolSlack,
150 "Slack off of machine epsilon used to check test results" );
155 template<
class Ordinal>
156 RCP<const Comm<Ordinal> > getDefaultComm()
159 return DefaultComm<Ordinal>::getComm();
167 RCP<const Comm<Ordinal> > comm = getDefaultComm<Ordinal>();
168 out <<
"comm = " << Teuchos::describe(*comm);
177 typedef typename PT::magnitudeType PacketMag;
180 RCP<const Comm<Ordinal> > comm = getDefaultComm<Ordinal>();
181 const Ordinal numProcs =
size(*comm);
183 #ifdef TEUCHOS_MPI_COMM_DUMP
187 Array<Packet> sendBuffer(as<Ordinal>(numProcs));
188 for (Ordinal k = 0; k < numProcs; ++k) {
189 sendBuffer[k] = as<Packet>(1);
192 Array<Ordinal> recvCounts(as<Ordinal>(numProcs), as<Ordinal>(1));
194 Array<Packet> myGlobalReducts(1);
196 Teuchos::reduceAllAndScatter<Ordinal,Packet>(
198 as<Ordinal>(sendBuffer.size()), &sendBuffer[0],
199 &recvCounts[0], &myGlobalReducts[0]
202 if (std::numeric_limits<Packet>::is_integer) {
206 const PacketMag local_errorTolSlack =
static_cast<PacketMag
>(errorTolSlack);
208 as<PacketMag>(defaultSmallNumber<PacketMag>() * local_errorTolSlack / numProcs)
219 typedef typename PT::magnitudeType PacketMag;
222 RCP<const Comm<Ordinal> > comm = getDefaultComm<Ordinal>();
223 const Ordinal numProcs =
size(*comm);
224 const Ordinal procRank =
rank(*comm);
226 Array<Packet> sendBuffer(as<Ordinal>(numProcs));
227 for (Ordinal k = 0; k < numProcs; ++k) {
228 sendBuffer[k] = as<Packet>(procRank + k);
231 Array<Ordinal> recvCounts(as<Ordinal>(numProcs), as<Ordinal>(1));
233 Array<Packet> myGlobalReducts(1);
235 Teuchos::reduceAllAndScatter<Ordinal,Packet>(
237 as<Ordinal>(sendBuffer.size()), &sendBuffer[0],
238 &recvCounts[0], &myGlobalReducts[0]
241 const Packet expectedMyGlobalReduct = as<Packet>(
242 numProcs * procRank + ((numProcs - 1) * numProcs)/2
245 if (std::numeric_limits<Packet>::is_integer) {
249 const PacketMag local_errorTolSlack =
static_cast<PacketMag
>(errorTolSlack);
251 as<PacketMag>(defaultSmallNumber<PacketMag>() * local_errorTolSlack / numProcs)
261 using Teuchos::broadcast;
265 using Teuchos::rcpFromRef;
266 using Teuchos::outArg;
273 using Teuchos::arcpClone;
274 using Teuchos::rcp_dynamic_cast;
278 typedef typename PT::magnitudeType PacketMag;
281 RCP<const Comm<Ordinal> > comm = getDefaultComm<Ordinal>();
282 const Ordinal numProcs =
size(*comm);
283 const Ordinal procRank =
rank(*comm);
291 out <<
"\nThis is Teuchos::SerialComm which does not support readySend!\n";
295 PT::seedrandom(as<unsigned int>(procRank));
296 Packet origSendData = PT::random();
297 Packet origRecvData = PT::random();
298 broadcast<Ordinal, Packet>( *comm, 0,
outArg(origSendData) );
300 Packet sendData = origSendData;
301 Packet recvData = origRecvData;
303 RCP<Teuchos::CommRequest<Ordinal> > recvRequest;
308 recvRequest = ireceive<Ordinal, Packet>(
310 rcp(&recvData,
false),
316 if (procRank == numProcs-1) {
319 readySend<Ordinal, Packet>(
348 int globalSuccess_int = -1;
349 reduceAll( *comm, Teuchos::REDUCE_SUM, success ? 0 : 1,
outArg(globalSuccess_int) );
357 using Teuchos::broadcast;
361 using Teuchos::rcpFromRef;
362 using Teuchos::outArg;
369 using Teuchos::arcpClone;
370 using Teuchos::rcp_dynamic_cast;
373 typedef typename PT::magnitudeType PacketMag;
376 RCP<const Comm<Ordinal> > comm = getDefaultComm<Ordinal>();
377 const Ordinal numProcs =
size(*comm);
378 const Ordinal procRank =
rank(*comm);
386 out <<
"\nThis is Teuchos::SerialComm which does not support readySend!\n";
390 const int dataLen = 3;
392 const ArrayRCP<Packet> origSendData = arcp<Packet>(dataLen);
393 const ArrayRCP<Packet> origRecvData = arcp<Packet>(dataLen);
394 PT::seedrandom(as<unsigned int>(procRank));
395 for (
int j = 0; j < dataLen; ++j) {
396 origSendData[j] = PT::random();
397 origRecvData[j] = PT::random();
399 broadcast<Ordinal, Packet>( *comm, 0, origSendData() );
401 const ArrayRCP<Packet> sendData = arcpClone<Packet>(origSendData());
402 const ArrayRCP<Packet> recvData = arcpClone<Packet>(origRecvData());
404 RCP<Teuchos::CommRequest<Ordinal> > recvRequest;
416 recvRequest = ireceive<Ordinal, Packet>(
418 recvData.persistingView(0, dataLen),
422 else if (procRank == numProcs-1) {
424 recvRequest = ireceive<Ordinal, Packet>(
426 recvData.persistingView(0, dataLen),
435 readySend<Ordinal, Packet>(
441 else if (procRank == numProcs-1) {
451 else if (procRank == numProcs-1) {
454 readySend<Ordinal, Packet>(
466 if (procRank == 0 || procRank == numProcs-1) {
477 int globalSuccess_int = -1;
478 reduceAll( *comm, Teuchos::REDUCE_SUM, success ? 0 : 1,
outArg(globalSuccess_int) );
486 using Teuchos::rcpFromRef;
487 using Teuchos::outArg;
492 using Teuchos::rcp_dynamic_cast;
495 typedef typename PT::magnitudeType PacketMag;
498 RCP<const Comm<Ordinal> > comm = getDefaultComm<Ordinal>();
499 const Ordinal numProcs =
size(*comm);
500 const Ordinal procRank =
rank(*comm);
508 out <<
"\nThis is Teuchos::SerialComm which does not yet support isend/ireceive!\n";
513 Packet orig_input_data = PT::random();
516 const Packet orig_output_data = as<Packet>(-1);
518 const Packet input_data = orig_input_data;
519 Packet output_data = orig_output_data;
521 RCP<Teuchos::CommRequest<Ordinal> > recvRequest;
522 RCP<Teuchos::CommRequest<Ordinal> > sendRequest;
524 out <<
"Exchanging messages" << endl;
529 sendRequest = isend<Ordinal, Packet>(
530 *comm,
Teuchos::rcp(
new Packet(input_data)), numProcs-1);
532 if (procRank == numProcs-1) {
534 recvRequest = ireceive<Ordinal, Packet>(
538 out <<
"Waiting for messages" << endl;
543 if (procRank == numProcs-1) {
550 out <<
"Testing message correctness" << endl;
552 if (procRank == numProcs-1) {
561 int globalSuccess_int = -1;
562 reduceAll( *comm, Teuchos::REDUCE_SUM, success ? 0 : 1,
outArg(globalSuccess_int) );
570 using Teuchos::rcpFromRef;
571 using Teuchos::outArg;
573 using Teuchos::arcpClone;
578 using Teuchos::broadcast;
580 using Teuchos::rcp_dynamic_cast;
584 typedef typename PT::magnitudeType PacketMag;
587 RCP<const Comm<Ordinal> > comm = getDefaultComm<Ordinal>();
588 const Ordinal numProcs =
size(*comm);
589 const Ordinal procRank =
rank(*comm);
597 out <<
"\nThis is Teuchos::SerialComm which does not yet support isend/ireceive!\n";
601 const int numSendRecv = 4;
602 const int sendLen = 3;
604 cerr <<
"Creating data" << endl;
606 const ArrayRCP<Packet> origInputData = arcp<Packet>(numSendRecv*sendLen);
607 const ArrayRCP<Packet> origOutputData = arcp<Packet>(numSendRecv*sendLen);
610 for (
int i = 0; i < numSendRecv; ++i, offset += sendLen) {
611 const ArrayRCP<Packet> origInputData_i =
612 origInputData.persistingView(offset, sendLen);
613 const ArrayRCP<Packet> origOutputData_i =
614 origOutputData.persistingView(offset, sendLen);
615 for (
int j = 0; j < sendLen; ++j) {
616 origInputData_i[j] = PT::random();
617 origOutputData_i[j] = PT::random();
621 cerr <<
"Broadcasting data" << endl;
622 broadcast<Ordinal, Packet>( *comm, 0, origInputData() );
624 const ArrayRCP<Packet> inputData = arcpClone<Packet>(origInputData());
625 const ArrayRCP<Packet> outputData = arcpClone<Packet>(origOutputData());
627 Array<RCP<Teuchos::CommRequest<Ordinal> > > recvRequests;
628 Array<RCP<Teuchos::CommRequest<Ordinal> > > sendRequests;
630 cerr <<
"Exchanging data" << endl;
637 for (
int i = 0; i < numSendRecv; ++i, offset += sendLen) {
638 sendRequests.push_back(
639 isend<Ordinal, Packet>(
641 arcpClone<Packet>(inputData(offset, sendLen)),
649 if (procRank == numProcs-1) {
652 for (
int i = 0; i < numSendRecv; ++i, offset += sendLen) {
653 recvRequests.push_back(
654 ireceive<Ordinal, Packet>(
655 *comm, outputData.persistingView(offset, sendLen), 0
661 cerr <<
"Waiting on messages" << endl;
664 waitAll( *comm, sendRequests() );
666 if (procRank == numProcs-1) {
667 waitAll( *comm, recvRequests() );
670 cerr <<
"Testing received data" << endl;
672 if (!sendRequests.empty()) {
673 for (
int i = 0; i < numSendRecv; ++i) {
678 if (!recvRequests.empty()) {
679 for (
int i = 0; i < numSendRecv; ++i) {
685 if (procRank == numProcs-1) {
694 int globalSuccess_int = -1;
695 reduceAll( *comm, Teuchos::REDUCE_SUM, success ? 0 : 1,
outArg(globalSuccess_int) );
702 RCP< const Comm<Ordinal> > comm = getDefaultComm<Ordinal>();
703 int initialRank = comm->getRank();
704 int initialSize = comm->getSize();
706 RCP< const Comm<Ordinal> > newComm = comm->duplicate();
714 RCP< const Comm<Ordinal> > comm = getDefaultComm<Ordinal>();
715 int initialRank = comm->getRank();
716 int initialSize = comm->getSize();
721 RCP< const Comm<Ordinal> > newComm = comm->split(initialRank % 2, 0);
724 int halfSize = initialSize / 2;
725 int newSize = newComm->getSize();
726 int newRank = newComm->getRank();
727 if (initialSize % 2 == 0) {
731 TEST_EQUALITY(newSize, initialRank % 2 == 0 ? halfSize + 1 : halfSize);
736 RCP< const Comm<Ordinal> > shouldBeNull = comm->split(-1, 0);
744 template<
typename ValueType>
745 class MonotoneSequence
747 ValueType currentValue_;
749 typedef ValueType value_type;
751 MonotoneSequence(
const value_type& initialValue) : currentValue_(initialValue)
754 value_type operator()()
756 return currentValue_++;
765 RCP< const Comm<Ordinal> > comm = getDefaultComm<Ordinal>();
766 int initialRank = comm->getRank();
767 int initialSize = comm->getSize();
770 std::vector< int > ranks(initialSize);
771 std::generate(ranks.begin(), ranks.end(), MonotoneSequence<int>(0));
772 std::reverse(ranks.begin(), ranks.end());
773 RCP< const Comm<Ordinal> > newComm = comm->createSubcommunicator(ranks);
775 int expectedNewRank = initialSize - initialRank - 1;
779 std::vector<int> rank0Only(1, 0);
780 RCP< const Comm<Ordinal> > rank0Comm = comm->createSubcommunicator(rank0Only);
782 if (initialRank == 0) {
790 #ifdef HAVE_TEUCHOS_MPI
795 using Teuchos::tuple;
using Teuchos::inoutArg;
799 const int comm_size = defaultComm->getSize();
800 const int comm_rank = defaultComm->getRank();
809 defaultComm->createSubcommunicator(tuple<int>(0, 1)());
811 if (comm_rank <= 1) {
813 const int masterComm_size = masterComm->getSize();
814 (void) masterComm_size;
815 const int masterComm_rank = masterComm->getRank();
819 masterComm->createSubcommunicator(tuple<int>(0, 1)());
821 masterComm->createSubcommunicator(tuple<int>(0)());
825 masterComm->createSubcommunicator(tuple<int>(0, 1)());
833 if (masterComm_rank == 0) { tag1 = my_tag; }
834 masterComm->barrier();
835 Teuchos::broadcast( *masterComm, 0,
inoutArg(tag1) );
838 if (masterComm_rank == 1) { tag2 = my_tag; }
839 masterComm->barrier();
840 Teuchos::broadcast( *masterComm, 1,
inoutArg(tag2) );
850 #endif // HAVE_TEUCHOS_MPI
858 #ifdef HAVE_TEUCHOS_COMPLEX
859 # define UNIT_TEST_TEMPLATE_2_INSTANT_COMPLEX_FLOAT(TEST_GROUP, TEST_NAME, ORDINAL)\
860 typedef std::complex<float> ComplexFloat; \
861 TEUCHOS_UNIT_TEST_TEMPLATE_2_INSTANT(TEST_GROUP, TEST_NAME, ORDINAL, ComplexFloat)
862 # define UNIT_TEST_TEMPLATE_2_INSTANT_COMPLEX_DOUBLE(TEST_GROUP, TEST_NAME, ORDINAL)\
863 typedef std::complex<double> ComplexDouble; \
864 TEUCHOS_UNIT_TEST_TEMPLATE_2_INSTANT(TEST_GROUP, TEST_NAME, ORDINAL, ComplexDouble)
866 # define UNIT_TEST_TEMPLATE_2_INSTANT_COMPLEX_FLOAT(TEST_GROUP, TEST_NAME, ORDINAL)
867 # define UNIT_TEST_TEMPLATE_2_INSTANT_COMPLEX_DOUBLE(TEST_GROUP, TEST_NAME, ORDINAL)
871 #define UNIT_TEST_GROUP_ORDINAL_PACKET( ORDINAL, PACKET ) \
872 TEUCHOS_UNIT_TEST_TEMPLATE_2_INSTANT( DefaultMpiComm, reduceAllAndScatter_1, ORDINAL, PACKET ) \
873 TEUCHOS_UNIT_TEST_TEMPLATE_2_INSTANT( DefaultMpiComm, reduceAllAndScatter_2, ORDINAL, PACKET ) \
874 TEUCHOS_UNIT_TEST_TEMPLATE_2_INSTANT( DefaultMpiComm, NonblockingSendReceive, ORDINAL, PACKET ) \
875 TEUCHOS_UNIT_TEST_TEMPLATE_2_INSTANT( DefaultMpiComm, NonblockingSendReceiveSet, ORDINAL, PACKET ) \
876 TEUCHOS_UNIT_TEST_TEMPLATE_2_INSTANT( DefaultMpiComm, ReadySend1, ORDINAL, PACKET ) \
877 TEUCHOS_UNIT_TEST_TEMPLATE_2_INSTANT( DefaultMpiComm, ReadySend, ORDINAL, PACKET )
879 #ifdef HAVE_TEUCHOS_QD
880 # define UNIT_TEST_GROUP_ORDINAL_QD(ORDINAL) \
881 UNIT_TEST_GROUP_ORDINAL_PACKET(ORDINAL, dd_real) \
882 UNIT_TEST_GROUP_ORDINAL_PACKET(ORDINAL, qd_real)
884 # define UNIT_TEST_GROUP_ORDINAL_QD(ORDINAL)
887 #define UNIT_TEST_GROUP_ORDINAL_PAIROFPACKETS( ORDINAL, PAIROFPACKETS ) \
888 TEUCHOS_UNIT_TEST_TEMPLATE_2_INSTANT( DefaultMpiComm, NonblockingSendReceive, ORDINAL, PAIROFPACKETS ) \
889 TEUCHOS_UNIT_TEST_TEMPLATE_2_INSTANT( DefaultMpiComm, NonblockingSendReceiveSet, ORDINAL, PAIROFPACKETS ) \
890 TEUCHOS_UNIT_TEST_TEMPLATE_2_INSTANT( DefaultMpiComm, ReadySend1, ORDINAL, PAIROFPACKETS ) \
891 TEUCHOS_UNIT_TEST_TEMPLATE_2_INSTANT( DefaultMpiComm, ReadySend, ORDINAL, PAIROFPACKETS )
893 #define UNIT_TEST_GROUP_ORDINAL_SUBCOMMUNICATORS( ORDINAL ) \
894 TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( DefaultMpiComm, duplicate, ORDINAL ) \
895 TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( DefaultMpiComm, split, ORDINAL ) \
896 TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( DefaultMpiComm, createSubcommunicator, ORDINAL )
899 typedef std::pair<short, short> PairOfShorts;
900 typedef std::pair<int,int> PairOfInts;
901 typedef std::pair<float,float> PairOfFloats;
902 typedef std::pair<double,double> PairOfDoubles;
910 #ifdef FAST_DEVELOPMENT_UNIT_TEST_BUILD
912 # define UNIT_TEST_GROUP_ORDINAL( ORDINAL ) \
913 UNIT_TEST_GROUP_ORDINAL_PACKET(ORDINAL, double) \
914 UNIT_TEST_GROUP_ORDINAL_PAIROFPACKETS(ORDINAL, PairOfDoubles) \
918 #else // FAST_DEVELOPMENT_UNIT_TEST_BUILD
920 # define UNIT_TEST_GROUP_ORDINAL( ORDINAL ) \
921 TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( DefaultMpiComm, basic, ORDINAL ) \
922 UNIT_TEST_GROUP_ORDINAL_PACKET(ORDINAL, short) \
923 UNIT_TEST_GROUP_ORDINAL_PACKET(ORDINAL, int) \
924 UNIT_TEST_GROUP_ORDINAL_PACKET(ORDINAL, float) \
925 UNIT_TEST_GROUP_ORDINAL_PACKET(ORDINAL, double) \
926 UNIT_TEST_TEMPLATE_2_INSTANT_COMPLEX_FLOAT(DefaultMpiComm, reduceAllAndScatter_1, ORDINAL) \
927 UNIT_TEST_TEMPLATE_2_INSTANT_COMPLEX_FLOAT(DefaultMpiComm, reduceAllAndScatter_2, ORDINAL) \
928 UNIT_TEST_TEMPLATE_2_INSTANT_COMPLEX_FLOAT(DefaultMpiComm, NonblockingSendReceive, ORDINAL) \
929 UNIT_TEST_TEMPLATE_2_INSTANT_COMPLEX_FLOAT(DefaultMpiComm, ReadySend1, ORDINAL) \
930 UNIT_TEST_TEMPLATE_2_INSTANT_COMPLEX_FLOAT(DefaultMpiComm, ReadySend, ORDINAL) \
931 UNIT_TEST_TEMPLATE_2_INSTANT_COMPLEX_DOUBLE(DefaultMpiComm, reduceAllAndScatter_1, ORDINAL) \
932 UNIT_TEST_TEMPLATE_2_INSTANT_COMPLEX_DOUBLE(DefaultMpiComm, reduceAllAndScatter_2, ORDINAL) \
933 UNIT_TEST_TEMPLATE_2_INSTANT_COMPLEX_DOUBLE(DefaultMpiComm, NonblockingSendReceive, ORDINAL) \
934 UNIT_TEST_TEMPLATE_2_INSTANT_COMPLEX_DOUBLE(DefaultMpiComm, ReadySend1, ORDINAL) \
935 UNIT_TEST_TEMPLATE_2_INSTANT_COMPLEX_DOUBLE(DefaultMpiComm, ReadySend, ORDINAL) \
936 UNIT_TEST_GROUP_ORDINAL_SUBCOMMUNICATORS(ORDINAL)
938 # define UNIT_TEST_GROUP_ORDINAL_WITH_PAIRS_AND_QD( ORDINAL ) \
939 TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( DefaultMpiComm, basic, ORDINAL ) \
940 UNIT_TEST_GROUP_ORDINAL_PACKET(ORDINAL, short) \
941 UNIT_TEST_GROUP_ORDINAL_PACKET(ORDINAL, int) \
942 UNIT_TEST_GROUP_ORDINAL_PACKET(ORDINAL, float) \
943 UNIT_TEST_GROUP_ORDINAL_PACKET(ORDINAL, double) \
944 UNIT_TEST_GROUP_ORDINAL_QD(ORDINAL) \
945 UNIT_TEST_GROUP_ORDINAL_PAIROFPACKETS(ORDINAL, PairOfShorts) \
946 UNIT_TEST_GROUP_ORDINAL_PAIROFPACKETS(ORDINAL, PairOfInts) \
947 UNIT_TEST_GROUP_ORDINAL_PAIROFPACKETS(ORDINAL, PairOfFloats) \
948 UNIT_TEST_GROUP_ORDINAL_PAIROFPACKETS(ORDINAL, PairOfDoubles) \
949 UNIT_TEST_TEMPLATE_2_INSTANT_COMPLEX_FLOAT(DefaultMpiComm, reduceAllAndScatter_1, ORDINAL) \
950 UNIT_TEST_TEMPLATE_2_INSTANT_COMPLEX_FLOAT(DefaultMpiComm, reduceAllAndScatter_2, ORDINAL) \
951 UNIT_TEST_TEMPLATE_2_INSTANT_COMPLEX_FLOAT(DefaultMpiComm, NonblockingSendReceive, ORDINAL) \
952 UNIT_TEST_TEMPLATE_2_INSTANT_COMPLEX_FLOAT(DefaultMpiComm, ReadySend1, ORDINAL) \
953 UNIT_TEST_TEMPLATE_2_INSTANT_COMPLEX_FLOAT(DefaultMpiComm, ReadySend, ORDINAL) \
954 UNIT_TEST_TEMPLATE_2_INSTANT_COMPLEX_DOUBLE(DefaultMpiComm, reduceAllAndScatter_1, ORDINAL) \
955 UNIT_TEST_TEMPLATE_2_INSTANT_COMPLEX_DOUBLE(DefaultMpiComm, reduceAllAndScatter_2, ORDINAL) \
956 UNIT_TEST_TEMPLATE_2_INSTANT_COMPLEX_DOUBLE(DefaultMpiComm, NonblockingSendReceive, ORDINAL) \
957 UNIT_TEST_TEMPLATE_2_INSTANT_COMPLEX_DOUBLE(DefaultMpiComm, ReadySend1, ORDINAL) \
958 UNIT_TEST_TEMPLATE_2_INSTANT_COMPLEX_DOUBLE(DefaultMpiComm, ReadySend, ORDINAL)
960 typedef short int ShortInt;
963 typedef
long int LongInt;
966 # ifdef HAVE_TEUCHOS_LONG_LONG_INT
967 typedef long long int LongLongInt;
971 #endif // FAST_DEVELOPMENT_UNIT_TEST_BUILD
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...
static std::pair< Packet, Packet > real(std::pair< Packet, Packet > x)
#define TEST_ASSERT(v1)
Assert the given statement is true.
TEUCHOSCOMM_LIB_DLL_EXPORT RCP< Teuchos::CommRequest< int > > isend(const ArrayRCP< const double > &sendBuffer, const int destRank, const int tag, const Comm< int > &comm)
bool is_null(const boost::shared_ptr< T > &p)
Returns true if p.get()==NULL.
void addOutputSetupOptions(const bool &addOutputSetupOptions)
Set if options will be automatically added to setup Teuchos::VerboseObjectBase::getDefaultOStream().
#define UNIT_TEST_GROUP_ORDINAL_WITH_PAIRS_AND_QD(ORDINAL)
Scalar defaultSmallNumber()
void broadcast(const Comm< Ordinal > &comm, const int rootRank, const Ordinal count, Packet buffer[])
Broadcast array of objects that use value semantics.
RCP< T2 > rcp_dynamic_cast(const RCP< T1 > &p1, bool throw_on_fail=false)
Dynamic cast of underlying RCP type from T1* to T2*.
static bool isnaninf(std::pair< Packet, Packet > x)
static CommandLineProcessor & getCLP()
Return the CLP to add options to.
static magnitudeType magnitude(std::pair< Packet, Packet > a)
static std::pair< Packet, Packet > zero()
static const bool isComparable
Determines if scalar type supports relational operators such as <, >, <=, >=.
#define TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL(TEST_GROUP, TEST_NAME, TYPE)
Macro for defining a templated unit test with one template parameter.
int rank(const Comm< Ordinal > &comm)
Get the process rank.
#define TEST_EQUALITY(v1, v2)
Assert the equality of v1 and v2.
#define TEUCHOS_UNIT_TEST_TEMPLATE_2_DECL(TEST_GROUP, TEST_NAME, TYPE1, TYPE2)
Macro for defining a templated unit test with two template parameters.
static void seedrandom(unsigned int s)
Concrete serial communicator subclass.
#define TEUCHOS_UNIT_TEST(TEST_GROUP, TEST_NAME)
Macro for defining a (non-templated) unit test.
static std::pair< Packet, Packet > squareroot(std::pair< Packet, Packet > x)
static Teuchos::RCP< const Comm< OrdinalType > > getComm()
Return the default global communicator.
Initialize, finalize, and query the global MPI session.
static const bool hasMachineParameters
Determines if scalar type have machine-specific parameters (i.e. eps(), sfmin(), base(), prec(), t(), rnd(), emin(), rmin(), emax(), rmax() are supported).
bool is_null(const ArrayRCP< T > &p)
Returns true if p.get()==NULL.
static std::pair< Packet, Packet > imag(std::pair< Packet, Packet > x)
void reduceAll(const Comm< Ordinal > &comm, const ValueTypeReductionOp< Ordinal, Packet > &reductOp, const Ordinal count, const Packet sendBuffer[], Packet globalReducts[])
Collective reduce all of array of objects using value semantics using a user-defined reduction operat...
static std::pair< Packet, Packet > pow(std::pair< Packet, Packet > x, std::pair< Packet, Packet > y)
This structure defines some basic traits for a scalar field type.
std::vector< std::string > split(const std::string &str, const std::string &delimiters, const size_t start)
Split the given string using the given set of delimiters.
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
Deprecated.
void setOption(const char option_true[], const char option_false[], bool *option_val, const char documentation[]=NULL)
Set a boolean option.
static std::pair< Packet, Packet > convert(const ConvertToPacket t)
void waitAll(const Comm< Ordinal > &comm, const ArrayView< RCP< CommRequest< Ordinal > > > &requests)
Wait for an array of Teuchos::CommRequest objects.
static std::pair< Packet, Packet > safeConvert(const ConvertToPacket t)
#define UNIT_TEST_GROUP_ORDINAL(ORDINAL)
#define TEST_EQUALITY_CONST(v1, v2)
Assert the equality of v1 and constant v2.
void barrier(const Comm< Ordinal > &comm)
Barrier.
Ptr< T > inoutArg(T &arg)
create a non-persisting (required or optional) input/output argument for a function call...
Return a default global communicator appropriate for the build.
int size(const Comm< Ordinal > &comm)
Get the number of processes in the communicator.
Default traits class for all conversions between value types.
TypeTo as(const TypeFrom &t)
Convert from one value type to another.
#define TEST_FLOATING_EQUALITY(v1, v2, tol)
Assert the relative floating-point equality of rel_error(v1,v2) <= tol.
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).
Abstract interface for distributed-memory communication.
#define TEST_COMPARE_ARRAYS(a1, a2)
Assert that a1.size()==a2.size() and a[i]==b[i], i=0....
ScalarTraits< Packet > PST
std::pair< typename PST::magnitudeType, typename PST::magnitudeType > magnitudeType
static std::string name()
RCP< T > rcpFromRef(T &r)
Return a non-owning weak RCP object from a raw object reference for a defined type.
RCP< CommStatus< Ordinal > > wait(const Comm< Ordinal > &comm, const Ptr< RCP< CommRequest< Ordinal > > > &request)
Wait on a single communication request, and return its status.
Smart reference counting pointer class for automatic garbage collection.
static std::pair< Packet, Packet > conjugate(std::pair< Packet, Packet > x)
static std::pair< Packet, Packet > one()
static const bool isComplex
Determines if scalar type is std::complex.
static std::pair< Packet, Packet > random()
Implementation of Comm that uses MPI for communication.
Ptr< T > outArg(T &arg)
create a non-persisting (required or optional) output argument for a function call.
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.
Class that helps parse command line input arguments from (argc,argv[]) and set options.
static std::string name()
Reference-counted smart pointer for managing arrays.
Memory-safe templated array class that encapsulates std::vector.