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

Public Member Functions

 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 ( testAllGather  )

◆ CPPUNIT_TEST() [2/26]

ParallelTest::CPPUNIT_TEST ( testAllGatherEmptyVectorString  )

◆ CPPUNIT_TEST() [3/26]

ParallelTest::CPPUNIT_TEST ( testAllGatherHalfEmptyVectorString  )

◆ CPPUNIT_TEST() [4/26]

ParallelTest::CPPUNIT_TEST ( testAllGatherString  )

◆ CPPUNIT_TEST() [5/26]

ParallelTest::CPPUNIT_TEST ( testAllGatherVectorString  )

◆ CPPUNIT_TEST() [6/26]

ParallelTest::CPPUNIT_TEST ( testBarrier  )

◆ CPPUNIT_TEST() [7/26]

ParallelTest::CPPUNIT_TEST ( testBroadcast  )

◆ CPPUNIT_TEST() [8/26]

ParallelTest::CPPUNIT_TEST ( testBroadcastNestedType  )

◆ CPPUNIT_TEST() [9/26]

ParallelTest::CPPUNIT_TEST ( testGather  )

◆ CPPUNIT_TEST() [10/26]

ParallelTest::CPPUNIT_TEST ( testGatherString  )

◆ CPPUNIT_TEST() [11/26]

ParallelTest::CPPUNIT_TEST ( testInfinityMax  )

◆ CPPUNIT_TEST() [12/26]

ParallelTest::CPPUNIT_TEST ( testInfinityMin  )

◆ CPPUNIT_TEST() [13/26]

ParallelTest::CPPUNIT_TEST ( testIrecvSend  )

◆ CPPUNIT_TEST() [14/26]

ParallelTest::CPPUNIT_TEST ( testIsendRecv  )

◆ CPPUNIT_TEST() [15/26]

ParallelTest::CPPUNIT_TEST ( testMax  )

◆ CPPUNIT_TEST() [16/26]

ParallelTest::CPPUNIT_TEST ( testMaxloc  )

◆ CPPUNIT_TEST() [17/26]

ParallelTest::CPPUNIT_TEST ( testMaxlocReal  )

◆ CPPUNIT_TEST() [18/26]

ParallelTest::CPPUNIT_TEST ( testMin  )

◆ CPPUNIT_TEST() [19/26]

ParallelTest::CPPUNIT_TEST ( testMinloc  )

◆ CPPUNIT_TEST() [20/26]

ParallelTest::CPPUNIT_TEST ( testMinlocReal  )

◆ CPPUNIT_TEST() [21/26]

ParallelTest::CPPUNIT_TEST ( testRecvIsendSets  )

◆ CPPUNIT_TEST() [22/26]

ParallelTest::CPPUNIT_TEST ( testRecvIsendVecVecs  )

◆ CPPUNIT_TEST() [23/26]

ParallelTest::CPPUNIT_TEST ( testScatter  )

◆ CPPUNIT_TEST() [24/26]

ParallelTest::CPPUNIT_TEST ( testSemiVerify  )

◆ CPPUNIT_TEST() [25/26]

ParallelTest::CPPUNIT_TEST ( testSendRecvVecVecs  )

◆ CPPUNIT_TEST() [26/26]

ParallelTest::CPPUNIT_TEST ( testSplit  )

◆ CPPUNIT_TEST_SUITE()

ParallelTest::CPPUNIT_TEST_SUITE ( ParallelTest  )

◆ CPPUNIT_TEST_SUITE_END()

ParallelTest::CPPUNIT_TEST_SUITE_END ( )

◆ 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  }

◆ tearDown()

void ParallelTest::tearDown ( )
inline

Definition at line 61 of file parallel_test.C.

62  {}

◆ testAllGather()

void ParallelTest::testAllGather ( )
inline

Definition at line 90 of file parallel_test.C.

91  {
92  std::vector<processor_id_type> vals;
93  TestCommWorld->allgather(cast_int<processor_id_type>(TestCommWorld->rank()),vals);
94 
95  for (processor_id_type i=0; i<vals.size(); i++)
96  CPPUNIT_ASSERT_EQUAL( i , vals[i] );
97  }

References TestCommWorld.

◆ testAllGatherEmptyVectorString()

void ParallelTest::testAllGatherEmptyVectorString ( )
inline

Definition at line 128 of file parallel_test.C.

129  {
130  std::vector<std::string> vals;
131  TestCommWorld->allgather(vals);
132 
133  CPPUNIT_ASSERT( vals.empty() );
134  }

References TestCommWorld.

◆ testAllGatherHalfEmptyVectorString()

void ParallelTest::testAllGatherHalfEmptyVectorString ( )
inline

Definition at line 138 of file parallel_test.C.

139  {
140  std::vector<std::string> vals;
141 
142  if (!TestCommWorld->rank())
143  vals.push_back("Proc 0 only");
144 
145  TestCommWorld->allgather(vals);
146 
147  CPPUNIT_ASSERT_EQUAL( vals[0], std::string("Proc 0 only") );
148  }

References TestCommWorld.

◆ testAllGatherString()

void ParallelTest::testAllGatherString ( )
inline

Definition at line 101 of file parallel_test.C.

102  {
103  std::vector<std::string> vals;
104  TestCommWorld->gather(0, "Processor" + _number[TestCommWorld->rank() % 10], vals);
105 
106  for (processor_id_type i=0; i<vals.size(); i++)
107  CPPUNIT_ASSERT_EQUAL( "Processor" + _number[i % 10] , vals[i] );
108  }

References TestCommWorld.

◆ testAllGatherVectorString()

void ParallelTest::testAllGatherVectorString ( )
inline

Definition at line 112 of file parallel_test.C.

113  {
114  std::vector<std::string> vals;
115  vals.push_back("Processor" + _number[TestCommWorld->rank() % 10] + "A");
116  vals.push_back("Processor" + _number[TestCommWorld->rank() % 10] + "B");
117  TestCommWorld->allgather(vals);
118 
119  for (processor_id_type i=0; i<(vals.size()/2); i++)
120  {
121  CPPUNIT_ASSERT_EQUAL( "Processor" + _number[i % 10] + "A" , vals[2*i] );
122  CPPUNIT_ASSERT_EQUAL( "Processor" + _number[i % 10] + "B" , vals[2*i+1] );
123  }
124  }

References TestCommWorld.

◆ testBarrier()

void ParallelTest::testBarrier ( )
inline

Definition at line 303 of file parallel_test.C.

304  {
305  TestCommWorld->barrier();
306  }

References TestCommWorld.

◆ testBroadcast()

void ParallelTest::testBroadcast ( )
inline

Definition at line 152 of file parallel_test.C.

153  {
154  std::vector<unsigned int> src(3), dest(3);
155 
156  src[0]=0;
157  src[1]=1;
158  src[2]=2;
159 
160  if (TestCommWorld->rank() == 0)
161  dest = src;
162 
163  TestCommWorld->broadcast(dest);
164 
165  for (std::size_t i=0; i<src.size(); i++)
166  CPPUNIT_ASSERT_EQUAL( src[i] , dest[i] );
167  }

References TestCommWorld.

◆ testBroadcastNestedType()

void ParallelTest::testBroadcastNestedType ( )
inline

Definition at line 171 of file parallel_test.C.

172  {
173  using std::pair;
174  typedef pair<pair<pair<pair<int, int>, int>, int>, int> pppp;
175  std::vector<pppp> src(3), dest(3);
176 
177  src[0].first.first.first.first=0;
178  src[0].first.first.first.second=-1;
179  src[0].first.second = -2;
180  src[0].second = -3;
181  src[1].first.first.first.first=10;
182  src[1].first.first.first.second=9;
183  src[1].first.second = 8;
184  src[1].second = 7;
185  src[2].first.first.first.first=20;
186  src[2].first.first.first.second=19;
187  src[2].first.second = 18;
188  src[2].second = 17;
189 
190  if (TestCommWorld->rank() == 0)
191  dest = src;
192 
193  TestCommWorld->broadcast(dest);
194 
195  for (std::size_t i=0; i<src.size(); i++)
196  {
197  CPPUNIT_ASSERT_EQUAL(src[i].first.first.first.first,
198  dest[i].first.first.first.first);
199  CPPUNIT_ASSERT_EQUAL(src[i].first.first.first.second,
200  dest[i].first.first.first.second);
201  CPPUNIT_ASSERT_EQUAL(src[i].first.first.second,
202  dest[i].first.first.second);
203  CPPUNIT_ASSERT_EQUAL(src[i].first.second,
204  dest[i].first.second);
205  CPPUNIT_ASSERT_EQUAL(src[i].second,
206  dest[i].second);
207  }
208  }

References TestCommWorld.

◆ testGather()

void ParallelTest::testGather ( )
inline

Definition at line 66 of file parallel_test.C.

67  {
68  std::vector<processor_id_type> vals;
69  TestCommWorld->gather(0,cast_int<processor_id_type>(TestCommWorld->rank()),vals);
70 
71  if (TestCommWorld->rank() == 0)
72  for (processor_id_type i=0; i<vals.size(); i++)
73  CPPUNIT_ASSERT_EQUAL( i , vals[i] );
74  }

References TestCommWorld.

◆ testGatherString()

void ParallelTest::testGatherString ( )
inline

Definition at line 78 of file parallel_test.C.

79  {
80  std::vector<std::string> vals;
81  TestCommWorld->gather(0, "Processor" + _number[TestCommWorld->rank() % 10], vals);
82 
83  if (TestCommWorld->rank() == 0)
84  for (processor_id_type i=0; i<vals.size(); i++)
85  CPPUNIT_ASSERT_EQUAL( "Processor" + _number[i % 10] , vals[i] );
86  }

References TestCommWorld.

◆ testInfinityMax()

void ParallelTest::testInfinityMax ( )
inline

Definition at line 404 of file parallel_test.C.

405  {
406  double max = std::numeric_limits<double>::infinity();
407 
408  TestCommWorld->max(max);
409 
410  CPPUNIT_ASSERT_EQUAL (max, std::numeric_limits<double>::infinity());
411 
412  max = -std::numeric_limits<double>::infinity();
413 
414  TestCommWorld->max(max);
415 
416  CPPUNIT_ASSERT_EQUAL (max, -std::numeric_limits<double>::infinity());
417  }

References TestCommWorld.

◆ testInfinityMin()

void ParallelTest::testInfinityMin ( )
inline

Definition at line 387 of file parallel_test.C.

388  {
389  double min = std::numeric_limits<double>::infinity();
390 
391  TestCommWorld->min(min);
392 
393  CPPUNIT_ASSERT_EQUAL (min, std::numeric_limits<double>::infinity());
394 
395  min = -std::numeric_limits<double>::infinity();
396 
397  TestCommWorld->min(min);
398 
399  CPPUNIT_ASSERT_EQUAL (min, -std::numeric_limits<double>::infinity());
400  }

References TestCommWorld.

◆ testIrecvSend()

void ParallelTest::testIrecvSend ( )
inline

Definition at line 482 of file parallel_test.C.

483  {
484  unsigned int procup = (TestCommWorld->rank() + 1) %
485  TestCommWorld->size();
486  unsigned int procdown = (TestCommWorld->size() +
487  TestCommWorld->rank() - 1) %
488  TestCommWorld->size();
489 
490  std::vector<unsigned int> src_val(3), recv_val(3);
491 
492  src_val[0] = 0;
493  src_val[1] = 1;
494  src_val[2] = 2;
495 
496  Parallel::Request request;
497 
498  if (TestCommWorld->size() > 1)
499  {
500  // Default communication
501  TestCommWorld->send_mode(Parallel::Communicator::DEFAULT);
502 
503  TestCommWorld->receive (procdown,
504  recv_val,
505  request);
506 
507  TestCommWorld->send (procup,
508  src_val);
509 
510  Parallel::wait (request);
511 
512  CPPUNIT_ASSERT_EQUAL ( src_val.size() , recv_val.size() );
513 
514  for (std::size_t i=0; i<src_val.size(); i++)
515  CPPUNIT_ASSERT_EQUAL( src_val[i] , recv_val[i] );
516 
517  // Synchronous communication
518  TestCommWorld->send_mode(Parallel::Communicator::SYNCHRONOUS);
519  std::fill (recv_val.begin(), recv_val.end(), 0);
520 
521 
522  TestCommWorld->receive (procdown,
523  recv_val,
524  request);
525 
526  TestCommWorld->send (procup,
527  src_val);
528 
529  Parallel::wait (request);
530 
531  CPPUNIT_ASSERT_EQUAL ( src_val.size() , recv_val.size() );
532 
533  for (std::size_t i=0; i<src_val.size(); i++)
534  CPPUNIT_ASSERT_EQUAL( src_val[i] , recv_val[i] );
535 
536  // Restore default communication
537  TestCommWorld->send_mode(Parallel::Communicator::DEFAULT);
538  }
539  }

References TestCommWorld.

◆ testIsendRecv()

void ParallelTest::testIsendRecv ( )
inline

Definition at line 421 of file parallel_test.C.

422  {
423  unsigned int procup = (TestCommWorld->rank() + 1) %
424  TestCommWorld->size();
425  unsigned int procdown = (TestCommWorld->size() +
426  TestCommWorld->rank() - 1) %
427  TestCommWorld->size();
428 
429  std::vector<unsigned int> src_val(3), recv_val(3);
430 
431  src_val[0] = 0;
432  src_val[1] = 1;
433  src_val[2] = 2;
434 
435  Parallel::Request request;
436 
437  if (TestCommWorld->size() > 1)
438  {
439  // Default communication
440  TestCommWorld->send_mode(Parallel::Communicator::DEFAULT);
441 
442  TestCommWorld->send (procup,
443  src_val,
444  request);
445 
446  TestCommWorld->receive (procdown,
447  recv_val);
448 
449  Parallel::wait (request);
450 
451  CPPUNIT_ASSERT_EQUAL ( src_val.size() , recv_val.size() );
452 
453  for (std::size_t i=0; i<src_val.size(); i++)
454  CPPUNIT_ASSERT_EQUAL( src_val[i] , recv_val[i] );
455 
456 
457  // Synchronous communication
458  TestCommWorld->send_mode(Parallel::Communicator::SYNCHRONOUS);
459  std::fill (recv_val.begin(), recv_val.end(), 0);
460 
461  TestCommWorld->send (procup,
462  src_val,
463  request);
464 
465  TestCommWorld->receive (procdown,
466  recv_val);
467 
468  Parallel::wait (request);
469 
470  CPPUNIT_ASSERT_EQUAL ( src_val.size() , recv_val.size() );
471 
472  for (std::size_t i=0; i<src_val.size(); i++)
473  CPPUNIT_ASSERT_EQUAL( src_val[i] , recv_val[i] );
474 
475  // Restore default communication
476  TestCommWorld->send_mode(Parallel::Communicator::DEFAULT);
477  }
478  }

References TestCommWorld.

◆ testMax()

void ParallelTest::testMax ( )
inline

Definition at line 321 of file parallel_test.C.

322  {
323  processor_id_type max = TestCommWorld->rank();
324 
325  TestCommWorld->max(max);
326 
327  CPPUNIT_ASSERT_EQUAL (cast_int<processor_id_type>(max+1),
328  cast_int<processor_id_type>(TestCommWorld->size()));
329  }

References TestCommWorld.

◆ testMaxloc()

void ParallelTest::testMaxloc ( )
inline

Definition at line 346 of file parallel_test.C.

347  {
348  int max = TestCommWorld->rank();
349  unsigned int maxid = 0;
350 
351  TestCommWorld->maxloc(max, maxid);
352 
353  CPPUNIT_ASSERT_EQUAL (max+1,
354  cast_int<int>(TestCommWorld->size()));
355  CPPUNIT_ASSERT_EQUAL (maxid, static_cast<unsigned int>(TestCommWorld->size()-1));
356  }

References TestCommWorld.

◆ testMaxlocReal()

void ParallelTest::testMaxlocReal ( )
inline

Definition at line 373 of file parallel_test.C.

374  {
375  Real max = TestCommWorld->rank();
376  unsigned int maxid = 0;
377 
378  TestCommWorld->maxloc(max, maxid);
379 
380  // Hope nobody uses 1677216 procs with single precision
381  CPPUNIT_ASSERT_EQUAL (max+1, Real(TestCommWorld->size()));
382  CPPUNIT_ASSERT_EQUAL (maxid, static_cast<unsigned int>(TestCommWorld->size()-1));
383  }

References libMesh::Real, and TestCommWorld.

◆ testMin()

void ParallelTest::testMin ( )
inline

Definition at line 310 of file parallel_test.C.

311  {
312  unsigned int min = TestCommWorld->rank();
313 
314  TestCommWorld->min(min);
315 
316  CPPUNIT_ASSERT_EQUAL (min, static_cast<unsigned int>(0));
317  }

References TestCommWorld.

◆ testMinloc()

void ParallelTest::testMinloc ( )
inline

Definition at line 333 of file parallel_test.C.

334  {
335  int min = (TestCommWorld->rank() + 1) % TestCommWorld->size();
336  unsigned int minid = 0;
337 
338  TestCommWorld->minloc(min, minid);
339 
340  CPPUNIT_ASSERT_EQUAL (min, static_cast<int>(0));
341  CPPUNIT_ASSERT_EQUAL (minid, static_cast<unsigned int>(TestCommWorld->size()-1));
342  }

References TestCommWorld.

◆ testMinlocReal()

void ParallelTest::testMinlocReal ( )
inline

Definition at line 360 of file parallel_test.C.

361  {
362  Real min = (TestCommWorld->rank() + 1) % TestCommWorld->size();
363  unsigned int minid = 0;
364 
365  TestCommWorld->minloc(min, minid);
366 
367  CPPUNIT_ASSERT_EQUAL (min, Real(0));
368  CPPUNIT_ASSERT_EQUAL (minid, static_cast<unsigned int>(TestCommWorld->size()-1));
369  }

References libMesh::Real, and TestCommWorld.

◆ testRecvIsendSets()

void ParallelTest::testRecvIsendSets ( )
inline

Definition at line 542 of file parallel_test.C.

543  {
544  unsigned int procup = (TestCommWorld->rank() + 1) %
545  TestCommWorld->size();
546  unsigned int procdown = (TestCommWorld->size() +
547  TestCommWorld->rank() - 1) %
548  TestCommWorld->size();
549 
550  std::set<unsigned int> src_val, recv_val;
551 
552  src_val.insert(4); // Chosen by fair dice roll
553  src_val.insert(42);
554  src_val.insert(1337);
555 
556  Parallel::Request request;
557 
558  if (TestCommWorld->size() > 1)
559  {
560  TestCommWorld->send (procup, src_val, request);
561 
562  TestCommWorld->receive (procdown,
563  recv_val);
564 
565  CPPUNIT_ASSERT_EQUAL ( src_val.size() , recv_val.size() );
566 
567  for (std::set<unsigned int>::const_iterator
568  it = src_val.begin(), end = src_val.end(); it != end;
569  ++it)
570  CPPUNIT_ASSERT ( recv_val.count(*it) );
571 
572  Parallel::wait (request);
573 
574  recv_val.clear();
575  }
576  }

References end, and TestCommWorld.

◆ testRecvIsendVecVecs()

void ParallelTest::testRecvIsendVecVecs ( )
inline

Definition at line 580 of file parallel_test.C.

581  {
582  unsigned int procup = (TestCommWorld->rank() + 1) %
583  TestCommWorld->size();
584  unsigned int procdown = (TestCommWorld->size() +
585  TestCommWorld->rank() - 1) %
586  TestCommWorld->size();
587 
588  std::vector<std::vector<unsigned int> > src_val(3), recv_val;
589 
590  src_val[0].push_back(4); // Chosen by fair dice roll
591  src_val[2].push_back(procup);
592  src_val[2].push_back(TestCommWorld->rank());
593 
594  Parallel::Request request;
595 
596  if (TestCommWorld->size() > 1)
597  {
598  TestCommWorld->send (procup, src_val, request);
599 
600  TestCommWorld->receive (procdown,
601  recv_val);
602 
603  CPPUNIT_ASSERT_EQUAL ( src_val.size() , recv_val.size() );
604 
605  for (std::size_t i = 0; i != 3; ++i)
606  CPPUNIT_ASSERT_EQUAL ( src_val[i].size(), recv_val[i].size() );
607 
608  CPPUNIT_ASSERT_EQUAL ( recv_val[0][0], static_cast<unsigned int> (4) );
609  CPPUNIT_ASSERT_EQUAL ( recv_val[2][0], static_cast<unsigned int> (TestCommWorld->rank()) );
610  CPPUNIT_ASSERT_EQUAL ( recv_val[2][1], procdown );
611 
612  Parallel::wait (request);
613 
614  recv_val.clear();
615  }
616  }

References TestCommWorld.

◆ testScatter()

void ParallelTest::testScatter ( )
inline

Definition at line 212 of file parallel_test.C.

213  {
214  // Test Scalar scatter
215  {
216  std::vector<processor_id_type> src;
217  processor_id_type dest;
218 
219  if (TestCommWorld->rank() == 0)
220  {
221  src.resize(TestCommWorld->size());
222  for (processor_id_type i=0; i<src.size(); i++)
223  src[i] = i;
224  }
225 
226  TestCommWorld->scatter(src, dest);
227 
228  CPPUNIT_ASSERT_EQUAL( TestCommWorld->rank(), dest );
229  }
230 
231  // Test Vector Scatter (equal-sized chunks)
232  {
233  std::vector<unsigned int> src;
234  std::vector<unsigned int> dest;
235  static const unsigned int CHUNK_SIZE = 3;
236 
237  if (TestCommWorld->rank() == 0)
238  {
239  src.resize(TestCommWorld->size() * CHUNK_SIZE);
240  for (std::size_t i=0; i<src.size(); i++)
241  src[i] = i;
242  }
243 
244  TestCommWorld->scatter(src, dest);
245 
246  for (unsigned int i=0; i<CHUNK_SIZE; i++)
247  CPPUNIT_ASSERT_EQUAL( TestCommWorld->rank() * CHUNK_SIZE + i, dest[i] );
248  }
249 
250  // Test Vector Scatter (jagged chunks)
251  {
252  std::vector<unsigned int> src;
253  std::vector<unsigned int> dest;
254  std::vector<int> counts;
255 
256  if (TestCommWorld->rank() == 0)
257  {
258  // Give each processor "rank" number of items ( Sum i=1..n == (n * (n + 1))/2 )
259  src.resize((TestCommWorld->size() * (TestCommWorld->size() + 1)) / 2);
260  counts.resize(TestCommWorld->size());
261 
262  for (std::size_t i=0; i<src.size(); i++)
263  src[i] = i;
264  for (unsigned int i=0; i<TestCommWorld->size(); i++)
265  counts[i] = static_cast<int>(i+1);
266  }
267 
268  TestCommWorld->scatter(src, counts, dest);
269 
270  unsigned int start_value = (TestCommWorld->rank() * (TestCommWorld->rank() + 1)) / 2;
271  for (unsigned int i=0; i<=TestCommWorld->rank(); i++)
272  CPPUNIT_ASSERT_EQUAL( start_value + i, dest[i] );
273  }
274 
275  // Test Vector of Vector Scatter
276  {
277  std::vector<std::vector<unsigned int>> src;
278  std::vector<unsigned int> dest;
279 
280  if (TestCommWorld->rank() == 0)
281  {
282  // Give each processor "rank" number of items ( Sum i=1..n == (n * (n + 1))/2 )
283  src.resize(TestCommWorld->size());
284  for (std::size_t i=0; i<src.size(); ++i)
285  src[i].resize(i+1);
286 
287  unsigned int global_counter = 0;
288  for (std::size_t i=0; i<src.size(); i++)
289  for (std::size_t j=0; j<src[i].size(); j++)
290  src[i][j] = global_counter++;
291  }
292 
293  TestCommWorld->scatter(src, dest);
294 
295  unsigned int start_value = (TestCommWorld->rank() * (TestCommWorld->rank() + 1)) / 2;
296  for (unsigned int i=0; i<=TestCommWorld->rank(); i++)
297  CPPUNIT_ASSERT_EQUAL( start_value + i, dest[i] );
298  }
299  }

References TestCommWorld.

◆ testSemiVerify()

void ParallelTest::testSemiVerify ( )
inline

Definition at line 661 of file parallel_test.C.

662  {
663  double inf = std::numeric_limits<double>::infinity();
664 
665  double *infptr = TestCommWorld->rank()%2 ? NULL : &inf;
666 
667  CPPUNIT_ASSERT (TestCommWorld->semiverify(infptr));
668 
669  inf = -std::numeric_limits<double>::infinity();
670 
671  CPPUNIT_ASSERT (TestCommWorld->semiverify(infptr));
672  }

References TestCommWorld.

◆ testSendRecvVecVecs()

void ParallelTest::testSendRecvVecVecs ( )
inline

Definition at line 619 of file parallel_test.C.

620  {
621  unsigned int procup = (TestCommWorld->rank() + 1) %
622  TestCommWorld->size();
623  unsigned int procdown = (TestCommWorld->size() +
624  TestCommWorld->rank() - 1) %
625  TestCommWorld->size();
626 
627  // Any odd processor out does nothing
628  if ((TestCommWorld->size() % 2) && procup == 0)
629  return;
630 
631  std::vector<std::vector<unsigned int> > src_val(3), recv_val;
632 
633  src_val[0].push_back(4); // Chosen by fair dice roll
634  src_val[2].push_back(procup);
635  src_val[2].push_back(TestCommWorld->rank());
636 
637  // Other even numbered processors send
638  if (TestCommWorld->rank() % 2 == 0)
639  TestCommWorld->send (procup, src_val);
640  // Other odd numbered processors receive
641  else
642  {
643  TestCommWorld->receive (procdown,
644  recv_val);
645 
646  CPPUNIT_ASSERT_EQUAL ( src_val.size() , recv_val.size() );
647 
648  for (std::size_t i = 0; i != 3; ++i)
649  CPPUNIT_ASSERT_EQUAL ( src_val[i].size(), recv_val[i].size() );
650 
651  CPPUNIT_ASSERT_EQUAL ( recv_val[0][0], static_cast<unsigned int> (4) );
652  CPPUNIT_ASSERT_EQUAL ( recv_val[2][0], static_cast<unsigned int> (TestCommWorld->rank()) );
653  CPPUNIT_ASSERT_EQUAL ( recv_val[2][1], procdown );
654 
655  recv_val.clear();
656  }
657  }

References TestCommWorld.

◆ testSplit()

void ParallelTest::testSplit ( )
inline

Definition at line 675 of file parallel_test.C.

676  {
677  Parallel::Communicator subcomm;
678  unsigned int rank = TestCommWorld->rank();
679  unsigned int color = rank % 2;
680  TestCommWorld->split(color, rank, subcomm);
681 
682  CPPUNIT_ASSERT(subcomm.size() >= 1);
683  CPPUNIT_ASSERT(subcomm.size() >= TestCommWorld->size() / 2);
684  CPPUNIT_ASSERT(subcomm.size() <= TestCommWorld->size() / 2 + 1);
685  }

References TestCommWorld.

◆ testSplitByType()

void ParallelTest::testSplitByType ( )
inline

Definition at line 688 of file parallel_test.C.

689  {
690  Parallel::Communicator subcomm;
691  unsigned int rank = TestCommWorld->rank();
692  Parallel::info i = 0;
693  int type = 0;
694 #ifdef LIBMESH_HAVE_MPI
695  type = MPI_COMM_TYPE_SHARED;
696  i = MPI_INFO_NULL;
697 #endif
698  TestCommWorld->split_by_type(type, rank, i, subcomm);
699 
700  CPPUNIT_ASSERT(subcomm.size() >= 1);
701  CPPUNIT_ASSERT(subcomm.size() <= TestCommWorld->size());
702  }

References TestCommWorld.

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:
end
IterBase * end
Also have a polymorphic pointer to the end object, this prevents iterating past the end.
Definition: variant_filter_iterator.h:343
TestCommWorld
libMesh::Parallel::Communicator * TestCommWorld
Definition: driver.C:111
libMesh::processor_id_type
uint8_t processor_id_type
Definition: id_types.h:104
ParallelTest::_number
std::vector< std::string > _number
Definition: parallel_test.C:43
libMesh::Real
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
Definition: libmesh_common.h:121