Intel® Fortran Compiler 16.0 User and Reference Guide
Puts automatic arrays and arrays created for temporary computations on the heap instead of the stack.
Linux and OS X: | -heap-arrays [size] -no-heap-arrays |
Windows: | /heap-arrays[:size] /heap-arrays- |
size |
Is an integer value representing the size of the arrays in kilobytes. Arrays smaller than size are put on the stack. |
-no-heap-arrays or /heap-arrays- |
The compiler puts automatic arrays and temporary arrays in the stack storage area. |
This option puts automatic arrays and arrays created for temporary computations on the heap instead of the stack.
When this option is specified, automatic (temporary) arrays that have a compile-time size greater than the value specified for size are put on the heap, rather than on the stack. If the compiler cannot determine the size at compile time, it always puts the automatic array on the heap.
If size is specified, the value is only used when the total size of the temporary array or automatic array can be determined at compile time, using compile-time constants. Any arrays known at compile-time to be larger than size are allocated on the heap instead of the stack. For example, if 10 is specified for size:
All automatic and temporary arrays equal to or larger than 10 KB are put on the heap.
All automatic and temporary arrays smaller than 10 KB are put on the stack.
If size is omitted, and the size of the temporary array or automatic array cannot be determined at compile time, it is assumed that the total size is greater than size and the array is allocated on the heap.
Visual Studio: Optimization > Heap Arrays
Eclipse: None
Xcode: Optimization > Heap Arrays
None
In Fortran, an automatic array gets its size from a run-time expression. For example:
RECURSIVE SUBROUTINE F( N ) INTEGER :: N REAL :: X ( N ) ! an automatic array REAL :: Y ( 1000 ) ! an explicit-shape local array on the stack
Array X in the example above is affected by the heap-array option; array Y is not.
Temporary arrays are often created before making a routine call, or when an array operation detects overlap. For example:
integer a(10000) a(2:) = a(1:ubound(a,dim=1)-1)
In this case, the array assignment uses a temporary intermediate array because there is clearly an overlap between the right hand side and the left hand side of the assignment.
If you specify the heap-arrays option, the compiler creates the temporary array on the heap.
If you specify the heap-arrays option with size 50, the compiler creates the temporary array on the stack. This is because the size of the temporary intermediate array can be determined at compile time (40Kb), and it's size is less than the size value.
In the following example, a contiguous array is created from the array slice declaration and passed on:
call somesub(a(1:10000:2))
If you specify the heap-arrays option, the compiler creates the temporary array on the heap.
If you specify the heap-arrays option with size 25, the compiler creates the temporary array on the stack. This is because the size of the temporary intermediate array at compile time is only 20Kb.