source: CIVL/examples/messagePassing/wildcardBad.cvl@ ca5efc4

1.23 2.0 main test-branch
Last change on this file since ca5efc4 was e6b02c8, checked in by Manchun Zheng <zmanchun@…>, 12 years ago

updates CIVL to use the new ABC FrontEnd. tests updated accordingly when necessary.

git-svn-id: svn://vsl.cis.udel.edu/civl/trunk@1380 fb995dde-84ed-4084-dfe6-e5aef3e2452c

  • Property mode set to 100644
File size: 989 bytes
Line 
1#include <comm.cvh>
2#include <stdio.h>
3#include <mpi.h>
4
5$input int NPROCS = 3;
6CMPI_Gcomm __MPI_COMM_WORLD;
7void MPI_Process(int place){
8
9 MPI_Comm MPI_COMM_WORLD = CMPI_Comm_create($here, __MPI_COMM_WORLD, place);
10 int nprocs, rank, msg;
11 MPI_Status status;
12
13 __MPI_Init(&MPI_COMM_WORLD);
14 MPI_Comm_rank(MPI_COMM_WORLD, &rank);
15 MPI_Comm_size(MPI_COMM_WORLD, &nprocs);
16 if(rank != 0){
17 msg = rank;
18 MPI_Send(&msg, 1, MPI_INT, 0, 1, MPI_COMM_WORLD);
19 }
20 else{
21 int source;
22
23 msg = -1;
24 printf("I'm process %d :\n", rank);
25 MPI_Recv(&msg, 1, MPI_INT, $COMM_ANY_SOURCE, 1, MPI_COMM_WORLD, &status);
26 MPI_Recv(&msg, 1, MPI_INT, 1, 1, MPI_COMM_WORLD, &status);
27 }
28
29 CMPI_Comm_destroy(MPI_COMM_WORLD);
30}
31
32void main(){
33
34 $proc procs[NPROCS];
35
36 __MPI_COMM_WORLD = CMPI_Gcomm_create($root, NPROCS);
37 for(int i=0; i<NPROCS; i++)
38 procs[i] = $spawn MPI_Process(i);
39 for(int i=0; i<NPROCS; i++)
40 $wait(procs[i]);
41
42 CMPI_Gcomm_destroy(__MPI_COMM_WORLD);
43}
Note: See TracBrowser for help on using the repository browser.