Skip to content

Instantly share code, notes, and snippets.

@salamza
Created April 24, 2016 09:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save salamza/81637009b7690851e547b6ab8e6a9f46 to your computer and use it in GitHub Desktop.
Save salamza/81637009b7690851e547b6ab8e6a9f46 to your computer and use it in GitHub Desktop.
#include <mpi.h>
#include <stdio.h>
#include <string.h>
int main (int argc, char **argv) {
int rank, size, partner;
int namelen;
char name[MPI_MAX_PROCESSOR_NAME];
/* initialize MPI */
MPI_Init(&argc, &argv);
/* how many processes */
MPI_Comm_size(MPI_COMM_WORLD, &size);
/* my rank */
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
/* my name is */
MPI_Get_processor_name(name, &namelen);
printf("Hello world: rank %d of %d running on %s \n", rank, size, name);
/* finalize MPI */
MPI_Finalize();
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment