QMCPACK
catch_main.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) 2016 Jeongnim Kim and QMCPACK developers.
6 //
7 // File developed by: Mark Dewing, markdewing@gmail.com, University of Illinois at Urbana-Champaign
8 //
9 // File created by: Mark Dewing, markdewing@gmail.com, University of Illinois at Urbana-Champaign
10 //////////////////////////////////////////////////////////////////////////////////////
11 
12 
13 #define CATCH_CONFIG_RUNNER
14 #include "catch.hpp"
15 #include "DeviceManager.h"
16 
17 #ifdef CATCH_MAIN_HAVE_MPI
18 #include "Message/Communicate.h"
19 #endif
20 #include "Host/OutputManager.h"
21 #include "MemoryUsage.h"
22 
23 // Replacement unit test main function to ensure that MPI is finalized once
24 // (and only once) at the end of the unit test.
25 
26 // turn on QMCPACK printout
27 bool turn_on_output = false;
28 
29 // AFQMC specific unit test arguments.
30 std::string UTEST_HAMIL, UTEST_WFN;
31 
32 int main(int argc, char* argv[])
33 {
34  Catch::Session session;
35  using namespace Catch::clara;
36  // Build command line parser.
37  auto cli = session.cli() |
38  Opt(UTEST_HAMIL, "UTEST_HAMIL")["--hamil"]("Hamiltonian file to be used by unit test if applicable.") |
39  Opt(UTEST_WFN, "UTEST_WFN")["--wfn"]("Wavefunction file to be used by unit test if applicable.") |
40  Opt(turn_on_output)["--turn-on-printout"]("Turn on QMCPACK output manager printout");
41  session.cli(cli);
42  // Parse arguments.
43  int parser_err = session.applyCommandLine(argc, argv);
44 #ifdef CATCH_MAIN_HAVE_MPI
45  mpi3::environment env(argc, argv);
46  OHMMS::Controller = new Communicate(env.world());
47  if (OHMMS::Controller->rank())
50  // assign accelerators within a node
51  qmcplusplus::DeviceManager::initializeGlobalDeviceManager(node_comm.rank(), node_comm.size());
52 #else
54 #endif
55  if (!turn_on_output)
56  {
57  qmcplusplus::app_log() << "QMCPACK printout is suppressed. Use --turn-on-printout to see all the printout."
58  << std::endl;
60  }
61  qmcplusplus::print_mem("Before running tests", qmcplusplus::app_log());
62  // Run the tests.
63  int result = session.run(argc, argv);
64 #ifdef CATCH_MAIN_HAVE_MPI
66 #endif
67  if (parser_err != 0)
68  {
69  return parser_err;
70  }
71  else
72  {
73  return result;
74  }
75 }
Declaration of OutputManager class.
std::ostream & app_log()
Definition: OutputManager.h:65
void shutOff()
Permanently shut off all streams.
bool turn_on_output
Definition: catch_main.cpp:27
Communicate * Controller
Global Communicator for a process.
Definition: Communicate.cpp:35
void print_mem(const std::string &title, std::ostream &log)
Definition: MemoryUsage.cpp:30
OutputManagerClass outputManager(Verbosity::HIGH)
std::string UTEST_WFN
Definition: catch_main.cpp:30
Wrapping information on parallelism.
Definition: Communicate.h:68
Communicate NodeComm() const
provide a node/shared-memory communicator from current (parent) communicator
void finalize()
int main(int argc, char *argv[])
Definition: catch_main.cpp:32
std::string UTEST_HAMIL
Definition: catch_main.cpp:30
static void initializeGlobalDeviceManager(int local_rank, int local_size)
initialize the global instance of DeviceManager arguments are the same as the constructor ...