Skip to content

Instantly share code, notes, and snippets.

@bholt
Created April 1, 2014 17:23
Show Gist options
  • Save bholt/9918803 to your computer and use it in GitHub Desktop.
Save bholt/9918803 to your computer and use it in GitHub Desktop.
MPI Hello World
#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);
char name[256];
// MPI_Get_processor_name(name, sizeof(name));
gethostname(name,255);
fprintf(stderr, "Hello from %s (%d/%d)\n", name, rank, size);
MPI_Finalize();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment