Visible to Intel only — GUID: GUID-718E11DD-126E-42AA-A25B-3156308110A2
Visible to Intel only — GUID: GUID-718E11DD-126E-42AA-A25B-3156308110A2
GAP Message (Diagnostic ID 30531)
Message
Store the value of the upper-bound expression of the loop at line %d into a temporary local variable, and use this variable as the new upper-bound expression of the loop. To do this, insert a statement of the form "temp = upper-bound of loop" right before the loop, where "temp" is the newly created local variable. Choose a variable name that is unique, then replace the loop's original upper-bound expression with "temp".
Advice
Use a local-variable for the loop upper-bound if the upper-bound does not change during the execution of the loop. This enables the compiler to recognize the loop as a proper counted do loop, which enables various loop optimizations including vectorization and parallelization.
This message appears when the compiler cannot output the exact upper-bound variable to be replaced.
Example
Consider the following:
class FooClass {
public:
const int getValue() { return m_numTimeSteps;}
void Foo2(double* vec);
private:
int m_numTimeSteps;
};
void FooClass::Foo2(double* vec)
{
// this will not vectorize
for (int k=0; k < m_numTimeSteps; k++)
vec[k] = 0.0;
// this will not vectorize
for (int k=0; k < getValue(); k++)
vec[k] = 0.0;
// this will vectorize
int ub1 = m_numTimeSteps;
for (int k=0; k < ub1; k++)
vec[k] = 0.0;
// this will vectorize
int ub2 = getValue();
for (int k=0; k < ub2; k++)
vec[k] = 0.0;
}
Verify
Confirm that the value of the upper-bound expression does not change throughout the entire execution of the loop.