Developer Guide and Reference

Contents

GAP Message (Diagnostic ID 30537)

Message

Add the "restrict" keyword to each pointer-typed formal parameter of the routine "%s". This allows optimizations such as parallelization and vectorization to be applied to the loop at line %d.

Advice

Rather than using option -fnoargument-alias (Linux* OS and
macOS*
) or /Qno-alias-args (Windows* OS), which affects the entire file, you can add the restrict qualifier to the pointer arguments to this routine. This change is more localized since it affects only the routines where the keyword is applied.
The restrict qualifier is part of C standard C99. This qualifier can be applied to a data pointer to indicate that during the scope of that pointer declaration, all data accessed through it will be accessed only through that pointer but not through any other pointer. So, the restrict keyword enables the compiler to perform certain optimizations based on the premise that a given object cannot be changed through another pointer. You must ensure that restrict-qualified pointers are used as they are intended to be used. Otherwise, undefined behavior may result.
The Intel® Compiler requires that you also specify option
[Q]restrict
when compiling non-C99 programs.
Example
Consider the following:
void matrix_mul_matrix(int N, float * C, float *A, float *B) { int i,j,k;   for (i=0; i<N; i++) { for (j=0; j<N; j++) { C[i*N+j]=0; for(k=0;k<N;k++) { C[i*N+j]+=A[i*N+k] * B[k*N+j]; } } } }
In this case, the compiler is unable to apply loop optimizations such as loop-interchange and vectorization at default setting
O2
.
If you determine it is safe to do so, you can modify the program code as follows:
void matrix_mul_matrix(int N, float * restrict C, float * restrict A, float * restrict B) { int i,j,k;   for (i=0; i<N; i++) { for (j=0; j<N; j++) { C[i*N+j]=0; for(k=0;k<N;k++) { C[i*N+j]+=A[i*N+k] * B[k*N+j]; } } } }
Note that instead of using the restrict qualifier, you could have specified
-fnoargument-alias
or
/Qno-alias-args
before compiling the code.

Verify

Make sure that semantics of the "restrict" pointer qualifier is satisfied: in the routine, all data accessed through the pointer must not be accessed through any other pointer.

Product and Performance Information

1

Intel's compilers may or may not optimize to the same degree for non-Intel microprocessors for optimizations that are not unique to Intel microprocessors. These optimizations include SSE2, SSE3, and SSSE3 instruction sets and other optimizations. Intel does not guarantee the availability, functionality, or effectiveness of any optimization on microprocessors not manufactured by Intel. Microprocessor-dependent optimizations in this product are intended for use with Intel microprocessors. Certain optimizations not specific to Intel microarchitecture are reserved for Intel microprocessors. Please refer to the applicable product User and Reference Guides for more information regarding the specific instruction sets covered by this notice.

Notice revision #20110804