source: CIVL/examples/concurrency/ring2.cvl

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