tags:

views:

215

answers:

2

this is how we use MPI_Init function

int main(int argc, char **argv)
{
    MPI_Init(&argc, &argv);
…
}

why does MPI_Init use pointers to argc and argv instead of values of argv?

+1  A: 

my guess to potentially allow to remove mpi arguments from commandline. passing argument count by pointer allows to modify its value from the point of main.

aaa
why would they do that? what if i examine the arguments before calling MPI_Init
iamrohitbanga
To parse MPI specific arguments. I don't have example for MPI, but GTK GUI toolkit has almost identical `gtk_init` function, that filters out some common X commandline options, such as `--display` and `--screen`.
el.pescado
A: 

It is less overhead to just pass two pointers.

Chad Brewbaker
actually i meant invoke the function as MPI_Init(argc, argv);
iamrohitbanga
that is also less overhead.
iamrohitbanga
Well, many times in practice the MPI code is the whole executable so it would make sense to pass all the command line arguments. Remember though, argc and argv are just local variable names. Inside your code before you call MPI_Init() you can pass it whatever you want.
Chad Brewbaker