[Patch, Fortran] PR42517: Bogus runtime error with -fopenmp -fcheck=recursion

H.J. Lu hjl.tools@gmail.com
Wed Dec 30 01:38:00 GMT 2009


On Tue, Dec 29, 2009 at 9:55 AM, Janus Weil <janus@gcc.gnu.org> wrote:
> Hi all,
>
> I recently noticed that -fcheck=recursion does not work together with
> OpenMP. This is not surprising, since all that the recursion check
> does is setting some internal logical variable to true when entering
> the procedure and setting it back to false when leaving. So that, if
> the procedure is already being executed, a second instance of that
> procedure can detect this situation and throw a runtime error.
>
> Now, in an OpenMP program you typically have several parallel threads,
> and any procedure can simultaneously be executed in multiple threads
> without being called recursively. Therefore the recursion check simply
> does not work for this case and throws false errors galore.
>
> The simplest way to avoid this false alarm is to disable the recursion
> checking when -fopenmp is given. This is what the attached patch does.
> It also documents this behavior in the manual. I think disabling the
> recursion check is most important for cases where -fopenmp is used
> together with -fcheck=all, since the other checks might still be
> useful.
>
> Surely there are ways to make the check work also for parallel
> programs. E.g. one could use a logical array (instead of a scalar) for
> each procedure, which would hold the information for each thread
> number, so that one would only get a runtime error if a procedure is
> being executed twice in a single thread. The question is if it's worth
> the trouble. I'm not very keen on doing this right now, and it's
> surely not stage-4 compatible, but one can leave it as an option for
> the future.
>
> So, is the attached patch ok for trunk? It was regtested on
> x86_64-unknown-linux-gnu.
>
> Cheers,
> Janus
>
>
> gcc/fortran/
> 2009-12-29 Janus Weil  <janus@gcc.gnu.org>
>
>        PR fortran/42517
>        * invoke.texi: Document the interference of
>        -fcheck=recursion and -fopenmp.
>        * trans-decl.c (gfc_generate_function_code): Disable -fcheck=recursion
>        when used with -fopenmp.
>
> gcc/testsuite/
> 2009-12-29  Janus Weil  <janus@gcc.gnu.org>
>
>        PR fortran/42517
>        * gfortran.dg/gomp/recursion1.f90: New test.
>

I have seen those on Linux/ia32:

FAIL: gfortran.dg/gomp/recursion1.f90  -O0  (test for excess errors)
FAIL: gfortran.dg/gomp/recursion1.f90  -O1  (test for excess errors)
FAIL: gfortran.dg/gomp/recursion1.f90  -O2  (test for excess errors)
FAIL: gfortran.dg/gomp/recursion1.f90  -O3 -fomit-frame-pointer  (test
for excess errors)
FAIL: gfortran.dg/gomp/recursion1.f90  -O3 -fomit-frame-pointer
-funroll-all-loops -finline-functions  (test for excess errors)
FAIL: gfortran.dg/gomp/recursion1.f90  -O3 -fomit-frame-pointer
-funroll-loops  (test for excess errors)
FAIL: gfortran.dg/gomp/recursion1.f90  -O3 -g  (test for excess errors)
FAIL: gfortran.dg/gomp/recursion1.f90  -Os  (test for excess errors)


-- 
H.J.



More information about the Gcc-patches mailing list