Teuchos Package Browser (Single Doxygen Collection)  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DefaultMpiComm_UnitTests.cpp
Go to the documentation of this file.
1 /*
2 // @HEADER
3 // ***********************************************************************
4 //
5 // Teuchos: Common Tools Package
6 // Copyright (2004) Sandia Corporation
7 //
8 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
9 // license for use of this work by or on behalf of the U.S. Government.
10 //
11 // Redistribution and use in source and binary forms, with or without
12 // modification, are permitted provided that the following conditions are
13 // met:
14 //
15 // 1. Redistributions of source code must retain the above copyright
16 // notice, this list of conditions and the following disclaimer.
17 //
18 // 2. Redistributions in binary form must reproduce the above copyright
19 // notice, this list of conditions and the following disclaimer in the
20 // documentation and/or other materials provided with the distribution.
21 //
22 // 3. Neither the name of the Corporation nor the names of the
23 // contributors may be used to endorse or promote products derived from
24 // this software without specific prior written permission.
25 //
26 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
27 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
30 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
31 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
32 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
33 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
34 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
35 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
36 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37 //
38 // Questions? Contact Michael A. Heroux (maherou@sandia.gov)
39 //
40 // ***********************************************************************
41 // @HEADER
42 */
43 
45 
46 
48 #include "Teuchos_CommHelpers.hpp"
49 #include "Teuchos_DefaultComm.hpp"
51 #include "Teuchos_getConst.hpp"
52 #include "Teuchos_as.hpp"
53 
54 #ifdef HAVE_TEUCHOS_QD
55 #include <qd/dd_real.h>
56 #endif
57 
58 namespace std {
59 
60 
61 template <typename Packet>
62 ostream & operator<< ( ostream& os, const pair<Packet, Packet>& arg)
63 {
64  os << "(" << arg.first << "," << arg.second << ")";
65  return os;
66 }
67 
68 
69 } // namespace std
70 
71 
72 namespace Teuchos {
73 
74 
75 template<typename Packet>
76 struct ScalarTraits<std::pair<Packet,Packet> >
77 {
79  typedef std::pair<typename PST::magnitudeType, typename PST::magnitudeType> magnitudeType;
80  static const bool isComplex = PST::isComplex;
81  static const bool isComparable = PST::isComparable;
82  static const bool hasMachineParameters = PST::hasMachineParameters;
83  // Not defined: eps(), sfmin(), base(), prec(), t(), rnd(), emin(), rmin(), emax(), rmax()
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() ); }
93  static inline std::string name() { return "std::pair<" + Teuchos::TypeNameTraits<Packet>::name() + "," + Teuchos::TypeNameTraits<Packet>::name() + ">"; }
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) ); }
96 };
97 
98 template<class Packet, class ConvertToPacket>
99 class ValueTypeConversionTraits<std::pair<Packet,Packet>, ConvertToPacket> {
100 public:
101  static std::pair<Packet,Packet> convert( const ConvertToPacket t )
102  {
103  return std::pair<Packet,Packet>(t,t);
104  }
105  static std::pair<Packet,Packet> safeConvert( const ConvertToPacket t )
106  {
107  return std::pair<Packet,Packet>(t,t);
108  }
109 };
110 
111 
112 } // namespace Teuchos
113 
114 
115 namespace {
116 
117 
118 using Teuchos::as;
119 using Teuchos::RCP;
120 using Teuchos::rcp;
121 using Teuchos::Array;
122 using Teuchos::Comm;
126 using Teuchos::outArg;
127 
128 
129 bool testMpi = true;
130 
131 
132 double errorTolSlack = 1e+1;
133 
134 
135 
137 {
138 
140 
141  clp.addOutputSetupOptions(true);
142 
143  clp.setOption(
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." );
147 
148  clp.setOption(
149  "error-tol-slack", &errorTolSlack,
150  "Slack off of machine epsilon used to check test results" );
151 
152 }
153 
154 
155 template<class Ordinal>
156 RCP<const Comm<Ordinal> > getDefaultComm()
157 {
158  if (testMpi) {
159  return DefaultComm<Ordinal>::getComm();
160  }
161  return rcp(new Teuchos::SerialComm<Ordinal>);
162 }
163 
164 
165 TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL( DefaultMpiComm, basic, Ordinal )
166 {
167  RCP<const Comm<Ordinal> > comm = getDefaultComm<Ordinal>();
168  out << "comm = " << Teuchos::describe(*comm);
169  TEST_EQUALITY( size(*comm), GlobalMPISession::getNProc() );
170 }
171 
172 
173 TEUCHOS_UNIT_TEST_TEMPLATE_2_DECL( DefaultMpiComm, reduceAllAndScatter_1, Ordinal, Packet )
174 {
175 
177  typedef typename PT::magnitudeType PacketMag;
179 
180  RCP<const Comm<Ordinal> > comm = getDefaultComm<Ordinal>();
181  const Ordinal numProcs = size(*comm);
182 
183 #ifdef TEUCHOS_MPI_COMM_DUMP
185 #endif
186 
187  Array<Packet> sendBuffer(as<Ordinal>(numProcs));
188  for (Ordinal k = 0; k < numProcs; ++k) {
189  sendBuffer[k] = as<Packet>(1);
190  }
191 
192  Array<Ordinal> recvCounts(as<Ordinal>(numProcs), as<Ordinal>(1));
193 
194  Array<Packet> myGlobalReducts(1);
195 
196  Teuchos::reduceAllAndScatter<Ordinal,Packet>(
197  *comm, Teuchos::REDUCE_SUM,
198  as<Ordinal>(sendBuffer.size()), &sendBuffer[0],
199  &recvCounts[0], &myGlobalReducts[0]
200  );
201 
202  if (std::numeric_limits<Packet>::is_integer) {
203  TEST_EQUALITY( myGlobalReducts[0], as<Packet>(numProcs) );
204  }
205  else {
206  const PacketMag local_errorTolSlack = static_cast<PacketMag>(errorTolSlack);
207  TEST_FLOATING_EQUALITY( myGlobalReducts[0], as<Packet>(numProcs),
208  as<PacketMag>(defaultSmallNumber<PacketMag>() * local_errorTolSlack / numProcs)
209  );
210  }
211 
212 }
213 
214 
215 TEUCHOS_UNIT_TEST_TEMPLATE_2_DECL( DefaultMpiComm, reduceAllAndScatter_2, Ordinal, Packet )
216 {
217 
219  typedef typename PT::magnitudeType PacketMag;
221 
222  RCP<const Comm<Ordinal> > comm = getDefaultComm<Ordinal>();
223  const Ordinal numProcs = size(*comm);
224  const Ordinal procRank = rank(*comm);
225 
226  Array<Packet> sendBuffer(as<Ordinal>(numProcs));
227  for (Ordinal k = 0; k < numProcs; ++k) {
228  sendBuffer[k] = as<Packet>(procRank + k);
229  }
230 
231  Array<Ordinal> recvCounts(as<Ordinal>(numProcs), as<Ordinal>(1));
232 
233  Array<Packet> myGlobalReducts(1);
234 
235  Teuchos::reduceAllAndScatter<Ordinal,Packet>(
236  *comm, Teuchos::REDUCE_SUM,
237  as<Ordinal>(sendBuffer.size()), &sendBuffer[0],
238  &recvCounts[0], &myGlobalReducts[0]
239  );
240 
241  const Packet expectedMyGlobalReduct = as<Packet>(
242  numProcs * procRank + ((numProcs - 1) * numProcs)/2
243  );
244 
245  if (std::numeric_limits<Packet>::is_integer) {
246  TEST_EQUALITY( myGlobalReducts[0], expectedMyGlobalReduct );
247  }
248  else {
249  const PacketMag local_errorTolSlack = static_cast<PacketMag>(errorTolSlack);
250  TEST_FLOATING_EQUALITY( myGlobalReducts[0], expectedMyGlobalReduct,
251  as<PacketMag>(defaultSmallNumber<PacketMag>() * local_errorTolSlack / numProcs)
252  );
253  }
254 
255 }
256 
257 
258 TEUCHOS_UNIT_TEST_TEMPLATE_2_DECL( DefaultMpiComm, ReadySend1, Ordinal, Packet )
259 {
260 
261  using Teuchos::broadcast;
262  using Teuchos::readySend;
263  using Teuchos::wait;
264  using Teuchos::as;
265  using Teuchos::rcpFromRef;
266  using Teuchos::outArg;
267  using Teuchos::isend;
268  using Teuchos::ireceive;
269  using Teuchos::wait;
270  using Teuchos::SerialComm;
271  using Teuchos::is_null;
272  using Teuchos::arcp;
273  using Teuchos::arcpClone;
274  using Teuchos::rcp_dynamic_cast;
275  using Teuchos::ArrayRCP;
276  using Teuchos::ptr;
278  typedef typename PT::magnitudeType PacketMag;
280 
281  RCP<const Comm<Ordinal> > comm = getDefaultComm<Ordinal>();
282  const Ordinal numProcs = size(*comm);
283  const Ordinal procRank = rank(*comm);
284 
285  if (
286  numProcs == 1
287  &&
288  !is_null(rcp_dynamic_cast<const SerialComm<Ordinal> >(comm))
289  )
290  {
291  out << "\nThis is Teuchos::SerialComm which does not support readySend!\n";
292  return; // Pass!
293  }
294 
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) );
299 
300  Packet sendData = origSendData;
301  Packet recvData = origRecvData;
302 
303  RCP<Teuchos::CommRequest<Ordinal> > recvRequest;
304 
305  // Post non-block receive on proc 0
306  if (procRank == 0) {
307  // Post non-blocking receive from proc n-1
308  recvRequest = ireceive<Ordinal, Packet>(
309  *comm,
310  rcp(&recvData,false),
311  numProcs-1
312  );
313  }
314  barrier(*comm);
315 
316  if (procRank == numProcs-1) {
317  // ready send from proc n-1 to proc 0
318  // send data in sendData
319  readySend<Ordinal, Packet>(
320  *comm,
321  sendData,
322  0
323  );
324  }
325  barrier(*comm);
326 
327  if (procRank == 0) {
328  // wait for request on 0
329  wait( *comm, outArg(recvRequest) );
330  }
331  barrier(*comm);
332 
333  // test that all procs have recvRequest == Teuchos::null
334  TEST_EQUALITY_CONST( recvRequest, Teuchos::null );
335 
336  // proc 0 should have recvData == sendData
337  if (procRank == 0) {
338  TEST_EQUALITY( recvData, sendData );
339  }
340  // other procs should have recvData == origRecvData (i.e., unchanged)
341  else {
342  TEST_EQUALITY( recvData, origRecvData );
343  }
344  // all procs should have sendData == origSendData
345  TEST_EQUALITY( sendData, origSendData );
346 
347  // All procs fail if any proc fails
348  int globalSuccess_int = -1;
349  reduceAll( *comm, Teuchos::REDUCE_SUM, success ? 0 : 1, outArg(globalSuccess_int) );
350  TEST_EQUALITY_CONST( globalSuccess_int, 0 );
351 }
352 
353 
354 TEUCHOS_UNIT_TEST_TEMPLATE_2_DECL( DefaultMpiComm, ReadySend, Ordinal, Packet )
355 {
356 
357  using Teuchos::broadcast;
358  using Teuchos::readySend;
359  using Teuchos::wait;
360  using Teuchos::as;
361  using Teuchos::rcpFromRef;
362  using Teuchos::outArg;
363  using Teuchos::isend;
364  using Teuchos::ireceive;
365  using Teuchos::wait;
366  using Teuchos::SerialComm;
367  using Teuchos::is_null;
368  using Teuchos::arcp;
369  using Teuchos::arcpClone;
370  using Teuchos::rcp_dynamic_cast;
371  using Teuchos::ArrayRCP;
373  typedef typename PT::magnitudeType PacketMag;
375 
376  RCP<const Comm<Ordinal> > comm = getDefaultComm<Ordinal>();
377  const Ordinal numProcs = size(*comm);
378  const Ordinal procRank = rank(*comm);
379 
380  if (
381  numProcs == 1
382  &&
383  !is_null(rcp_dynamic_cast<const SerialComm<Ordinal> >(comm))
384  )
385  {
386  out << "\nThis is Teuchos::SerialComm which does not support readySend!\n";
387  return; // Pass!
388  }
389 
390  const int dataLen = 3;
391 
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();
398  }
399  broadcast<Ordinal, Packet>( *comm, 0, origSendData() );
400 
401  const ArrayRCP<Packet> sendData = arcpClone<Packet>(origSendData());
402  const ArrayRCP<Packet> recvData = arcpClone<Packet>(origRecvData());
403 
404  RCP<Teuchos::CommRequest<Ordinal> > recvRequest;
405 
406  // both proc 0 and proc n-1 will post non-block receives, into recvData
407  // then proc 0 will initiate a ready-send to proc n-1; the latter will initiate a wait
408  // a barrier
409  // then proc n-1 will initiate a ready-send to proc 0 of the data from recvData; the latter will initiate a wait
410  // a barrier
411  // now both of these procs should have matching data in sendData and recvData
412 
413  // Post non-block receive on both procs
414  if (procRank == 0) {
415  // Post non-blocking receive from proc n-1
416  recvRequest = ireceive<Ordinal, Packet>(
417  *comm,
418  recvData.persistingView(0, dataLen),
419  numProcs-1
420  );
421  }
422  else if (procRank == numProcs-1) {
423  // Post non-blocking receive from proc 0
424  recvRequest = ireceive<Ordinal, Packet>(
425  *comm,
426  recvData.persistingView(0, dataLen),
427  0
428  );
429  }
430  barrier(*comm);
431 
432  if (procRank == 0) {
433  // ready send from proc 0 to proc n-1
434  // send data in sendData
435  readySend<Ordinal, Packet>(
436  *comm,
437  sendData(),
438  numProcs-1
439  );
440  }
441  else if (procRank == numProcs-1) {
442  // wait for request on proc n-1
443  wait( *comm, outArg(recvRequest) );
444  }
445  barrier(*comm);
446 
447  if (procRank == 0) {
448  // wait for request on 0
449  wait( *comm, outArg(recvRequest) );
450  }
451  else if (procRank == numProcs-1) {
452  // ready send from proc n-1 to proc 0
453  // send data in recvData: THIS IS IMPORTANT: SEE ABOVE
454  readySend<Ordinal, Packet>(
455  *comm,
456  recvData(),
457  0
458  );
459  }
460  barrier(*comm);
461 
462  // test that all procs (even non-participating) have recvRequest == Teuchos::null
463  TEST_EQUALITY_CONST( recvRequest, Teuchos::null );
464 
465  // participating procs should have recvData == sendData
466  if (procRank == 0 || procRank == numProcs-1) {
467  TEST_COMPARE_ARRAYS( recvData, sendData );
468  }
469  // non-participating procs should have recvData == origRecvData (i.e., unchanged)
470  else {
471  TEST_COMPARE_ARRAYS( recvData, origRecvData );
472  }
473  // all procs should have sendData == origSendData
474  TEST_COMPARE_ARRAYS( sendData, origSendData );
475 
476  // All procs fail if any proc fails
477  int globalSuccess_int = -1;
478  reduceAll( *comm, Teuchos::REDUCE_SUM, success ? 0 : 1, outArg(globalSuccess_int) );
479  TEST_EQUALITY_CONST( globalSuccess_int, 0 );
480 }
481 
482 
483 TEUCHOS_UNIT_TEST_TEMPLATE_2_DECL( DefaultMpiComm, NonblockingSendReceive, Ordinal, Packet )
484 {
485  using Teuchos::as;
486  using Teuchos::rcpFromRef;
487  using Teuchos::outArg;
488  using Teuchos::isend;
489  using Teuchos::ireceive;
490  using Teuchos::wait;
491  using Teuchos::SerialComm;
492  using Teuchos::rcp_dynamic_cast;
493  using std::endl;
495  typedef typename PT::magnitudeType PacketMag;
497 
498  RCP<const Comm<Ordinal> > comm = getDefaultComm<Ordinal>();
499  const Ordinal numProcs = size(*comm);
500  const Ordinal procRank = rank(*comm);
501 
502  if (
503  numProcs == 1
504  &&
505  !is_null(rcp_dynamic_cast<const SerialComm<Ordinal> >(comm))
506  )
507  {
508  out << "\nThis is Teuchos::SerialComm which does not yet support isend/ireceive!\n";
509  return; // Pass!
510  }
511 
512  // Only use randomize on one proc and then broacast
513  Packet orig_input_data = PT::random();
514  broadcast( *comm, 0, &orig_input_data );
515 
516  const Packet orig_output_data = as<Packet>(-1);
517 
518  const Packet input_data = orig_input_data;
519  Packet output_data = orig_output_data;
520 
521  RCP<Teuchos::CommRequest<Ordinal> > recvRequest;
522  RCP<Teuchos::CommRequest<Ordinal> > sendRequest;
523 
524  out << "Exchanging messages" << endl;
525 
526  if (procRank == 0) {
527  // Create copy of data to make sure that persisting relationship is
528  // maintained!
529  sendRequest = isend<Ordinal, Packet>(
530  *comm, Teuchos::rcp(new Packet(input_data)), numProcs-1);
531  }
532  if (procRank == numProcs-1) {
533  // We will need to read output_data after wait(...) below
534  recvRequest = ireceive<Ordinal, Packet>(
535  *comm, rcpFromRef(output_data), 0);
536  }
537 
538  out << "Waiting for messages" << endl;
539 
540  if (procRank == 0) {
541  wait( *comm, outArg(sendRequest) );
542  }
543  if (procRank == numProcs-1) {
544  wait( *comm, outArg(recvRequest) );
545  }
546 
547  TEST_EQUALITY_CONST( sendRequest, Teuchos::null );
548  TEST_EQUALITY_CONST( recvRequest, Teuchos::null );
549 
550  out << "Testing message correctness" << endl;
551 
552  if (procRank == numProcs-1) {
553  TEST_EQUALITY( output_data, input_data );
554  }
555  else {
556  TEST_EQUALITY( output_data, orig_output_data );
557  }
558  TEST_EQUALITY( input_data, orig_input_data );
559 
560  // All procs fail if any proc fails
561  int globalSuccess_int = -1;
562  reduceAll( *comm, Teuchos::REDUCE_SUM, success ? 0 : 1, outArg(globalSuccess_int) );
563  TEST_EQUALITY_CONST( globalSuccess_int, 0 );
564 }
565 
566 
567 TEUCHOS_UNIT_TEST_TEMPLATE_2_DECL( DefaultMpiComm, NonblockingSendReceiveSet, Ordinal, Packet )
568 {
569  using Teuchos::as;
570  using Teuchos::rcpFromRef;
571  using Teuchos::outArg;
572  using Teuchos::arcp;
573  using Teuchos::arcpClone;
574  using Teuchos::ArrayRCP;
575  using Teuchos::isend;
576  using Teuchos::ireceive;
577  using Teuchos::wait;
578  using Teuchos::broadcast;
579  using Teuchos::SerialComm;
580  using Teuchos::rcp_dynamic_cast;
581  using std::cerr;
582  using std::endl;
584  typedef typename PT::magnitudeType PacketMag;
586 
587  RCP<const Comm<Ordinal> > comm = getDefaultComm<Ordinal>();
588  const Ordinal numProcs = size(*comm);
589  const Ordinal procRank = rank(*comm);
590 
591  if (
592  numProcs == 1
593  &&
594  !is_null(rcp_dynamic_cast<const SerialComm<Ordinal> >(comm))
595  )
596  {
597  out << "\nThis is Teuchos::SerialComm which does not yet support isend/ireceive!\n";
598  return; // Pass!
599  }
600 
601  const int numSendRecv = 4;
602  const int sendLen = 3;
603 
604  cerr << "Creating data" << endl;
605 
606  const ArrayRCP<Packet> origInputData = arcp<Packet>(numSendRecv*sendLen);
607  const ArrayRCP<Packet> origOutputData = arcp<Packet>(numSendRecv*sendLen);
608  {
609  int offset = 0;
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();
618  }
619  }
620  }
621  cerr << "Broadcasting data" << endl;
622  broadcast<Ordinal, Packet>( *comm, 0, origInputData() );
623 
624  const ArrayRCP<Packet> inputData = arcpClone<Packet>(origInputData());
625  const ArrayRCP<Packet> outputData = arcpClone<Packet>(origOutputData());
626 
627  Array<RCP<Teuchos::CommRequest<Ordinal> > > recvRequests;
628  Array<RCP<Teuchos::CommRequest<Ordinal> > > sendRequests;
629 
630  cerr << "Exchanging data" << endl;
631 
632  // Send from proc 0 to proc numProcs-1
633  if (procRank == 0) {
634  // Create copy of data to make sure that persisting relationship is
635  // maintained!
636  int offset = 0;
637  for (int i = 0; i < numSendRecv; ++i, offset += sendLen) {
638  sendRequests.push_back(
639  isend<Ordinal, Packet>(
640  *comm,
641  arcpClone<Packet>(inputData(offset, sendLen)),
642  numProcs-1
643  )
644  );
645  }
646  }
647 
648  // Receive from proc 0 on proc numProcs-1
649  if (procRank == numProcs-1) {
650  // We will need to read output_data after wait(...) below
651  int offset = 0;
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
656  )
657  );
658  }
659  }
660 
661  cerr << "Waiting on messages" << endl;
662 
663  if (procRank == 0) {
664  waitAll( *comm, sendRequests() );
665  }
666  if (procRank == numProcs-1) {
667  waitAll( *comm, recvRequests() );
668  }
669 
670  cerr << "Testing received data" << endl;
671 
672  if (!sendRequests.empty()) {
673  for (int i = 0; i < numSendRecv; ++i) {
674  TEST_EQUALITY_CONST( sendRequests[i], Teuchos::null );
675  }
676  }
677 
678  if (!recvRequests.empty()) {
679  for (int i = 0; i < numSendRecv; ++i) {
680  TEST_EQUALITY_CONST( recvRequests[i], Teuchos::null );
681  }
682  }
683  // ToDo: Write a test macro for this in one shot!
684 
685  if (procRank == numProcs-1) {
686  TEST_COMPARE_ARRAYS( outputData, inputData );
687  }
688  else {
689  TEST_COMPARE_ARRAYS( outputData, origOutputData );
690  }
691  TEST_COMPARE_ARRAYS( inputData, origInputData );
692 
693  // All procs fail if any proc fails
694  int globalSuccess_int = -1;
695  reduceAll( *comm, Teuchos::REDUCE_SUM, success ? 0 : 1, outArg(globalSuccess_int) );
696  TEST_EQUALITY_CONST( globalSuccess_int, 0 );
697 
698 }
699 
700 TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL(DefaultMpiComm, duplicate, Ordinal)
701 {
702  RCP< const Comm<Ordinal> > comm = getDefaultComm<Ordinal>();
703  int initialRank = comm->getRank();
704  int initialSize = comm->getSize();
705 
706  RCP< const Comm<Ordinal> > newComm = comm->duplicate();
707  TEST_EQUALITY(newComm->getSize(), initialSize);
708  TEST_EQUALITY(newComm->getRank(), initialRank);
709 
710  // TODO Make sure the communication space is distinct.
711 }
712 
713 TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL(DefaultMpiComm, split, Ordinal) {
714  RCP< const Comm<Ordinal> > comm = getDefaultComm<Ordinal>();
715  int initialRank = comm->getRank();
716  int initialSize = comm->getSize();
717 
718  // Partition this communicator into two: one with the odd ranks and one with
719  // the even ones. Pass a common key for everyone to maintain the same
720  // ordering as in the initial communicator.
721  RCP< const Comm<Ordinal> > newComm = comm->split(initialRank % 2, 0);
722 
723  // Check the size of the new communicator and my rank within it.
724  int halfSize = initialSize / 2;
725  int newSize = newComm->getSize();
726  int newRank = newComm->getRank();
727  if (initialSize % 2 == 0) {
728  TEST_EQUALITY(newSize, halfSize);
729  }
730  else {
731  TEST_EQUALITY(newSize, initialRank % 2 == 0 ? halfSize + 1 : halfSize);
732  }
733  TEST_EQUALITY(newRank, initialRank / 2);
734 
735  // Negative color values get a null communicator.
736  RCP< const Comm<Ordinal> > shouldBeNull = comm->split(-1, 0);
737  TEST_ASSERT(shouldBeNull.is_null());
738 }
739 
740 
741 namespace {
742 
743 
744 template<typename ValueType>
745 class MonotoneSequence
746 {
747  ValueType currentValue_;
748 public:
749  typedef ValueType value_type;
750 
751  MonotoneSequence(const value_type& initialValue) : currentValue_(initialValue)
752  {}
753 
754  value_type operator()()
755  {
756  return currentValue_++;
757  }
758 };
759 
760 
761 } // namepsace
762 
763 
764 TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL(DefaultMpiComm, createSubcommunicator, Ordinal) {
765  RCP< const Comm<Ordinal> > comm = getDefaultComm<Ordinal>();
766  int initialRank = comm->getRank();
767  int initialSize = comm->getSize();
768 
769  // Create a new communicator that reverses all of the ranks.
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);
774  TEST_EQUALITY(newComm->getSize(), initialSize);
775  int expectedNewRank = initialSize - initialRank - 1;
776  TEST_EQUALITY(newComm->getRank(), expectedNewRank);
777 
778  // Processes that aren't in the group get a null communicator.
779  std::vector<int> rank0Only(1, 0);
780  RCP< const Comm<Ordinal> > rank0Comm = comm->createSubcommunicator(rank0Only);
781  // Original rank 0 should be valid, all others should be null.
782  if (initialRank == 0) {
783  TEST_ASSERT(rank0Comm.is_valid_ptr());
784  } else {
785  TEST_ASSERT(rank0Comm.is_null());
786  }
787 }
788 
789 
790 #ifdef HAVE_TEUCHOS_MPI
791 
792 
793 TEUCHOS_UNIT_TEST(DefaultMpiComm, TagConsistency )
794 {
795  using Teuchos::tuple; using Teuchos::inoutArg;
796 
797  const Teuchos::RCP<const Teuchos::Comm<int> > defaultComm =
799  const int comm_size = defaultComm->getSize();
800  const int comm_rank = defaultComm->getRank();
801 
802  // Must have at least two processes to run this test!
803  if (comm_size < 2) {
804  return;
805  }
806 
807  // Create a subcomm that contains just two processes
808  const Teuchos::RCP<const Teuchos::Comm<int> > masterComm =
809  defaultComm->createSubcommunicator(tuple<int>(0, 1)());
810 
811  if (comm_rank <= 1) {
812 
813  const int masterComm_size = masterComm->getSize();
814  (void) masterComm_size; // Forestall "unused variable" warning.
815  const int masterComm_rank = masterComm->getRank();
816 
817  // Split the main communicator into 2 overlapping groups
819  masterComm->createSubcommunicator(tuple<int>(0, 1)());
821  masterComm->createSubcommunicator(tuple<int>(0)());
822 
823  // Create another communicator.
825  masterComm->createSubcommunicator(tuple<int>(0, 1)());
826 
827  // Get my mpi tag for comm 3.
828  int my_tag = Teuchos::rcp_dynamic_cast<const Teuchos::MpiComm<int> >(
829  comm_3 )->getTag();
830 
831  // Collect the tags for comm 3.
832  int tag1 = 0;
833  if (masterComm_rank == 0) { tag1 = my_tag; }
834  masterComm->barrier();
835  Teuchos::broadcast( *masterComm, 0, inoutArg(tag1) );
836 
837  int tag2 = 0;
838  if (masterComm_rank == 1) { tag2 = my_tag; }
839  masterComm->barrier();
840  Teuchos::broadcast( *masterComm, 1, inoutArg(tag2) );
841 
842  // This currently fails.
843  TEST_EQUALITY( tag1, tag2 );
844 
845  }
846 
847 }
848 
849 
850 #endif // HAVE_TEUCHOS_MPI
851 
852 
853 //
854 // Instantiations
855 //
856 
857 
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)
865 #else
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)
868 #endif
869 
870 
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 )
878 
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)
883 #else
884 # define UNIT_TEST_GROUP_ORDINAL_QD(ORDINAL)
885 #endif
886 
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 )
892 
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 )
897 
898 
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;
903 
904 
905 // Uncomment this for really fast development cycles but make sure to comment
906 // it back again before checking in so that we can test all the types.
907 // #define FAST_DEVELOPMENT_UNIT_TEST_BUILD
908 
909 
910 #ifdef FAST_DEVELOPMENT_UNIT_TEST_BUILD
911 
912 # define UNIT_TEST_GROUP_ORDINAL( ORDINAL ) \
913  UNIT_TEST_GROUP_ORDINAL_PACKET(ORDINAL, double) \
914  UNIT_TEST_GROUP_ORDINAL_PAIROFPACKETS(ORDINAL, PairOfDoubles) \
915 
917 
918 #else // FAST_DEVELOPMENT_UNIT_TEST_BUILD
919 
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)
937 
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)
959 
960  typedef short int ShortInt;
961  UNIT_TEST_GROUP_ORDINAL(ShortInt)
963  typedef long int LongInt;
964  UNIT_TEST_GROUP_ORDINAL(LongInt) // can't do QD with LongInt, one of the tests complains
965 
966 # ifdef HAVE_TEUCHOS_LONG_LONG_INT
967  typedef long long int LongLongInt;
968  UNIT_TEST_GROUP_ORDINAL(LongLongInt)
969 # endif
970 
971 #endif // FAST_DEVELOPMENT_UNIT_TEST_BUILD
972 
973 
974 } // namespace
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 const bool isComparable
Determines if scalar type supports relational operators such as &lt;, &gt;, &lt;=, &gt;=.
#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.
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.
void waitAll(const Comm< Ordinal > &comm, const ArrayView< RCP< CommRequest< Ordinal > > > &requests)
Wait for an array of Teuchos::CommRequest objects.
#define UNIT_TEST_GROUP_ORDINAL(ORDINAL)
Unit testing support.
#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.
Definition: Teuchos_as.hpp:179
TypeTo as(const TypeFrom &t)
Convert from one value type to another.
Definition: Teuchos_as.hpp:287
#define TEST_FLOATING_EQUALITY(v1, v2, tol)
Assert the relative floating-point equality of rel_error(v1,v2) &lt;= 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....
std::pair< typename PST::magnitudeType, typename PST::magnitudeType > magnitudeType
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 const bool isComplex
Determines if scalar type is std::complex.
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.
TEUCHOS_STATIC_SETUP()
Reference-counted smart pointer for managing arrays.
Memory-safe templated array class that encapsulates std::vector.