source: CIVL/examples/omp/overflush.cvl@ 8190175

main test-branch
Last change on this file since 8190175 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: 791 bytes
Line 
1#define N 3
2double A[N];
3
4void fill_rand(int n, double* p) {
5 for (int i = 0; i < n; i++)
6 $havoc(p+i);
7}
8
9double Sum_array(int n, double* p) {
10 double sum = 0;
11
12 for (int i = 0; i < n; i++)
13 sum += p[i];
14 return sum;
15}
16
17
18int main() {
19 double sum = 0;
20 int flag=0, flg_tmp;
21
22#pragma omp parallel sections shared(A, flag, sum) private(flg_tmp)
23 {
24#pragma omp section
25 {
26 for (int i = 0; i < N; i++) {
27 double tmp;
28
29 $havoc(&tmp);
30 A[i] = tmp;
31 }
32#pragma omp flush
33#pragma omp atomic write
34 flag=1;
35 //#pragma omp flush(flag)
36 }
37#pragma omp section
38 {
39 while (1) {
40 //#pragma omp flush(flag)
41#pragma omp atomic read
42 flg_tmp = flag;
43 if (flg_tmp == 1) break;
44 }
45#pragma omp flush
46 for (int i = 0; i < N; i++)
47 sum += A[i];
48 }
49 }
50}
Note: See TracBrowser for help on using the repository browser.