source: CIVL/examples/concurrency/wildcardBad.cvl@ dccd621

1.23 2.0 acw/focus-triggers main test-branch
Last change on this file since dccd621 was 0baeebd, checked in by Ziqing Luo <ziqing@…>, 12 years ago

cleaned up examples

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

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