main
test-branch
| Line | |
|---|
| 1 | /* commDupBad.c : A simple buggy example related to the MPI routine:
|
|---|
| 2 | MPI_Comm_dup(MPI_Comm *).
|
|---|
| 3 | */
|
|---|
| 4 | #include <mpi.h>
|
|---|
| 5 |
|
|---|
| 6 | int main(int argc, char * argv[]) {
|
|---|
| 7 | int size, rank;
|
|---|
| 8 | MPI_Comm anotherComm;
|
|---|
| 9 | double buf;
|
|---|
| 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 | buf = 2.0;
|
|---|
| 17 | if(rank == 0) {
|
|---|
| 18 | for(int i = 1 ; i < size; i++)
|
|---|
| 19 | MPI_Send(&buf, 1, MPI_DOUBLE, i, 0, MPI_COMM_WORLD);
|
|---|
| 20 | }else
|
|---|
| 21 | MPI_Recv(&buf, 1, MPI_DOUBLE, 0, 0, anotherComm, MPI_STATUS_IGNORE);
|
|---|
| 22 | MPI_Comm_free(&anotherComm);
|
|---|
| 23 | MPI_Finalize();
|
|---|
| 24 | return 0;
|
|---|
| 25 | }
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.