Jump to content United States-English
HP.com Home Products and Services Support and Drivers Solutions How to Buy
» Contact HP
More options
HP.com home
Parallel Programming Guide for HP-UX Systems: K-Class and V-Class Servers > Chapter 5 Loop and cross-module optimization features

Test promotion

» 

Technical documentation

Complete book in PDF
» Feedback
Content starts here

 » Table of Contents

 » Glossary

Test promotion involves promoting a test out of the loop that encloses it by replicating the containing loop for each branch of the test. The replicated loops contain fewer tests than the originals, or no tests at all, so the loops execute much faster. Multiple tests are promoted, and copies of the loop are made for each test.

Test promotion

Consider the following Fortran loop:

DO I=1, 100
DO J=1, 100
IF(FOO .EQ. BAR) THEN
A(I,J) = I + J
ELSE
A(I,J) = 0
ENDIF
ENDDO
ENDDO

Test promotion (and loop interchange) produces the following code:

IF(FOO .EQ. BAR) THEN
DO J=1, 100
DO I=1, 100
A(I,J) = I + J
ENDDO
ENDDO
ELSE
DO J=1, 100
DO I=1, 100
A(I,J) = 0
ENDDO
ENDDO
ENDIF

For loops containing large numbers of tests, loop replication can greatly increase the size of the code.

Each DO loop in Fortran and for loop in C and C++ whose bounds are not known at compile-time is implicitly tested to check that the loop iterates at least once. This test may be promoted, with the promotion noted in the Optimization Report. If you see unexpected promotions in the report, this implicit testing may be the cause. For more information on the Optimization Report, see "Optimization Report," on page 151.

Printable version
Privacy statement Using this site means you accept its terms Feedback to webmaster
© Hewlett-Packard Development Company, L.P.