Created
December 2, 2011 16:05
-
-
Save aprell/1423772 to your computer and use it in GitHub Desktop.
Hello MPI
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
#include <mpi.h> | |
#define WORKER(id) if (ID == (id)) | |
#define MASTER WORKER(0) | |
int main(int argc, char *argv[]) | |
{ | |
int numprocs, ID; | |
MPI_Init(&argc, &argv); | |
MPI_Comm_size(MPI_COMM_WORLD, &numprocs); | |
MPI_Comm_rank(MPI_COMM_WORLD, &ID); | |
MASTER printf("Master %d: Hello MPI!\n", ID); | |
else printf("Worker %d: Hello MPI!\n", ID); | |
MPI_Finalize(); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment