[PATCH, fortran] Add -frecursive and fix local array handling with -fopenmp
Janne Blomqvist
blomqvist.janne@gmail.com
Thu Aug 16 08:51:00 GMT 2007
On 8/15/07, Asher Langton <langton2@llnl.gov> wrote:
> Here's a patch to fix the OpenMP issue with local arrays being
> allocated statically, as discussed here:
>
> http://gcc.gnu.org/ml/fortran/2007-08/msg00000.html
>
> I also added an '-frecursive' flag, which sets max_stack_var_size to -1.
For a slightly modified approach, why not leave the -frecursive option
part of the patch out as unnecessary (one less option to clutter the
manual with :) ), and make flag_max_stack_var_size=-1 the default
rather than the current (arbitrary?) limit of 32768. Those who then
really want some cutoff size to store local variable statically can
then use the -fmax-stack-var-size= option explicitly rather than start
seeing weird effects for when going over the limit like Asher did when
using OpenMP (I guess it's not very obvious why things start to fail
in this case).
And, since running out of stack space due to large arrays on the stack
seems to be much more common in Fortran rather than recursing
infinitely, add something like the following to
libgfortran/runtime/main.c:
#include <sys/time.h>
#include <sys/resource.h>
#ifdef HAVE_GETRLIMIT && HAVE_SETRLIMIT
/* Try to remove stack space limits. */
void
set_stack_rlimit()
{
struct rlimit rlim;
getrlimit (RLIMIT_STACK, &rlim);
rlim.rlim_cur = rlim.rlim_max;
setrlimit (RLIMIT_STACK, &rlim);
// + some appropriate error handling, checking return values etc.
}
#endif
--
Janne Blomqvist
More information about the Fortran
mailing list