Improper nesting of OpenMP* constructs

Two OpenMP* constructs are improperly (dynamically) nested.

The OpenMP specification imposes several restrictions on how OpenMP constructs can be dynamically nested, that is, which OpenMP constructs can be legally encountered during execution of another region. OpenMP parallel regions can be nested within one another, but some restrictions apply. Generally speaking, two parallel regions can only be nested if there is an intermediate single threaded region, as created by a SINGLE, CRITICAL, or MASTER directive.

To be precise, the following restrictions apply. In the following, the term "worksharing region" is shorthand for any one of the following constructs: loop (FOR/DO), SECTIONS, SINGLE, or WORKSHARE. The term "closely nested region" means a region that is dynamically nested inside another region with no parallel region nested between them.

ID

Observation

Description

1

OpenMP declaration

The location of the outer construct

2

OpenMP usage error

The location of the illegally nested construct

Examples


int glob;

void work(int i, int j) {
    /* incorrect nesting of regions */
    #pragma omp single
    {
        glob += j;
    }
}

void wrong(int n)
{
    int i;
    #pragma omp parallel for
    for (i = 0; i < n; i++) {
        work(i, 0);
    }
}
        

Copyright © 2010, Intel Corporation. All rights reserved.