brintos

brintos / llvm-project-archived public Read only

0
0
Text · 4.8 KiB · 8e00721 Raw
186 lines · plain
1! This test checks correct propagation of location information in OpenACC2! operations.3 4 5! RUN: bbc -fopenacc -emit-hlfir --mlir-print-debuginfo --mlir-print-local-scope %s -o - | FileCheck %s6module acc_locations7  implicit none8 9  contains10 11  subroutine standalone_data_directive_locations(arr)12    real, dimension(10) :: arr13 14    !$acc enter data create(arr)15    !CHECK-LABEL: acc.enter_data16    !CHECK-SAME:  loc("{{.*}}locations.f90":14:11)17 18    !$acc update device(arr)19    !CHECK-LABEL: acc.update_device varPtr20    !CHECK-SAME:  loc("{{.*}}locations.f90":18:25)21    !CHECK-LABEL: acc.update dataOperands22    !CHECK-SAME:  loc("{{.*}}locations.f90":18:11)23 24    !$acc update host(arr)25    !CHECK-LABEL: acc.getdeviceptr varPtr26    !CHECK-SAME:  loc("{{.*}}locations.f90":24:23)27    !CHECK-LABEL: acc.update dataOperands28    !CHECK-SAME:  loc("{{.*}}locations.f90":24:11)29    !CHECK-LABEL: acc.update_host30    !CHECK-SAME:  loc("{{.*}}locations.f90":24:23)31 32    !$acc exit data delete(arr)33    !CHECK-LABEL: acc.exit_data34    !CHECK-SAME:  loc("{{.*}}locations.f90":32:11)35 36  end subroutine37 38  subroutine nested_acc_locations(arr1d)39    real, dimension(10) :: arr1d40    integer :: i41 42    !$acc data copy(arr1d)43    !$acc parallel44    !$acc loop45    do i = 1, 1046      arr1d(i) = arr1d(i) * 247    end do48    !$acc end parallel49    !$acc end data50 51    !CHECK: acc.data52    !CHECK: acc.parallel53    !CHECK: acc.loop54 55    !CHECK:        acc.yield loc("{{.*}}locations.f90":44:11)56    !CHECK-NEXT: } attributes {{.*}} loc(fused["{{.*}}locations.f90":44:11, "{{.*}}locations.f90":45:5])57 58    !CHECK:        acc.yield loc("{{.*}}locations.f90":43:11)59    !CHECK-NEXT: } loc("{{.*}}locations.f90":43:11)60 61    !CHECK-NEXT:   acc.terminator loc("{{.*}}locations.f90":42:11)62    !CHECK-NEXT: } loc("{{.*}}locations.f90":42:11)63 64  end subroutine65 66  subroutine runtime_directive()67 68    !$acc init69    !CHECK-LABEL: acc.init70    !CHECK-SAME:  loc("{{.*}}locations.f90":68:11)71 72    !$acc shutdown73    !CHECK-LABEL: acc.shutdown74    !CHECK-SAME:  loc("{{.*}}locations.f90":72:11)75 76  end subroutine77 78  subroutine combined_directive_locations(arr)79    real :: arr(:)80    integer :: i81 82    !$acc parallel loop83    do i = 1, size(arr)84      arr(i) = arr(i) * arr(i)85    end do86 87    !CHECK: acc.parallel88    !CHECK: acc.loop89    !CHECK:      acc.yield loc("{{.*}}locations.f90":82:11)90    !CHECK-NEXT: } {{.*}} loc(fused["{{.*}}locations.f90":82:11, "{{.*}}locations.f90":83:5])91    !CHECK:      acc.yield loc("{{.*}}locations.f90":82:11)92    !CHECK-NEXT: } loc("{{.*}}locations.f90":82:11)93  end subroutine94 95  subroutine if_clause_expr_location(arr)96    real :: arr(:)97    integer :: i98 99    !$acc parallel loop if(.true.)100    do i = 1, size(arr)101      arr(i) = arr(i) * arr(i)102    end do103 104    !CHECK: %{{.*}} = arith.constant true loc("{{.*}}locations.f90":99:25)105 106    !CHECK: acc.parallel107    !CHECK: acc.loop108    !CHECK:      acc.yield loc("{{.*}}locations.f90":99:11)109    !CHECK-NEXT: } {{.*}} loc(fused["{{.*}}locations.f90":99:11, "{{.*}}locations.f90":100:5])110    !CHECK:      acc.yield loc("{{.*}}locations.f90":99:11)111    !CHECK-NEXT: } loc("{{.*}}locations.f90":99:11)112  end subroutine113 114  subroutine atomic_read_loc()115    integer(4) :: x116    integer(8) :: y117 118    !$acc atomic read119    y = x120  end121  !CHECK: acc.atomic.read {{.*}} loc("{{.*}}locations.f90":118:11)122 123  subroutine atomic_capture_loc()124    implicit none125    integer :: k, v, i126 127    k = 1128    v = 0129 130    !$acc atomic capture131    v = k132    k = (i + 1) * 3.14133    !$acc end atomic134 135! CHECK: acc.atomic.capture {136! CHECK:   acc.atomic.read {{.*}} loc("{{.*}}locations.f90":130:11)137! CHECK:   acc.atomic.write {{.*}} loc("{{.*}}locations.f90":130:11)138! CHECK: } loc("{{.*}}locations.f90":130:11)139 140  end subroutine141 142  subroutine atomic_update_loc()143    implicit none144    integer :: x, y, z145 146    !$acc atomic147    y = y + 1148! CHECK: acc.atomic.update %{{.*}} : !fir.ref<i32> {149! CHECK: ^bb0(%{{.*}}: i32 loc("{{.*}}locations.f90":142:3)):150! CHECK: } loc("{{.*}}locations.f90":142:3)151 152    !$acc atomic update153    z = x * z154  end subroutine155 156  subroutine acc_loop_fused_locations(arr)157    real, dimension(10,10,10) :: arr158    integer :: i, j, k159 160    !$acc loop collapse(3)161    do i = 1, 10162      do j = 1, 10163        do k = 1, 10164          arr(i,j,k) = arr(i,j,k) * 2165        end do166      end do167    end do168  end subroutine169 170! CHECK-LABEL: func.func @_QMacc_locationsPacc_loop_fused_locations171! CHECK: acc.loop172! CHECK: } attributes {collapse = [3]{{.*}}} loc(fused["{{.*}}locations.f90":160:11, "{{.*}}locations.f90":161:5, "{{.*}}locations.f90":162:7, "{{.*}}locations.f90":163:9])173 174  subroutine data_end_locations(arr)175    real, dimension(10) :: arr176 177    !$acc data copy(arr)178    !CHECK-LABEL: acc.copyin179    !CHECK-SAME:  loc("{{.*}}locations.f90":177:21)180 181    !$acc end data182    !CHECK-LABEL: acc.copyout183    !CHECK-SAME:  loc("{{.*}}locations.f90":181:11)184  end subroutine185end module186