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.