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

Stack vs. Save attribute and performance

ahasan
Beginner
389 Views
If a subroutine or functions is called repeatedly, such as the MainWindowProc() in a win32 program, is it better to use the SAVE attribute for all variables in that function or subroutine rather than using the stack?
I am curious about how this affects program performance or efficiency.
0 Kudos
2 Replies
Steven_L_Intel1
Employee
389 Views
Using SAVE will defeat some optimizations. Such routines don't tend to have large local variables, so the performance difference relative to the allocation type is probably not measurable. Stack is friendlier to cache than static.
0 Kudos
ahasan
Beginner
389 Views
Thanks Steve. I appreciate the reply and info.
0 Kudos
Reply