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:
520 bytes
|
| Rev | Line | |
|---|
| [f4bd985] | 1 | #include "allreduce.h"
|
|---|
| 2 | #include "stdlib.h"
|
|---|
| 3 |
|
|---|
| 4 | #define VEC_N 10
|
|---|
| 5 |
|
|---|
| 6 | int main() {
|
|---|
| 7 | MPI_Init(NULL, NULL);
|
|---|
| 8 |
|
|---|
| 9 | struct comm * comm = (struct comm*)malloc(sizeof(struct comm));
|
|---|
| 10 |
|
|---|
| 11 | comm->c = MPI_COMM_WORLD;
|
|---|
| 12 | MPI_Comm_rank(comm->c, &comm->id);
|
|---|
| 13 | MPI_Comm_size(comm->c, &comm->np);
|
|---|
| 14 |
|
|---|
| 15 | int vn = VEC_N;
|
|---|
| 16 | int v[VEC_N], buf[VEC_N];
|
|---|
| 17 |
|
|---|
| 18 | for (int i = 0; i < VEC_N; i++) v[i] = 1;
|
|---|
| 19 |
|
|---|
| 20 | comm_allreduce(comm, gs_int, gs_add,
|
|---|
| 21 | v, vn, buf);
|
|---|
| 22 |
|
|---|
| 23 | $assert($forall (int i : 0 .. VEC_N-1) buf[i] == comm->np);
|
|---|
| 24 |
|
|---|
| 25 | MPI_Finalize();
|
|---|
| 26 | free(comm);
|
|---|
| 27 | }
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.