brintos

brintos / llvm-project-archived public Read only

0
0
Text · 16.9 KiB · 4e29329 Raw
417 lines · plain
1! RUN: %flang_fc1 -fopenmp-simd -fdebug-dump-parse-tree %s 2>&1 | FileCheck %s2 3! Test that non-SIMD OpenMPConstructs are removed on the parse tree level4! when -fopenmp-simd is specified.5! Tests the logic in lib/Semantics/rewrite-parse-tree.cpp6 7! CHECK-LABEL: Name = 'test_simd'8subroutine test_simd()9  integer :: i10 11  ! CHECK: ExecutionPartConstruct -> ExecutableConstruct -> OpenMPConstruct -> OpenMPLoopConstruct12  ! CHECK: OmpDirectiveName -> llvm::omp::Directive = simd13  ! CHECK: ExecutionPartConstruct -> ExecutableConstruct -> DoConstruct14  !$omp simd15  do i = 1, 10016  end do17end subroutine18 19! CHECK-LABEL: Name = 'test_do_simd'20subroutine test_do_simd()21  integer :: i22 23  ! CHECK: ExecutionPartConstruct -> ExecutableConstruct -> OpenMPConstruct -> OpenMPLoopConstruct24  ! CHECK: OmpDirectiveName -> llvm::omp::Directive = do simd25  ! CHECK: ExecutionPartConstruct -> ExecutableConstruct -> DoConstruct26  !$omp do simd27  do i = 1, 10028  end do29end subroutine30 31 32! CHECK-LABEL: Name = 'test_parallel_do_simd'33subroutine test_parallel_do_simd()34  integer :: i35 36  ! CHECK: ExecutionPartConstruct -> ExecutableConstruct -> OpenMPConstruct -> OpenMPLoopConstruct37  ! CHECK: OmpDirectiveName -> llvm::omp::Directive = parallel do simd38  ! CHECK: ExecutionPartConstruct -> ExecutableConstruct -> DoConstruct39  !$omp parallel do simd40  do i = 1, 10041  end do42end subroutine43 44! CHECK-LABEL: Name = 'test_simd_scan'45subroutine test_simd_scan()46  integer :: i47  real :: sum48 49  ! CHECK: ExecutionPartConstruct -> ExecutableConstruct -> OpenMPConstruct -> OpenMPLoopConstruct50  ! CHECK: OmpDirectiveName -> llvm::omp::Directive = simd51  !$omp simd reduction(inscan,+:sum)52  do i = 1, N53    sum = sum + a(i)54    ! CHECK: ExecutionPartConstruct -> ExecutableConstruct -> OpenMPConstruct -> OpenMPStandaloneConstruct -> OpenMPSimpleStandaloneConstruct -> OmpDirectiveSpecification55    ! CHECK: OmpDirectiveName -> llvm::omp::Directive = scan56    !$omp scan inclusive(sum)57    sum       = sum + a(i)58  end do59 60end subroutine61 62! CHECK-LABEL: Name = 'test_simd_atomic'63subroutine test_simd_atomic()64  integer :: i, x65 66  ! CHECK: ExecutionPartConstruct -> ExecutableConstruct -> OpenMPConstruct -> OpenMPLoopConstruct67  ! CHECK: OmpDirectiveName -> llvm::omp::Directive = simd68  ! CHECK: ExecutionPartConstruct -> ExecutableConstruct -> DoConstruct69  !$omp simd70  do i = 1, 10071  ! CHECK-NOT: ExecutionPartConstruct -> ExecutableConstruct -> OpenMPConstruct -> OpenMPAtomicConstruct72  ! CHECK: ExecutionPartConstruct -> ExecutableConstruct -> ActionStmt -> AssignmentStmt = 'x=i'73  !$omp atomic write74  x = i75  end do76end subroutine77 78! CHECK-LABEL: Name = 'test_do'79subroutine test_do()80  integer :: i81 82  ! CHECK-NOT: ExecutionPartConstruct -> ExecutableConstruct -> OpenMPConstruct -> OpenMPLoopConstruct83  ! CHECK-NOT: OmpDirectiveName -> llvm::omp::Directive = do84  ! CHECK: ExecutionPartConstruct -> ExecutableConstruct -> DoConstruct85  !$omp parallel do86  do i = 1, 10087  end do88end subroutine89 90! CHECK-LABEL: Name = 'test_do_nested'91subroutine test_do_nested()92  integer :: i93 94  ! CHECK-NOT: ExecutionPartConstruct -> ExecutableConstruct -> OpenMPConstruct -> OpenMPLoopConstruct95  ! CHECK-NOT: OmpDirectiveName -> llvm::omp::Directive = parallel do96  ! CHECK: ExecutionPartConstruct -> ExecutableConstruct -> DoConstruct97  ! CHECK: ExecutionPartConstruct -> ExecutableConstruct -> DoConstruct98  !$omp parallel do99  do i = 1, 100100    do j = 1, 100101    end do102  end do103end subroutine104 105! CHECK-LABEL: Name = 'test_target'106subroutine test_target()107  integer :: i108 109  ! CHECK-NOT: ExecutionPartConstruct -> ExecutableConstruct -> OpenMPConstruct -> OpenMPBlockct110  ! CHECK-NOT: OmpDirectiveName -> llvm::omp::Directive = target111  ! CHECK: ExecutionPartConstruct -> ExecutableConstruct -> DoConstruct112  !$omp target113  do i = 1, 100114  end do115  !$omp end target116end subroutine117 118! CHECK-LABEL: Name = 'test_target_teams_distribute'119subroutine test_target_teams_distribute()120  integer :: i121 122  ! CHECK-NOT: ExecutionPartConstruct -> ExecutableConstruct -> OpenMPConstruct -> OpenMPLoopConstruct123  ! CHECK-NOT: OmpDirectiveName -> llvm::omp::Directive = target teams distribute124  ! CHECK: ExecutionPartConstruct -> ExecutableConstruct -> DoConstruct125  !$omp target teams distribute126  do i = 1, 100127  end do128  !$omp end target teams distribute129end subroutine130 131 132! CHECK-LABEL: Name = 'test_target_data'133subroutine test_target_data()134  ! CHECK-NOT: ExecutionPartConstruct -> ExecutableConstruct -> OpenMPConstruct -> OmpBlockConstruct135  ! CHECK-NOT: OmpDirectiveName -> llvm::omp::Directive = target data136  ! CHECK: ExecutionPartConstruct -> ExecutableConstruct -> DoConstruct137  !$omp target data map(to: A) map(tofrom: B)138  do i = 1, 100139  end do140  !$omp end target data141end subroutine142 143! CHECK-LABEL: Name = 'test_loop'144subroutine test_loop()145  integer :: i146 147  ! CHECK-NOT: ExecutionPartConstruct -> ExecutableConstruct -> OpenMPConstruct -> OpenMPLoopConstruct148  ! CHECK-NOT: OmpDirectiveName -> llvm::omp::Directive = loop149  ! CHECK: ExecutionPartConstruct -> ExecutableConstruct -> DoConstruct150  !$omp loop bind(thread)151  do i = 1, 100152  end do153end subroutine154 155! CHECK-LABEL: Name = 'test_unroll'156subroutine test_unroll()157  integer :: i158 159  ! CHECK-NOT: ExecutionPartConstruct -> ExecutableConstruct -> OpenMPConstruct -> OpenMPLoopConstruct160  ! CHECK-NOT: OmpDirectiveName -> llvm::omp::Directive = unroll161  ! CHECK: ExecutionPartConstruct -> ExecutableConstruct -> DoConstruct162  !$omp unroll163  do i = 1, 100164  end do165end subroutine166 167! CHECK-LABEL: Name = 'test_do_ordered'168subroutine test_do_ordered()169  integer :: i, x170  x = 0171 172  ! CHECK-NOT: ExecutionPartConstruct -> ExecutableConstruct -> OpenMPConstruct -> OpenMPLoopConstruct173  ! CHECK-NOT: OmpDirectiveName -> llvm::omp::Directive = do174  ! CHECK: ExecutionPartConstruct -> ExecutableConstruct -> DoConstruct175  !$omp do ordered176  do i = 1, 100177  ! CHECK-NOT: ExecutionPartConstruct -> ExecutableConstruct -> OpenMPConstruct -> OmpBlockConstruct178  ! CHECK-NOT: OmpDirectiveName -> llvm::omp::Directive = ordered179  !$omp ordered180  x = x + 1181  !$omp end ordered182  end do183end subroutine184 185! CHECK-LABEL: Name = 'test_cancel'186subroutine test_cancel()187  integer :: i, x188  x = 0189 190  ! CHECK-NOT: ExecutionPartConstruct -> ExecutableConstruct -> OpenMPConstruct -> OpenMPLoopConstruct191  ! CHECK-NOT: OmpDirectiveName -> llvm::omp::Directive = parallel do192  ! CHECK: ExecutionPartConstruct -> ExecutableConstruct -> DoConstruct193  !$omp parallel do194  do i = 1, 100195  if (i == 10) then196    ! CHECK-NOT: ExecutionPartConstruct -> ExecutableConstruct -> OpenMPConstruct -> OpenMPStandaloneConstruct -> OpenMPCancelConstruct -> OmpDirectiveSpecification197    ! CHECK-NOT: OmpDirectiveName -> llvm::omp::Directive = cancel198    !$omp cancel do199  end if200  ! CHECK-NOT: ExecutionPartConstruct -> ExecutableConstruct -> OpenMPConstruct -> OpenMPStandaloneConstruct -> OpenMPCancellationPointConstruct -> OmpDirectiveSpecification201  ! CHECK-NOT: OmpDirectiveName -> llvm::omp::Directive = cancellation point202  !$omp cancellation point do203  end do204end subroutine205 206! CHECK-LABEL: Name = 'test_scan'207subroutine test_scan()208  integer :: i, sum209 210  ! CHECK-NOT: ExecutionPartConstruct -> ExecutableConstruct -> OpenMPConstruct -> OpenMPLoopConstruct211  ! CHECK-NOT: OmpDirectiveName -> llvm::omp::Directive = parallel do212  ! CHECK: ExecutionPartConstruct -> ExecutableConstruct -> DoConstruct213  !$omp parallel do reduction(inscan, +: sum)214  do i = 1, n215    sum = sum + i216    ! CHECK-NOT: ExecutionPartConstruct -> ExecutableConstruct -> OpenMPConstruct -> OpenMPStandaloneConstruct -> OpenMPSimpleStandaloneConstruct -> OmpDirectiveSpecification217    ! CHECK-NOT: OmpDirectiveName -> llvm::omp::Directive = scan218    !$omp scan inclusive(sum)219  end do220  !$omp end parallel do221end subroutine222 223! CHECK-LABEL: Name = 'test_target_map'224subroutine test_target_map()225  integer :: array(10)226 227  ! CHECK-NOT: ExecutionPartConstruct -> ExecutableConstruct -> OpenMPConstruct -> OmpBlockConstruct228  ! CHECK-NOT: OmpDirectiveName -> llvm::omp::Directive = target229  !$omp target map(tofrom: array(2:10))230    array(2) = array(2) * 2231  !$omp end target232end subroutine233 234! CHECK-LABEL: Name = 'test_sections'235subroutine test_sections()236  ! CHECK-NOT: ExecutionPartConstruct -> ExecutableConstruct -> OpenMPConstruct -> OpenMPSectionsConstruct237  !$omp sections238  ! CHECK-NOT: OpenMPConstruct -> OpenMPSectionConstruct239  !$omp section240  ! CHECK-NOT: OpenMPConstruct -> OpenMPSectionConstruct241  !$omp section242  !$omp end sections243end subroutine244 245! CHECK-LABEL: Name = 'test_threadprivate_mod'246module test_threadprivate_mod247  implicit none248  ! CHECK: DeclarationConstruct -> SpecificationConstruct -> TypeDeclarationStmt249  ! CHECK: Name = 'x'250  ! CHECK: Name = 'y'251  integer :: x, y252  ! CHECK: DeclarationConstruct -> SpecificationConstruct -> OtherSpecificationStmt -> CommonStmt253  ! CHECK: Name = 'x'254  ! CHECK: Name = 'y'255  common /vars/ x, y256  ! CHECK-NOT: DeclarationConstruct -> SpecificationConstruct -> OpenMPDeclarativeConstruct -> OpenMPThreadprivate257  !$omp threadprivate(/vars/)258end module259 260! CHECK-LABEL: Name = 'test_atomic'261subroutine test_atomic()262  real :: z, x, y263  !$omp parallel private(tid, z)264    ! CHECK-NOT: ExecutionPartConstruct -> ExecutableConstruct -> OpenMPConstruct -> OpenMPAtomicConstruct265    ! CHECK: ExecutionPartConstruct -> ExecutableConstruct -> ActionStmt -> AssignmentStmt = 'x=y'266    !$omp atomic write267      x = y268    ! CHECK-NOT: ExecutionPartConstruct -> ExecutableConstruct -> OpenMPConstruct -> OpenMPAtomicConstruct269    ! CHECK: ExecutionPartConstruct -> ExecutableConstruct -> ActionStmt -> AssignmentStmt = 'z=x'270    !$omp atomic read271      z = x272    ! CHECK-NOT: ExecutionPartConstruct -> ExecutableConstruct -> OpenMPConstruct -> OpenMPAtomicConstruct273    ! CHECK: ExecutionPartConstruct -> ExecutableConstruct -> ActionStmt -> AssignmentStmt = 'x=x+1._4'274    !$omp atomic update275      x = x + 1276    ! CHECK-NOT: ExecutionPartConstruct -> ExecutableConstruct -> OpenMPConstruct -> OpenMPAtomicConstruct277    ! CHECK: ExecutionPartConstruct -> ExecutableConstruct -> ActionStmt -> AssignmentStmt = 'z=x'278    !$omp atomic read279      z = x280    ! CHECK-NOT: ExecutionPartConstruct -> ExecutableConstruct -> OpenMPConstruct -> OpenMPAtomicConstruct281    ! CHECK: ExecutionPartConstruct -> ExecutableConstruct -> ActionStmt -> AssignmentStmt = 'x=x+y'282    !$omp atomic capture283      x   = x + y284    !$omp end atomic285  !$omp end parallel286end subroutine287 288! CHECK-LABEL: Name = 'test_task_single_taskwait'289subroutine test_task_single_taskwait()290  integer :: x291  ! CHECK-NOT: ExecutionPartConstruct -> ExecutableConstruct -> OpenMPConstruct -> OmpBlockConstruct292  ! CHECK-NOT: OmpDirectiveName -> llvm::omp::Directive = parallel293  !$omp parallel294  ! CHECK-NOT: ExecutionPartConstruct -> ExecutableConstruct -> OpenMPConstruct -> OmpBlockConstruct295  ! CHECK-NOT: OmpDirectiveName -> llvm::omp::Directive = single296  !$omp single297    ! CHECK: ExecutionPartConstruct -> ExecutableConstruct -> DoConstruct298    do i = 1, 5299      ! CHECK-NOT: ExecutionPartConstruct -> ExecutableConstruct -> OpenMPConstruct -> OmpBlockConstruct300      ! CHECK-NOT: OmpDirectiveName -> llvm::omp::Directive = task301      ! CHECK: ExecutionPartConstruct -> ExecutableConstruct -> ActionStmt -> AssignmentStmt = 'x=i'302      !$omp task303      x = i304      !$omp end task305    end do306    ! CHECK-NOT: ExecutionPartConstruct -> ExecutableConstruct -> OpenMPConstruct -> OpenMPStandaloneConstruct -> OpenMPSimpleStandaloneConstruct -> OmpDirectiveSpecification307    ! CHECK-NOT: OmpDirectiveName -> llvm::omp::Directive = taskwait308    !$omp taskwait309  !$omp end single310  !$omp end parallel311end subroutine312 313! CHECK-LABEL: Name = 'test_task_taskyield_flush_barrier'314subroutine test_task_taskyield_flush_barrier()315  integer :: x, i316  ! CHECK-NOT: ExecutionPartConstruct -> ExecutableConstruct -> OpenMPConstruct -> OmpBlockConstruct317  ! CHECK-NOT: OmpDirectiveName -> llvm::omp::Directive = parallel318  !$omp parallel319    ! CHECK-NOT: ExecutionPartConstruct -> ExecutableConstruct -> OpenMPConstruct -> OpenMPStandaloneConstruct -> OpenMPSimpleStandaloneConstruct -> OmpDirectiveSpecification320    ! CHECK-NOT: OmpDirectiveName -> llvm::omp::Directive = barrier321    !$omp barrier322    ! CHECK-NOT: ExecutionPartConstruct -> ExecutableConstruct -> OpenMPConstruct -> OmpBlockConstruct323    ! CHECK-NOT: OmpDirectiveName -> llvm::omp::Directive = single324    !$omp single325      ! CHECK-NOT: ExecutionPartConstruct -> ExecutableConstruct -> OpenMPConstruct -> OmpBlockConstruct326      ! CHECK-NOT: OmpDirectiveName -> llvm::omp::Directive = task327      !$omp task328        ! CHECK-NOT: ExecutionPartConstruct -> ExecutableConstruct -> OpenMPConstruct -> OpenMPStandaloneConstruct -> OpenMPSimpleStandaloneConstruct -> OmpDirectiveSpecification329        ! CHECK-NOT: OmpDirectiveName -> llvm::omp::Directive = taskyield330        !$omp taskyield331        ! CHECK: ExecutionPartConstruct -> ExecutableConstruct -> ActionStmt -> AssignmentStmt = 'x=i'332        x = i333        ! CHECK-NOT: ExecutionPartConstruct -> ExecutableConstruct -> OpenMPConstruct -> OpenMPStandaloneConstruct -> OpenMPFlushConstruct -> OmpDirectiveSpecification334        !$omp flush335      !$omp end task336      ! CHECK-NOT: ExecutionPartConstruct -> ExecutableConstruct -> OpenMPConstruct -> OmpBlockConstruct337      ! CHECK-NOT: OmpDirectiveName -> llvm::omp::Directive = task338      !$omp task339        ! CHECK-NOT: ExecutionPartConstruct -> ExecutableConstruct -> OpenMPConstruct -> OpenMPStandaloneConstruct -> OpenMPFlushConstruct -> OmpDirectiveSpecification340        !$omp flush341      !$omp end task342      ! CHECK-NOT: ExecutionPartConstruct -> ExecutableConstruct -> OpenMPConstruct -> OpenMPStandaloneConstruct -> OpenMPSimpleStandaloneConstruct -> OmpDirectiveSpecification343      ! CHECK-NOT: OmpDirectiveName -> llvm::omp::Directive = taskwait344      !$omp taskwait345    !$omp end single346  !$omp end parallel347end subroutine348 349! CHECK-LABEL: Name = 'test_master_masked'350subroutine test_master_masked()351  ! CHECK-NOT: ExecutionPartConstruct -> ExecutableConstruct -> OpenMPConstruct -> OmpBlockConstruct352  ! CHECK-NOT: OmpDirectiveName -> llvm::omp::Directive = parallel353  !$omp parallel private(tid)354    ! CHECK-NOT: ExecutionPartConstruct -> ExecutableConstruct -> OpenMPConstruct -> OmpBlockConstruct355    ! CHECK-NOT: OmpDirectiveName -> llvm::omp::Directive = masked356    !$omp masked357    ! CHECK: ExecutionPartConstruct -> ExecutableConstruct -> ActionStmt -> AssignmentStmt = 'x=y'358    x = y359    !$omp end masked360    ! CHECK-NOT: ExecutionPartConstruct -> ExecutableConstruct -> OpenMPConstruct -> OmpBlockConstruct361    ! CHECK-NOT: OmpDirectiveName -> llvm::omp::Directive = master362    !$omp master363    ! CHECK: ExecutionPartConstruct -> ExecutableConstruct -> ActionStmt -> AssignmentStmt = 'y=x'364    y = x365    !$omp end master366  !$omp end parallel367end subroutine368 369! CHECK-LABEL: Name = 'test_critical'370subroutine test_critical()371  ! CHECK-NOT: ExecutionPartConstruct -> ExecutableConstruct -> OpenMPConstruct -> OmpBlockConstruct372  ! CHECK-NOT: OmpDirectiveName -> llvm::omp::Directive = parallel373  !$omp parallel do private(i)374  do i = 1, 4375    !$omp critical(mylock)376    ! CHECK: ExecutionPartConstruct -> ExecutableConstruct -> ActionStmt -> AssignmentStmt = 'x=y'377    x = y378    !$omp end critical(mylock)379  end do380  !$omp end parallel do381end subroutine382 383! CHECK-LABEL: Name = 'test_target_enter_exit_update_data'384subroutine test_target_enter_exit_update_data()385  ! CHECK-NOT: ExecutionPartConstruct -> ExecutableConstruct -> OpenMPConstruct -> OpenMPStandaloneConstruct -> OpenMPSimpleStandaloneConstruct -> OmpDirectiveSpecification386  ! CHECK-NOT: OmpDirectiveName -> llvm::omp::Directive = target enter data387  !$omp target enter data map(to: A)388  ! CHECK-NOT: ExecutionPartConstruct -> ExecutableConstruct -> OpenMPConstruct -> OmpBlockConstruct389  ! CHECK-NOT: OmpDirectiveName -> llvm::omp::Directive = target teams distribute parallel do390  !$omp target teams distribute parallel do391  ! CHECK: ExecutionPartConstruct -> ExecutableConstruct -> DoConstruct392  do i = 1, n393    ! CHECK: ExecutionPartConstruct -> ExecutableConstruct -> ActionStmt -> AssignmentStmt = 'x=y'394    x = y395  end do396  !$omp end target teams distribute parallel do397  ! CHECK-NOT: ExecutionPartConstruct -> ExecutableConstruct -> OpenMPConstruct -> OpenMPStandaloneConstruct -> OpenMPSimpleStandaloneConstruct -> OmpDirectiveSpecification398  ! CHECK-NOT: OmpDirectiveName -> llvm::omp::Directive = target update399  !$omp target update from(A)400  ! CHECK-NOT: ExecutionPartConstruct -> ExecutableConstruct -> OpenMPConstruct -> OpenMPStandaloneConstruct -> OpenMPSimpleStandaloneConstruct -> OmpDirectiveSpecification401  ! CHECK-NOT: OmpDirectiveName -> llvm::omp::Directive = target exit data402  !$omp target exit data map(from: A)403end subroutine404 405! CHECK-LABEL: Name = 'test_declare_mapper'406module test_declare_mapper407  implicit none408 409  type :: myvec_t410    integer               :: len411    real, allocatable     :: data(:)412  end type myvec_t413 414  ! CHECK-NOT: DeclarationConstruct -> SpecificationConstruct -> OpenMPDeclarativeConstruct -> OpenMPDeclareMapperConstruct415  !$omp declare mapper(myvec_t :: v) map(v, v%data(1:v%len))416end module417