libMesh
Public Member Functions | Private Attributes | List of all members
ParallelTest Class Reference
Inheritance diagram for ParallelTest:
[legend]

Public Member Functions

 LIBMESH_CPPUNIT_TEST_SUITE (ParallelTest)
 
 CPPUNIT_TEST (testGather)
 
 CPPUNIT_TEST (testAllGather)
 
 CPPUNIT_TEST (testGatherString)
 
 CPPUNIT_TEST (testAllGatherString)
 
 CPPUNIT_TEST (testAllGatherVectorString)
 
 CPPUNIT_TEST (testAllGatherEmptyVectorString)
 
 CPPUNIT_TEST (testAllGatherHalfEmptyVectorString)
 
 CPPUNIT_TEST (testBroadcast)
 
 CPPUNIT_TEST (testBroadcastNestedType)
 
 CPPUNIT_TEST (testScatter)
 
 CPPUNIT_TEST (testBarrier)
 
 CPPUNIT_TEST (testMin)
 
 CPPUNIT_TEST (testMax)
 
 CPPUNIT_TEST (testMinloc)
 
 CPPUNIT_TEST (testMaxloc)
 
 CPPUNIT_TEST (testMinlocReal)
 
 CPPUNIT_TEST (testMaxlocReal)
 
 CPPUNIT_TEST (testInfinityMin)
 
 CPPUNIT_TEST (testInfinityMax)
 
 CPPUNIT_TEST (testIsendRecv)
 
 CPPUNIT_TEST (testIrecvSend)
 
 CPPUNIT_TEST (testRecvIsendSets)
 
 CPPUNIT_TEST (testRecvIsendVecVecs)
 
 CPPUNIT_TEST (testSendRecvVecVecs)
 
 CPPUNIT_TEST (testSemiVerify)
 
 CPPUNIT_TEST (testSplit)
 
 CPPUNIT_TEST_SUITE_END ()
 
void setUp ()
 
void tearDown ()
 
void testGather ()
 
void testGatherString ()
 
void testAllGather ()
 
void testAllGatherString ()
 
void testAllGatherVectorString ()
 
void testAllGatherEmptyVectorString ()
 
void testAllGatherHalfEmptyVectorString ()
 
void testBroadcast ()
 
void testBroadcastNestedType ()
 
void testScatter ()
 
void testBarrier ()
 
void testMin ()
 
void testMax ()
 
void testMinloc ()
 
void testMaxloc ()
 
void testMinlocReal ()
 
void testMaxlocReal ()
 
void testInfinityMin ()
 
void testInfinityMax ()
 
void testIsendRecv ()
 
void testIrecvSend ()
 
void testRecvIsendSets ()
 
void testRecvIsendVecVecs ()
 
void testSendRecvVecVecs ()
 
void testSemiVerify ()
 
void testSplit ()
 
void testSplitByType ()
 

Private Attributes

std::vector< std::string > _number
 

Detailed Description

Definition at line 9 of file parallel_test.C.

Member Function Documentation

◆ CPPUNIT_TEST() [1/26]

ParallelTest::CPPUNIT_TEST ( testGather  )

◆ CPPUNIT_TEST() [2/26]

ParallelTest::CPPUNIT_TEST ( testAllGather  )

◆ CPPUNIT_TEST() [3/26]

ParallelTest::CPPUNIT_TEST ( testGatherString  )

◆ CPPUNIT_TEST() [4/26]

ParallelTest::CPPUNIT_TEST ( testAllGatherString  )

◆ CPPUNIT_TEST() [5/26]

ParallelTest::CPPUNIT_TEST ( testAllGatherVectorString  )

◆ CPPUNIT_TEST() [6/26]

ParallelTest::CPPUNIT_TEST ( testAllGatherEmptyVectorString  )

◆ CPPUNIT_TEST() [7/26]

ParallelTest::CPPUNIT_TEST ( testAllGatherHalfEmptyVectorString  )

◆ CPPUNIT_TEST() [8/26]

ParallelTest::CPPUNIT_TEST ( testBroadcast  )

◆ CPPUNIT_TEST() [9/26]

ParallelTest::CPPUNIT_TEST ( testBroadcastNestedType  )

◆ CPPUNIT_TEST() [10/26]

ParallelTest::CPPUNIT_TEST ( testScatter  )

◆ CPPUNIT_TEST() [11/26]

ParallelTest::CPPUNIT_TEST ( testBarrier  )

◆ CPPUNIT_TEST() [12/26]

ParallelTest::CPPUNIT_TEST ( testMin  )

◆ CPPUNIT_TEST() [13/26]

ParallelTest::CPPUNIT_TEST ( testMax  )

◆ CPPUNIT_TEST() [14/26]

ParallelTest::CPPUNIT_TEST ( testMinloc  )

◆ CPPUNIT_TEST() [15/26]

ParallelTest::CPPUNIT_TEST ( testMaxloc  )

◆ CPPUNIT_TEST() [16/26]

ParallelTest::CPPUNIT_TEST ( testMinlocReal  )

◆ CPPUNIT_TEST() [17/26]

ParallelTest::CPPUNIT_TEST ( testMaxlocReal  )

◆ CPPUNIT_TEST() [18/26]

ParallelTest::CPPUNIT_TEST ( testInfinityMin  )

◆ CPPUNIT_TEST() [19/26]

ParallelTest::CPPUNIT_TEST ( testInfinityMax  )

◆ CPPUNIT_TEST() [20/26]

ParallelTest::CPPUNIT_TEST ( testIsendRecv  )

◆ CPPUNIT_TEST() [21/26]

ParallelTest::CPPUNIT_TEST ( testIrecvSend  )

◆ CPPUNIT_TEST() [22/26]

ParallelTest::CPPUNIT_TEST ( testRecvIsendSets  )

◆ CPPUNIT_TEST() [23/26]

ParallelTest::CPPUNIT_TEST ( testRecvIsendVecVecs  )

◆ CPPUNIT_TEST() [24/26]

ParallelTest::CPPUNIT_TEST ( testSendRecvVecVecs  )

◆ CPPUNIT_TEST() [25/26]

ParallelTest::CPPUNIT_TEST ( testSemiVerify  )

◆ CPPUNIT_TEST() [26/26]

ParallelTest::CPPUNIT_TEST ( testSplit  )

◆ CPPUNIT_TEST_SUITE_END()

ParallelTest::CPPUNIT_TEST_SUITE_END ( )

◆ LIBMESH_CPPUNIT_TEST_SUITE()

ParallelTest::LIBMESH_CPPUNIT_TEST_SUITE ( ParallelTest  )

◆ setUp()

void ParallelTest::setUp ( )
inline

Definition at line 46 of file parallel_test.C.

47  {
48  _number.resize(10);
49  _number[0] = "Zero";
50  _number[1] = "One";
51  _number[2] = "Two";
52  _number[3] = "Three";
53  _number[4] = "Four";
54  _number[5] = "Five";
55  _number[6] = "Six";
56  _number[7] = "Seven";
57  _number[8] = "Eight";
58  _number[9] = "Nine";
59  }
std::vector< std::string > _number
Definition: parallel_test.C:43

◆ tearDown()

void ParallelTest::tearDown ( )
inline

Definition at line 61 of file parallel_test.C.

62  {}

◆ testAllGather()

void ParallelTest::testAllGather ( )
inline

Definition at line 94 of file parallel_test.C.

References TIMPI::Communicator::allgather(), TIMPI::Communicator::rank(), and TestCommWorld.

95  {
96  LOG_UNIT_TEST;
97 
98  std::vector<processor_id_type> vals;
99  TestCommWorld->allgather(cast_int<processor_id_type>(TestCommWorld->rank()),vals);
100 
101  for (processor_id_type i=0; i<vals.size(); i++)
102  CPPUNIT_ASSERT_EQUAL( i , vals[i] );
103  }
void allgather(const T &send_data, std::vector< T, A > &recv_data) const
libMesh::Parallel::Communicator * TestCommWorld
Definition: driver.C:159
processor_id_type rank() const
uint8_t processor_id_type

◆ testAllGatherEmptyVectorString()

void ParallelTest::testAllGatherEmptyVectorString ( )
inline

Definition at line 138 of file parallel_test.C.

References TIMPI::Communicator::allgather(), and TestCommWorld.

139  {
140  LOG_UNIT_TEST;
141 
142  std::vector<std::string> vals;
143  TestCommWorld->allgather(vals);
144 
145  CPPUNIT_ASSERT( vals.empty() );
146  }
void allgather(const T &send_data, std::vector< T, A > &recv_data) const
libMesh::Parallel::Communicator * TestCommWorld
Definition: driver.C:159

◆ testAllGatherHalfEmptyVectorString()

void ParallelTest::testAllGatherHalfEmptyVectorString ( )
inline

Definition at line 150 of file parallel_test.C.

References TIMPI::Communicator::allgather(), TIMPI::Communicator::rank(), and TestCommWorld.

151  {
152  LOG_UNIT_TEST;
153 
154  std::vector<std::string> vals;
155 
156  if (!TestCommWorld->rank())
157  vals.push_back("Proc 0 only");
158 
159  TestCommWorld->allgather(vals);
160 
161  CPPUNIT_ASSERT_EQUAL( vals[0], std::string("Proc 0 only") );
162  }
void allgather(const T &send_data, std::vector< T, A > &recv_data) const
libMesh::Parallel::Communicator * TestCommWorld
Definition: driver.C:159
processor_id_type rank() const

◆ testAllGatherString()

void ParallelTest::testAllGatherString ( )
inline

Definition at line 107 of file parallel_test.C.

References TIMPI::Communicator::gather(), TIMPI::Communicator::rank(), and TestCommWorld.

108  {
109  LOG_UNIT_TEST;
110 
111  std::vector<std::string> vals;
112  TestCommWorld->gather(0, "Processor" + _number[TestCommWorld->rank() % 10], vals);
113 
114  for (processor_id_type i=0; i<vals.size(); i++)
115  CPPUNIT_ASSERT_EQUAL( "Processor" + _number[i % 10] , vals[i] );
116  }
libMesh::Parallel::Communicator * TestCommWorld
Definition: driver.C:159
void gather(const unsigned int root_id, const T &send_data, std::vector< T, A > &recv) const
processor_id_type rank() const
uint8_t processor_id_type
std::vector< std::string > _number
Definition: parallel_test.C:43

◆ testAllGatherVectorString()

void ParallelTest::testAllGatherVectorString ( )
inline

Definition at line 120 of file parallel_test.C.

References TIMPI::Communicator::allgather(), TIMPI::Communicator::rank(), and TestCommWorld.

121  {
122  LOG_UNIT_TEST;
123 
124  std::vector<std::string> vals;
125  vals.push_back("Processor" + _number[TestCommWorld->rank() % 10] + "A");
126  vals.push_back("Processor" + _number[TestCommWorld->rank() % 10] + "B");
127  TestCommWorld->allgather(vals);
128 
129  for (processor_id_type i=0; i<(vals.size()/2); i++)
130  {
131  CPPUNIT_ASSERT_EQUAL( "Processor" + _number[i % 10] + "A" , vals[2*i] );
132  CPPUNIT_ASSERT_EQUAL( "Processor" + _number[i % 10] + "B" , vals[2*i+1] );
133  }
134  }
void allgather(const T &send_data, std::vector< T, A > &recv_data) const
libMesh::Parallel::Communicator * TestCommWorld
Definition: driver.C:159
processor_id_type rank() const
uint8_t processor_id_type
std::vector< std::string > _number
Definition: parallel_test.C:43

◆ testBarrier()

void ParallelTest::testBarrier ( )
inline

Definition at line 321 of file parallel_test.C.

References TIMPI::Communicator::barrier(), and TestCommWorld.

322  {
323  LOG_UNIT_TEST;
324 
326  }
libMesh::Parallel::Communicator * TestCommWorld
Definition: driver.C:159
void barrier() const

◆ testBroadcast()

void ParallelTest::testBroadcast ( )
inline

Definition at line 166 of file parallel_test.C.

References TIMPI::Communicator::broadcast(), TIMPI::Communicator::rank(), and TestCommWorld.

167  {
168  LOG_UNIT_TEST;
169 
170  // Workaround for spurious warning from operator=
171  // https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100366
172  std::vector<unsigned int> src{0,1,2}, dest(3,0);
173 
174  if (TestCommWorld->rank() == 0)
175  dest = src;
176 
177  TestCommWorld->broadcast(dest);
178 
179  for (std::size_t i=0; i<3; i++)
180  CPPUNIT_ASSERT_EQUAL( src[i] , dest[i] );
181  }
libMesh::Parallel::Communicator * TestCommWorld
Definition: driver.C:159
processor_id_type rank() const
void broadcast(T &data, const unsigned int root_id=0, const bool identical_sizes=false) const

◆ testBroadcastNestedType()

void ParallelTest::testBroadcastNestedType ( )
inline

Definition at line 185 of file parallel_test.C.

References TIMPI::Communicator::broadcast(), TIMPI::Communicator::rank(), and TestCommWorld.

186  {
187  LOG_UNIT_TEST;
188 
189  using std::pair;
190  typedef pair<pair<pair<pair<int, int>, int>, int>, int> pppp;
191  std::vector<pppp> src(3), dest(3);
192 
193  src[0].first.first.first.first=0;
194  src[0].first.first.first.second=-1;
195  src[0].first.second = -2;
196  src[0].second = -3;
197  src[1].first.first.first.first=10;
198  src[1].first.first.first.second=9;
199  src[1].first.second = 8;
200  src[1].second = 7;
201  src[2].first.first.first.first=20;
202  src[2].first.first.first.second=19;
203  src[2].first.second = 18;
204  src[2].second = 17;
205 
206  if (TestCommWorld->rank() == 0)
207  dest = src;
208 
209  TestCommWorld->broadcast(dest);
210 
211  for (std::size_t i=0; i<src.size(); i++)
212  {
213  CPPUNIT_ASSERT_EQUAL(src[i].first.first.first.first,
214  dest[i].first.first.first.first);
215  CPPUNIT_ASSERT_EQUAL(src[i].first.first.first.second,
216  dest[i].first.first.first.second);
217  CPPUNIT_ASSERT_EQUAL(src[i].first.first.second,
218  dest[i].first.first.second);
219  CPPUNIT_ASSERT_EQUAL(src[i].first.second,
220  dest[i].first.second);
221  CPPUNIT_ASSERT_EQUAL(src[i].second,
222  dest[i].second);
223  }
224  }
libMesh::Parallel::Communicator * TestCommWorld
Definition: driver.C:159
processor_id_type rank() const
void broadcast(T &data, const unsigned int root_id=0, const bool identical_sizes=false) const

◆ testGather()

void ParallelTest::testGather ( )
inline

Definition at line 66 of file parallel_test.C.

References TIMPI::Communicator::gather(), TIMPI::Communicator::rank(), and TestCommWorld.

67  {
68  LOG_UNIT_TEST;
69 
70  std::vector<processor_id_type> vals;
71  TestCommWorld->gather(0,cast_int<processor_id_type>(TestCommWorld->rank()),vals);
72 
73  if (TestCommWorld->rank() == 0)
74  for (processor_id_type i=0; i<vals.size(); i++)
75  CPPUNIT_ASSERT_EQUAL( i , vals[i] );
76  }
libMesh::Parallel::Communicator * TestCommWorld
Definition: driver.C:159
void gather(const unsigned int root_id, const T &send_data, std::vector< T, A > &recv) const
processor_id_type rank() const
uint8_t processor_id_type

◆ testGatherString()

void ParallelTest::testGatherString ( )
inline

Definition at line 80 of file parallel_test.C.

References TIMPI::Communicator::gather(), TIMPI::Communicator::rank(), and TestCommWorld.

81  {
82  LOG_UNIT_TEST;
83 
84  std::vector<std::string> vals;
85  TestCommWorld->gather(0, "Processor" + _number[TestCommWorld->rank() % 10], vals);
86 
87  if (TestCommWorld->rank() == 0)
88  for (processor_id_type i=0; i<vals.size(); i++)
89  CPPUNIT_ASSERT_EQUAL( "Processor" + _number[i % 10] , vals[i] );
90  }
libMesh::Parallel::Communicator * TestCommWorld
Definition: driver.C:159
void gather(const unsigned int root_id, const T &send_data, std::vector< T, A > &recv) const
processor_id_type rank() const
uint8_t processor_id_type
std::vector< std::string > _number
Definition: parallel_test.C:43

◆ testInfinityMax()

void ParallelTest::testInfinityMax ( )
inline

Definition at line 438 of file parallel_test.C.

References TIMPI::Communicator::max(), and TestCommWorld.

439  {
440  LOG_UNIT_TEST;
441 
442  double max = std::numeric_limits<double>::infinity();
443 
444  TestCommWorld->max(max);
445 
446  CPPUNIT_ASSERT_EQUAL (max, std::numeric_limits<double>::infinity());
447 
448  max = -std::numeric_limits<double>::infinity();
449 
450  TestCommWorld->max(max);
451 
452  CPPUNIT_ASSERT_EQUAL (max, -std::numeric_limits<double>::infinity());
453  }
libMesh::Parallel::Communicator * TestCommWorld
Definition: driver.C:159
void max(const T &r, T &o, Request &req) const

◆ testInfinityMin()

void ParallelTest::testInfinityMin ( )
inline

Definition at line 419 of file parallel_test.C.

References TIMPI::Communicator::min(), and TestCommWorld.

420  {
421  LOG_UNIT_TEST;
422 
423  double min = std::numeric_limits<double>::infinity();
424 
425  TestCommWorld->min(min);
426 
427  CPPUNIT_ASSERT_EQUAL (min, std::numeric_limits<double>::infinity());
428 
429  min = -std::numeric_limits<double>::infinity();
430 
431  TestCommWorld->min(min);
432 
433  CPPUNIT_ASSERT_EQUAL (min, -std::numeric_limits<double>::infinity());
434  }
libMesh::Parallel::Communicator * TestCommWorld
Definition: driver.C:159
void min(const T &r, T &o, Request &req) const

◆ testIrecvSend()

void ParallelTest::testIrecvSend ( )
inline

Definition at line 520 of file parallel_test.C.

References TIMPI::Communicator::DEFAULT, TIMPI::Communicator::rank(), TIMPI::Communicator::receive(), TIMPI::Communicator::send(), TIMPI::Communicator::send_mode(), TIMPI::Communicator::size(), TIMPI::Communicator::SYNCHRONOUS, and TestCommWorld.

521  {
522  LOG_UNIT_TEST;
523 
524  unsigned int procup = (TestCommWorld->rank() + 1) %
525  TestCommWorld->size();
526  unsigned int procdown = (TestCommWorld->size() +
527  TestCommWorld->rank() - 1) %
528  TestCommWorld->size();
529 
530  std::vector<unsigned int> src_val(3), recv_val(3);
531 
532  src_val[0] = 0;
533  src_val[1] = 1;
534  src_val[2] = 2;
535 
536  Parallel::Request request;
537 
538  if (TestCommWorld->size() > 1)
539  {
540  // Default communication
541  TestCommWorld->send_mode(Parallel::Communicator::DEFAULT);
542 
543  TestCommWorld->receive (procdown,
544  recv_val,
545  request);
546 
547  TestCommWorld->send (procup,
548  src_val);
549 
550  Parallel::wait (request);
551 
552  CPPUNIT_ASSERT_EQUAL ( src_val.size() , recv_val.size() );
553 
554  for (std::size_t i=0; i<src_val.size(); i++)
555  CPPUNIT_ASSERT_EQUAL( src_val[i] , recv_val[i] );
556 
557  // Synchronous communication
558  TestCommWorld->send_mode(Parallel::Communicator::SYNCHRONOUS);
559  std::fill (recv_val.begin(), recv_val.end(), 0);
560 
561 
562  TestCommWorld->receive (procdown,
563  recv_val,
564  request);
565 
566  TestCommWorld->send (procup,
567  src_val);
568 
569  Parallel::wait (request);
570 
571  CPPUNIT_ASSERT_EQUAL ( src_val.size() , recv_val.size() );
572 
573  for (std::size_t i=0; i<src_val.size(); i++)
574  CPPUNIT_ASSERT_EQUAL( src_val[i] , recv_val[i] );
575 
576  // Restore default communication
577  TestCommWorld->send_mode(Parallel::Communicator::DEFAULT);
578  }
579  }
MPI_Request request
void send_mode(const SendMode sm)
libMesh::Parallel::Communicator * TestCommWorld
Definition: driver.C:159
processor_id_type rank() const
processor_id_type size() const
Status receive(const unsigned int dest_processor_id, T &buf, const MessageTag &tag=any_tag) const
void send(const unsigned int dest_processor_id, const T &buf, const MessageTag &tag=no_tag) const

◆ testIsendRecv()

void ParallelTest::testIsendRecv ( )
inline

Definition at line 457 of file parallel_test.C.

References TIMPI::Communicator::DEFAULT, TIMPI::Communicator::rank(), TIMPI::Communicator::receive(), TIMPI::Communicator::send(), TIMPI::Communicator::send_mode(), TIMPI::Communicator::size(), TIMPI::Communicator::SYNCHRONOUS, and TestCommWorld.

458  {
459  LOG_UNIT_TEST;
460 
461  unsigned int procup = (TestCommWorld->rank() + 1) %
462  TestCommWorld->size();
463  unsigned int procdown = (TestCommWorld->size() +
464  TestCommWorld->rank() - 1) %
465  TestCommWorld->size();
466 
467  std::vector<unsigned int> src_val(3), recv_val(3);
468 
469  src_val[0] = 0;
470  src_val[1] = 1;
471  src_val[2] = 2;
472 
473  Parallel::Request request;
474 
475  if (TestCommWorld->size() > 1)
476  {
477  // Default communication
478  TestCommWorld->send_mode(Parallel::Communicator::DEFAULT);
479 
480  TestCommWorld->send (procup,
481  src_val,
482  request);
483 
484  TestCommWorld->receive (procdown,
485  recv_val);
486 
487  Parallel::wait (request);
488 
489  CPPUNIT_ASSERT_EQUAL ( src_val.size() , recv_val.size() );
490 
491  for (std::size_t i=0; i<src_val.size(); i++)
492  CPPUNIT_ASSERT_EQUAL( src_val[i] , recv_val[i] );
493 
494 
495  // Synchronous communication
496  TestCommWorld->send_mode(Parallel::Communicator::SYNCHRONOUS);
497  std::fill (recv_val.begin(), recv_val.end(), 0);
498 
499  TestCommWorld->send (procup,
500  src_val,
501  request);
502 
503  TestCommWorld->receive (procdown,
504  recv_val);
505 
506  Parallel::wait (request);
507 
508  CPPUNIT_ASSERT_EQUAL ( src_val.size() , recv_val.size() );
509 
510  for (std::size_t i=0; i<src_val.size(); i++)
511  CPPUNIT_ASSERT_EQUAL( src_val[i] , recv_val[i] );
512 
513  // Restore default communication
514  TestCommWorld->send_mode(Parallel::Communicator::DEFAULT);
515  }
516  }
MPI_Request request
void send_mode(const SendMode sm)
libMesh::Parallel::Communicator * TestCommWorld
Definition: driver.C:159
processor_id_type rank() const
processor_id_type size() const
Status receive(const unsigned int dest_processor_id, T &buf, const MessageTag &tag=any_tag) const
void send(const unsigned int dest_processor_id, const T &buf, const MessageTag &tag=no_tag) const

◆ testMax()

void ParallelTest::testMax ( )
inline

Definition at line 343 of file parallel_test.C.

References TIMPI::Communicator::max(), TIMPI::Communicator::rank(), TIMPI::Communicator::size(), and TestCommWorld.

344  {
345  LOG_UNIT_TEST;
346 
348 
349  TestCommWorld->max(max);
350 
351  CPPUNIT_ASSERT_EQUAL (cast_int<processor_id_type>(max+1),
352  cast_int<processor_id_type>(TestCommWorld->size()));
353  }
libMesh::Parallel::Communicator * TestCommWorld
Definition: driver.C:159
processor_id_type rank() const
processor_id_type size() const
uint8_t processor_id_type
void max(const T &r, T &o, Request &req) const

◆ testMaxloc()

void ParallelTest::testMaxloc ( )
inline

Definition at line 372 of file parallel_test.C.

References TIMPI::Communicator::maxloc(), TIMPI::Communicator::rank(), TIMPI::Communicator::size(), and TestCommWorld.

373  {
374  LOG_UNIT_TEST;
375 
376  int max = TestCommWorld->rank();
377  unsigned int maxid = 0;
378 
379  TestCommWorld->maxloc(max, maxid);
380 
381  CPPUNIT_ASSERT_EQUAL (max+1,
382  cast_int<int>(TestCommWorld->size()));
383  CPPUNIT_ASSERT_EQUAL (maxid, static_cast<unsigned int>(TestCommWorld->size()-1));
384  }
libMesh::Parallel::Communicator * TestCommWorld
Definition: driver.C:159
processor_id_type rank() const
processor_id_type size() const
void maxloc(T &r, unsigned int &max_id) const

◆ testMaxlocReal()

void ParallelTest::testMaxlocReal ( )
inline

Definition at line 403 of file parallel_test.C.

References TIMPI::Communicator::maxloc(), TIMPI::Communicator::rank(), libMesh::Real, TIMPI::Communicator::size(), and TestCommWorld.

404  {
405  LOG_UNIT_TEST;
406 
407  Real max = TestCommWorld->rank();
408  unsigned int maxid = 0;
409 
410  TestCommWorld->maxloc(max, maxid);
411 
412  // Hope nobody uses 1677216 procs with single precision
413  CPPUNIT_ASSERT_EQUAL (max+1, Real(TestCommWorld->size()));
414  CPPUNIT_ASSERT_EQUAL (maxid, static_cast<unsigned int>(TestCommWorld->size()-1));
415  }
libMesh::Parallel::Communicator * TestCommWorld
Definition: driver.C:159
processor_id_type rank() const
processor_id_type size() const
void maxloc(T &r, unsigned int &max_id) const
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real

◆ testMin()

void ParallelTest::testMin ( )
inline

Definition at line 330 of file parallel_test.C.

References TIMPI::Communicator::min(), TIMPI::Communicator::rank(), and TestCommWorld.

331  {
332  LOG_UNIT_TEST;
333 
334  unsigned int min = TestCommWorld->rank();
335 
336  TestCommWorld->min(min);
337 
338  CPPUNIT_ASSERT_EQUAL (min, static_cast<unsigned int>(0));
339  }
libMesh::Parallel::Communicator * TestCommWorld
Definition: driver.C:159
processor_id_type rank() const
void min(const T &r, T &o, Request &req) const

◆ testMinloc()

void ParallelTest::testMinloc ( )
inline

Definition at line 357 of file parallel_test.C.

References TIMPI::Communicator::minloc(), TIMPI::Communicator::rank(), TIMPI::Communicator::size(), and TestCommWorld.

358  {
359  LOG_UNIT_TEST;
360 
361  int min = (TestCommWorld->rank() + 1) % TestCommWorld->size();
362  unsigned int minid = 0;
363 
364  TestCommWorld->minloc(min, minid);
365 
366  CPPUNIT_ASSERT_EQUAL (min, static_cast<int>(0));
367  CPPUNIT_ASSERT_EQUAL (minid, static_cast<unsigned int>(TestCommWorld->size()-1));
368  }
void minloc(T &r, unsigned int &min_id) const
libMesh::Parallel::Communicator * TestCommWorld
Definition: driver.C:159
processor_id_type rank() const
processor_id_type size() const

◆ testMinlocReal()

void ParallelTest::testMinlocReal ( )
inline

Definition at line 388 of file parallel_test.C.

References TIMPI::Communicator::minloc(), TIMPI::Communicator::rank(), libMesh::Real, TIMPI::Communicator::size(), and TestCommWorld.

389  {
390  LOG_UNIT_TEST;
391 
392  Real min = (TestCommWorld->rank() + 1) % TestCommWorld->size();
393  unsigned int minid = 0;
394 
395  TestCommWorld->minloc(min, minid);
396 
397  CPPUNIT_ASSERT_EQUAL (min, Real(0));
398  CPPUNIT_ASSERT_EQUAL (minid, static_cast<unsigned int>(TestCommWorld->size()-1));
399  }
void minloc(T &r, unsigned int &min_id) const
libMesh::Parallel::Communicator * TestCommWorld
Definition: driver.C:159
processor_id_type rank() const
processor_id_type size() const
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real

◆ testRecvIsendSets()

void ParallelTest::testRecvIsendSets ( )
inline

Definition at line 582 of file parallel_test.C.

References TIMPI::Communicator::rank(), TIMPI::Communicator::receive(), TIMPI::Communicator::send(), TIMPI::Communicator::size(), and TestCommWorld.

583  {
584  LOG_UNIT_TEST;
585 
586  unsigned int procup = (TestCommWorld->rank() + 1) %
587  TestCommWorld->size();
588  unsigned int procdown = (TestCommWorld->size() +
589  TestCommWorld->rank() - 1) %
590  TestCommWorld->size();
591 
592  std::set<unsigned int> src_val, recv_val;
593 
594  src_val.insert(4); // Chosen by fair dice roll
595  src_val.insert(42);
596  src_val.insert(1337);
597 
598  Parallel::Request request;
599 
600  if (TestCommWorld->size() > 1)
601  {
602  TestCommWorld->send (procup, src_val, request);
603 
604  TestCommWorld->receive (procdown,
605  recv_val);
606 
607  CPPUNIT_ASSERT_EQUAL ( src_val.size() , recv_val.size() );
608 
609  for (std::set<unsigned int>::const_iterator
610  it = src_val.begin(), end = src_val.end(); it != end;
611  ++it)
612  CPPUNIT_ASSERT ( recv_val.count(*it) );
613 
614  Parallel::wait (request);
615 
616  recv_val.clear();
617  }
618  }
MPI_Request request
libMesh::Parallel::Communicator * TestCommWorld
Definition: driver.C:159
processor_id_type rank() const
processor_id_type size() const
Status receive(const unsigned int dest_processor_id, T &buf, const MessageTag &tag=any_tag) const
void send(const unsigned int dest_processor_id, const T &buf, const MessageTag &tag=no_tag) const

◆ testRecvIsendVecVecs()

void ParallelTest::testRecvIsendVecVecs ( )
inline

Definition at line 622 of file parallel_test.C.

References TIMPI::Communicator::rank(), TIMPI::Communicator::receive(), TIMPI::Communicator::send(), TIMPI::Communicator::size(), and TestCommWorld.

623  {
624  LOG_UNIT_TEST;
625 
626  unsigned int procup = (TestCommWorld->rank() + 1) %
627  TestCommWorld->size();
628  unsigned int procdown = (TestCommWorld->size() +
629  TestCommWorld->rank() - 1) %
630  TestCommWorld->size();
631 
632  std::vector<std::vector<unsigned int> > src_val(3), recv_val;
633 
634  src_val[0].push_back(4); // Chosen by fair dice roll
635  src_val[2].push_back(procup);
636  src_val[2].push_back(TestCommWorld->rank());
637 
638  Parallel::Request request;
639 
640  if (TestCommWorld->size() > 1)
641  {
642  TestCommWorld->send (procup, src_val, request);
643 
644  TestCommWorld->receive (procdown,
645  recv_val);
646 
647  CPPUNIT_ASSERT_EQUAL ( src_val.size() , recv_val.size() );
648 
649  for (std::size_t i = 0; i != 3; ++i)
650  CPPUNIT_ASSERT_EQUAL ( src_val[i].size(), recv_val[i].size() );
651 
652  CPPUNIT_ASSERT_EQUAL ( recv_val[0][0], static_cast<unsigned int> (4) );
653  CPPUNIT_ASSERT_EQUAL ( recv_val[2][0], static_cast<unsigned int> (TestCommWorld->rank()) );
654  CPPUNIT_ASSERT_EQUAL ( recv_val[2][1], procdown );
655 
656  Parallel::wait (request);
657 
658  recv_val.clear();
659  }
660  }
MPI_Request request
libMesh::Parallel::Communicator * TestCommWorld
Definition: driver.C:159
processor_id_type rank() const
processor_id_type size() const
Status receive(const unsigned int dest_processor_id, T &buf, const MessageTag &tag=any_tag) const
void send(const unsigned int dest_processor_id, const T &buf, const MessageTag &tag=no_tag) const

◆ testScatter()

void ParallelTest::testScatter ( )
inline

Definition at line 228 of file parallel_test.C.

References TIMPI::Communicator::rank(), TIMPI::Communicator::scatter(), TIMPI::Communicator::size(), and TestCommWorld.

229  {
230  LOG_UNIT_TEST;
231 
232  // Test Scalar scatter
233  {
234  std::vector<processor_id_type> src;
235  processor_id_type dest;
236 
237  if (TestCommWorld->rank() == 0)
238  {
239  src.resize(TestCommWorld->size());
240  for (processor_id_type i=0; i<src.size(); i++)
241  src[i] = i;
242  }
243 
244  TestCommWorld->scatter(src, dest);
245 
246  CPPUNIT_ASSERT_EQUAL( TestCommWorld->rank(), dest );
247  }
248 
249  // Test Vector Scatter (equal-sized chunks)
250  {
251  std::vector<unsigned int> src;
252  std::vector<unsigned int> dest;
253  static const unsigned int CHUNK_SIZE = 3;
254 
255  if (TestCommWorld->rank() == 0)
256  {
257  src.resize(TestCommWorld->size() * CHUNK_SIZE);
258  for (std::size_t i=0; i<src.size(); i++)
259  src[i] = i;
260  }
261 
262  TestCommWorld->scatter(src, dest);
263 
264  for (unsigned int i=0; i<CHUNK_SIZE; i++)
265  CPPUNIT_ASSERT_EQUAL( TestCommWorld->rank() * CHUNK_SIZE + i, dest[i] );
266  }
267 
268  // Test Vector Scatter (jagged chunks)
269  {
270  std::vector<unsigned int> src;
271  std::vector<unsigned int> dest;
272  std::vector<int> counts;
273 
274  if (TestCommWorld->rank() == 0)
275  {
276  // Give each processor "rank" number of items ( Sum i=1..n == (n * (n + 1))/2 )
277  src.resize((TestCommWorld->size() * (TestCommWorld->size() + 1)) / 2);
278  counts.resize(TestCommWorld->size());
279 
280  for (std::size_t i=0; i<src.size(); i++)
281  src[i] = i;
282  for (unsigned int i=0; i<TestCommWorld->size(); i++)
283  counts[i] = static_cast<int>(i+1);
284  }
285 
286  TestCommWorld->scatter(src, counts, dest);
287 
288  unsigned int start_value = (TestCommWorld->rank() * (TestCommWorld->rank() + 1)) / 2;
289  for (unsigned int i=0; i<=TestCommWorld->rank(); i++)
290  CPPUNIT_ASSERT_EQUAL( start_value + i, dest[i] );
291  }
292 
293  // Test Vector of Vector Scatter
294  {
295  std::vector<std::vector<unsigned int>> src;
296  std::vector<unsigned int> dest;
297 
298  if (TestCommWorld->rank() == 0)
299  {
300  // Give each processor "rank" number of items ( Sum i=1..n == (n * (n + 1))/2 )
301  src.resize(TestCommWorld->size());
302  for (std::size_t i=0; i<src.size(); ++i)
303  src[i].resize(i+1);
304 
305  unsigned int global_counter = 0;
306  for (std::size_t i=0; i<src.size(); i++)
307  for (std::size_t j=0; j<src[i].size(); j++)
308  src[i][j] = global_counter++;
309  }
310 
311  TestCommWorld->scatter(src, dest);
312 
313  unsigned int start_value = (TestCommWorld->rank() * (TestCommWorld->rank() + 1)) / 2;
314  for (unsigned int i=0; i<=TestCommWorld->rank(); i++)
315  CPPUNIT_ASSERT_EQUAL( start_value + i, dest[i] );
316  }
317  }
void scatter(const std::vector< T, A > &data, T &recv, const unsigned int root_id=0) const
libMesh::Parallel::Communicator * TestCommWorld
Definition: driver.C:159
processor_id_type rank() const
processor_id_type size() const
uint8_t processor_id_type

◆ testSemiVerify()

void ParallelTest::testSemiVerify ( )
inline

Definition at line 707 of file parallel_test.C.

References TIMPI::Communicator::rank(), TIMPI::Communicator::semiverify(), and TestCommWorld.

708  {
709  LOG_UNIT_TEST;
710 
711  double inf = std::numeric_limits<double>::infinity();
712 
713  double *infptr = TestCommWorld->rank()%2 ? NULL : &inf;
714 
715  CPPUNIT_ASSERT (TestCommWorld->semiverify(infptr));
716 
717  inf = -std::numeric_limits<double>::infinity();
718 
719  CPPUNIT_ASSERT (TestCommWorld->semiverify(infptr));
720  }
libMesh::Parallel::Communicator * TestCommWorld
Definition: driver.C:159
processor_id_type rank() const
bool semiverify(const T *r) const

◆ testSendRecvVecVecs()

void ParallelTest::testSendRecvVecVecs ( )
inline

Definition at line 663 of file parallel_test.C.

References TIMPI::Communicator::rank(), TIMPI::Communicator::receive(), TIMPI::Communicator::send(), TIMPI::Communicator::size(), and TestCommWorld.

664  {
665  LOG_UNIT_TEST;
666 
667  unsigned int procup = (TestCommWorld->rank() + 1) %
668  TestCommWorld->size();
669  unsigned int procdown = (TestCommWorld->size() +
670  TestCommWorld->rank() - 1) %
671  TestCommWorld->size();
672 
673  // Any odd processor out does nothing
674  if ((TestCommWorld->size() % 2) && procup == 0)
675  return;
676 
677  std::vector<std::vector<unsigned int> > src_val(3), recv_val;
678 
679  src_val[0].push_back(4); // Chosen by fair dice roll
680  src_val[2].push_back(procup);
681  src_val[2].push_back(TestCommWorld->rank());
682 
683  // Other even numbered processors send
684  if (TestCommWorld->rank() % 2 == 0)
685  TestCommWorld->send (procup, src_val);
686  // Other odd numbered processors receive
687  else
688  {
689  TestCommWorld->receive (procdown,
690  recv_val);
691 
692  CPPUNIT_ASSERT_EQUAL ( src_val.size() , recv_val.size() );
693 
694  for (std::size_t i = 0; i != 3; ++i)
695  CPPUNIT_ASSERT_EQUAL ( src_val[i].size(), recv_val[i].size() );
696 
697  CPPUNIT_ASSERT_EQUAL ( recv_val[0][0], static_cast<unsigned int> (4) );
698  CPPUNIT_ASSERT_EQUAL ( recv_val[2][0], static_cast<unsigned int> (TestCommWorld->rank()) );
699  CPPUNIT_ASSERT_EQUAL ( recv_val[2][1], procdown );
700 
701  recv_val.clear();
702  }
703  }
libMesh::Parallel::Communicator * TestCommWorld
Definition: driver.C:159
processor_id_type rank() const
processor_id_type size() const
Status receive(const unsigned int dest_processor_id, T &buf, const MessageTag &tag=any_tag) const
void send(const unsigned int dest_processor_id, const T &buf, const MessageTag &tag=no_tag) const

◆ testSplit()

void ParallelTest::testSplit ( )
inline

Definition at line 723 of file parallel_test.C.

References TIMPI::Communicator::rank(), TIMPI::Communicator::size(), libMesh::Parallel::Communicator::size(), TIMPI::Communicator::split(), and TestCommWorld.

724  {
725  LOG_UNIT_TEST;
726 
727  Parallel::Communicator subcomm;
728  unsigned int rank = TestCommWorld->rank();
729  unsigned int color = rank % 2;
730  TestCommWorld->split(color, rank, subcomm);
731 
732  CPPUNIT_ASSERT(subcomm.size() >= 1);
733  CPPUNIT_ASSERT(subcomm.size() >= TestCommWorld->size() / 2);
734  CPPUNIT_ASSERT(subcomm.size() <= TestCommWorld->size() / 2 + 1);
735  }
libMesh::Parallel::Communicator * TestCommWorld
Definition: driver.C:159
processor_id_type rank() const
processor_id_type size() const
void split(int color, int key, Communicator &target) const

◆ testSplitByType()

void ParallelTest::testSplitByType ( )
inline

Definition at line 738 of file parallel_test.C.

References TIMPI::Communicator::rank(), TIMPI::Communicator::size(), libMesh::Parallel::Communicator::size(), TIMPI::Communicator::split_by_type(), and TestCommWorld.

739  {
740  LOG_UNIT_TEST;
741 
742  Parallel::Communicator subcomm;
743  unsigned int rank = TestCommWorld->rank();
744  Parallel::info i = 0;
745  int type = 0;
746 #ifdef LIBMESH_HAVE_MPI
747  type = MPI_COMM_TYPE_SHARED;
748  i = MPI_INFO_NULL;
749 #endif
750  TestCommWorld->split_by_type(type, rank, i, subcomm);
751 
752  CPPUNIT_ASSERT(subcomm.size() >= 1);
753  CPPUNIT_ASSERT(subcomm.size() <= TestCommWorld->size());
754  }
libMesh::Parallel::Communicator * TestCommWorld
Definition: driver.C:159
processor_id_type rank() const
processor_id_type size() const
void split_by_type(int split_type, int key, info i, Communicator &target) const

Member Data Documentation

◆ _number

std::vector<std::string> ParallelTest::_number
private

Definition at line 43 of file parallel_test.C.


The documentation for this class was generated from the following file: