#pragma simd_level

Category

Optimization and tuning

Purpose

Controls the compiler code generation of vector instructions for individual loops.

Vector instructions can offer high performance when used with algorithmic-intensive tasks such as multimedia applications. You have the flexibility to control the aggressiveness of autosimdization on a loop-by-loop basis, and might be able to achieve further performance gain with this fine grain control.

The supported levels are from 0 to 10. level(0) indicates performing no autosimdization on the loop that follows the pragma directive. level(10) indicates performing the most aggressive form of autosimdization on the loop. With this pragma directive, you can control the autosimdization behavior on a loop-by-loop basis.

Syntax

Read syntax diagramSkip visual syntax diagram
>>-#--pragma--simd_level--(--n--)------------------------------><

Parameters

n
A scalar integer initialization expression, from 0 to 10, specifying the aggressiveness of autosimdization on the loop that follows the pragma directive.

Usage

A loop with no simd_level pragma is set to simd level 5 by default, if -qsimd=auto is in effect.

#pragma simd_level(0) is equivalent to #pragma nosimd, where autosimdization is not performed on the loop that follows the pragma directive.

#pragma simd_level(10) instructs the compiler to perform autosimdization on the loop that follows the pragma directive most aggressively, including bypassing cost analysis.

Rules

The rules of #pragma simd_level directive are listed as follows:
  • The #pragma simd_level directive has effect only for architectures that support vector instructions and when used with -qsimd=auto.
  • The #pragma simd_level directive applies to while, do while, and for loops.
  • The #pragma simd_level directive applies only to the loop immediately following it. The directive has no effect on other loops that are nested within the specified loop. It is possible to set different simd levels for the inner and outer loops by specifying separate #pragma simd_level directives.
  • The #pragma simd_level directive can be mixed with loop optimization (-qhot) and OpenMP directives without requiring any specific optimization level. For more information about -qhot and OpenMP directives, see -qhot in this document and Using OpenMP directives in the IBM® XL C Optimization and Programming Guide.

Examples

...
#pragma simd_level(10)
for (i=1; i<1000; i++) { 
/* program code */

} ...

Related information