Skip to content

Commit 6f62757

Browse files
authored
[MLIR][OpenMP] NFC: Update parallel workshare loop reduction tests (#105835)
This patch updates MLIR tests for `omp.parallel` + `omp.wsloop` reductions to move the reduction clause into `omp.wsloop` rather than the parent `omp.parallel`, as mandated by the spec for these cases and also to match what Flang is already producing for `parallel do reduction(...)` combined constructs. From the OpenMP Spec version 5.2, section 17.2: > The effect of the reduction clause is as if it is applied to all leaf constructs that permit the clause, except for the following constructs: > - The `parallel` construct, when combined with the `sections`, worksharing-loop, `loop`, or `taskloop` construct; [...]
1 parent 063e0bd commit 6f62757

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

mlir/test/Dialect/OpenMP/ops.mlir

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1019,10 +1019,10 @@ func.func @parallel_reduction_byref() {
10191019
func.func @parallel_wsloop_reduction(%lb : index, %ub : index, %step : index) {
10201020
%c1 = arith.constant 1 : i32
10211021
%0 = llvm.alloca %c1 x i32 : (i32) -> !llvm.ptr
1022-
// CHECK: omp.parallel reduction(@add_f32 %{{.*}} -> %{{.+}} : !llvm.ptr) {
1023-
omp.parallel reduction(@add_f32 %0 -> %prv : !llvm.ptr) {
1024-
// CHECK: omp.wsloop {
1025-
omp.wsloop {
1022+
// CHECK: omp.parallel {
1023+
omp.parallel {
1024+
// CHECK: omp.wsloop reduction(@add_f32 %{{.*}} -> %{{.+}} : !llvm.ptr) {
1025+
omp.wsloop reduction(@add_f32 %0 -> %prv : !llvm.ptr) {
10261026
// CHECK: omp.loop_nest (%{{.+}}) : index = (%{{.+}}) to (%{{.+}}) step (%{{.+}}) {
10271027
omp.loop_nest (%iv) : index = (%lb) to (%ub) step (%step) {
10281028
%1 = arith.constant 2.0 : f32
@@ -1216,10 +1216,10 @@ func.func @parallel_reduction2() {
12161216
func.func @parallel_wsloop_reduction2(%lb : index, %ub : index, %step : index) {
12171217
%c1 = arith.constant 1 : i32
12181218
%0 = llvm.alloca %c1 x i32 : (i32) -> !llvm.ptr
1219-
// CHECK: omp.parallel reduction(@add2_f32 %{{.*}} -> %{{.+}} : !llvm.ptr) {
1220-
omp.parallel reduction(@add2_f32 %0 -> %prv : !llvm.ptr) {
1221-
// CHECK: omp.wsloop {
1222-
omp.wsloop {
1219+
// CHECK: omp.parallel {
1220+
omp.parallel {
1221+
// CHECK: omp.wsloop reduction(@add2_f32 %{{.*}} -> %{{.+}} : !llvm.ptr) {
1222+
omp.wsloop reduction(@add2_f32 %0 -> %prv : !llvm.ptr) {
12231223
// CHECK: omp.loop_nest (%{{.+}}) : index = (%{{.+}}) to (%{{.+}}) step (%{{.+}}) {
12241224
omp.loop_nest (%iv) : index = (%lb) to (%ub) step (%step) {
12251225
%1 = arith.constant 2.0 : f32

mlir/test/Target/LLVMIR/openmp-reduction.mlir

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -540,8 +540,8 @@ llvm.func @parallel_nested_workshare_reduction(%ub : i64) {
540540
%lb = llvm.mlir.constant(1 : i64) : i64
541541
%step = llvm.mlir.constant(1 : i64) : i64
542542

543-
omp.parallel reduction(@add_i32 %0 -> %prv : !llvm.ptr) {
544-
omp.wsloop {
543+
omp.parallel {
544+
omp.wsloop reduction(@add_i32 %0 -> %prv : !llvm.ptr) {
545545
omp.loop_nest (%iv) : i64 = (%lb) to (%ub) step (%step) {
546546
%ival = llvm.trunc %iv : i64 to i32
547547
%lprv = llvm.load %prv : !llvm.ptr -> i32

0 commit comments

Comments
 (0)