Skip to content

Instantly share code, notes, and snippets.

@MinhasKamal
Created December 30, 2015 19:52
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 MinhasKamal/b6776b39ac06357f94aa to your computer and use it in GitHub Desktop.
Save MinhasKamal/b6776b39ac06357f94aa to your computer and use it in GitHub Desktop.
#include <stdio.h>
#include <stdlib.h>
#include <mpi.h>
int main(int argc, char** argv) {
int myrank, nprocs;
MPI_Init(&argc, &argv);
MPI_Comm_size(MPI_COMM_WORLD, &nprocs);
MPI_Comm_rank(MPI_COMM_WORLD, &myrank);
printf("Hello from processor %d of %d\n", myrank, nprocs);
printHostName();
MPI_Finalize();
return 0;
}
void printHostName(){
char hostname[1024];
gethostname(hostname, 1024);
puts(hostname);
return;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment