OpenMP 5.1 规范是否允许带有非矩形循环的折叠子句?
Is collapse clause with non-rectangular loops allowed by the OpenMP 5.1 Spec?
考虑以下 OpenMP 代码:
#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;
}
}
}
}
此代码是否符合 OpenMP 规范 5.1 标准?我在规范中找不到任何不允许此类代码的措辞,但我不确定我是否遗漏了什么。
谢谢!
Is this OpenMP Spec 5.1 compliant?
根据 Support for non-rectangular collapsed loops 是的,它是合规的。
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.
在 OpenMP 5.0 specification 第 625 页,版本 4.5 到 5.0 的差异,可以阅读以下内容:
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.
考虑以下 OpenMP 代码:
#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;
}
}
}
}
此代码是否符合 OpenMP 规范 5.1 标准?我在规范中找不到任何不允许此类代码的措辞,但我不确定我是否遗漏了什么。
谢谢!
Is this OpenMP Spec 5.1 compliant?
根据 Support for non-rectangular collapsed loops 是的,它是合规的。
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.
在 OpenMP 5.0 specification 第 625 页,版本 4.5 到 5.0 的差异,可以阅读以下内容:
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.