Created
March 10, 2014 10:32
-
-
Save understeer/9462697 to your computer and use it in GitHub Desktop.
OpenMPI test sample
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
/* | |
* Usage: | |
* mpicc mpitest.c -o mpitest | |
* mpirun -np 2 -H `hostname` ./mpitest | |
*/ | |
#include <stdio.h> | |
#include <mpi.h> | |
int main(int argc, char *argv[]) | |
{ | |
int rank, size, h_len; | |
char hostname[MPI_MAX_PROCESSOR_NAME]; | |
MPI_Init(&argc, &argv); | |
// get rank of this proces | |
MPI_Comm_rank(MPI_COMM_WORLD, &rank); | |
// get total process number | |
MPI_Comm_size(MPI_COMM_WORLD, &size); | |
MPI_Get_processor_name(hostname, &h_len); | |
printf("Start! rank:%d size: %d at %s\n", rank, size,hostname); | |
//do something | |
printf("Done! rank:%d size: %d at %s\n", rank, size,hostname); | |
MPI_Finalize(); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment