source: CIVL/examples/mpi/collective/simpleExscan.c

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: 532 bytes
Line 
1#include <mpi.h>
2#include <stdio.h>
3#include <assert.h>
4
5
6int main() {
7 int rank;
8 double prefixSums[3];
9 double values[3] = {1, 2, 3};
10
11 MPI_Init(NULL, NULL);
12 MPI_Comm_rank(MPI_COMM_WORLD, &rank);
13
14 MPI_Exscan(values, prefixSums, 3, MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD);
15
16 printf("I'm rank %d, my results are %f, %f, %f\n", rank, prefixSums[0], prefixSums[1], prefixSums[2]);
17 if (rank > 0)
18 assert(prefixSums[0] == rank && prefixSums[1] == 2 * (rank)
19 && prefixSums[2] == 3 * (rank));
20 MPI_Finalize();
21 return 0;
22}
Note: See TracBrowser for help on using the repository browser.