[Mlir-commits] [flang] [llvm] [mlir] [flang][OpenMP] Add basic support to lower `loop` directive to MLIR (PR #114199)
Sergio Afonso
llvmlistbot at llvm.org
Thu Oct 31 08:51:41 PDT 2024
================
@@ -0,0 +1,82 @@
+! This test checks lowering of OpenMP loop Directive.
+
+! RUN: bbc -emit-hlfir -fopenmp -fopenmp-version=50 -o - %s 2>&1 | FileCheck %s
+! RUN: %flang_fc1 -emit-hlfir -fopenmp -fopenmp-version=50 -o - %s 2>&1 | FileCheck %s
+
+! CHECK: omp.declare_reduction @[[RED:add_reduction_i32]] : i32
+! CHECK: omp.private {type = private} @[[DUMMY_PRIV:.*test_privateEdummy_private.*]] : !fir.ref<i32>
+! CHECK: omp.private {type = private} @[[I_PRIV:.*test_no_clausesEi.*]] : !fir.ref<i32>
+
+! CHECK-LABEL: func.func @_QPtest_no_clauses
+subroutine test_no_clauses()
+ integer :: i, j, dummy = 1
+
+ ! CHECK: omp.loop private(@[[I_PRIV]] %{{.*}}#0 -> %[[ARG:.*]] : !fir.ref<i32>) {
+ ! CHECK: omp.loop_nest (%[[IV:.*]]) : i32 = (%{{.*}}) to (%{{.*}}) {{.*}} {
+ ! CHECK: %[[ARG_DECL:.*]]:2 = hlfir.declare %[[ARG]]
+ ! CHECK: fir.store %[[IV]] to %[[ARG_DECL]]#1 : !fir.ref<i32>
+ ! CHECK: }
+ ! CHECK: }
+ !$omp loop
+ do i=1,10
+ dummy = dummy + 1
+ end do
+ !$omp end loop
+end subroutine
+
+! CHECK-LABEL: func.func @_QPtest_collapse
+subroutine test_collapse()
+ integer :: i, j, dummy = 1
+ ! CHECK: omp.loop private(@{{.*}} %{{.*}}#0 -> %{{.*}}, @{{.*}} %{{.*}}#0 -> %{{.*}} : {{.*}}) {
+ ! CHECK: omp.loop_nest (%{{.*}}, %{{.*}}) : i32 {{.*}} {
+ ! CHECK: }
+ ! CHECK: }
+ !$omp loop collapse(2)
+ do i=1,10
+ do j=2,20
+ dummy = dummy + 1
+ end do
+ end do
+ !$omp end loop
+end subroutine
+
+! CHECK-LABEL: func.func @_QPtest_private
+subroutine test_private()
+ integer :: i, dummy = 1
+ ! CHECK: omp.loop private(@[[DUMMY_PRIV]] %{{.*}}#0 -> %{{.*}}, @{{.*}} %{{.*}}#0 -> %{{.*}} : {{.*}}) {
+ ! CHECK: omp.loop_nest (%{{.*}}) : i32 = (%{{.*}}) to (%{{.*}}) {{.*}} {
+ ! CHECK: }
----------------
skatrak wrote:
Check that the private copy is the one being accessed in the body.
https://github.com/llvm/llvm-project/pull/114199
More information about the Mlir-commits
mailing list