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:
651 bytes
|
| Rev | Line | |
|---|
| [5d951df] | 1 | /* This example show how to collectively call MPI collective
|
|---|
| 2 | functions. They must be called by every included process in a same
|
|---|
| 3 | order. */
|
|---|
| [ec2d23f2] | 4 | #include <mpi.h>
|
|---|
| 5 | #include <assert.h>
|
|---|
| 6 |
|
|---|
| 7 | int main(int argc, char * argv[]) {
|
|---|
| 8 | int nprocs, rank;
|
|---|
| 9 | int num;
|
|---|
| 10 | int recv;
|
|---|
| 11 |
|
|---|
| 12 | MPI_Init(&argc, &argv);
|
|---|
| 13 | MPI_Comm_size(MPI_COMM_WORLD, &nprocs);
|
|---|
| 14 | MPI_Comm_rank(MPI_COMM_WORLD, &rank);
|
|---|
| 15 | if(rank == 0) num = 3;
|
|---|
| 16 | MPI_Bcast(&num, 1, MPI_INT, 0, MPI_COMM_WORLD);
|
|---|
| 17 | MPI_Reduce(&num, &recv, 1, MPI_INT, MPI_SUM, 0, MPI_COMM_WORLD);
|
|---|
| 18 | if(rank == 0) num = recv;
|
|---|
| 19 | MPI_Bcast(&num, 1, MPI_INT, 0, MPI_COMM_WORLD);
|
|---|
| 20 | assert(num == 3 * nprocs);
|
|---|
| 21 | MPI_Finalize();
|
|---|
| 22 | return 0;
|
|---|
| 23 | }
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.