#pragma omp distribute simd

Purpose

The omp distribute simd directive distributes loop iterations to each master thread and then executes each set of distributed iterations concurrently by using SIMD instructions.

Syntax

Read syntax diagramSkip visual syntax diagram
                                   .-+---+-------.   
                                   | '-,-'       |   
                                   V             |   
>>-#--pragma--omp distribute simd----+---------+-+-------------><
                                     '-clauses-'     

Read syntax diagramSkip visual syntax diagram
>>-for-loops---------------------------------------------------><

Parameters

The omp distribute simd construct is a composite construct. clause can be any of the clauses that are accepted by the omp distribute or omp simd directive with identical meanings and restrictions.

Usage

The omp distribute simd directive takes effect only if you specify both the -qsmp and -qoffload compiler options.

Rules

If any specified clause except the collapse clause is applicable to both the omp distribute and omp simd directives, the clause is applied twice; the collapse clause is applied only once.

You can specify only loop iteration variables on the linear clause.

Examples

const int N = 8;
int a[N];
int i;
#pragma omp target map(to: N) map(tofrom: a)
#pragma omp teams num_teams(2) thread_limit(N/2)
#pragma omp distribute simd
for (i=0; i<N; i++)
{
  a[i] = N;
}
#pragma omp end distribute simd
#pragma omp end teams
#pragma omp end target

In this example, the target region contains a teams region that consists of two teams. The iterations of the closely nested distribute loop are assigned to the teams that are actually created. With the omp distribute simd directive, the master thread of each team executes each set of distributed iterations concurrently by using SIMD instructions.



Voice your opinion on getting help information Ask IBM compiler experts a technical question in the IBM XL compilers forum Reach out to us