The compiler detects some restrictions noted in the OpenMP* API Versions 2.0 and 2.5. When static verification is enabled, the compiler performs some additional checks against restrictions in the OpenMP API, including checks for the correct use of the following:
Example: Incorrect usage of OpenMP directives
File gafort.f90 contains the following lines:
310 !$OMP PARALLEL DO ORDERED
311 ! create an array of locks
312 !$ DO i = 1,indmax
313 !$ CALL omp_init_lock(lck(i))
314 !$ ENDDO
315 !$OMP END PARALLEL DO
The parallel region has the clause ORDERED but has no corresponding ORDERED OpenMP directive. Static verification issues the following message:
gafort.f90(310): error #12204: ORDERED directives must appear in the dynamic extent of a DO or PARALLEL DO directive which has an ORDERED clause
Static verification checks for data dependencies between objects in loops with parallel directives, like !$OMP PARALLEL DO or !$OMP DO inside parallel region.
It then applies the compiler's algorithms for dependence analysis and also other algorithms to expand data dependence analysis to the global program context.
Example 1:
1 #include <stdio.h>
2 int
3 main() {
4 int j;
5 float a[100], b[100];
6 b[0] = 1.0;
7 a[0] = 2.0 ;
8 #pragma omp parallel shared(a,b)
9 #pragma omp for
10 for (j=1;j<100;j++) {
11 a[j] = 3.6*b[j-1];
12 b[j] = a[j-1]/3;
13 }
14 for(j=0;j<100;j++)
15 printf("%f %f\n", a[j], b[j]);
16 printf("\n");
17 return 0;
18 }
Static verification issues the following warnings:
omp.c(11): warning #12251: flow data dependence from line 11 to line 12, due to "a" may lead to incorrect program execution in parallel mode
omp.c(12): warning #12251: flow data dependence from line 12 to line 11, due to "b" may lead to incorrect program execution in parallel mode
Example 2:
File gafort.f90 contains the following lines:
1089 !$OMP PARALLEL PRIVATE(rand, iother, itemp, temp, my_cpu_id)
1090 my_cpu_id = 1
1091 !$ my_cpu_id = omp_get_thread_num() + 1
1092 !$OMP DO
1093 DO j=1,npopsiz-1
1094 CALL ran3(1,rand,my_cpu_id,0)
1095 iother=j+1+DINT(DBLE(npopsiz-j)*rand)
…
1103 itemp(1:nchrome)=iparent(1:nchrome,iother)
1104 iparent(1:nchrome,iother)=iparent(1:nchrome,j)
1105 iparent(1:nchrome,j)=itemp(1:nchrome)
…
1116 END DO
1117 !$OMP END DO
1118 !$OMP END PARALLEL
Static verification issues following warnings:
gafort.f90(1103): warning #12251: anti data dependence from line 1103 to line 1104, due to "IPARENT" may lead to incorrect program execution in parallel mode
gafort.f90(1103): warning #12251: anti data dependence from line 1103 to line 1105, due to "IPARENT" may lead to incorrect program execution in parallel mode
gafort.f90(1104): warning #12251: anti data dependence from line 1104 to line 1104, due to "IPARENT" may lead to incorrect program execution in parallel mode
gafort.f90(1104): warning #12251: flow data dependence from line 1104 to line 1103, due to "IPARENT" may lead to incorrect program execution in parallel mode
gafort.f90(1104): warning #12251: flow data dependence from line 1104 to line 1104, due to "IPARENT" may lead to incorrect program execution in parallel mode
gafort.f90(1105): warning #12251: flow data dependence from line 1105 to line 1103, due to "IPARENT" may lead to incorrect program execution in parallel mode