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:
851 bytes
|
| Line | |
|---|
| 1 | /* wildcard_coassert_bad: A root process receives messages twice from
|
|---|
| 2 | every other process using a wildcard receive. This program has a
|
|---|
| 3 | data race-condition. */
|
|---|
| 4 | #include <mpi.h>
|
|---|
| 5 | #include <stdio.h>
|
|---|
| 6 | #include <civl-mpi.cvh>
|
|---|
| 7 |
|
|---|
| 8 | int size, rank, x;
|
|---|
| 9 | int root = 0;
|
|---|
| 10 |
|
|---|
| 11 | void recv(int iter) {
|
|---|
| 12 | for(int i = 1; i < size; i++)
|
|---|
| 13 | MPI_Recv(&x, 1, MPI_INT, MPI_ANY_SOURCE, 0, MPI_COMM_WORLD, MPI_STATUS_IGNORE);
|
|---|
| 14 | $mpi_coassert(MPI_COMM_WORLD, x == iter);
|
|---|
| 15 | }
|
|---|
| 16 |
|
|---|
| 17 | void send(int msg) {
|
|---|
| 18 | MPI_Send(&msg, 1, MPI_INT, root, 0, MPI_COMM_WORLD);
|
|---|
| 19 | printf("Proc:%d sends %d\n", rank, msg);
|
|---|
| 20 | //@ assert x@root == msg;
|
|---|
| 21 | }
|
|---|
| 22 |
|
|---|
| 23 | int main(int argc, char * argv[]) {
|
|---|
| 24 | MPI_Init(&argc, &argv);
|
|---|
| 25 | MPI_Comm_rank(MPI_COMM_WORLD, &rank);
|
|---|
| 26 | MPI_Comm_size(MPI_COMM_WORLD, &size);
|
|---|
| 27 | for(int i = 0; i < 2; i++)
|
|---|
| 28 | if(!rank)
|
|---|
| 29 | recv(i);
|
|---|
| 30 | else
|
|---|
| 31 | send(i);
|
|---|
| 32 | MPI_Finalize();
|
|---|
| 33 | return 0;
|
|---|
| 34 | }
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.