main
test-branch
| Rev | Line | |
|---|
| [462d355] | 1 | #include<mpi.h>
|
|---|
| 2 | #include<assert.h>
|
|---|
| 3 | #include<civlc.cvh>
|
|---|
| 4 | #include<stdio.h>
|
|---|
| 5 |
|
|---|
| 6 | $input int x, y;
|
|---|
| 7 | $input int _mpi_nprocs=2;
|
|---|
| 8 | //$assume (x > y);
|
|---|
| 9 |
|
|---|
| 10 | int main() {
|
|---|
| 11 | int rank, buf;
|
|---|
| 12 | int data[2];
|
|---|
| 13 |
|
|---|
| 14 | MPI_Init(NULL, NULL);
|
|---|
| 15 | MPI_Comm_rank(MPI_COMM_WORLD, &rank);
|
|---|
| 16 | if(!rank)
|
|---|
| 17 | data[0] = x;
|
|---|
| 18 | else
|
|---|
| 19 | data[0] = y;
|
|---|
| 20 | data[1] = rank;
|
|---|
| 21 | MPI_Allreduce(data, data, 1, MPI_2INT, MPI_MINLOC, MPI_COMM_WORLD);
|
|---|
| 22 | printf("data[1] = %d\n", data[1]);
|
|---|
| 23 | MPI_Bcast(&buf, 1, MPI_INT, data[1], MPI_COMM_WORLD);
|
|---|
| 24 | MPI_Finalize();
|
|---|
| 25 | return 0;
|
|---|
| 26 | }
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.