What is MPI_Init function?

MPI library

MPI (Message Passing Interface) is a library that enables you to write parallel programs in C or Fortran77. The library uses commonly available operating system services to create parallel processes and exchange information among these processes.

Parallel processing

MPI_Init

This method starts the MPI execution environment. It is important that this function is called by only one thread. This thread is known as the main thread, and it must call the MPI_Finalize method after the implementation is completed.

MPI_Init starts an MPI computation.

Syntax

int MPI_Init( int *argc, char ***argv)

Parameters

  • argc is the pointer to the number of arguments.

  • argv is the pointer to the vector of arguments.

Return value

The function returns an error if it is unsuccessful. By default, the error aborts the MPI job.

In case of success, it returns MPI_SUCCESS- the value returned upon successful termination of any MPI routine.

It returns MPI_ERR_OTHER if MPI_Init is used again in the program. MPI_Init must be used once in the program.

Free Resources

Copyright ©2025 Educative, Inc. All rights reserved