1 #define TRACE_NAME "MPISentry"
2 #include "artdaq-mpich-plugin/Application/MPISentry.hh"
4 #include "artdaq/DAQdata/Globals.hh"
5 #include "cetlib_except/exception.h"
10 MPI_Init(argc_ptr, argv_ptr);
15 : threading_level_(0), rank_(-1), procs_(0) {
16 MPI_Init_thread(argc_ptr, argv_ptr, threading_level, &threading_level_);
19 std::ostringstream threadresult;
20 threadresult <<
"MPI initialized with requested thread support level of " << threading_level
21 <<
", actual support level = " << threading_level_ <<
".";
23 TLOG(TLVL_DEBUG) << threadresult.str();
25 if (threading_level != threading_level_)
throw cet::exception(
"MPISentry") << threadresult.str();
27 TLOG(TLVL_DEBUG) <<
"size = " << procs_ <<
", rank = " << rank_;
31 MPI_Comm& local_group_comm)
32 : threading_level_(0), rank_(-1), procs_(0) {
33 MPI_Init_thread(argc_ptr, argv_ptr, threading_level, &threading_level_);
36 std::ostringstream threadresult;
37 threadresult <<
"MPI initialized with requested thread support level of " << threading_level
38 <<
", actual support level = " << threading_level_ <<
".";
40 TLOG(TLVL_DEBUG) << threadresult.str();
42 if (threading_level != threading_level_)
throw cet::exception(
"MPISentry") << threadresult.str();
44 TLOG(TLVL_DEBUG) <<
"size = " << procs_ <<
", rank = " << rank_;
46 int status = MPI_Comm_split(MPI_COMM_WORLD, type, 0, &local_group_comm);
48 if (status == MPI_SUCCESS) {
50 MPI_Comm_rank(local_group_comm, &temp_rank);
52 TLOG(TLVL_DEBUG) <<
"Successfully created local communicator for type " << type <<
", identifier = 0x" << std::hex
53 << local_group_comm << std::dec <<
", rank = " << temp_rank <<
".";
55 std::ostringstream groupcommresult;
56 groupcommresult <<
"Failed to create the local MPI communicator group for "
57 <<
"task type #" << type <<
", status code = " << status <<
".";
58 TLOG(TLVL_ERROR) << groupcommresult.str();
59 throw cet::exception(
"MPISentry") << groupcommresult.str();
71 void artdaq::MPISentry::initialize_() {
72 MPI_Comm_size(MPI_COMM_WORLD, &procs_);
73 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.