Function causes an illegal exit from OpenMP* construct.
OpenMP constructs typically apply to a structured block, that is, statement with a single point of entry and exit. A function called within an OpenMP construct is not permitted to escape that construct by calling longjmp or by throwing a C++ exception that is caught outside. Similarly, it is illegal to use setjmp inside a parallel region, as this can cause the region to be entered using a non-standard flow of control.
Entering or leaving OpenMP constructs in this way can bypass critical compiler generated code to manage the runtime environment. Thus, this kind of indirect flow of control can disrupt the integrity of the OpenMP runtime environment. The C exit routine and FORTRAN STOP routine can be called inside an OpenMP construct. While they do indirectly leave the OpenMP construct, they normally cause the process to terminate.
ID |
Observation |
Description |
---|---|---|
1 |
OpenMP usage error |
The place the illegal exit happened |
#include <cstdio> #include <stdexcept> #include <omp.h> int main(int argc, char **argv) { try { #pragma omp parallel for ordered for (int i = 1; i < 100; i++) { if (i > 10) { // bad: exception not caught // inside parallel region throw std::runtime_error("test"); } #pragma omp ordered printf("test: %d\n", i); } } catch (std::runtime_error) { } return 0; }
Copyright © 2010, Intel Corporation. All rights reserved.