source: CIVL/examples/omp/canonicalForLoops.c@ 83af34d

1.23 2.0 main test-branch
Last change on this file since 83af34d was 59eb487, checked in by Ziqing Luo <ziqing@…>, 12 years ago

A new exmaple for testing canonical for loops

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

  • Property mode set to 100644
File size: 671 bytes
Line 
1#include <omp.h>
2#include <stdio.h>
3
4int main (int argc, char * argv[]){
5 double a[3];
6 double b[3];
7 double c[3];
8 int zero = 0;
9 int three = 3;
10 int one = 1;
11 int i;
12
13#pragma omp parallel
14 {
15#pragma omp for
16 for(i=zero; three > i; i+=one)
17 a[i] = i;
18 }
19#pragma omp parallel
20 {
21#pragma omp for
22 for(int j=three; j > zero; j = j - 1){
23 b[three - j] = three - j;
24 }
25 }
26
27#pragma omp parallel
28 {
29#pragma omp for
30 for(int j=three; j >= one; j--){
31 c[three - j] = three - j;
32 }
33 }
34
35 //Properties checking
36 for(int j = 0; j<three; j++){
37 $assert a[j] == b[j];
38 $assert b[j] == j;
39 $assert c[j] == b[j];
40 }
41 return 0;
42}
Note: See TracBrowser for help on using the repository browser.