| | 154 | |
| | 155 | * Example 2 : ( `DRB014-outofbounds-orig-yes.c` from DataRaceBench v1.2.0 ) |
| | 156 | {{{ |
| | 157 | #include <stdio.h> |
| | 158 | int main(int argc, char* argv[]) |
| | 159 | { |
| | 160 | int i,j; |
| | 161 | int n=10, m=10; |
| | 162 | double b[n][m]; |
| | 163 | #pragma omp parallel for private(j) |
| | 164 | for (i=1;i<n;i++) |
| | 165 | for (j=0;j<m;j++) // Note there will be out of bound access |
| | 166 | b[i][j]=b[i][j-1]; |
| | 167 | |
| | 168 | printf ("b[50][50]=%f\n",b[50][50]); |
| | 169 | |
| | 170 | return 0; |
| | 171 | } |
| | 172 | }}} |
| | 173 | * OpenMP Simplifier proves that `b[i][j]` and `b[i][j-1]` that accessed by different threads which hold different values of `i` will have no data race as long as no array out-of-bound error happens. |
| | 174 | * OpenMP Simplifier sequentializes the OpenMP program while the verification condition for array out-of-bound freedom will be checked by CIVL by default. |
| | 175 | * The CIVL back-end runs the sequentialized program and detects the array out-of-bound access. |
| | 176 | |
| | 177 | Example 3 |
| | 178 | {{{ |
| | 179 | #include <omp.h> |
| | 180 | int main() |
| | 181 | { |
| | 182 | int a[50],i; |
| | 183 | |
| | 184 | a[0] = 1; |
| | 185 | #pragma omp parallel for |
| | 186 | for(i=1; i<49; i++) |
| | 187 | { |
| | 188 | int c; |
| | 189 | |
| | 190 | c = i + 10; |
| | 191 | a[i + c] = a[i + c]; |
| | 192 | } |
| | 193 | } |
| | 194 | }}} |
| | 195 | * OpenMP Simplifier cannot prove data-race freedom for this program. |
| | 196 | * OpenMP2CIVL Transformer will transform this program to a equivalent CIVL-C program for model checking |