Skip to content

Commit c2026f4

Browse files
committed
Addressed review comments: Binding Fortran symbols to entry block arguments in taskgroup construct and fixed testcases
1 parent 3f53c5e commit c2026f4

File tree

6 files changed

+30
-28
lines changed

6 files changed

+30
-28
lines changed

flang/lib/Lower/OpenMP/ClauseProcessor.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,12 +112,12 @@ class ClauseProcessor {
112112
processEnter(llvm::SmallVectorImpl<DeclareTargetCapturePair> &result) const;
113113
bool processIf(omp::clause::If::DirectiveNameModifier directiveName,
114114
mlir::omp::IfClauseOps &result) const;
115-
bool processIsDevicePtr(
116-
mlir::omp::IsDevicePtrClauseOps &result,
117-
llvm::SmallVectorImpl<const semantics::Symbol *> &isDeviceSyms) const;
118115
bool processInReduction(
119116
mlir::Location currentLocation, mlir::omp::InReductionClauseOps &result,
120117
llvm::SmallVectorImpl<const semantics::Symbol *> &outReductionSyms) const;
118+
bool processIsDevicePtr(
119+
mlir::omp::IsDevicePtrClauseOps &result,
120+
llvm::SmallVectorImpl<const semantics::Symbol *> &isDeviceSyms) const;
121121
bool
122122
processLink(llvm::SmallVectorImpl<DeclareTargetCapturePair> &result) const;
123123

flang/lib/Lower/OpenMP/DataSharingProcessor.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -416,8 +416,7 @@ void DataSharingProcessor::collectSymbols(
416416

417417
bool collectSymbols = (itr == clauses.end());
418418

419-
converter.collectSymbolSet(eval, allSymbols, flag,
420-
/*collectSymbols=*/collectSymbols,
419+
converter.collectSymbolSet(eval, allSymbols, flag, collectSymbols,
421420
/*collectHostAssociatedSymbols=*/true);
422421

423422
llvm::SetVector<const semantics::Symbol *> symbolsInNestedRegions;

flang/lib/Lower/OpenMP/OpenMP.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2537,18 +2537,18 @@ genTaskgroupOp(lower::AbstractConverter &converter, lower::SymMap &symTable,
25372537

25382538
auto genRegionEntryCB = [&](mlir::Operation *op) {
25392539
genEntryBlock(converter.getFirOpBuilder(), taskgroupArgs, op->getRegion(0));
2540+
bindEntryBlockArgs(converter,
2541+
llvm::cast<mlir::omp::BlockArgOpenMPOpInterface>(op),
2542+
taskgroupArgs);
25402543
return llvm::to_vector(taskgroupArgs.getSyms());
25412544
};
25422545

2543-
OpWithBodyGenInfo genInfo =
2546+
return genOpWithBody<mlir::omp::TaskgroupOp>(
25442547
OpWithBodyGenInfo(converter, symTable, semaCtx, loc, eval,
25452548
llvm::omp::Directive::OMPD_taskgroup)
25462549
.setClauses(&item->clauses)
2547-
.setGenRegionEntryCb(genRegionEntryCB);
2548-
2549-
auto taskgroupOp =
2550-
genOpWithBody<mlir::omp::TaskgroupOp>(genInfo, queue, item, clauseOps);
2551-
return taskgroupOp;
2550+
.setGenRegionEntryCb(genRegionEntryCB),
2551+
queue, item, clauseOps);
25522552
}
25532553

25542554
static mlir::omp::TaskwaitOp

flang/test/Lower/OpenMP/taskgroup-task-array-reduction.f90

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,18 @@
1515
! CHECK: omp.yield
1616
! CHECK: }
1717

18-
! CHECK-LABEL: func.func @_QPtaskreduction
18+
! CHECK-LABEL: func.func @_QPtask_reduction
1919
! CHECK-SAME: (%[[VAL_0:.*]]: !fir.box<!fir.array<?xf32>> {fir.bindc_name = "x"}) {
2020
! CHECK: %[[VAL_1:.*]] = fir.dummy_scope : !fir.dscope
2121
! CHECK: %[[VAL_2:.*]]:2 = hlfir.declare %[[VAL_0]] dummy_scope %[[VAL_1]]
22-
! CHECK-SAME {uniq_name = "_QFtaskreductionEx"} : (!fir.box<!fir.array<?xf32>>, !fir.dscope) -> (!fir.box<!fir.array<?xf32>>, !fir.box<!fir.array<?xf32>>)
22+
! CHECK-SAME: {uniq_name = "_QFtask_reductionEx"} : (!fir.box<!fir.array<?xf32>>, !fir.dscope) -> (!fir.box<!fir.array<?xf32>>, !fir.box<!fir.array<?xf32>>)
2323
! CHECK: omp.parallel {
2424
! CHECK: %[[VAL_3:.*]] = fir.alloca !fir.box<!fir.array<?xf32>>
2525
! CHECK: fir.store %[[VAL_2]]#1 to %[[VAL_3]] : !fir.ref<!fir.box<!fir.array<?xf32>>>
26-
! CHECK: omp.taskgroup task_reduction(byref @add_reduction_byref_box_Uxf32 %[[VAL_3]] -> %[[VAL_4:.*]]: !fir.ref<!fir.box<!fir.array<?xf32>>>) {
27-
! CHECK: %[[VAL_5:.*]] = fir.alloca !fir.box<!fir.array<?xf32>>
28-
! CHECK: fir.store %[[VAL_2]]#1 to %[[VAL_5]] : !fir.ref<!fir.box<!fir.array<?xf32>>>
29-
! CHECK: omp.task in_reduction(byref @add_reduction_byref_box_Uxf32 %[[VAL_5]] -> %[[VAL_6:.*]] : !fir.ref<!fir.box<!fir.array<?xf32>>>) {
26+
! CHECK: omp.taskgroup task_reduction(byref @add_reduction_byref_box_Uxf32 %[[VAL_3]] -> %[[VAL_4:.*]]: !fir.ref<!fir.box<!fir.array<?xf32>>>) {
27+
! CHECK: %[[VAL_5:.*]]:2 = hlfir.declare %[[VAL_4]]
28+
! CHECK-SAME: {uniq_name = "_QFtask_reductionEx"} : (!fir.ref<!fir.box<!fir.array<?xf32>>>) -> (!fir.ref<!fir.box<!fir.array<?xf32>>>, !fir.ref<!fir.box<!fir.array<?xf32>>>)
29+
! CHECK: omp.task in_reduction(byref @add_reduction_byref_box_Uxf32 %[[VAL_5]]#0 -> %[[VAL_6:.*]] : !fir.ref<!fir.box<!fir.array<?xf32>>>) {
3030
! [...]
3131
! CHECK: omp.terminator
3232
! CHECK: }
@@ -37,7 +37,7 @@
3737
! CHECK: return
3838
! CHECK: }
3939

40-
subroutine taskReduction(x)
40+
subroutine task_reduction(x)
4141
real, dimension(:) :: x
4242
!$omp parallel
4343
!$omp taskgroup task_reduction(+:x)

flang/test/Lower/OpenMP/taskgroup-task_reduction01.f90

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,12 @@
1616
!CHECK: %[[VAL_0:.*]] = fir.alloca i32 {bindc_name = "res", uniq_name = "_QFomp_taskgroup_task_reductionEres"}
1717
!CHECK: %[[VAL_1:.*]]:2 = hlfir.declare %[[VAL_0]] {uniq_name = "_QFomp_taskgroup_task_reductionEres"} : (!fir.ref<i32>) -> (!fir.ref<i32>, !fir.ref<i32>)
1818
!CHECK: omp.taskgroup task_reduction(@[[RED_I32_NAME]] %[[VAL_1]]#0 -> %[[VAL_2:.*]] : !fir.ref<i32>) {
19-
!CHECK: %[[VAL_3:.*]] = fir.load %[[VAL_1]]#0 : !fir.ref<i32>
20-
!CHECK: %[[VAL_4:.*]] = arith.constant 1 : i32
21-
!CHECK: %[[VAL_5:.*]] = arith.addi %[[VAL_3]], %[[VAL_4]] : i32
22-
!CHECK: hlfir.assign %[[VAL_5]] to %[[VAL_1]]#0 : i32, !fir.ref<i32>
19+
!CHECK: %[[VAL_3:.*]]:2 = hlfir.declare %[[VAL_2]]
20+
!CHECK-SAME: {uniq_name = "_QFomp_taskgroup_task_reductionEres"} : (!fir.ref<i32>) -> (!fir.ref<i32>, !fir.ref<i32>)
21+
!CHECK: %[[VAL_4:.*]] = fir.load %[[VAL_3]]#0 : !fir.ref<i32>
22+
!CHECK: %[[VAL_5:.*]] = arith.constant 1 : i32
23+
!CHECK: %[[VAL_6:.*]] = arith.addi %[[VAL_4]], %[[VAL_5]] : i32
24+
!CHECK: hlfir.assign %[[VAL_6]] to %[[VAL_3]]#0 : i32, !fir.ref<i32>
2325
!CHECK: omp.terminator
2426
!CHECK: }
2527
!CHECK: return

flang/test/Lower/OpenMP/taskgroup-task_reduction02.f90

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,13 @@
1515
!CHECK-LABEL: func.func @_QPin_reduction() {
1616
! [...]
1717
!CHECK: omp.taskgroup task_reduction(@[[RED_I32_NAME]] %[[VAL_1:.*]]#0 -> %[[VAL_3:.*]] : !fir.ref<i32>) {
18-
!CHECK: omp.task in_reduction(@[[RED_I32_NAME]] %[[VAL_1]]#0 -> %[[VAL_4:.*]] : !fir.ref<i32>) {
19-
!CHECK: %[[VAL_5:.*]]:2 = hlfir.declare %[[VAL_4]] {uniq_name = "_QFin_reductionEx"} : (!fir.ref<i32>) -> (!fir.ref<i32>, !fir.ref<i32>)
20-
! [...]
21-
!CHECK: omp.terminator
22-
!CHECK: }
23-
!CHECK: omp.terminator
18+
!CHECK: %[[VAL_4:.*]]:2 = hlfir.declare %[[VAL_3]] {uniq_name = "_QFin_reductionEx"} : (!fir.ref<i32>) -> (!fir.ref<i32>, !fir.ref<i32>)
19+
!CHECK: omp.task in_reduction(@[[RED_I32_NAME]] %[[VAL_4]]#0 -> %[[VAL_5:.*]] : !fir.ref<i32>) {
20+
!CHECK: %[[VAL_6:.*]]:2 = hlfir.declare %[[VAL_5]] {uniq_name = "_QFin_reductionEx"} : (!fir.ref<i32>) -> (!fir.ref<i32>, !fir.ref<i32>)
21+
! [...]
22+
!CHECK: omp.terminator
23+
!CHECK: }
24+
!CHECK: omp.terminator
2425
!CHECK: }
2526
!CHECK: return
2627
!CHECK: }

0 commit comments

Comments
 (0)