Skip to content

Instantly share code, notes, and snippets.

@jdherman
Created July 31, 2014 20:50
Show Gist options
  • Save jdherman/c24deff6386afb30c5bb to your computer and use it in GitHub Desktop.
Save jdherman/c24deff6386afb30c5bb to your computer and use it in GitHub Desktop.
run any program in parallel
#include <mpi.h>
#include <stdio.h>
int main (argc, argv)
int argc;
char *argv[];
{
int rank,size;
char cmd[1000];
MPI_Init (&argc, &argv); /* starts MPI */
MPI_Comm_rank (MPI_COMM_WORLD, &rank); /* get current process id */
MPI_Comm_size (MPI_COMM_WORLD, &size); /* get number of processes */
sprintf(cmd,"%s %d %d",argv[1],rank,size);
system(cmd);
MPI_Finalize();
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment