artdaq  v3_00_03
transfer_driver_mpi.cc
1 #define MPI_MODE 1
2 
3 #include "artdaq/DAQdata/Globals.hh"
4 #include "proto/TransferTest.hh"
5 #include "fhiclcpp/make_ParameterSet.h"
6 #include <mpi.h>
7 #include <cstdlib>
8 
9 #include <sys/types.h>
10 #include <unistd.h>
11 
12 int main(int argc, char* argv[])
13 {
14  artdaq::configureMessageFacility("transfer_driver_mpi");
15  TLOG_ARB(TLVL_TRACE, "transfer_driver_mpi") << "BEGIN" << TLOG_ENDL;
16  char envvar[] = "MV2_ENABLE_AFFINITY=0";
17  if (putenv(envvar) != 0)
18  {
19  std::cerr << "Unable to set MV2_ENABLE_AFFINITY environment variable!";
20  return 1;
21  }
22  auto const requested_threading = MPI_THREAD_SERIALIZED;
23  int provided_threading = -1;
24  auto rc = MPI_Init_thread(&argc, &argv, requested_threading, &provided_threading);
25  assert(rc == 0);
26  assert(requested_threading == provided_threading);
27  TLOG_ARB(TLVL_TRACE, "transfer_driver_mpi") << "MPI_Init_thread rc=" << std::to_string(rc) << TLOG_ENDL;
28  rc = MPI_Comm_rank(MPI_COMM_WORLD, &my_rank);
29  assert(rc == 0);
30  TLOG_ARB(TLVL_TRACE, "transfer_driver_mpi")<< "MPI_Comm_rank rc=" << std::to_string(rc) << TLOG_ENDL;
31 
32 
33  if (my_rank == 0)
34  {
35  std::cout << "argc:" << argc << std::endl;
36  for (int i = 0; i < argc; ++i)
37  {
38  std::cout << "argv[" << i << "]: " << argv[i] << std::endl;
39  }
40  }
41 
42  if (argc != 2)
43  {
44  std::cerr << argv[0] << " requires 1 argument, " << argc - 1 << " provided\n";
45  return 1;
46  }
47 
48  cet::filepath_lookup lookup_policy("FHICL_FILE_PATH");
49  fhicl::ParameterSet ps;
50 
51  auto fhicl = std::string(argv[1]);
52  make_ParameterSet(fhicl, lookup_policy, ps);
53 
54  artdaq::TransferTest theTest(ps,0);
55 
56  //std::cout << "Entering infinite loop to connect debugger. PID=" << std::to_string(getpid()) << std::endl;
57  //volatile bool loopForever = true;
58  //while (loopForever) {
59  // usleep(1000);
60  //}
61 
62  theTest.runTest();
63 
64  rc = MPI_Finalize();
65  assert(rc == 0);
66  TLOG_ARB(TLVL_TRACE, "transfer_driver_mpi") << "END" << TLOG_ENDL;
67  return 0;
68 }
Test a set of TransferInterface plugins.
Definition: TransferTest.hh:17