brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.3 KiB · e5c3601 Raw
74 lines · plain
1! REQUIRES: openmp_runtime2 3!RUN: %flang_fc1 -emit-hlfir %openmp_flags %s -o - | FileCheck %s4 5!CHECK: omp.critical.declare @help26!CHECK: omp.critical.declare @help1 hint(contended)7 8subroutine omp_critical()9  use omp_lib10  integer :: x, y11!CHECK: omp.critical(@help1)12!$OMP CRITICAL(help1) HINT(omp_lock_hint_contended)13  x = x + y14!CHECK: omp.terminator15!$OMP END CRITICAL(help1)16 17! Test that the same name can be used again18! Also test with the zero hint expression19!CHECK: omp.critical(@help2)20!$OMP CRITICAL(help2) HINT(omp_lock_hint_none)21  x = x - y22!CHECK: omp.terminator23!$OMP END CRITICAL(help2)24 25!CHECK: omp.critical26!$OMP CRITICAL27  y = x + y28!CHECK: omp.terminator29!$OMP END CRITICAL30end subroutine omp_critical31 32 33! Tests that privatization for pre-determined variables (here `i`) is properly34! handled.35subroutine predetermined_privatization()36  integer :: a(10), i37 38  !CHECK: omp.parallel39  !$omp parallel do40 41  do i = 2, 1042    !CHECK: omp.wsloop private(@{{.*}} %{{.*}} -> %[[PRIV_I_ALLOC:.*]] : !fir.ref<i32>)43    !CHECK: omp.loop_nest (%[[IV:[^[:space:]]+]])44    !CHECK: %[[PRIV_I_DECL:.*]]:2 = hlfir.declare %[[PRIV_I_ALLOC]]45    !CHECK: hlfir.assign %[[IV]] to %[[PRIV_I_DECL]]#046    !CHECK: omp.critical47    !$omp critical48    a(i) = a(i-1) + 149    !$omp end critical50  end do51  !$omp end parallel do52end53 54! https://github.com/llvm/llvm-project/issues/7576755!CHECK-LABEL: func @_QPparallel_critical_privatization(56subroutine parallel_critical_privatization()57  integer :: i58 59  !CHECK: %[[I:.*]] = fir.alloca i32 {bindc_name = "i", uniq_name = "_QFparallel_critical_privatizationEi"}60  !CHECK: %[[I_DECL:.*]]:2 = hlfir.declare %[[I]] {uniq_name = "_QFparallel_critical_privatizationEi"} : (!fir.ref<i32>) -> (!fir.ref<i32>, !fir.ref<i32>)61  !CHECK: omp.parallel private(@{{.*}} %[[I_DECL]]#0 -> %[[PRIV_I:.*]] : !fir.ref<i32>) {62  !CHECK:   %[[PRIV_I_DECL:.*]]:2 = hlfir.declare %[[PRIV_I]] {uniq_name = "_QFparallel_critical_privatizationEi"} : (!fir.ref<i32>) -> (!fir.ref<i32>, !fir.ref<i32>)63  !$omp parallel default(firstprivate)64    !CHECK: omp.critical {65    !$omp critical66      !CHECK: %[[C200:.*]] = arith.constant 200 : i3267      !CHECK: hlfir.assign %[[C200]] to %[[PRIV_I_DECL]]#0 : i32, !fir.ref<i32>68      i = 20069    !CHECK: }70    !$omp end critical71  !CHECK: }72  !$omp end parallel73end subroutine74