Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

gfortran flag for intel's -heap-arrays [size]

What is the gfortran flag equivalent for intel ifort's

-heap-arrays [size]
like image 600
user189035 Avatar asked Apr 03 '14 08:04

user189035


People also ask

Is Ifort faster than gfortran?

On the kinds of programs I run ifort is usually about 30% faster than gfortran.

Does Intel oneAPI include Fortran?

Intel oneAPI is a cross-platform toolset that covers several programming languages including C, C++, Fortran and Python.

What is Flag in Fortran?

gfortran has many different command line options (also known as flags) that control what the compiler does and how it does it. To use these flags, simply include them on the command line when you run gfortran, e.g. $ gfortran -Wall -Wextra -c mysubroutine.f90 -o mysubroutine.o.


2 Answers

I've found this:

-fmax-stack-var-size=n This option specifies the size in bytes of the largest array that will be put on the stack; if the size is exceeded static memory is used (except in procedures marked as RECURSIVE). Use the option -frecursive to allow for recursive procedures which do not have a RECURSIVE attribute or for parallel programs. Use -fno-automatic to never use the stack. This option currently only affects local arrays declared with constant bounds, and may not apply to all character variables. Future versions of GNU Fortran may improve this behavior.

The default value for n is 32768.

from gfortran's website. I think it'll do the trick.

like image 84
user189035 Avatar answered Oct 07 '22 03:10

user189035


This is an old question, but the accepted answer is not fully correct and I would like to add context for future users like me who come across the post looking for answers.

I believe both intel's ifort and gcc's gfortran have some byte limit where arrays above said limit are not allocated on the stack, but instead are in static memory.

Intel's: -heap-arrays [size], will put any array bigger than [size] kilobytes on the heap, instead of in static memory or on the stack depending on the size.

Gcc does not have this option and instead only has -fmax-stack-var-size=n, where any variable above n bytes is not placed on the stack. The documentation (https://gcc.gnu.org/onlinedocs/gfortran/Code-Gen-Options.html) says:

if the size is exceeded static memory is used (except in procedures marked as RECURSIVE).

The key difference here is that these large variables are NOT guaranteed to be placed on the heap.

Therefore the two options from intel and gcc are not identical, and more care needs to be taken to ensure large arrays in gfortran are not shared in static memory.

like image 32
midnightGreen Avatar answered Oct 07 '22 04:10

midnightGreen