Created
July 12, 2015 11:56
-
-
Save keisukefukuda/076e51646c292fdfd213 to your computer and use it in GitHub Desktop.
計算機システム MPIサンプル [6]
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
/* | |
* 計算機システム MPIサンプル [6] | |
* MPIのプロセスが実際にどのホストで実行されているかを調べる | |
*/ | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <assert.h> | |
#include <mpi.h> | |
#include <sys/utsname.h> | |
void print_host() { | |
int rank; | |
struct utsname uts; | |
MPI_Comm_rank(MPI_COMM_WORLD, &rank); | |
uname(&uts); | |
/* | |
* 注意:環境により、行毎に表示されたり、 | |
* 行同士が混ざって表示されることがある. | |
* プロセス同士での表示の順番は保証されない | |
*/ | |
printf("rank %d: %s\n", rank, uts.nodename); | |
} | |
int main(int argc, char **argv) { | |
MPI_Init(&argc, &argv); | |
print_host(); | |
MPI_Finalize(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment