1 #define TRACE_NAME "MPISentry"
2 #include "artdaq/DAQdata/Globals.hh"
3 #include "artdaq-mpich-plugin/Application/MPISentry.hh"
5 #include "cetlib_except/exception.h"
16 MPI_Init(argc_ptr, argv_ptr);
29 MPI_Init_thread(argc_ptr, argv_ptr, threading_level, &threading_level_);
32 std::ostringstream threadresult;
33 threadresult <<
"MPI initialized with requested thread support level of "
34 << threading_level <<
", actual support level = "
35 << threading_level_ <<
".";
37 TLOG(TLVL_DEBUG) << threadresult.str() ;
39 if (threading_level != threading_level_)
throw cet::exception(
"MPISentry") << threadresult.str();
51 int threading_level, artdaq::TaskType type, MPI_Comm& local_group_comm)
57 MPI_Init_thread(argc_ptr, argv_ptr, threading_level, &threading_level_);
60 std::ostringstream threadresult;
61 threadresult <<
"MPI initialized with requested thread support level of "
62 << threading_level <<
", actual support level = "
63 << threading_level_ <<
".";
65 TLOG(TLVL_DEBUG) << threadresult.str() ;
67 if (threading_level != threading_level_)
throw cet::exception(
"MPISentry") << threadresult.str();
76 int status = MPI_Comm_split(MPI_COMM_WORLD, type, 0, &local_group_comm);
78 if (status == MPI_SUCCESS)
81 MPI_Comm_rank(local_group_comm, &temp_rank);
83 TLOG(TLVL_DEBUG) <<
"Successfully created local communicator for type "
84 << type <<
", identifier = 0x"
85 << std::hex << local_group_comm << std::dec
86 <<
", rank = " << temp_rank <<
".";
90 std::ostringstream groupcommresult;
91 groupcommresult <<
"Failed to create the local MPI communicator group for "
92 <<
"task type #" << type <<
", status code = " << status <<
".";
93 TLOG(TLVL_ERROR) << groupcommresult.str();
94 throw cet::exception(
"MPISentry") << groupcommresult.str();
108 return threading_level_;
129 MPI_Comm_size(MPI_COMM_WORLD, &procs_);
130 MPI_Comm_rank(MPI_COMM_WORLD, &rank_);
MPISentry(int *argc_ptr, char ***argv_ptr)
MPISentry Constructor.
int rank() const
Get the MPI rank of the application.
int threading_level() const
Get the actual threading level.
int procs() const
The number of processes in the MPI context.
~MPISentry()
MPISentry Destructor. Calls MPI_Finalize.