Static Analysis Problem Type Reference
A worksharing construct appears in a context where it will not execute in parallel.
An OpenMP* worksharing construct defines a collection of units of work that could be executed in parallel. However, the presence of a worksharing construct alone does not create a team of threads that will execute those units of work in parallel. Rather, a worksharing region binds to the innermost enclosing PARALLEL region. This error indicates that this worksharing construct is not (or not always) dynamically enclosed within a PARALLEL region and, therefore, will (or may) not execute in parallel.
The most straightforward fix is to replace the worksharing construct with a parallel worksharing construct. For example, instead of "#pragma omp for" (for C) or "!$OMP DO" (for FORTRAN), use "#pragma omp parallel for" or "!$OMP PARALLEL DO".
|
ID |
Code Location |
Description |
|---|---|---|
|
1 |
OpenMP declaration |
The location of the worksharing construct |
void f(int n, double *a1, double *a2, double *a3)
{
int i;
// should be #pragma omp parallel for unless called from a parallel region
#pragma omp for
for (i = 1; i++; i < n) {
a1[i] = a2[i] * a3[i];
}
}
Here is the same example in FORTRAN:
subroutine F(N, A1, A2, A3)
integer N, I
real A1(N), A2(N), A3(N)
! Should be $OMP PARALLEL DO if not called from parallel region
!$OMP DO
do I = 1, N
A1[I] = A2[I] * A3[I]
end do
!$OMP END DO
end subroutine F