Skip to content

Instantly share code, notes, and snippets.

@Macorreag
Created June 11, 2019 12:32
Show Gist options
  • Save Macorreag/a258a25c4b934d0ef5a52464563ab1f4 to your computer and use it in GitHub Desktop.
Save Macorreag/a258a25c4b934d0ef5a52464563ab1f4 to your computer and use it in GitHub Desktop.
Hello World with MPI
/*
* compile with : mpicc -o helloworld mpi_HelloWorld.c
* run with mpirun -np [#Number of Cores] helloworld
*/
#include <stdio.h>
#include "mpi.h"
int main(int argc,char **argv){
int rank,size;
MPI_Init(&argc,&argv);
MPI_Comm_size(MPI_COMM_WORLD,&size);
MPI_Comm_rank(MPI_COMM_WORLD,&rank);
printf("Hello world from process %d od %d\n",rank,size);
MPI_Finalize();
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment