Skip to content

Instantly share code, notes, and snippets.

@salamza
Created April 24, 2016 09:22
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