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

FORALL statement and stack temps

ulsterjam
Beginner
742 Views

Hi all,

Can "those in the the know" confirm if a stack temp is created for the following forall statement:

forall (index=start:finish:step) array(index)=array(index) * scalar

(where start!=lbound(array) and/or finish!=ubound(array) )

This is related to a previous post I made regarding stack temps and implicit array assignments of the form:

array(:) = array(:) * scalar

I had thought that the forall statement helped the compiler perform some autoparallelisation due to non-dependencies in the forall loop expression. Unfortunately, my code is now terminating with seg faults when my array
size is > 2^24 ( I run some big calculations).

I had assumed that a forall was just syntatic sugar for special cases of an explicit do loop and hence would not incurr stack temps. My tests though have proved otherwise. Can someone confirm this?

By the way when I replace the forall with an explicit do loop all is well. Also the -heap-array parameter has no effect on the forall as far as I can tell.

Regards,

Tim.

0 Kudos
2 Replies
jimdempseyatthecove
Honored Contributor III
742 Views

Tim,

This is easy enough for you to check out. Compile with array bounds checking Off. Place a break point on the forall. Then on break open a Dissassembly window. Don't be intimidated by assembler code. Step through the assembly code, you should be smart enough to follow what is happening and see if a stack temp is used.

Jim Dempsey

0 Kudos
TimP
Honored Contributor III
742 Views
There is no reason to use forall() in place of a simple array assignment. Unless you used a parallelization option, I can't think of a good reason for a difference in generated code. If you are interested, why not compile the source file with -S ? ifortputs the Fortran source lines in the comment fields on the right in the .s file.
0 Kudos
Reply