main
|
Last change
on this file was ea777aa, checked in by Alex Wilton <awilton@…>, 3 years ago |
|
Moved examples, include, build_default.properties, common.xml, and README out from dev.civl.com into the root of the repo.
git-svn-id: svn://vsl.cis.udel.edu/civl/trunk@5704 fb995dde-84ed-4084-dfe6-e5aef3e2452c
|
-
Property mode
set to
100644
|
|
File size:
561 bytes
|
| Rev | Line | |
|---|
| [a9a9973] | 1 | /* Good broadcasts.
|
|---|
| 2 | */
|
|---|
| 3 | #include<mpi.h>
|
|---|
| 4 | #include<assert.h>
|
|---|
| 5 |
|
|---|
| 6 | int nprocs;
|
|---|
| 7 | int myrank;
|
|---|
| 8 |
|
|---|
| 9 | #define count 10
|
|---|
| 10 |
|
|---|
| 11 | void main() {
|
|---|
| 12 | int argc;
|
|---|
| 13 | char **argv;
|
|---|
| 14 | double x[count];
|
|---|
| 15 | double y[count];
|
|---|
| 16 | int i;
|
|---|
| 17 |
|
|---|
| 18 | MPI_Init(&argc, &argv);
|
|---|
| 19 | MPI_Comm_rank(MPI_COMM_WORLD, &myrank);
|
|---|
| 20 | MPI_Comm_size(MPI_COMM_WORLD, &nprocs);
|
|---|
| 21 | for (i=0; i<count; i++)
|
|---|
| 22 | x[i]=myrank;
|
|---|
| 23 | MPI_Allreduce(&x[0], &y[0], count, MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD);
|
|---|
| 24 | for (i=0; i<count; i++)
|
|---|
| 25 | assert(x[i]==myrank);
|
|---|
| 26 | for (i=0; i<count; i++)
|
|---|
| 27 | assert(y[i]==nprocs*(nprocs-1)/2);
|
|---|
| 28 | MPI_Finalize();
|
|---|
| 29 | }
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.