This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
Re: [Patch, Fortran] PR42517: Bogus runtime error with -fopenmp -fcheck=recursion
- From: Dave Korn <dave dot korn dot cygwin at googlemail dot com>
- To: Janus Weil <janus at gcc dot gnu dot org>
- Cc: gfortran <fortran at gcc dot gnu dot org>, gcc-patches <gcc-patches at gcc dot gnu dot org>
- Date: Tue, 29 Dec 2009 18:31:07 +0000
- Subject: Re: [Patch, Fortran] PR42517: Bogus runtime error with -fopenmp -fcheck=recursion
- References: <854832d40912290955s4a201a69m2c1d21557d7c0215@mail.gmail.com>
Janus Weil wrote:
> 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.
> Surely there are ways to make the check work also for parallel
> programs.
Yes, that's what TLS was made for; I hesitate to use the word "trivial"
since it won't be, but conceptually it is: just create a __thread variable
instead of an ordinary static one for the recursion check guard var.
cheers,
DaveK