Now installed as r11-5571-gf4e7ea81d1369d4d6cb6d8e440aefb3407142e05.
Tobias
On 27.11.20 11:16, Tobias Burnus wrote:
Two fixes – simple, see patch + commit text.
Longer description:
* options:
Background:
- OpenMP, OpenACC and imply that a function is called
concurrently and -frecursive implies recusive. In all those
cases, the code may fail if a local variable is in static memory
instead of stack or heap. – If a user specified 'save', we
can assume/hope that they will deal with it - but with
-fno-automatic (→ 'save' implied), the flags clash.
- Additionally, to avoid placing local arrays in static memory,
for -fopenmp/-fopenacc -frecursive and 'unlimited' stack size
use for const-size arrays is implied.
This patch:
- Handle OpenACC as OpenMP (before it didn't imply -frecursive.
* Recursive run-time check. The current code currently generates:
subroutine foo()
logical, save :: currently_called = .false.
if (currently_called) error_stop "No recursive but called"
currently_called = .true.
...
... ! Rest of code, which could indirectly call this proc again
...
currently_called = .false.
end
This works well for recursive calls but less so for concurrency
(→ OpenMP, OpenACC).
As noted above, by default OpenMP/OpenACC implies -frecursive
and, hence, there is no recursive check generated.
The question is what code should be generated for, e.g.
-fno-automatic -fopenmp or -fopenacc -fmax-stack-var-size=20
In that case, -frecursive is unset. We have two choices:
- Either still always reset, which may not detect concurrent
use (including recursive + concurrent use) do to a race condition.
- Or avoid resetting the flag
But then calling the procedure twice (e.g. beginning + end of the
program) will generate a bogus error.
The current code does the second – at least for -fopenmp.
→ PATCH: Simply use the same condition twice instead of a complicated
test; do so via: 'if (recurcheckvar == NULL_TREE)'.
Current code:
tree recurcheckvar = NULL_TREE;
...
if ((gfc_option.rtcheck & GFC_RTCHECK_RECURSION)
&& !is_recursive && !flag_recursive && !sym->attr.artificial)
... // declare 'recurcheckvar', generate error-message code etc.
...
/* Reset recursion-check variable. */
if ((gfc_option.rtcheck & GFC_RTCHECK_RECURSION)
&& !is_recursive && !flag_openmp && recurcheckvar != NULL_TREE)
Comments? Suggestions? – If not, I will commit it as obvious in the next
days.
Tobias
-----------------
Mentor Graphics (Deutschland) GmbH, Arnulfstraße 201, 80634 München / Germany
Registergericht München HRB 106955, Geschäftsführer: Thomas Heurung, Alexander
Walter