main
test-branch
| Line | |
|---|
| 1 | /**
|
|---|
| 2 | * This example demonstrates the usage of MPI collective operations,
|
|---|
| 3 | * which should be called in the same orders for all MPI processes.
|
|---|
| 4 | * This example has an error when there are more than five MPI processes.
|
|---|
| 5 | */
|
|---|
| 6 |
|
|---|
| 7 | #include<mpi.h>
|
|---|
| 8 | #include<assert.h>
|
|---|
| 9 |
|
|---|
| 10 | int main(int argc, char * argv[])
|
|---|
| 11 | {
|
|---|
| 12 | int rank;
|
|---|
| 13 | int procs;
|
|---|
| 14 | int value;
|
|---|
| 15 |
|
|---|
| 16 | MPI_Init(&argc,&argv);
|
|---|
| 17 | MPI_Comm_size(MPI_COMM_WORLD, &procs);
|
|---|
| 18 | MPI_Comm_rank(MPI_COMM_WORLD, &rank);
|
|---|
| 19 |
|
|---|
| 20 | if (rank == 0)
|
|---|
| 21 | value = 123;
|
|---|
| 22 |
|
|---|
| 23 | if (rank != 5)
|
|---|
| 24 | MPI_Bcast(&value, 1, MPI_INT, 0, MPI_COMM_WORLD);
|
|---|
| 25 | //assert(value == 123);
|
|---|
| 26 | MPI_Finalize();
|
|---|
| 27 | return 0;
|
|---|
| 28 | }
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.