File tree Expand file tree Collapse file tree 3 files changed +41
-9
lines changed Expand file tree Collapse file tree 3 files changed +41
-9
lines changed Original file line number Diff line number Diff line change @@ -136,10 +136,10 @@ void AccStructureChecker::CheckNotInComputeConstruct() {
136
136
}
137
137
}
138
138
139
- bool AccStructureChecker::IsInsideParallelConstruct () const {
139
+ bool AccStructureChecker::IsInsideKernelsConstruct () const {
140
140
if (auto directive = getParentComputeConstruct ())
141
- if (*directive == llvm::acc::ACCD_parallel ||
142
- *directive == llvm::acc::ACCD_parallel_loop )
141
+ if (*directive == llvm::acc::ACCD_kernels ||
142
+ *directive == llvm::acc::ACCD_kernels_loop )
143
143
return true ;
144
144
return false ;
145
145
}
@@ -293,7 +293,10 @@ void AccStructureChecker::CheckNotInSameOrSubLevelLoopConstruct() {
293
293
bool invalid{false };
294
294
if (parentClause == llvm::acc::Clause::ACCC_gang &&
295
295
cl == llvm::acc::Clause::ACCC_gang) {
296
- if (IsInsideParallelConstruct ()) {
296
+ if (IsInsideKernelsConstruct ()) {
297
+ context_.Say (GetContext ().clauseSource ,
298
+ " Nested GANG loops are not allowed in the region of a KERNELS construct" _err_en_US);
299
+ } else {
297
300
auto parentDim = getGangDimensionSize (parent);
298
301
auto currentDim = getGangDimensionSize (GetContext ());
299
302
std::int64_t parentDimNum = 1 , currentDimNum = 1 ;
@@ -317,8 +320,6 @@ void AccStructureChecker::CheckNotInSameOrSubLevelLoopConstruct() {
317
320
parentDimStr);
318
321
continue ;
319
322
}
320
- } else {
321
- invalid = true ;
322
323
}
323
324
} else if (parentClause == llvm::acc::Clause::ACCC_worker &&
324
325
(cl == llvm::acc::Clause::ACCC_gang ||
Original file line number Diff line number Diff line change @@ -101,7 +101,7 @@ class AccStructureChecker
101
101
bool IsLoopConstruct (llvm::acc::Directive directive) const ;
102
102
std::optional<llvm::acc::Directive> getParentComputeConstruct () const ;
103
103
bool IsInsideComputeConstruct () const ;
104
- bool IsInsideParallelConstruct () const ;
104
+ bool IsInsideKernelsConstruct () const ;
105
105
void CheckNotInComputeConstruct ();
106
106
std::optional<std::int64_t > getGangDimensionSize (
107
107
DirectiveContext &dirContext);
Original file line number Diff line number Diff line change @@ -340,10 +340,10 @@ program openacc_loop_validity
340
340
341
341
! $acc kernels loop gang(dim:3)
342
342
do i = 1 , n
343
- ! ERROR: GANG clause is not allowed in the region of a loop with the GANG clause
343
+ ! ERROR: Nested GANG loops are not allowed in the region of a KERNELS construct
344
344
! $acc loop gang(dim:2)
345
345
do j = 1 , n
346
- ! ERROR: GANG clause is not allowed in the region of a loop with the GANG clause
346
+ ! ERROR: Nested GANG loops are not allowed in the region of a KERNELS construct
347
347
! $acc loop gang(dim:1) worker vector
348
348
do k = 1 , i
349
349
end do
@@ -447,4 +447,35 @@ program openacc_loop_validity
447
447
END DO
448
448
END DO
449
449
450
+ contains
451
+
452
+ subroutine sub1 ()
453
+ ! $acc routine gang(dim:2)
454
+ implicit none
455
+ integer , parameter :: N = 256
456
+ integer :: i, j
457
+
458
+ ! $acc loop gang(dim:2)
459
+ DO j = 1 , N
460
+ ! $acc loop gang(dim:1) vector
461
+ DO i = 1 , N
462
+ END DO
463
+ END DO
464
+ end subroutine sub1
465
+
466
+ subroutine sub2 ()
467
+ ! $acc routine gang(dim:2)
468
+ implicit none
469
+ integer , parameter :: N = 256
470
+ integer :: i, j
471
+
472
+ ! $acc loop gang(dim:2)
473
+ DO j = 1 , N
474
+ ! ERROR: GANG(dim:2) clause is not allowed in the region of a loop with the GANG(dim:2) clause
475
+ ! $acc loop gang(dim:2) vector
476
+ DO i = 1 , N
477
+ END DO
478
+ END DO
479
+ end subroutine sub2
480
+
450
481
end program openacc_loop_validity
You can’t perform that action at this time.
0 commit comments