main
test-branch
| Rev | Line | |
|---|
| [1079bef] | 1 | /* commDup.c : A simple example shows how to use the MPI_Routine
|
|---|
| 2 | MPI_Comm_dup(MPI_Comm*).
|
|---|
| 3 | */
|
|---|
| 4 | #include <mpi.h>
|
|---|
| 5 | #include <assert.h>
|
|---|
| 6 |
|
|---|
| 7 | int main(int argc, char * argv[]) {
|
|---|
| 8 | int size, rank, buf;
|
|---|
| 9 | MPI_Comm anotherComm;
|
|---|
| 10 |
|
|---|
| 11 | MPI_Init(&argc, &argv);
|
|---|
| 12 | MPI_Comm_rank(MPI_COMM_WORLD, &rank);
|
|---|
| 13 | MPI_Comm_size(MPI_COMM_WORLD, &size);
|
|---|
| 14 | MPI_Comm_dup(MPI_COMM_WORLD, &anotherComm);
|
|---|
| 15 |
|
|---|
| 16 | MPI_Reduce(&rank, &buf, 1, MPI_INT, MPI_SUM, 0, MPI_COMM_WORLD);
|
|---|
| 17 | MPI_Bcast(&buf, 1, MPI_INT, 0, anotherComm);
|
|---|
| 18 | assert(buf == ((size - 1) * size / 2));
|
|---|
| 19 | MPI_Comm_free(&anotherComm);
|
|---|
| 20 | MPI_Finalize();
|
|---|
| 21 | return 0;
|
|---|
| 22 | }
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.