public inbox for fortran@gcc.gnu.org
 help / color / mirror / Atom feed
* Local arrays of variable size are allocated
@ 2016-04-13 17:09 Alberto Luaces
  0 siblings, 0 replies; 5+ messages in thread
From: Alberto Luaces @ 2016-04-13 17:09 UTC (permalink / raw)
  To: fortran

Hello,

in a procedure as

--8<---------------cut here---------------start------------->8---
subroutine name (size)
  integer, intent(in) :: size
  integer:: v(3, size)

  v(:,:) = 0
  
end subroutine name
--8<---------------cut here---------------end--------------->8---

I can see that "v" is allocated with malloc() on entry (and freed on
exit), instead of being mapped into the stack.

I imagine this is done in a general basis as a protection from stack
overflows, but in my case it is adding a significant overhead.

Can adjust anything so only stack space is used?

Thanks,

-- 
Alberto

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Local arrays of variable size are allocated
  2016-04-13 20:44 ` Dominique d'Humières
@ 2016-04-13 20:52   ` Alberto Luaces
  0 siblings, 0 replies; 5+ messages in thread
From: Alberto Luaces @ 2016-04-13 20:52 UTC (permalink / raw)
  To: fortran

Dominique d'Humières writes:

>> Spot on, Dominique! -Ofast triggers "-fstack-arrays", which does exactly
>> what I need.
>
> Beware of pr68829.
>

Thanks!  Yes, I imagined that the default was overly-conservative in
order to avoid stack overflows.  I will be watching for that, even my
arrays are pretty small.  That was the reason why I had a big overhead
in small, frequent-called functions.

-- 
Alberto

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Local arrays of variable size are allocated
  2016-04-13 18:18 Dominique d'Humières
  2016-04-13 19:41 ` Alberto Luaces
@ 2016-04-13 20:44 ` Dominique d'Humières
  2016-04-13 20:52   ` Alberto Luaces
  1 sibling, 1 reply; 5+ messages in thread
From: Dominique d'Humières @ 2016-04-13 20:44 UTC (permalink / raw)
  To: aluaces; +Cc: fortran

> Spot on, Dominique! -Ofast triggers "-fstack-arrays", which does exactly
> what I need.

Beware of pr68829.

Dominique

> Le 13 avr. 2016 à 20:18, Dominique d'Humières <dominiq@lps.ens.fr> a écrit :
> 
>> Can adjust anything so only stack space is used?
> 
> Which options are you using? You may want to try -Ofast.
> 
> Dominique
> 

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Local arrays of variable size are allocated
  2016-04-13 18:18 Dominique d'Humières
@ 2016-04-13 19:41 ` Alberto Luaces
  2016-04-13 20:44 ` Dominique d'Humières
  1 sibling, 0 replies; 5+ messages in thread
From: Alberto Luaces @ 2016-04-13 19:41 UTC (permalink / raw)
  To: fortran

Dominique d'Humières writes:

>> Can adjust anything so only stack space is used?
>
> Which options are you using? You may want to try -Ofast.

Spot on, Dominique! -Ofast triggers "-fstack-arrays", which does exactly
what I need.

-- 
Alberto

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Local arrays of variable size are allocated
@ 2016-04-13 18:18 Dominique d'Humières
  2016-04-13 19:41 ` Alberto Luaces
  2016-04-13 20:44 ` Dominique d'Humières
  0 siblings, 2 replies; 5+ messages in thread
From: Dominique d'Humières @ 2016-04-13 18:18 UTC (permalink / raw)
  To: aluaces; +Cc: fortran

> Can adjust anything so only stack space is used?

Which options are you using? You may want to try -Ofast.

Dominique

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2016-04-13 20:52 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-04-13 17:09 Local arrays of variable size are allocated Alberto Luaces
2016-04-13 18:18 Dominique d'Humières
2016-04-13 19:41 ` Alberto Luaces
2016-04-13 20:44 ` Dominique d'Humières
2016-04-13 20:52   ` Alberto Luaces

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).