Skip to content

Instantly share code, notes, and snippets.

@rehrumesh
Created May 31, 2015 13:08
Show Gist options
  • Save rehrumesh/9bea8c0784d6df04cc8a to your computer and use it in GitHub Desktop.
Save rehrumesh/9bea8c0784d6df04cc8a to your computer and use it in GitHub Desktop.
Hello world with hostname
#include <stdio.h>
#include "mpi.h"
int main(int argc, char **argv)
{
int me, nprocs, namelen;
char processor_name[MPI_MAX_PROCESSOR_NAME];
MPI_Init(&argc, &argv);
MPI_Comm_size(MPI_COMM_WORLD, &nprocs);
MPI_Comm_rank(MPI_COMM_WORLD, &me);
MPI_Get_processor_name(processor_name, &namelen);
printf("Hello World! I'm process %d of %d on %s\n", me, nprocs,
processor_name);
MPI_Finalize();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment