Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

/heap_arrays

Ralf
Beginner
574 Views
Hi group,
A question about option/heap_arrays:
as I understand it, it will put automatic arrays on the heap instead of the stack.
Will the automatic arrays therefore "exist" in the heap after the subroutine-exit?
Ist itpreferable to declare the current automatic arrays as allocatable arrays ?
Cheers
-Ralf
0 Kudos
4 Replies
mecej4
Honored Contributor III
574 Views
An option that would require that users change their source code (in order to deallocate at subroutine exit those local arrays that were allocated on the heap) would be quite unpopular. I believe that heap allocated arrays are managed separately by the Fortran runtime and are not accessible through the Fortran ALLOCATED() and DEALLOCATE() statements.

There is some overhead for garbage collection. That is why the compiler gives you the ability to specify a threshold for array sizes that has to be exceeded to become eligible for heap allocation.
0 Kudos
Steven_L_Intel1
Employee
574 Views
The temporaries allocated on the heap are automatically deallocated when they are no longer needed. This may be at routine exit, or earlier in some cases.
0 Kudos
Ralf
Beginner
574 Views
Ok, that's good to know - thanks!
0 Kudos
Steven_L_Intel1
Employee
574 Views
Quoting mecej4
There is some overhead for garbage collection. That is why the compiler gives you the ability to specify a threshold for array sizes that has to be exceeded to become eligible for heap allocation.

The option for the threshold is really not useful. At present it is effective only for automatic arrays whose size is known at compile time, which is very unlikely. There is no "garbage collection", but the compiler does keep a list, per routine, of heap-allocated temporaries and automatics and makes sure they are deleted on routine exit.

0 Kudos
Reply