[flang-commits] [flang] [flang][acc] Allow nested gang loops inside acc routines (PR #158693)

via flang-commits flang-commits at lists.llvm.org
Tue Sep 16 04:42:21 PDT 2025


================
@@ -293,7 +293,7 @@ void AccStructureChecker::CheckNotInSameOrSubLevelLoopConstruct() {
           bool invalid{false};
           if (parentClause == llvm::acc::Clause::ACCC_gang &&
               cl == llvm::acc::Clause::ACCC_gang) {
-            if (IsInsideParallelConstruct()) {
+            if (!IsInsideKernelsConstruct()) {
----------------
khaki3 wrote:

Thanks for the review.

>"nested GANG clause is not allowed inside the region of a KERNEL construct"

I'd change it to `nested GANG loops are not allowed in the region of a KERNELS construct".

>it makes little sense to have nested GANG clauses

Probably, you checked the spec 3.4. By the time I made the concerned commit, I was checking the spec 3.3. In both, nested GANG loops are prohibited in a KERNELS construct.

>[2074] When the parent compute construct is a kernels
construct, the gang clause behaves as follows. (...)
>[2079] The region of a loop with the gang clause may not contain
another loop with a gang clause unless within a nested compute region.

https://openacc.org/sites/default/files/inline-images/Specification/OpenACC-3.3-final.pdf

The spec 3.4 says:

>[2319] • A loop construct with a gang, worker, or vector clause must not lexically enclose
[2320] another loop construct with a gang, worker, or vector clause specifying an equal or
[2321] higher level of parallelism unless the loop constructs have different parent compute scopes.
[2322] For example, in a loop nest that contains no interleaved compute constructs or procedures, a
[2323] gang(dim:1) loop must not enclose a gang(dim:3) loop or be enclosed by a worker
[2324] loop, but a seq loop is permitted at any nesting level.

>[2378] When the parent compute construct is a kernels construct, the gang clause behaves as follows.
>[2380] (...) The dim argument is not allowed.

https://openacc.org/sites/default/files/inline-images/Specification/OpenACC-3.4.pdf

https://github.com/llvm/llvm-project/pull/158693


More information about the flang-commits mailing list