Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change arguments of called programs (SMPI entry points)? #312

Closed
mpoquet opened this issue Nov 13, 2018 · 3 comments
Closed

Change arguments of called programs (SMPI entry points)? #312

mpoquet opened this issue Nov 13, 2018 · 3 comments
Labels

Comments

@mpoquet
Copy link
Collaborator

mpoquet commented Nov 13, 2018

The way SMPI programs are called seems strange to me in current SMPI.

I can implement the following, which might be saner for users.

  • set the executed program as argv[0]
  • remove the rank from the arguments

What do you think?

Example

Here is a tiny MPI program.

#include <mpi.h>
#include <stdio.h>

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

    int rank, size;
    MPI_Comm_rank(MPI_COMM_WORLD, &rank);
    MPI_Comm_size(MPI_COMM_WORLD, &size);

    printf("rank=%d, size=%d, args=['%s'", rank, size, argv[0]);
    for (int i = 1; i < argc; i++)
        printf(", '%s'", argv[i]);
    printf("]\n");

    MPI_Finalize();
    return 0;
}

Execution with usual MPI implementation

With OpenMPI, running

mpicc hello.c -o hello
mpirun -np 2 ./hello mpi world

outputs

rank=0, size=2, args=['./hello', 'mpi', 'world']
rank=1, size=2, args=['./hello', 'mpi', 'world']

Execution with SMPI

With SimGrid (81e177c), running

smpicc hello.c -o hello
smpirun -platform ${SG_DIR}/examples/platforms/small_platform.xml \
        -hostfile ${SG_DIR}/examples/smpi/hostfile \
        --log=xbt_cfg.thresh:warning --log=smpi_kernel.thresh:warning \
        -np 2 ./hello mpi world

outputs

rank=0, size=2, args=['0', 'mpi', 'world']
rank=1, size=2, args=['1', 'mpi', 'world']
@mpoquet mpoquet added the smpi label Nov 13, 2018
@mpoquet
Copy link
Collaborator Author

mpoquet commented Nov 15, 2018

After some tests, I think I'll rather keep rank and add instance_id in the entry points' arguments, and remove those additional arguments when leaving PMPI_Init (and maybe do something else for FORTRAN, as the way args are set for FORTRAN is already specialized in current code base).

This would allow the smpi-msg-masterslave example to work the same way that it is doing now (actor initialization in PMPI_Init), while wiping out these internal arguments from argc/argv once user apps have called MPI_Init.

@mpoquet
Copy link
Collaborator Author

mpoquet commented Nov 15, 2018

Or change smpirun so it uses actor properties instead of arguments!

@agiersch
Copy link
Collaborator

Tested with the current version, and got the expected result:

rank=1, size=2, args=['./hello', 'mpi', 'world']
rank=0, size=2, args=['./hello', 'mpi', 'world']

Closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants