[flang-commits] [flang] dae2c24 - [flang][OpenMP][NFC] Cleanup the sections tests
Shraiysh Vaishay via flang-commits
flang-commits at lists.llvm.org
Fri May 27 06:20:21 PDT 2022
Author: Shraiysh Vaishay
Date: 2022-05-27T18:50:11+05:30
New Revision: dae2c24eb2385d5bf34e7199bae26080a5eb17b3
URL: https://github.com/llvm/llvm-project/commit/dae2c24eb2385d5bf34e7199bae26080a5eb17b3
DIFF: https://github.com/llvm/llvm-project/commit/dae2c24eb2385d5bf34e7199bae26080a5eb17b3.diff
LOG: [flang][OpenMP][NFC] Cleanup the sections tests
This patch cleans up the sections tests as per the recent effort to
separate integration tests from unit tests.
Reviewed By: kiranchandramohan, peixin
Differential Revision: https://reviews.llvm.org/D126368
Added:
Modified:
flang/test/Fir/convert-to-llvm-openmp-and-fir.fir
flang/test/Lower/OpenMP/sections.f90
Removed:
################################################################################
diff --git a/flang/test/Fir/convert-to-llvm-openmp-and-fir.fir b/flang/test/Fir/convert-to-llvm-openmp-and-fir.fir
index 601cf70815cf0..b6da69a20a5e5 100644
--- a/flang/test/Fir/convert-to-llvm-openmp-and-fir.fir
+++ b/flang/test/Fir/convert-to-llvm-openmp-and-fir.fir
@@ -104,3 +104,70 @@ func.func @_QPsb(%arr: !fir.box<!fir.array<?xi32>> {fir.bindc_name = "arr"}) {
// CHECK: omp.yield
// CHECK: omp.terminator
// CHECK: llvm.return
+
+// -----
+
+func.func private @foo()
+func.func private @bar()
+
+func.func @sections_no_data() {
+ omp.sections {
+ omp.section {
+ fir.call @foo() : () -> ()
+ omp.terminator
+ }
+ omp.section {
+ fir.call @bar() : () -> ()
+ omp.terminator
+ }
+ omp.terminator
+ }
+ return
+}
+
+// CHECK-LABEL: llvm.func @sections_no_data
+// CHECK: omp.sections {
+// CHECK: omp.section {
+// CHECK: llvm.call @foo() : () -> ()
+// CHECK: omp.terminator
+// CHECK: }
+// CHECK: omp.section {
+// CHECK: llvm.call @bar() : () -> ()
+// CHECK: omp.terminator
+// CHECK: }
+// CHECK: omp.terminator
+// CHECK: }
+
+// -----
+
+func.func private @foo(!fir.ref<i32>)
+func.func private @bar(!fir.ref<i32>, !fir.ref<i32>)
+
+func.func @sections_data_without_clauses(%arg0: !fir.ref<i32> {fir.bindc_name = "a"}, %arg1: !fir.ref<i32> {fir.bindc_name = "b"}) {
+ omp.sections {
+ omp.section {
+ fir.call @foo(%arg0) : (!fir.ref<i32>) -> ()
+ omp.terminator
+ }
+ omp.section {
+ fir.call @bar(%arg0, %arg1) : (!fir.ref<i32>, !fir.ref<i32>) -> ()
+ omp.terminator
+ }
+ omp.terminator
+ }
+ return
+}
+
+// CHECK-LABEL: llvm.func @sections_data_without_clauses
+// CHECK-SAME: (%[[ARG0:.+]]: !llvm.ptr<i32> {fir.bindc_name = "a"}, %[[ARG1:.+]]: !llvm.ptr<i32> {fir.bindc_name = "b"})
+// CHECK: omp.sections {
+// CHECK: omp.section {
+// CHECK: llvm.call @foo(%arg0) : (!llvm.ptr<i32>) -> ()
+// CHECK: omp.terminator
+// CHECK: }
+// CHECK: omp.section {
+// CHECK: llvm.call @bar(%[[ARG0]], %[[ARG1]]) : (!llvm.ptr<i32>, !llvm.ptr<i32>) -> ()
+// CHECK: omp.terminator
+// CHECK: }
+// CHECK: omp.terminator
+// CHECK: }
diff --git a/flang/test/Lower/OpenMP/sections.f90 b/flang/test/Lower/OpenMP/sections.f90
index f18babcd31a05..a882308479aed 100644
--- a/flang/test/Lower/OpenMP/sections.f90
+++ b/flang/test/Lower/OpenMP/sections.f90
@@ -1,116 +1,58 @@
! This test checks the lowering of OpenMP sections construct with several clauses present
-! RUN: %flang_fc1 -emit-fir -fopenmp %s -o - | FileCheck %s --check-prefix="FIRDialect"
-! RUN: %flang_fc1 -emit-fir -fopenmp %s -o - | fir-opt --fir-to-llvm-ir | FileCheck %s --check-prefix="LLVMDialect"
-! TODO before (%flang_fc1 -emit-fir -fopenmp %s -o - | fir-opt --fir-to-llvm-ir | tco | FileCheck %s --check-prefix="LLVMIR"):
-! ensure allocate clause lowering
+! RUN: %flang_fc1 -emit-fir -fopenmp %s -o - | FileCheck %s
-!FIRDialect: func @_QQmain() {
-!FIRDialect: %[[COUNT:.*]] = fir.address_of(@_QFEcount) : !fir.ref<i32>
-!FIRDialect: %[[DOUBLE_COUNT:.*]] = fir.address_of(@_QFEdouble_count) : !fir.ref<i32>
-!FIRDialect: %[[ETA:.*]] = fir.alloca f32 {bindc_name = "eta", uniq_name = "_QFEeta"}
-!FIRDialect: %[[CONST_1:.*]] = arith.constant 1 : i32
-!FIRDialect: omp.sections allocate(%[[CONST_1]] : i32 -> %0 : !fir.ref<i32>) {
-!FIRDialect: omp.section {
-!FIRDialect: {{.*}} = arith.constant 5 : i32
-!FIRDialect: fir.store {{.*}} to {{.*}} : !fir.ref<i32>
-!FIRDialect: {{.*}} = fir.load %[[COUNT]] : !fir.ref<i32>
-!FIRDialect: {{.*}} = fir.load %[[DOUBLE_COUNT]] : !fir.ref<i32>
-!FIRDialect: {{.*}} = arith.muli {{.*}}, {{.*}} : i32
-!FIRDialect: {{.*}} = fir.convert {{.*}} : (i32) -> f32
-!FIRDialect: fir.store {{.*}} to %[[ETA]] : !fir.ref<f32>
-!FIRDialect: omp.terminator
-!FIRDialect: }
-!FIRDialect: omp.section {
-!FIRDialect: {{.*}} = fir.load %[[DOUBLE_COUNT]] : !fir.ref<i32>
-!FIRDialect: {{.*}} = arith.constant 1 : i32
-!FIRDialect: {{.*}} = arith.addi {{.*}} : i32
-!FIRDialect: fir.store {{.*}} to %[[DOUBLE_COUNT]] : !fir.ref<i32>
-!FIRDialect: omp.terminator
-!FIRDialect: }
-!FIRDialect: omp.section {
-!FIRDialect: {{.*}} = fir.load %[[ETA]] : !fir.ref<f32>
-!FIRDialect: {{.*}} = arith.constant 7.000000e+00 : f32
-!FIRDialect: {{.*}} = arith.subf {{.*}} : f32
-!FIRDialect: fir.store {{.*}} to %[[ETA]] : !fir.ref<f32>
-!FIRDialect: {{.*}} = fir.load %[[COUNT]] : !fir.ref<i32>
-!FIRDialect: {{.*}} = fir.convert {{.*}} : (i32) -> f32
-!FIRDialect: {{.*}} = fir.load %[[ETA]] : !fir.ref<f32>
-!FIRDialect: {{.*}} = arith.mulf {{.*}}, {{.*}} : f32
-!FIRDialect: {{.*}} = fir.convert {{.*}} : (f32) -> i32
-!FIRDialect: fir.store {{.*}} to %[[COUNT]] : !fir.ref<i32>
-!FIRDialect: {{.*}} = fir.load %[[COUNT]] : !fir.ref<i32>
-!FIRDialect: {{.*}} = fir.convert {{.*}} : (i32) -> f32
-!FIRDialect: {{.*}} = fir.load %[[ETA]] : !fir.ref<f32>
-!FIRDialect: {{.*}} = arith.subf {{.*}}, {{.*}} : f32
-!FIRDialect: {{.*}} = fir.convert {{.*}} : (f32) -> i32
-!FIRDialect: fir.store {{.*}} to %[[DOUBLE_COUNT]] : !fir.ref<i32>
-!FIRDialect: omp.terminator
-!FIRDialect: }
-!FIRDialect: omp.terminator
-!FIRDialect: }
-!FIRDialect: omp.sections nowait {
-!FIRDialect: omp.terminator
-!FIRDialect: }
-!FIRDialect: return
-!FIRDialect: }
+!CHECK: func @_QQmain() {
+!CHECK: %[[COUNT:.*]] = fir.address_of(@_QFEcount) : !fir.ref<i32>
+!CHECK: %[[DOUBLE_COUNT:.*]] = fir.address_of(@_QFEdouble_count) : !fir.ref<i32>
+!CHECK: %[[ETA:.*]] = fir.alloca f32 {bindc_name = "eta", uniq_name = "_QFEeta"}
+!CHECK: %[[CONST_1:.*]] = arith.constant 1 : i32
+!CHECK: omp.sections allocate(%[[CONST_1]] : i32 -> %0 : !fir.ref<i32>) {
+!CHECK: omp.section {
+!CHECK: {{.*}} = arith.constant 5 : i32
+!CHECK: fir.store {{.*}} to {{.*}} : !fir.ref<i32>
+!CHECK: {{.*}} = fir.load %[[COUNT]] : !fir.ref<i32>
+!CHECK: {{.*}} = fir.load %[[DOUBLE_COUNT]] : !fir.ref<i32>
+!CHECK: {{.*}} = arith.muli {{.*}}, {{.*}} : i32
+!CHECK: {{.*}} = fir.convert {{.*}} : (i32) -> f32
+!CHECK: fir.store {{.*}} to %[[ETA]] : !fir.ref<f32>
+!CHECK: omp.terminator
+!CHECK: }
+!CHECK: omp.section {
+!CHECK: {{.*}} = fir.load %[[DOUBLE_COUNT]] : !fir.ref<i32>
+!CHECK: {{.*}} = arith.constant 1 : i32
+!CHECK: {{.*}} = arith.addi {{.*}} : i32
+!CHECK: fir.store {{.*}} to %[[DOUBLE_COUNT]] : !fir.ref<i32>
+!CHECK: omp.terminator
+!CHECK: }
+!CHECK: omp.section {
+!CHECK: {{.*}} = fir.load %[[ETA]] : !fir.ref<f32>
+!CHECK: {{.*}} = arith.constant 7.000000e+00 : f32
+!CHECK: {{.*}} = arith.subf {{.*}} : f32
+!CHECK: fir.store {{.*}} to %[[ETA]] : !fir.ref<f32>
+!CHECK: {{.*}} = fir.load %[[COUNT]] : !fir.ref<i32>
+!CHECK: {{.*}} = fir.convert {{.*}} : (i32) -> f32
+!CHECK: {{.*}} = fir.load %[[ETA]] : !fir.ref<f32>
+!CHECK: {{.*}} = arith.mulf {{.*}}, {{.*}} : f32
+!CHECK: {{.*}} = fir.convert {{.*}} : (f32) -> i32
+!CHECK: fir.store {{.*}} to %[[COUNT]] : !fir.ref<i32>
+!CHECK: {{.*}} = fir.load %[[COUNT]] : !fir.ref<i32>
+!CHECK: {{.*}} = fir.convert {{.*}} : (i32) -> f32
+!CHECK: {{.*}} = fir.load %[[ETA]] : !fir.ref<f32>
+!CHECK: {{.*}} = arith.subf {{.*}}, {{.*}} : f32
+!CHECK: {{.*}} = fir.convert {{.*}} : (f32) -> i32
+!CHECK: fir.store {{.*}} to %[[DOUBLE_COUNT]] : !fir.ref<i32>
+!CHECK: omp.terminator
+!CHECK: }
+!CHECK: omp.terminator
+!CHECK: }
+!CHECK: omp.sections nowait {
+!CHECK: omp.terminator
+!CHECK: }
+!CHECK: return
+!CHECK: }
-!LLVMDialect: llvm.func @_QQmain() {
-!LLVMDialect: %[[COUNT:.*]] = llvm.mlir.addressof @_QFEcount : !llvm.ptr<i32>
-!LLVMDialect: {{.*}} = builtin.unrealized_conversion_cast %[[COUNT]] : !llvm.ptr<i32> to !fir.ref<i32>
-!LLVMDialect: %[[DOUBLE_COUNT:.*]] = llvm.mlir.addressof @_QFEdouble_count : !llvm.ptr<i32>
-!LLVMDialect: %[[ALLOCATOR:.*]] = llvm.mlir.constant(1 : i64) : i64
-!LLVMDialect: %[[ETA:.*]] = llvm.alloca %[[ALLOCATOR]] x f32 {bindc_name = "eta", in_type = f32, operand_segment_sizes = dense<0> : vector<2xi32>, uniq_name = "_QFEeta"} : (i64) -> !llvm.ptr<f32>
-!LLVMDialect: %[[CONSTANT:.*]] = llvm.mlir.constant(1 : i32) : i32
-!LLVMDialect: omp.sections allocate(%[[CONSTANT]] : i32 -> %1 : !fir.ref<i32>) {
-!LLVMDialect: omp.section {
-!LLVMDialect: {{.*}} = llvm.mlir.constant(5 : i32) : i32
-!LLVMDialect: llvm.store {{.*}}, %[[COUNT]] : !llvm.ptr<i32>
-!LLVMDialect: {{.*}} = llvm.load %[[COUNT]] : !llvm.ptr<i32>
-!LLVMDialect: {{.*}} = llvm.load %[[DOUBLE_COUNT]] : !llvm.ptr<i32>
-!LLVMDialect: {{.*}} = llvm.mul {{.*}}, {{.*}} : i32
-!LLVMDialect: {{.*}} = llvm.sitofp {{.*}} : i32 to f32
-!LLVMDialect: llvm.store {{.*}}, %[[ETA]] : !llvm.ptr<f32>
-!LLVMDialect: omp.terminator
-!LLVMDialect: }
-!LLVMDialect: omp.section {
-!LLVMDialect: {{.*}} = llvm.load %[[DOUBLE_COUNT]] : !llvm.ptr<i32>
-!LLVMDialect: {{.*}} = llvm.mlir.constant(1 : i32) : i32
-!LLVMDialect: {{.*}} = llvm.add {{.*}}, {{.*}} : i32
-!LLVMDialect: llvm.store {{.*}}, %[[DOUBLE_COUNT]] : !llvm.ptr<i32>
-!LLVMDialect: omp.terminator
-!LLVMDialect: }
-!LLVMDialect: omp.section {
-!LLVMDialect: {{.*}} = llvm.load %[[ETA]] : !llvm.ptr<f32>
-!LLVMDialect: {{.*}} = llvm.mlir.constant(7.000000e+00 : f32) : f32
-!LLVMDialect: {{.*}} = llvm.fsub {{.*}}, {{.*}} : f32
-!LLVMDialect: llvm.store {{.*}}, %[[ETA]] : !llvm.ptr<f32>
-!LLVMDialect: {{.*}} = llvm.load %[[COUNT]] : !llvm.ptr<i32>
-!LLVMDialect: {{.*}} = llvm.sitofp {{.*}} : i32 to f32
-!LLVMDialect: {{.*}} = llvm.load %[[ETA]] : !llvm.ptr<f32>
-!LLVMDialect: {{.*}} = llvm.fmul {{.*}}, {{.*}} : f32
-!LLVMDialect: {{.*}} = llvm.fptosi {{.*}} : f32 to i32
-!LLVMDialect: llvm.store {{.*}}, %[[COUNT]] : !llvm.ptr<i32>
-!LLVMDialect: {{.*}} = llvm.load %[[COUNT]] : !llvm.ptr<i32>
-!LLVMDialect: {{.*}} = llvm.sitofp {{.*}} : i32 to f32
-!LLVMDialect: {{.*}} = llvm.load %[[ETA]] : !llvm.ptr<f32>
-!LLVMDialect: {{.*}} = llvm.fsub {{.*}}, {{.*}} : f32
-!LLVMDialect: {{.*}} = llvm.fptosi {{.*}} : f32 to i32
-!LLVMDialect: llvm.store {{.*}}, %[[DOUBLE_COUNT]] : !llvm.ptr<i32>
-!LLVMDialect: omp.terminator
-!LLVMDialect: }
-!LLVMDialect: omp.terminator
-!LLVMDialect: }
-!LLVMDialect: omp.sections nowait {
-!LLVMDialect: omp.section {
-!LLVMDialect: omp.terminator
-!LLVMDialect: }
-!LLVMDialect: omp.terminator
-!LLVMDialect: }
-!LLVMDialect: llvm.return
-!LLVMDialect: }
-
-program sample
+program sample
use omp_lib
integer :: count = 0, double_count = 1
!$omp sections private (eta, double_count) allocate(omp_high_bw_mem_alloc: count)
@@ -129,48 +71,28 @@ program sample
!$omp end sections nowait
end program sample
-!FIRDialect: func @_QPfirstprivate(%[[ARG:.*]]: !fir.ref<f32> {fir.bindc_name = "alpha"}) {
-!FIRDialect: omp.sections {
-!FIRDialect: omp.section {
-!FIRDialect: omp.terminator
-!FIRDialect: }
-!FIRDialect: omp.terminator
-!FIRDialect: }
-!FIRDialect: omp.sections {
-!FIRDialect: omp.section {
-!FIRDialect: %[[PRIVATE_VAR:.*]] = fir.load %[[ARG]] : !fir.ref<f32>
-!FIRDialect: %[[CONSTANT:.*]] = arith.constant 5.000000e+00 : f32
-!FIRDialect: %[[PRIVATE_VAR_2:.*]] = arith.mulf %[[PRIVATE_VAR]], %[[CONSTANT]] : f32
-!FIRDialect: fir.store %[[PRIVATE_VAR_2]] to %[[ARG]] : !fir.ref<f32>
-!FIRDialect: omp.terminator
-!FIRDialect: }
-!FIRDialect: omp.terminator
-!FIRDialect: }
-!FIRDialect: return
-!FIRDialect: }
-
-!LLVMDialect: llvm.func @_QPfirstprivate(%[[ARG:.*]]: !llvm.ptr<f32> {fir.bindc_name = "alpha"}) {
-!LLVMDialect: omp.sections {
-!LLVMDialect: omp.section {
-!LLVMDialect: omp.terminator
-!LLVMDialect: }
-!LLVMDialect: omp.terminator
-!LLVMDialect: }
-!LLVMDialect: omp.sections {
-!LLVMDialect: omp.section {
-!LLVMDialect: {{.*}} = llvm.load %[[ARG]] : !llvm.ptr<f32>
-!LLVMDialect: {{.*}} = llvm.mlir.constant(5.000000e+00 : f32) : f32
-!LLVMDialect: {{.*}} = llvm.fmul {{.*}}, {{.*}} : f32
-!LLVMDialect: llvm.store {{.*}}, %[[ARG]] : !llvm.ptr<f32>
-!LLVMDialect: omp.terminator
-!LLVMDialect: }
-!LLVMDialect: omp.terminator
-!LLVMDialect: }
-!LLVMDialect: llvm.return
-!LLVMDialect: }
+!CHECK: func @_QPfirstprivate(%[[ARG:.*]]: !fir.ref<f32> {fir.bindc_name = "alpha"}) {
+!CHECK: omp.sections {
+!CHECK: omp.section {
+!CHECK: omp.terminator
+!CHECK: }
+!CHECK: omp.terminator
+!CHECK: }
+!CHECK: omp.sections {
+!CHECK: omp.section {
+!CHECK: %[[PRIVATE_VAR:.*]] = fir.load %[[ARG]] : !fir.ref<f32>
+!CHECK: %[[CONSTANT:.*]] = arith.constant 5.000000e+00 : f32
+!CHECK: %[[PRIVATE_VAR_2:.*]] = arith.mulf %[[PRIVATE_VAR]], %[[CONSTANT]] : f32
+!CHECK: fir.store %[[PRIVATE_VAR_2]] to %[[ARG]] : !fir.ref<f32>
+!CHECK: omp.terminator
+!CHECK: }
+!CHECK: omp.terminator
+!CHECK: }
+!CHECK: return
+!CHECK: }
subroutine firstprivate(alpha)
- real :: alpha
+ real :: alpha
!$omp sections firstprivate(alpha)
!$omp end sections
More information about the flang-commits
mailing list