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

checking array bounds slows the program

Intel_C_Intel
Employee
546 Views
Hi,
I've noticed that the /check:bounds compile option (check array and string bounds) can really slow down the program. In my case a matrix solver subroutine (lots of array operations) takes twice as long or longer to run if the array bounds option is used. Does a large amount of overhead code get added to the compiled routine to check the array bounds? Should I expect such a dramatic slow down due to the check bounds option? If such a large slow down is expected, then I'll just use the array bounds check for testing and then turn it off for the release. I'm using IVF Version 9.0.2713.2003, but am working on downloading the 9.0.028 update.
Thanks for your help and advice,
Greg
0 Kudos
4 Replies
Steven_L_Intel1
Employee
546 Views
I know we've very recently done some work to eliminate unnecessary bounds checking for many whole-array operations. I don't think that change has made it out to a server near you yet. The issue addressed is when you do something like:

A = B

where A and B are arrays, the compiler was individually checking each element transfer.

Nevertheless, array bounds checking WILL slow down your code, no matter what, so if performance is important to you, you should keep it off for production builds.
0 Kudos
Intel_C_Intel
Employee
546 Views
Steve, thanks for the information. If the analysis time only increased 10% or 20% with the array bounds check we could probably live with it for the advantage of trapping array errors during run time. Instead, I think we will need to rely on testing and then turn the array bounds checking off for release for the faster analysis.
Thanks,
Greg
0 Kudos
Steven_L_Intel1
Employee
546 Views
I would not expect more than 10-20% once we get the whole-array issue sorted out.
0 Kudos
Intel_C_Intel
Employee
546 Views

Hello,

Depending of the usage of the software- programming philosophy may vary a lot, and the following philosophy may or may not be recommended for your application. However, it is sometimes useful to combine:

1. Extensive checking in DEBUG mode, with

2. Defensive programming inRELEASE mode.

Then bugs may be catched inDEBUG mode simultaneously as bugs to not result in a crash in RELEASE mode. In terms of array bounds checking, this can be applied inDEBUG mode, while one can force the array index to always be valid in RELEASE mode, in the following way:

- DEBUG mode: IF (Something is wrong) THEN Stop and catch bug.

- RELEASE mode: IF (Something is wrong) THEN Something is not wrong.

Note that this philiosophy clearly does not apply to all types of software, however the DEBUG mode is, as the name tells you, a mode to detect BUGS, and fix them, while RELEASE mode should be efficient and not crash. For special types of failures, it is also possible to detect if some erroneous calculations has been carried out in RELEASE mode (without crashing the program), which then may be investigted further in DEBUG mode.

Best Regards,

Lars Petter Endresen

0 Kudos
Reply