source:
CIVL/mods/dev.civl.com/examples/mpi/simple/bcast_int.c@
cb4d4f4
| Last change on this file since cb4d4f4 was aad342c, checked in by , 3 years ago | |
|---|---|
|
|
| File size: 389 bytes | |
| Line | |
|---|---|
| 1 | /* Good broadcasts. |
| 2 | */ |
| 3 | #include<mpi.h> |
| 4 | #include<assert.h> |
| 5 | |
| 6 | int nprocs; |
| 7 | int myrank; |
| 8 | |
| 9 | void main() { |
| 10 | int argc; |
| 11 | char **argv; |
| 12 | int x; |
| 13 | int y; |
| 14 | |
| 15 | MPI_Init(&argc, &argv); |
| 16 | MPI_Comm_rank(MPI_COMM_WORLD, &myrank); |
| 17 | x=myrank; |
| 18 | y=myrank; |
| 19 | MPI_Bcast(&x, 1, MPI_INT, 0, MPI_COMM_WORLD); |
| 20 | MPI_Bcast(&y, 1, MPI_INT, 1, MPI_COMM_WORLD); |
| 21 | assert(x==0); |
| 22 | assert(y==1); |
| 23 | MPI_Finalize(); |
| 24 | } |
Note:
See TracBrowser
for help on using the repository browser.
