source: CIVL/examples/contracts/contractsMPI/diffusion1dExchange_ensures_bad.c@ bb03188

main test-branch
Last change on this file since bb03188 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: 2.2 KB
RevLine 
[aaa9c8d]1#include<mpi.h>
2#include<civlc.cvh>
3#include<stdio.h>
4
5#pragma CIVL ACSL
6#define DATA_LIMIT 1024
7
8int left, right, nxl, nx, rank, nprocs;
9double * u, * u_new, k;
10
11#define OWNER(index) ((nprocs*(index+1)-1)/nx)
12
13#define FIRST(rank) ((rank)*nx/nprocs)
14
15#define LOCAL_OF(index) (index - (OWNER(index)*nx/nprocs) + 1)
16
17#define READ(index) (\on(OWNER(index), u)[LOCAL_OF(index)])
18
19/* TODO: ideally the requirements for left and right neighbor shall be
20 * that left != rank && right != rank &&
21 * the set L { l | \on(left, i), 0 <= i < \mpi_comm_size} equals
22 * to the set process rank set R {0, 1, ..., \mpi_comm_size-1, MPI_PROC_NULL}.
23 * ditto for 'right'.
24 *
25 * But currently we can only assume that data is distributed in a typical way.
26 */
27
28/*@ \mpi_collective(MPI_COMM_WORLD, P2P):
29 @ requires rank == \mpi_comm_rank;
30 @ requires nxl > 0 && nxl < DATA_LIMIT;
31 @ requires \mpi_valid(u, nxl + 2, MPI_DOUBLE);
32 @ requires left != \mpi_comm_rank &&
33 @ ( 0 <= left && left < \mpi_comm_size ||
34 @ left == MPI_PROC_NULL );
35 @ requires right != \mpi_comm_rank &&
36 @ ( 0 <= right && right < \mpi_comm_size ||
37 @ right == MPI_PROC_NULL );
38 @ requires right != left;
39 @ behavior hasLeft:
40 @ assumes left != MPI_PROC_NULL;
41 @ requires rank == \on(left, right); // I'm the 'right' of my left
42 @ assigns \mpi_region(u, 1, MPI_DOUBLE);
43 @ ensures \on(left, u[nxl]) == u[0] && \on(left, u[nxl+1]) == u[1];
44 @ waitsfor left;
45 @ behavior hasRight:
46 @ assumes right != MPI_PROC_NULL;
47 @ requires rank == \on(right, left); // I'm the 'left' of my right
48 @ assigns \mpi_region(&u[nxl+1], 1, MPI_DOUBLE);
49 @ ensures \on(right, u[1]) == u[nxl + 1] && \on(right, u[1]) == u[nxl]; // intentianal error
50 @ waitsfor right;
51 @*/
52void exchange_ghost_cells() {
53 MPI_Sendrecv(&u[1], 1, MPI_DOUBLE, left, 0,
54 &u[nxl+1], 1, MPI_DOUBLE, right, 0,
55 MPI_COMM_WORLD, MPI_STATUS_IGNORE);
56 MPI_Sendrecv(&u[nxl], 1, MPI_DOUBLE, right, 0,
57 &u[0], 1, MPI_DOUBLE, left, 0,
58 MPI_COMM_WORLD, MPI_STATUS_IGNORE);
59 printf("rank=%d, left=%d, right=%d\n", rank, left, right);
60}
Note: See TracBrowser for help on using the repository browser.