QMCPACK
test_mpi_exception_wrapper.cpp
Go to the documentation of this file.
1 //////////////////////////////////////////////////////////////////////////////////////
2 // This file is distributed under the University of Illinois/NCSA Open Source License.
3 // See LICENSE file in top directory for details.
4 //
5 // Copyright (c) 2020 QMCPACK developers.
6 //
7 // File developed by: Peter Doak, doakpw@ornl.gov, Oak Ridge National Laboratory
8 //
9 // File created by: Peter Doak, doakpw@ornl.gov, Oak Ridge National Laboratory
10 //////////////////////////////////////////////////////////////////////////////////////
11 
12 #include "catch.hpp"
13 
15 #include "Message/Communicate.h"
16 
17 namespace qmcplusplus
18 {
19 /** Openmp generally works but is not guaranteed with std::atomic
20  */
21 void mpiTestFunctionWrapped(Communicate* comm, std::vector<double> &fake_args)
22 {
23  CHECK(fake_args.size() == 4);
24 
25  if (comm->size() != 3)
26  throw std::runtime_error("Bad Rank Count, test_mpi_exception_wrapper can only be run with 3 MPI ranks.");
27 }
28 
29 TEST_CASE("MPIExceptionWrapper function case", "[Utilities]")
30 {
32 
34  std::vector<double> test_vec{1, 2, 3, 4};
35  mew(mpiTestFunctionWrapped, comm, test_vec);
36 
37  // would really like to check for the MPIAbort but that kills the test program.
38 }
39 
40 TEST_CASE("MPIExceptionWrapper lambda case", "[Utilities]")
41 {
43 
45  std::vector<double> test_vec{1, 2, 3, 4};
46  auto lambdaTestFunction = [](Communicate* comm, std::vector<double>& fake_args) {
47  CHECK(fake_args.size() == 4);
48  if (comm->size() != 3)
49  throw std::runtime_error("Bad Rank Count, test_mpi_exception_wrapper can only be run with 3 MPI ranks.");
50  };
51  mew(lambdaTestFunction, comm, test_vec);
52 }
53 
54 } // namespace qmcplusplus
helper functions for EinsplineSetBuilder
Definition: Configuration.h:43
TEST_CASE("complex_helper", "[type_traits]")
Communicate * Controller
Global Communicator for a process.
Definition: Communicate.cpp:35
int size() const
return the number of tasks
Definition: Communicate.h:118
Wrapping information on parallelism.
Definition: Communicate.h:68
CHECK(log_values[0]==ComplexApprox(std::complex< double >{ 5.603777579195571, -6.1586603331188225 }))
void mpiTestFunctionWrapped(Communicate *comm, std::vector< double > &fake_args)
Openmp generally works but is not guaranteed with std::atomic.