Skip to content

Commit a870335

Browse files
committed
[Flang][OpenMP] Add support for taskloop nogroup Lowering
NoGroup is a clause that is supported by taskloop in the OpenMP standards. Until this point, this has been marked as TODO as support was not present in AST->FIR lowering. This has now been added so the clause can be emitted in HLFIR/FIR. Lowering from FIR to LLVM IR is not available as this has not been completed for taskloop.
1 parent 06b3529 commit a870335

File tree

4 files changed

+35
-3
lines changed

4 files changed

+35
-3
lines changed

flang/lib/Lower/OpenMP/ClauseProcessor.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -406,6 +406,11 @@ bool ClauseProcessor::processMergeable(
406406
return markClauseOccurrence<omp::clause::Mergeable>(result.mergeable);
407407
}
408408

409+
bool ClauseProcessor::processNogroup(
410+
mlir::omp::NogroupClauseOps &result) const {
411+
return markClauseOccurrence<omp::clause::Nogroup>(result.nogroup);
412+
}
413+
409414
bool ClauseProcessor::processNowait(mlir::omp::NowaitClauseOps &result) const {
410415
return markClauseOccurrence<omp::clause::Nowait>(result.nowait);
411416
}

flang/lib/Lower/OpenMP/ClauseProcessor.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ class ClauseProcessor {
8989
bool processInclusive(mlir::Location currentLocation,
9090
mlir::omp::InclusiveClauseOps &result) const;
9191
bool processMergeable(mlir::omp::MergeableClauseOps &result) const;
92+
bool processNogroup(mlir::omp::NogroupClauseOps &result) const;
9293
bool processNowait(mlir::omp::NowaitClauseOps &result) const;
9394
bool processNumTasks(lower::StatementContext &stmtCtx,
9495
mlir::omp::NumTasksClauseOps &result) const;

flang/lib/Lower/OpenMP/OpenMP.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1771,13 +1771,14 @@ static void genTaskloopClauses(lower::AbstractConverter &converter,
17711771

17721772
ClauseProcessor cp(converter, semaCtx, clauses);
17731773
cp.processGrainsize(stmtCtx, clauseOps);
1774+
cp.processNogroup(clauseOps);
17741775
cp.processNumTasks(stmtCtx, clauseOps);
17751776

17761777
cp.processTODO<clause::Allocate, clause::Collapse, clause::Default,
17771778
clause::Final, clause::If, clause::InReduction,
1778-
clause::Lastprivate, clause::Mergeable, clause::Nogroup,
1779-
clause::Priority, clause::Reduction, clause::Shared,
1780-
clause::Untied>(loc, llvm::omp::Directive::OMPD_taskloop);
1779+
clause::Lastprivate, clause::Mergeable, clause::Priority,
1780+
clause::Reduction, clause::Shared, clause::Untied>(
1781+
loc, llvm::omp::Directive::OMPD_taskloop);
17811782
}
17821783

17831784
static void genTaskwaitClauses(lower::AbstractConverter &converter,
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
! Test the Nogroup clause when used with the taskloop directive
2+
! RUN: bbc -emit-hlfir -fopenmp -fopenmp-version=45 %s -o - 2>&1 | FileCheck %s
3+
! RUN: %flang_fc1 -emit-hlfir -fopenmp -fopenmp-version=45 %s -o - 2>&1 | FileCheck %s
4+
5+
! CHECK-LABEL: omp.private
6+
! CHECK-SAME: {type = private} @[[I_PRIVATE:.*]] : i32
7+
! CHECK-LABEL: omp.private
8+
! CHECK-SAME: {type = firstprivate} @[[SUM_FIRSTPRIVATE:.*]] : i32 copy
9+
10+
! CHECK: %[[ALLOCA_I:.*]] = fir.alloca i32 {bindc_name = "i", uniq_name = "_QFtestEi"}
11+
! CHECK: %[[DECLARE_I:.*]]:2 = hlfir.declare %[[ALLOCA_I]] {uniq_name = "_QFtestEi"} : (!fir.ref<i32>) -> (!fir.ref<i32>, !fir.ref<i32>)
12+
! CHECK: %[[ALLOCA_SUM:.*]] = fir.alloca i32 {bindc_name = "sum", uniq_name = "_QFtestEsum"}
13+
! CHECK: %[[DECLARE_SUM:.*]]:2 = hlfir.declare %[[ALLOCA_SUM]] {uniq_name = "_QFtestEsum"} : (!fir.ref<i32>) -> (!fir.ref<i32>, !fir.ref<i32>)
14+
15+
subroutine test()
16+
integer :: i, sum
17+
18+
! CHECK-LABEL: omp.taskloop
19+
! CHECK-SAME: nogroup private(@_QFtestEsum_firstprivate_i32 %[[DECLARE_SUM]]#0 -> %arg0, @_QFtestEi_private_i32 %[[DECLARE_I]]#0 -> %arg1 : !fir.ref<i32>, !fir.ref<i32>)
20+
!$omp taskloop nogroup
21+
do i=1,10
22+
sum = sum + i
23+
end do
24+
!$omp end taskloop
25+
end subroutine

0 commit comments

Comments
 (0)