28 #ifdef TIMPI_ENABLE_EXCEPTIONS 35 timpi_not_implemented();
45 int mpi_thread_requested,
46 bool handle_mpi_errors,
47 MPI_Comm COMM_WORLD_IN) :
48 i_initialized_mpi(false),
49 err_handler_set(false)
54 timpi_call_mpi(MPI_Initialized (&flag));
58 int mpi_thread_provided;
61 (MPI_Init_thread (&argc, const_cast<char ***>(&argv),
62 mpi_thread_requested, &mpi_thread_provided));
64 if (mpi_thread_provided < mpi_thread_requested)
77 std::string thread_type;
78 switch (mpi_thread_requested)
81 thread_type =
"MPI_THREAD_SINGLE";
84 thread_type =
"MPI_THREAD_FUNNELED";
87 thread_type =
"MPI_THREAD_SERIALIZED";
90 thread_type =
"MPI_THREAD_MULTIPLE";
93 timpi_error_msg(
"Unsupported mpi thread requested '" << mpi_thread_requested <<
"'");
96 timpi_warning(
"Warning: MPI failed to guarantee " << thread_type <<
"\n" 97 <<
"for a threaded run.\n" 106 this->
_comm = std::make_unique<Communicator>(COMM_WORLD_IN);
109 this->
_ref = std::make_unique<SemiPermanent::Ref>();
113 if (handle_mpi_errors)
129 this->
_comm = std::make_unique<Communicator>();
130 this->
_ref = std::make_unique<SemiPermanent::Ref>();
150 #ifdef TIMPI_ENABLE_EXCEPTIONS 151 if (!std::uncaught_exceptions())
158 #ifdef TIMPI_HAVE_MPI 161 unsigned int error_code =
163 if (error_code != MPI_SUCCESS)
166 "Failure when freeing MPI_Errhandler! Continuing..." <<
177 int error_code = MPI_Finalize();
178 if (error_code != MPI_SUCCESS)
180 char error_string[MPI_MAX_ERROR_STRING+1];
181 int error_string_len;
182 MPI_Error_string(error_code, error_string,
184 std::cerr <<
"Failure from MPI_Finalize():\n" 185 << error_string << std::endl;
TIMPIInit(int argc, const char *const *argv, int mpi_thread_requested=0, bool handle_mpi_errors=false, MPI_Comm COMM_WORLD_IN=MPI_COMM_WORLD)
Initialize the library for use, with the command line options provided.
std::unique_ptr< SemiPermanent::Ref > _ref
void barrier() const
Pause execution until all processors reach a certain point.
void TIMPI_MPI_Handler(MPI_Comm *, int *,...)
virtual ~TIMPIInit()
Destructor.
MPI_Errhandler my_errhandler
std::unique_ptr< Communicator > _comm
const Communicator & comm() const
Returns the Communicator created by this object, which will be a compatibility shim if MPI is not ena...