Reputation: 83
Consider the following OpenMP code:
#pragma omp target teams distribute parallel for collapse(4) map(tofrom: a) private(i,j,k,l)
for (i = 0; i < SIZE_N; i++) {
for (j = 0; j < SIZE_M; j++) {
for (k = i; k < SIZE_N; k++) {
for (l = 0; l < SIZE_M; l++) {
a[i][j][k][l] += i+2*j+3*k+4*l;
}
}
}
}
Is this code OpenMP Spec 5.1 compliant? I could not find in the spec any wording that does not allowed this kind of code, but I am not sure I am missing something.
Thanks!
Upvotes: 2
Views: 360
Reputation: 51493
Is this OpenMP Spec 5.1 compliant?
Accordingly to Support for non-rectangular collapsed loops yes it is compliant.
Before OpenMP 5.0, all OpenMP looping constructs (worksharing loops, simd, distribute, taskloop, and combined or composite constructs based on those) were required to be rectangular. This means that all of the lower bound, upper bound, and increment expressions of all the associated loops in the loop nest were required to be invariant against the outermost loop. OpenMP 5.0 still requires all the increment expressions to be loop-invariant, but allows some cases where the lower and upper bound expressions of the inner loops can be based on a single outer-loop iterator.
I cannot find in the spec any wording that does not allowed this kind of code, but I am not sure I am missing something.
In the OpenMP 5.0 specification page 625, Version 4.5 to 5.0 Differences, one can read the following:
The collapse of associated loops that are imperfectly nested loops was defined for the worksharing-loop (see Section 2.9.2 on page 101), simd (see Section 2.9.3.1 on page 110), taskloop (see Section 2.10.2 on page 140) and distribute (see Section 2.9.4.2 on page 123) constructs.
Upvotes: 3