20 #ifdef HAVE_TEUCHOS_MPI
24 #ifdef HAVE_TEUCHOS_QD
25 # include <qd/dd_real.h>
31 template <
typename Packet>
32 ostream & operator<< ( ostream& os, const pair<Packet, Packet>& arg)
34 os <<
"(" << arg.first <<
"," << arg.second <<
")";
45 template<
typename Packet>
49 typedef std::pair<typename PST::magnitudeType, typename PST::magnitudeType>
magnitudeType;
54 static inline magnitudeType magnitude(std::pair<Packet,Packet> a) {
return std::pair<Packet,Packet>( PST::magnitude(a.first), PST::magnitude(a.second) ); }
55 static inline std::pair<Packet,Packet>
zero() {
return std::pair<Packet,Packet>(PST::zero(),PST::zero()); }
56 static inline std::pair<Packet,Packet>
one() {
return std::pair<Packet,Packet>(PST::one(), PST::one()); }
57 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) ); }
58 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) ); }
59 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) ); }
60 static inline bool isnaninf(std::pair<Packet,Packet> x) {
return PST::isnaninf(x.first) || PST::isnaninf(x.second); }
61 static inline void seedrandom(
unsigned int s) { PST::seedrandom(s); }
62 static inline std::pair<Packet,Packet>
random() {
return std::pair<Packet,Packet>( PST::random(), PST::random() ); }
64 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)); }
65 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) ); }
68 template<
class Packet,
class ConvertToPacket>
71 static std::pair<Packet,Packet>
convert(
const ConvertToPacket t )
73 return std::pair<Packet,Packet>(t,t);
75 static std::pair<Packet,Packet>
safeConvert(
const ConvertToPacket t )
77 return std::pair<Packet,Packet>(t,t);
96 using Teuchos::outArg;
102 double errorTolSlack = 1e+1;
114 "test-mpi",
"test-serial", &testMpi,
115 "Test MPI (if available) or force test of serial. In a serial build,"
116 " this option is ignored and a serial comm is always used." );
119 "error-tol-slack", &errorTolSlack,
120 "Slack off of machine epsilon used to check test results" );
125 template<
class Ordinal>
126 RCP<const Comm<Ordinal> > getDefaultComm()
129 return DefaultComm<Ordinal>::getComm();
137 RCP<const Comm<Ordinal> > comm = getDefaultComm<Ordinal>();
138 out <<
"comm = " << Teuchos::describe(*comm);
143 #ifdef HAVE_TEUCHOS_MPI
148 ECHO(MPI_Comm rawMpiComm = MPI_COMM_WORLD);
149 ECHO(
const RCP<
const Comm<int> > comm =
150 Teuchos::createMpiComm<int>(Teuchos::opaqueWrapper(rawMpiComm)));
151 out <<
"comm = " << Teuchos::describe(*comm);
152 ECHO(MPI_Comm rawMpiComm2 = Teuchos::getRawMpiComm<int>(*comm));
159 ECHO(MPI_Comm rawMpiComm = MPI_COMM_WORLD);
160 ECHO(
const RCP<
const Comm<int> > comm =
161 Teuchos::createMpiComm<int>(Teuchos::opaqueWrapper(rawMpiComm), 123));
162 out <<
"comm = " << Teuchos::describe(*comm);
163 ECHO(MPI_Comm rawMpiComm2 = Teuchos::getRawMpiComm<int>(*comm));
169 #endif // HAVE_TEUCHOS_MPI
175 using Teuchos::broadcast;
179 using Teuchos::rcpFromRef;
180 using Teuchos::outArg;
187 using Teuchos::arcpClone;
188 using Teuchos::rcp_dynamic_cast;
195 RCP<const Comm<Ordinal> > comm = getDefaultComm<Ordinal>();
196 const Ordinal numProcs =
size(*comm);
197 const Ordinal procRank =
rank(*comm);
205 out <<
"\nThis is Teuchos::SerialComm which does not support readySend!\n";
209 PT::seedrandom(as<unsigned int>(procRank));
210 Packet origSendData = PT::random();
211 Packet origRecvData = PT::random();
212 broadcast<Ordinal, Packet>( *comm, 0,
outArg(origSendData) );
214 Packet sendData = origSendData;
215 Packet recvData = origRecvData;
217 RCP<Teuchos::CommRequest<Ordinal> > recvRequest;
222 recvRequest = ireceive<Ordinal, Packet>(
224 rcp(&recvData,
false),
230 if (procRank == numProcs-1) {
233 readySend<Ordinal, Packet>(
262 int globalSuccess_int = -1;
271 using Teuchos::broadcast;
275 using Teuchos::rcpFromRef;
276 using Teuchos::outArg;
283 using Teuchos::arcpClone;
284 using Teuchos::rcp_dynamic_cast;
290 RCP<const Comm<Ordinal> > comm = getDefaultComm<Ordinal>();
291 const Ordinal numProcs =
size(*comm);
292 const Ordinal procRank =
rank(*comm);
300 out <<
"\nThis is Teuchos::SerialComm which does not support readySend!\n";
304 const int dataLen = 3;
306 const ArrayRCP<Packet> origSendData = arcp<Packet>(dataLen);
307 const ArrayRCP<Packet> origRecvData = arcp<Packet>(dataLen);
308 PT::seedrandom(as<unsigned int>(procRank));
309 for (
int j = 0; j < dataLen; ++j) {
310 origSendData[j] = PT::random();
311 origRecvData[j] = PT::random();
313 broadcast<Ordinal, Packet>( *comm, 0, origSendData() );
315 const ArrayRCP<Packet> sendData = arcpClone<Packet>(origSendData());
316 const ArrayRCP<Packet> recvData = arcpClone<Packet>(origRecvData());
318 RCP<Teuchos::CommRequest<Ordinal> > recvRequest;
330 recvRequest = ireceive<Ordinal, Packet>(
332 recvData.persistingView(0, dataLen),
336 else if (procRank == numProcs-1) {
338 recvRequest = ireceive<Ordinal, Packet>(
340 recvData.persistingView(0, dataLen),
349 readySend<Ordinal, Packet>(
355 else if (procRank == numProcs-1) {
365 else if (procRank == numProcs-1) {
368 readySend<Ordinal, Packet>(
380 if (procRank == 0 || procRank == numProcs-1) {
391 int globalSuccess_int = -1;
400 using Teuchos::rcpFromRef;
401 using Teuchos::outArg;
406 using Teuchos::rcp_dynamic_cast;
410 RCP<const Comm<Ordinal> > comm = getDefaultComm<Ordinal>();
411 const Ordinal numProcs =
size(*comm);
412 const Ordinal procRank =
rank(*comm);
420 out <<
"\nThis is Teuchos::SerialComm which does not yet support isend/ireceive!\n";
425 Packet orig_input_data = PT::random();
428 const Packet orig_output_data = as<Packet>(-1);
430 const Packet input_data = orig_input_data;
431 Packet output_data = orig_output_data;
433 RCP<Teuchos::CommRequest<Ordinal> > recvRequest;
434 RCP<Teuchos::CommRequest<Ordinal> > sendRequest;
436 out <<
"Exchanging messages" << endl;
441 sendRequest = isend<Ordinal, Packet>(
442 *comm,
Teuchos::rcp(
new Packet(input_data)), numProcs-1);
444 if (procRank == numProcs-1) {
446 recvRequest = ireceive<Ordinal, Packet>(
450 out <<
"Waiting for messages" << endl;
455 if (procRank == numProcs-1) {
462 out <<
"Testing message correctness" << endl;
464 if (procRank == numProcs-1) {
473 int globalSuccess_int = -1;
482 using Teuchos::rcpFromRef;
483 using Teuchos::outArg;
487 using Teuchos::rcp_dynamic_cast;
490 RCP<const Comm<Ordinal>> comm = getDefaultComm<Ordinal>();
491 const Ordinal numProcs =
size(*comm);
492 const Ordinal procRank =
rank(*comm);
495 out <<
"\nThis is Teuchos::SerialComm which does not yet support isend/ireceive!\n";
500 Packet input_data = PT::random();
502 Packet output_data = as<Packet>(-1);
504 const Ordinal sendRank = (procRank + 1) % numProcs;
505 const Ordinal recvRank = (procRank + numProcs - 1) % numProcs;
507 RCP<Teuchos::CommRequest<Ordinal>> recvRequest = ireceive<Ordinal, Packet>(*comm,
rcpFromRef(output_data), recvRank);
508 RCP<Teuchos::CommRequest<Ordinal>> sendRequest = isend<Ordinal, Packet>(*comm,
rcpFromRef(input_data), sendRank);
514 int globalSuccess_int = -1;
523 using Teuchos::rcpFromRef;
524 using Teuchos::outArg;
527 using Teuchos::rcp_dynamic_cast;
529 RCP<const Comm<Ordinal>> comm = getDefaultComm<Ordinal>();
530 const Ordinal numProcs =
size(*comm);
531 const Ordinal procRank =
rank(*comm);
534 out <<
"\nThis is Teuchos::SerialComm which does not yet support isend/ireceive!\n";
538 Packet output_data = as<Packet>(-1);
540 RCP<Teuchos::CommRequest<Ordinal>> recvRequest;
541 const Ordinal recvRank = (procRank + numProcs - 1) % numProcs;
543 recvRequest = ireceive<Ordinal, Packet>(*comm,
rcpFromRef(output_data), recvRank);
547 int globalSuccess_int = -1;
553 template <
class Ordinal>
554 bool null_request_is_always_ready_if_mpi_available() {
555 #ifdef HAVE_TEUCHOS_MPI
556 Teuchos::MpiCommRequestBase<Ordinal> nullRequest;
557 return nullRequest.isReady();
565 using Teuchos::outArg;
567 RCP<const Comm<Ordinal>> comm = getDefaultComm<Ordinal>();
568 TEST_ASSERT(null_request_is_always_ready_if_mpi_available<Ordinal>());
571 int globalSuccess_int = -1;
580 using Teuchos::rcpFromRef;
581 using Teuchos::outArg;
583 using Teuchos::arcpClone;
588 using Teuchos::broadcast;
590 using Teuchos::rcp_dynamic_cast;
596 RCP<const Comm<Ordinal> > comm = getDefaultComm<Ordinal>();
597 const Ordinal numProcs =
size(*comm);
598 const Ordinal procRank =
rank(*comm);
606 out <<
"\nThis is Teuchos::SerialComm which does not yet support isend/ireceive!\n";
610 const int numSendRecv = 4;
611 const int sendLen = 3;
613 out <<
"Creating data" << endl;
615 const ArrayRCP<Packet> origInputData = arcp<Packet>(numSendRecv*sendLen);
616 const ArrayRCP<Packet> origOutputData = arcp<Packet>(numSendRecv*sendLen);
619 for (
int i = 0; i < numSendRecv; ++i, offset += sendLen) {
620 const ArrayRCP<Packet> origInputData_i =
621 origInputData.persistingView(offset, sendLen);
622 const ArrayRCP<Packet> origOutputData_i =
623 origOutputData.persistingView(offset, sendLen);
624 for (
int j = 0; j < sendLen; ++j) {
625 origInputData_i[j] = PT::random();
626 origOutputData_i[j] = PT::random();
630 out <<
"Broadcasting data" << endl;
631 broadcast<Ordinal, Packet>( *comm, 0, origInputData() );
633 const ArrayRCP<Packet> inputData = arcpClone<Packet>(origInputData());
634 const ArrayRCP<Packet> outputData = arcpClone<Packet>(origOutputData());
636 Array<RCP<Teuchos::CommRequest<Ordinal> > > recvRequests;
637 Array<RCP<Teuchos::CommRequest<Ordinal> > > sendRequests;
639 out <<
"Exchanging data" << endl;
646 for (
int i = 0; i < numSendRecv; ++i, offset += sendLen) {
647 sendRequests.push_back(
648 isend<Ordinal, Packet>(
650 arcpClone<Packet>(inputData(offset, sendLen)),
658 if (procRank == numProcs-1) {
661 for (
int i = 0; i < numSendRecv; ++i, offset += sendLen) {
662 recvRequests.push_back(
663 ireceive<Ordinal, Packet>(
664 *comm, outputData.persistingView(offset, sendLen), 0
670 out <<
"Waiting on messages" << endl;
673 waitAll( *comm, sendRequests() );
675 if (procRank == numProcs-1) {
676 waitAll( *comm, recvRequests() );
679 out <<
"Testing received data" << endl;
681 if (!sendRequests.empty()) {
682 for (
int i = 0; i < numSendRecv; ++i) {
687 if (!recvRequests.empty()) {
688 for (
int i = 0; i < numSendRecv; ++i) {
694 if (procRank == numProcs-1) {
703 int globalSuccess_int = -1;
711 RCP< const Comm<Ordinal> > comm = getDefaultComm<Ordinal>();
712 int initialRank = comm->getRank();
713 int initialSize = comm->getSize();
715 RCP< const Comm<Ordinal> > newComm = comm->duplicate();
723 RCP< const Comm<Ordinal> > comm = getDefaultComm<Ordinal>();
724 int initialRank = comm->getRank();
725 int initialSize = comm->getSize();
730 RCP< const Comm<Ordinal> > newComm = comm->split(initialRank % 2, 0);
733 int halfSize = initialSize / 2;
734 int newSize = newComm->getSize();
735 int newRank = newComm->getRank();
736 if (initialSize % 2 == 0) {
740 TEST_EQUALITY(newSize, initialRank % 2 == 0 ? halfSize + 1 : halfSize);
745 RCP< const Comm<Ordinal> > shouldBeNull = comm->split(-1, 0);
753 template<
typename ValueType>
754 class MonotoneSequence
756 ValueType currentValue_;
758 typedef ValueType value_type;
760 MonotoneSequence(
const value_type& initialValue) : currentValue_(initialValue)
763 value_type operator()()
765 return currentValue_++;
774 RCP< const Comm<Ordinal> > comm = getDefaultComm<Ordinal>();
775 int initialRank = comm->getRank();
776 int initialSize = comm->getSize();
779 std::vector< int > ranks(initialSize);
780 std::generate(ranks.begin(), ranks.end(), MonotoneSequence<int>(0));
781 std::reverse(ranks.begin(), ranks.end());
782 RCP< const Comm<Ordinal> > newComm = comm->createSubcommunicator(ranks);
784 int expectedNewRank = initialSize - initialRank - 1;
788 std::vector<int> rank0Only(1, 0);
789 RCP< const Comm<Ordinal> > rank0Comm = comm->createSubcommunicator(rank0Only);
791 if (initialRank == 0) {
799 #ifdef HAVE_TEUCHOS_MPI
804 using Teuchos::tuple;
using Teuchos::inoutArg;
808 const int comm_size = defaultComm->getSize();
809 const int comm_rank = defaultComm->getRank();
818 defaultComm->createSubcommunicator(tuple<int>(0, 1)());
820 if (comm_rank <= 1) {
822 const int masterComm_size = masterComm->getSize();
823 (void) masterComm_size;
824 const int masterComm_rank = masterComm->getRank();
828 masterComm->createSubcommunicator(tuple<int>(0, 1)());
830 masterComm->createSubcommunicator(tuple<int>(0)());
834 masterComm->createSubcommunicator(tuple<int>(0, 1)());
837 int my_tag = Teuchos::rcp_dynamic_cast<
const Teuchos::MpiComm<int> >(
842 if (masterComm_rank == 0) { tag1 = my_tag; }
843 masterComm->barrier();
844 Teuchos::broadcast( *masterComm, 0,
inoutArg(tag1) );
847 if (masterComm_rank == 1) { tag2 = my_tag; }
848 masterComm->barrier();
849 Teuchos::broadcast( *masterComm, 1,
inoutArg(tag2) );
859 #endif // HAVE_TEUCHOS_MPI
867 #ifdef HAVE_TEUCHOS_COMPLEX
868 # define UNIT_TEST_TEMPLATE_2_INSTANT_COMPLEX_FLOAT(TEST_GROUP, TEST_NAME, ORDINAL)\
869 typedef std::complex<float> ComplexFloat; \
870 TEUCHOS_UNIT_TEST_TEMPLATE_2_INSTANT(TEST_GROUP, TEST_NAME, ORDINAL, ComplexFloat)
871 # define UNIT_TEST_TEMPLATE_2_INSTANT_COMPLEX_DOUBLE(TEST_GROUP, TEST_NAME, ORDINAL)\
872 typedef std::complex<double> ComplexDouble; \
873 TEUCHOS_UNIT_TEST_TEMPLATE_2_INSTANT(TEST_GROUP, TEST_NAME, ORDINAL, ComplexDouble)
875 # define UNIT_TEST_TEMPLATE_2_INSTANT_COMPLEX_FLOAT(TEST_GROUP, TEST_NAME, ORDINAL)
876 # define UNIT_TEST_TEMPLATE_2_INSTANT_COMPLEX_DOUBLE(TEST_GROUP, TEST_NAME, ORDINAL)
880 #define UNIT_TEST_GROUP_ORDINAL_PACKET( ORDINAL, PACKET ) \
881 TEUCHOS_UNIT_TEST_TEMPLATE_2_INSTANT( DefaultMpiComm, NonblockingSendReceive, ORDINAL, PACKET ) \
882 TEUCHOS_UNIT_TEST_TEMPLATE_2_INSTANT( DefaultMpiComm, NonblockingSendReceive_isReady_true, ORDINAL, PACKET ) \
883 TEUCHOS_UNIT_TEST_TEMPLATE_2_INSTANT( DefaultMpiComm, NonblockingSendReceive_isReady_false, ORDINAL, PACKET ) \
884 TEUCHOS_UNIT_TEST_TEMPLATE_2_INSTANT( DefaultMpiComm, NonblockingSendReceive_isReady_nullIsTrue, ORDINAL, PACKET ) \
885 TEUCHOS_UNIT_TEST_TEMPLATE_2_INSTANT( DefaultMpiComm, NonblockingSendReceiveSet, ORDINAL, PACKET ) \
886 TEUCHOS_UNIT_TEST_TEMPLATE_2_INSTANT( DefaultMpiComm, ReadySend1, ORDINAL, PACKET ) \
887 TEUCHOS_UNIT_TEST_TEMPLATE_2_INSTANT( DefaultMpiComm, ReadySend, ORDINAL, PACKET )
889 #ifdef HAVE_TEUCHOS_QD
890 # define UNIT_TEST_GROUP_ORDINAL_QD(ORDINAL) \
891 UNIT_TEST_GROUP_ORDINAL_PACKET(ORDINAL, dd_real) \
892 UNIT_TEST_GROUP_ORDINAL_PACKET(ORDINAL, qd_real)
894 # define UNIT_TEST_GROUP_ORDINAL_QD(ORDINAL)
897 #define UNIT_TEST_GROUP_ORDINAL_PAIROFPACKETS( ORDINAL, PAIROFPACKETS ) \
898 TEUCHOS_UNIT_TEST_TEMPLATE_2_INSTANT( DefaultMpiComm, NonblockingSendReceive, ORDINAL, PAIROFPACKETS ) \
899 TEUCHOS_UNIT_TEST_TEMPLATE_2_INSTANT( DefaultMpiComm, NonblockingSendReceive_isReady_true, ORDINAL, PAIROFPACKETS ) \
900 TEUCHOS_UNIT_TEST_TEMPLATE_2_INSTANT( DefaultMpiComm, NonblockingSendReceive_isReady_false, ORDINAL, PAIROFPACKETS ) \
901 TEUCHOS_UNIT_TEST_TEMPLATE_2_INSTANT( DefaultMpiComm, NonblockingSendReceive_isReady_nullIsTrue, ORDINAL, PAIROFPACKETS ) \
902 TEUCHOS_UNIT_TEST_TEMPLATE_2_INSTANT( DefaultMpiComm, NonblockingSendReceiveSet, ORDINAL, PAIROFPACKETS ) \
903 TEUCHOS_UNIT_TEST_TEMPLATE_2_INSTANT( DefaultMpiComm, ReadySend1, ORDINAL, PAIROFPACKETS ) \
904 TEUCHOS_UNIT_TEST_TEMPLATE_2_INSTANT( DefaultMpiComm, ReadySend, ORDINAL, PAIROFPACKETS )
906 #define UNIT_TEST_GROUP_ORDINAL_SUBCOMMUNICATORS( ORDINAL ) \
907 TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( DefaultMpiComm, duplicate, ORDINAL ) \
908 TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( DefaultMpiComm, split, ORDINAL ) \
909 TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( DefaultMpiComm, createSubcommunicator, ORDINAL )
912 typedef std::pair<short, short> PairOfShorts;
913 typedef std::pair<int,int> PairOfInts;
914 typedef std::pair<float,float> PairOfFloats;
915 typedef std::pair<double,double> PairOfDoubles;
923 #ifdef FAST_DEVELOPMENT_UNIT_TEST_BUILD
925 # define UNIT_TEST_GROUP_ORDINAL( ORDINAL ) \
926 UNIT_TEST_GROUP_ORDINAL_PACKET(ORDINAL, double) \
927 UNIT_TEST_GROUP_ORDINAL_PAIROFPACKETS(ORDINAL, PairOfDoubles) \
931 #else // FAST_DEVELOPMENT_UNIT_TEST_BUILD
933 # define UNIT_TEST_GROUP_ORDINAL( ORDINAL ) \
934 TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( DefaultMpiComm, basic, ORDINAL ) \
935 UNIT_TEST_GROUP_ORDINAL_PACKET(ORDINAL, short) \
936 UNIT_TEST_GROUP_ORDINAL_PACKET(ORDINAL, int) \
937 UNIT_TEST_GROUP_ORDINAL_PACKET(ORDINAL, float) \
938 UNIT_TEST_GROUP_ORDINAL_PACKET(ORDINAL, double) \
939 UNIT_TEST_TEMPLATE_2_INSTANT_COMPLEX_FLOAT(DefaultMpiComm, NonblockingSendReceive, ORDINAL) \
940 UNIT_TEST_TEMPLATE_2_INSTANT_COMPLEX_FLOAT(DefaultMpiComm, NonblockingSendReceive_isReady_true, ORDINAL) \
941 UNIT_TEST_TEMPLATE_2_INSTANT_COMPLEX_FLOAT(DefaultMpiComm, NonblockingSendReceive_isReady_false, ORDINAL) \
942 UNIT_TEST_TEMPLATE_2_INSTANT_COMPLEX_FLOAT(DefaultMpiComm, NonblockingSendReceive_isReady_nullIsTrue, ORDINAL) \
943 UNIT_TEST_TEMPLATE_2_INSTANT_COMPLEX_FLOAT(DefaultMpiComm, ReadySend1, ORDINAL) \
944 UNIT_TEST_TEMPLATE_2_INSTANT_COMPLEX_FLOAT(DefaultMpiComm, ReadySend, ORDINAL) \
945 UNIT_TEST_TEMPLATE_2_INSTANT_COMPLEX_DOUBLE(DefaultMpiComm, NonblockingSendReceive, ORDINAL) \
946 UNIT_TEST_TEMPLATE_2_INSTANT_COMPLEX_DOUBLE(DefaultMpiComm, NonblockingSendReceive_isReady_true, ORDINAL) \
947 UNIT_TEST_TEMPLATE_2_INSTANT_COMPLEX_DOUBLE(DefaultMpiComm, NonblockingSendReceive_isReady_false, ORDINAL) \
948 UNIT_TEST_TEMPLATE_2_INSTANT_COMPLEX_DOUBLE(DefaultMpiComm, NonblockingSendReceive_isReady_nullIsTrue, ORDINAL) \
949 UNIT_TEST_TEMPLATE_2_INSTANT_COMPLEX_DOUBLE(DefaultMpiComm, ReadySend1, ORDINAL) \
950 UNIT_TEST_TEMPLATE_2_INSTANT_COMPLEX_DOUBLE(DefaultMpiComm, ReadySend, ORDINAL) \
951 UNIT_TEST_GROUP_ORDINAL_SUBCOMMUNICATORS(ORDINAL)
953 # define UNIT_TEST_GROUP_ORDINAL_WITH_PAIRS_AND_QD( ORDINAL ) \
954 TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( DefaultMpiComm, basic, ORDINAL ) \
955 UNIT_TEST_GROUP_ORDINAL_PACKET(ORDINAL, short) \
956 UNIT_TEST_GROUP_ORDINAL_PACKET(ORDINAL, int) \
957 UNIT_TEST_GROUP_ORDINAL_PACKET(ORDINAL, float) \
958 UNIT_TEST_GROUP_ORDINAL_PACKET(ORDINAL, double) \
959 UNIT_TEST_GROUP_ORDINAL_QD(ORDINAL) \
960 UNIT_TEST_GROUP_ORDINAL_PAIROFPACKETS(ORDINAL, PairOfShorts) \
961 UNIT_TEST_GROUP_ORDINAL_PAIROFPACKETS(ORDINAL, PairOfInts) \
962 UNIT_TEST_GROUP_ORDINAL_PAIROFPACKETS(ORDINAL, PairOfFloats) \
963 UNIT_TEST_GROUP_ORDINAL_PAIROFPACKETS(ORDINAL, PairOfDoubles) \
964 UNIT_TEST_TEMPLATE_2_INSTANT_COMPLEX_FLOAT(DefaultMpiComm, NonblockingSendReceive, ORDINAL) \
965 UNIT_TEST_TEMPLATE_2_INSTANT_COMPLEX_FLOAT(DefaultMpiComm, NonblockingSendReceive_isReady_true, ORDINAL) \
966 UNIT_TEST_TEMPLATE_2_INSTANT_COMPLEX_FLOAT(DefaultMpiComm, NonblockingSendReceive_isReady_false, ORDINAL) \
967 UNIT_TEST_TEMPLATE_2_INSTANT_COMPLEX_FLOAT(DefaultMpiComm, NonblockingSendReceive_isReady_nullIsTrue, ORDINAL) \
968 UNIT_TEST_TEMPLATE_2_INSTANT_COMPLEX_FLOAT(DefaultMpiComm, ReadySend1, ORDINAL) \
969 UNIT_TEST_TEMPLATE_2_INSTANT_COMPLEX_FLOAT(DefaultMpiComm, ReadySend, ORDINAL) \
970 UNIT_TEST_TEMPLATE_2_INSTANT_COMPLEX_DOUBLE(DefaultMpiComm, NonblockingSendReceive, ORDINAL) \
971 UNIT_TEST_TEMPLATE_2_INSTANT_COMPLEX_DOUBLE(DefaultMpiComm, NonblockingSendReceive_isReady_true, ORDINAL) \
972 UNIT_TEST_TEMPLATE_2_INSTANT_COMPLEX_DOUBLE(DefaultMpiComm, NonblockingSendReceive_isReady_false, ORDINAL) \
973 UNIT_TEST_TEMPLATE_2_INSTANT_COMPLEX_DOUBLE(DefaultMpiComm, NonblockingSendReceive_isReady_nullIsTrue, ORDINAL) \
974 UNIT_TEST_TEMPLATE_2_INSTANT_COMPLEX_DOUBLE(DefaultMpiComm, ReadySend1, ORDINAL) \
975 UNIT_TEST_TEMPLATE_2_INSTANT_COMPLEX_DOUBLE(DefaultMpiComm, ReadySend, ORDINAL)
977 typedef short int ShortInt;
980 typedef
long int LongInt;
983 typedef
long long int LongLongInt;
986 #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.
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.
#define ECHO(statement)
Echo the given statement before it is executed.
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)
bool is_null(const std::shared_ptr< T > &p)
Returns true if p.get()==NULL.
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[])
Wrapper for MPI_Allreduce that takes a custom reduction operator.
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)
Implementation of Teuchos wrappers for MPI.
#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.
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
RCP< Teuchos::CommRequest< int > > isend(const ArrayRCP< const double > &sendBuffer, const int destRank, const int tag, const Comm< int > &comm)
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()
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.
Replacement for std::vector that is compatible with the Teuchos Memory Management classes...