gko::experimental::mpi::environment#

RAII wrapper around MPI_Init_thread / MPI_Finalize. Construct one at the top of main and let its destructor finalise MPI when the program exits.

int main(int argc, char* argv[]) {
    gko::experimental::mpi::environment env{argc, argv};
    // ... use Ginkgo distributed types ...
}

The constructor requests a thread-support level (serialized by default). is_initialized and is_finalized are static helpers that let library code skip its own MPI_Init if the host application has already initialised MPI.

class environment#

Class that sets up and finalizes the MPI environment. This class is a simple RAII wrapper to MPI_Init and MPI_Finalize.

MPI_Init must have been called before calling any MPI functions.

Note

If MPI_Init has already been called, then this class should not be used.

Public Functions

inline int get_provided_thread_support() const#

Return the provided thread support.

Returns:

the provided thread support

inline environment(
int &argc,
char **&argv,
const thread_type thread_t = thread_type::serialized,
)#

Call MPI_Init_thread and initialize the MPI environment

Parameters:
  • argc – the number of arguments to the main function.

  • argv – the arguments provided to the main function.

  • thread_t – the type of threading for initialization. See @thread_type

inline ~environment()#

Call MPI_Finalize at the end of the scope of this class.