1

As far as I understand the C implementation of MPI, the MPI_Init function makes no use of arguments &argc and &argv passed to it. The mpiexec or mpirun probably runs multiple programs and passes the MPI_COMM_WORLD object to each of the processes through some datastream externally (so that each program can extract information like size, rank etc. - Please correct me here).

When I check the argv[ ] strings, it contains only the program path.

So I think that signature of MPI_Init must be MPI_Init(void) instead of MPI_Init(int* argc, char*** argv). Is there any reason for passing arguments to MPI_Init? or is it defined this way for future usage if any?

Sourabh Bhat
  • 1,793
  • 16
  • 21
  • @JohnZwinck It is not the same question. My question is not about passing pointer or not! I want to understand why are arguments passed at all. The arguments are not used by MPI and argument passed seems trivial and unusable by MPI. As a matter of fact, I passed empty strings to MPI_Init() and the program worked without any problem. – Sourabh Bhat Mar 22 '14 at 07:34
  • The documentation I found said passing NULL for both is acceptable too. I guess they aren't used. But MPI is a stable standard, can't be changed now. – John Zwinck Mar 22 '14 at 07:37
  • Yes, however I have seen all the programs in literature passing `&argc, &argv` to MPI_Init(), which are the arguments passed by `mpiexec` to the program. At first I thought that the rank and size is passed through arguments by `mpiexec` to `MPI_Init`, but printing the arguments showed that the arguments are of no use. So I want to know whether there is a special case when the arguments contain some information for MPI_Init? – Sourabh Bhat Mar 22 '14 at 07:47
  • What does the documentation for your particular MPI implementation say? Why not just pass the args and forget about it? :) – John Zwinck Mar 22 '14 at 07:53
  • 1
    :) The documentation talks nothing about the arguments, other than saying "pointer to number of arguments" and "pointer to argument vector"! The reason why I stumbled upon this is, I wanted to set the number of processes run before calling MPI_Init from inside the program... or so I thought is possible. Anyways thanks for the suggestions. – Sourabh Bhat Mar 22 '14 at 08:04

0 Answers0