source: CIVL/examples/library/omp/barrierFlush.cvl@ fffb3b88

1.23 2.0 main test-branch
Last change on this file since fffb3b88 was 3ff27cf, checked in by Manchun Zheng <zmanchun@…>, 11 years ago

updated examples since $assert/$assume has been changed to functions; fixed the model builder for the new side-effect remover.

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

  • Property mode set to 100644
File size: 995 bytes
Line 
1#include<civlc.cvh>
2#include<civl-omp.cvh>
3#include<stdio.h>
4
5void main(){
6 int data = 123;
7 $omp_gteam gteam = $omp_gteam_create($here, 3);
8 $omp_gshared gshared = $omp_gshared_create(gteam, &data);
9
10 void thread(int tid) {
11 int data_local;
12 int data_status;
13 int private;
14
15 $omp_team team = $omp_team_create($here, gteam, tid);
16 $omp_shared shared = $omp_shared_create(team, gshared, &data_local, &data_status);
17 printf("Hello from thread %d\n", tid);
18 $omp_read(shared, &private, &data_local);
19 $assert(private == 123);
20 if(tid == 0){
21 // data = 456;
22 int tmp = 456;
23
24 $omp_write(shared, &data_local, &tmp);
25 }
26 $omp_barrier_and_flush(team);
27 $omp_read(shared, &private, &data_local);
28 $assert(private == 456);
29 $omp_shared_destroy(shared);
30 $omp_team_destroy(team);
31 }
32
33 $parfor (int i: ($domain){ 0 .. 2 }) {
34 thread(i);
35 }
36 $assert(data == 456);
37 $omp_gshared_destroy(gshared);
38 $omp_gteam_destroy(gteam);
39}
Note: See TracBrowser for help on using the repository browser.