otsdaq  v1_01_04
 All Classes Namespaces Functions
MPIInitializer.cc
1 #include "otsdaq-core/MPICore/MPIInitializer.h"
2 
3 #include "otsdaq-core/MessageFacility/MessageFacility.h"
4 #include "otsdaq-core/Macros/CoutHeaderMacros.h"
5 #include "artdaq/BuildInfo/GetPackageBuildInfo.hh"
6 #include "fhiclcpp/make_ParameterSet.h"
7 
8 
9 
10 #include <iostream>
11 
12 
13 using namespace ots;
14 
15 //========================================================================================================================
16 MPIInitializer::MPIInitializer(void)
17  : local_group_comm_(0), rank_(0)
18 {
19 }
20 
21 //========================================================================================================================
22 void MPIInitializer::init(std::string name, artdaq::TaskType taskType)
23 {
24 
25  std::cout << __COUT_HDR_FL__ << __PRETTY_FUNCTION__ << "BEGIN" << std::endl;
26 
27  INIT_MF((name + "App").c_str());
28  //artdaq::configureMessageFacility("boardreader");
29  //artdaq::configureMessageFacility(name.c_str());
30 
31  std::cout << __COUT_HDR_FL__ << __PRETTY_FUNCTION__ << "MF initialized" << std::endl;
32 
33  // initialization
34  //FIXME This was FUNNELED
35  int const wanted_threading_level { MPI_THREAD_MULTIPLE };
36 
37  //std::cout << __COUT_HDR_FL__ << "MPI INITIALIZER RETURNS: " << MPI_Init_thread(0, 0, wanted_threading_level, 0) << std::endl;
38  //std::cout << __COUT_HDR_FL__ << __PRETTY_FUNCTION__ << "I WAS STUCK" << std::endl;
39 
40 
41  //int const wanted_threading_level { MPI_THREAD_FUNNELED };
42 
43  //MPI_Comm local_group_comm;
44  //std::unique_ptr<artdaq::MPISentry> mpiSentry;
45 
46  try
47  {
48  //mpiSentry_.reset( new artdaq::MPISentry(0, 0, wanted_threading_level, artdaq::TaskType::BoardReaderTask, local_group_comm_) );
49  mpiSentry_.reset( new artdaq::MPISentry(0, 0, wanted_threading_level, taskType, local_group_comm_) );
50  }
51  catch (cet::exception& errormsg)
52  {
53  std::cout << __COUT_HDR_FL__ << __PRETTY_FUNCTION__ << "DIDN't FIND MPI!" << std::endl;
54 
55 // mf::LogError("BoardReaderMain") << errormsg ;
56 // mf::LogError("BoardReaderMain") << "MPISentry error encountered in BoardReaderMain; exiting...";
57  mf::LogError(name) << errormsg ;
58  mf::LogError(name) << "MPISentry error encountered in " << name << "; exiting...";
59  throw errormsg;
60  }
61 
62  rank_ = mpiSentry_->rank();
63 // std::string name = "BoardReader";
64  unsigned short port = 5100;
65 
66  //artdaq::setMsgFacAppName(name, port);
67  mf::LogDebug(name + "InterfaceManager") << "artdaq version " <<
68  artdaq::GetPackageBuildInfo::getPackageBuildInfo().getPackageVersion()
69  << ", built " <<
70  artdaq::GetPackageBuildInfo::getPackageBuildInfo().getBuildTimestamp();
71 
72  // create the BoardReaderApp
73  // artdaq::BoardReaderApp br_app(local_group_comm, name);
74  std::cout << __COUT_HDR_FL__ << __PRETTY_FUNCTION__ << "END" << std::endl;
75 }
76 
77 //========================================================================================================================
78 MPIInitializer::~MPIInitializer(void)
79 {
80  mpiSentry_.reset(nullptr);
81 }