source: CIVL/examples/contracts/reduce_coassert.c@ 397ae5f

main test-branch
Last change on this file since 397ae5f 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: 611 bytes
Line 
1/* Reduce_coassert: All processes in the MPI_COMM_WORLD sum up their
2 ranks, the result is reduced to a root process. */
3#include <mpi.h>
4#include <stdio.h>
5#include <civl-mpi.cvh>
6
7int size, rank;
8int root = 0, sum;
9
10int main(int argc, char * argv[]) {
11 MPI_Init(&argc, &argv);
12 MPI_Comm_rank(MPI_COMM_WORLD, &rank);
13 MPI_Comm_size(MPI_COMM_WORLD, &size);
14 for(int i = 0; i < 4; i++) {
15 MPI_Reduce(&i, &sum, 1, MPI_INT, MPI_SUM, root, MPI_COMM_WORLD);
16 if(!rank)printf("iteration: %d sum=%d\n", i, sum);
17 $mpi_coassert(MPI_COMM_WORLD, sum@root == (i*size));
18 }
19 MPI_Finalize();
20 return 0;
21}
Note: See TracBrowser for help on using the repository browser.