32 timpi_not_implemented();
42 int mpi_thread_requested,
43 bool handle_mpi_errors,
44 MPI_Comm COMM_WORLD_IN) :
45 i_initialized_mpi(false),
46 err_handler_set(false)
51 timpi_call_mpi(MPI_Initialized (&flag));
55 int mpi_thread_provided;
58 (MPI_Init_thread (&argc, const_cast<char ***>(&argv),
59 mpi_thread_requested, &mpi_thread_provided));
61 if (mpi_thread_provided < mpi_thread_requested)
74 std::string thread_type;
75 switch (mpi_thread_requested)
78 thread_type =
"MPI_THREAD_SINGLE";
81 thread_type =
"MPI_THREAD_FUNNELED";
84 thread_type =
"MPI_THREAD_SERIALIZED";
87 thread_type =
"MPI_THREAD_MULTIPLE";
90 timpi_error_msg(
"Unsupported mpi thread requested '" << mpi_thread_requested <<
"'");
93 timpi_warning(
"Warning: MPI failed to guarantee " << thread_type <<
"\n" 94 <<
"for a threaded run.\n" 103 this->
_comm = std::make_unique<Communicator>(COMM_WORLD_IN);
106 this->
_ref = std::make_unique<SemiPermanent::Ref>();
110 if (handle_mpi_errors)
126 this->
_comm = std::make_unique<Communicator>();
127 this->
_ref = std::make_unique<SemiPermanent::Ref>();
148 #ifdef TIMPI_HAVE_MPI 151 unsigned int error_code =
153 if (error_code != MPI_SUCCESS)
156 "Failure when freeing MPI_Errhandler! Continuing..." <<
167 int error_code = MPI_Finalize();
168 if (error_code != MPI_SUCCESS)
170 char error_string[MPI_MAX_ERROR_STRING+1];
171 int error_string_len;
172 MPI_Error_string(error_code, error_string,
174 std::cerr <<
"Failure from MPI_Finalize():\n" 175 << 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...