source: CIVL/examples/library/omp/sections.cvl@ 9becdb9

1.23 2.0 main test-branch
Last change on this file since 9becdb9 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: 1.2 KB
Line 
1#include<civlc.cvh>
2#include<civl-omp.cvh>
3#include<stdio.h>
4
5#define numSections 6
6
7void main(){
8 int data[numSections];
9 $omp_gteam gteam = $omp_gteam_create($here, 3);
10 $omp_gshared gshared = $omp_gshared_create(gteam, &data);
11
12 void thread(int tid) {
13 int data_local[numSections];
14 int data_status[numSections];
15 $omp_team team = $omp_team_create($here, gteam, tid);
16 $omp_shared shared = $omp_shared_create(team, gshared, &data_local, &data_status);
17 $domain(1) my_secs = $omp_arrive_sections(team, 0, numSections);
18
19 printf("Hello from thread %d\n", tid);
20 $for (int i : my_secs) {
21 switch (i) {
22 case 0: {
23 $omp_write(shared, &data_local[i], &tid);
24 break;
25 }
26 default: {
27 $omp_write(shared, &data_local[i], &tid);
28 }
29 } /* end of switch */
30 } /* end of $for loop */
31 $omp_barrier_and_flush(team);
32 $omp_shared_destroy(shared);
33 $omp_team_destroy(team);
34 }
35
36 $parfor (int i: ($domain){ 0 .. 2 }) {
37 thread(i);
38 }
39 for(int i = 0; i < numSections; i++){
40 $assert(i % 3 == data[i]);
41 //printf("*data*[%d] = %d", i, data[i]);
42 }
43 $omp_gshared_destroy(gshared);
44 $omp_gteam_destroy(gteam);
45}
Note: See TracBrowser for help on using the repository browser.