Created
April 10, 2017 00:43
-
-
Save kaityo256/096f59a6fcdf287fda7e0d28ebd22746 to your computer and use it in GitHub Desktop.
MPI sample
This file contains hidden or 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 <mpi.h> | |
| int | |
| main(int argc, char **argv) { | |
| int rank = 0; | |
| MPI_Init(&argc, &argv); | |
| MPI_Comm_rank(MPI_COMM_WORLD, &rank); | |
| if (0 == rank) { | |
| int send_value = 12345; | |
| MPI_Send(&send_value, 1, MPI_INT, 1, 0, MPI_COMM_WORLD); | |
| } else { | |
| class Hoge { | |
| private: | |
| int private_value; | |
| public: | |
| void recv() { | |
| MPI_Status st; | |
| MPI_Recv(&private_value, 1, MPI_INT, 0, 0, MPI_COMM_WORLD, &st); | |
| } | |
| void show() { | |
| printf("my private value is %d\n", private_value); | |
| } | |
| }; | |
| Hoge h; | |
| h.recv(); | |
| h.show(); | |
| } | |
| MPI_Finalize(); | |
| } |
Author
kaityo256
commented
Apr 10, 2017
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment