Skip to content

Instantly share code, notes, and snippets.

@salamza

salamza/hello-mpi.c

Created Apr 24, 2016
Embed
What would you like to do?
#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
You can’t perform that action at this time.