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:
1.0 KB
|
| Line | |
|---|
| 1 | #include <civlc.cvh>
|
|---|
| 2 | /* Create nprocs processes. Have them exchange data in a cycle.
|
|---|
| 3 | * Commandline example:
|
|---|
| 4 | * civl verify -input_mpi_nprocs=3 ring2.cvl -simplify=false
|
|---|
| 5 | */
|
|---|
| 6 | #include<comm.cvh>
|
|---|
| 7 | #include<stdio.h>
|
|---|
| 8 | #include "mp_root2.cvh"
|
|---|
| 9 |
|
|---|
| 10 | void MPI_Process (int __rank) {
|
|---|
| 11 | #include "mp_proc2.cvh"
|
|---|
| 12 |
|
|---|
| 13 | // ******************* BEGIN PROGRAM SOURCE *************************
|
|---|
| 14 |
|
|---|
| 15 | int rank, nprocs, count;
|
|---|
| 16 | double x, y;
|
|---|
| 17 | MPI_Status stat;
|
|---|
| 18 | MPI_Comm MPI_COMM_WORLD = $comm_create($here, __MPI_Comm_World, __rank);
|
|---|
| 19 |
|
|---|
| 20 | MPI_Comm_rank(MPI_COMM_WORLD, &rank);
|
|---|
| 21 | MPI_Comm_size(MPI_COMM_WORLD, &nprocs);
|
|---|
| 22 | x = rank;
|
|---|
| 23 | MPI_Sendrecv(&x, 1, MPI_DOUBLE, (rank+1)%nprocs, 0, &y, 1, MPI_DOUBLE,
|
|---|
| 24 | (rank+nprocs-1)%nprocs, 0, MPI_COMM_WORLD, &stat);
|
|---|
| 25 | $assert(y == (rank+nprocs-1)%nprocs);
|
|---|
| 26 | MPI_Get_count(&stat, MPI_DOUBLE, &count);
|
|---|
| 27 | $assert(count == 1);
|
|---|
| 28 | $assert(stat.MPI_SOURCE == (rank+nprocs-1)%nprocs);
|
|---|
| 29 | $assert(stat.MPI_TAG == 0);
|
|---|
| 30 | $comm_destroy(MPI_COMM_WORLD);
|
|---|
| 31 |
|
|---|
| 32 | // ******************** END PROGRAM SOURCE ***************************
|
|---|
| 33 |
|
|---|
| 34 | }
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.