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