brintos

brintos / llvm-project-archived public Read only

0
0
Text · 5.9 KiB · 40c76b2 Raw
199 lines · plain
1! RUN: not %flang_fc1 -fsyntax-only -fopenacc %s 2>&1 | FileCheck %s2program acc_data_test3    implicit none4    integer :: a(100), b(100), c(100), d(100)5    integer :: i, s ! FIXME: if s is named sum you get semantic errors.6 7    ! Positive tests8 9    ! Basic data construct in program body10    !$acc data copy(a, b) create(c)11    a = 112    b = 213    c = a + b14    !$acc end data15    print *, "After first data region"16 17    ! Data construct within IF block18    if (.true.) then19        !$acc data copyout(a)20        a = a + 121        !$acc end data22        print *, "Inside if block"23    end if24 25    ! Data construct within DO loop26    do i = 1, 1027        !$acc data present(a)28        a(i) = a(i) * 229        !$acc end data30        print *, "Loop iteration", i31    end do32 33    ! Nested data constructs34    !$acc data copyin(a)35    s = 036    !$acc data copy(s)37    s = s + 138    !$acc end data39    print *, "After nested data"40    !$acc end data41 42    ! Negative tests  43    ! Basic data construct in program body44    !$acc data copy(a, b) create(d) bogus()45    !CHECK: acc-data-statement.f90:46    !CHECK-SAME: error: expected end of OpenACC directive47    !CHECK-NEXT: !$acc data copy(a, b) create(d) bogus()48    !CHECK-NEXT: ^49    !CHECK-NEXT: in the context: OpenACC construct50    !CHECK-NEXT: !$acc data copy(a, b) create(d) bogus()51    !CHECK-NEXT: ^52    !CHECK-NEXT: in the context: execution part53    !CHECK-NEXT: !$acc data copy(a, b) create(c)54    !CHECK-NEXT: ^55    a = 156    b = 257    d = a + b58!   !$acc end data59    print *, "After first data region"60 61    ! Data construct within IF block62    if (.true.) then63        !$acc data copyout(a)64        a = a + 165!       !$acc end data66        print *, "Inside if block"67        !CHECK: acc-data-statement.f90:68        !CHECK-SAME: error: expected OpenACC end block directive69        !CHECK-NEXT: end if70        !CHECK-NEXT: ^ 71        !CHECK-NEXT: in the context: OpenACC construct72        !CHECK-NEXT: !$acc data copyout(a)73        !CHECK-NEXT: ^74        !CHECK-NEXT: in the context: IF construct75        !CHECK-NEXT: if (.true.) then76        !CHECK-NEXT: ^77    end if78 79    ! Data construct within DO loop80    do i = 1, 1081        !$acc data present(a)82        a(i) = a(i) * 283!       !$acc end data84        print *, "Loop iteration", i85        !CHECK: acc-data-statement.f90:86        !CHECK-SAME: error: expected OpenACC end block directive87        !CHECK-NEXT: end do88        !CHECK-NEXT: ^ 89        !CHECK-NEXT: in the context: OpenACC construct90        !CHECK-NEXT: !$acc data present(a)91        !CHECK-NEXT: ^92        !CHECK-NEXT: in the context: DO construct93        !CHECK-NEXT: do i = 1, 1094        !CHECK-NEXT: ^95    end do96 97    ! Nested data constructs98    !$acc data copyin(a)99    s = 0100    !$acc data copy(s)101    s = s + 1102!   !$acc end data103    print *, "After nested data"104    !$acc end data  I forgot to comment this out.105    !CHECK: acc-data-statement.f90:106    !CHECK-SAME: error: expected end of OpenACC directive107    !CHECK-NEXT: !$acc end data  I forgot to comment this out.108    !CHECK-NEXT: ^109    !CHECK-NEXT: in the context: OpenACC construct110    !CHECK-NEXT: !$acc data copy(s)111    !CHECK-NEXT: ^112    !CHECK-NEXT: in the context: OpenACC construct113    !CHECK-NEXT: !$acc data copyin(a)114    !CHECK-NEXT: ^115    print *, "Program finished"116 117    !CHECK: acc-data-statement.f90:118    !CHECK-SAME: error: expected OpenACC end block directive119    !CHECK-NEXT: contains120    !CHECK-NEXT: ^121    !CHECK-NEXT: in the context: OpenACC construct122    !CHECK-NEXT: !$acc data copyin(a)123    !CHECK-NEXT: ^124    !CHECK-NEXT: in the context: OpenACC construct125    !CHECK-NEXT: !$acc data copy(a, b) create(d) bogus()126    !CHECK-NEXT: ^127    !CHECK: acc-data-statement.f90:128    !CHECK-SAME: error: expected OpenACC end block directive129    !CHECK-NEXT: contains130    !CHECK-NEXT: ^131    !CHECK-NEXT: in the context: OpenACC construct132    !CHECK-NEXT: $acc data copy(a, b) create(d) bogus()133    !CHECK-NEXT: ^134    !CHECK-NEXT: in the context: execution part135    !CHECK-NEXT: !$acc data copy(a, b) create(c)136    !CHECK-NEXT: ^137contains138    subroutine positive_process_array(x)139        integer, intent(inout) :: x(:)140        141        ! Data construct in subroutine142        !$acc data copy(x)143        x = x + 1144        !$acc end data145        print *, "Subroutine finished"146    end subroutine147 148    function positive_compute_sum(x) result(total)149        integer, intent(in) :: x(:)150        integer :: total151        152        ! Data construct in function153        !$acc data copyin(x) copy(total)154        total = sum(x)155        !$acc end data156        print *, "Function finished"157    end function158    159    subroutine negative_process_array(x)160        integer, intent(inout) :: x(:)161        162        ! Data construct in subroutine163        !$acc data copy(x)164        x = x + 1165!       !$acc end data166        print *, "Subroutine finished"167        !CHECK: acc-data-statement.f90:168        !CHECK-SAME: error: expected OpenACC end block directive169        !CHECK-NEXT: end subroutine170        !CHECK-NEXT: ^171        !CHECK-NEXT: in the context: OpenACC construct172        !CHECK-NEXT: !$acc data copy(x)173        !CHECK-NEXT: ^174        !CHECK-NEXT: in the context: SUBROUTINE subprogram175        !CHECK-NEXT: subroutine negative_process_array(x)176        !CHECK-NEXT: ^177    end subroutine178 179    function negative_compute_sum(x) result(total)180        integer, intent(in) :: x(:)181        integer :: total182        total = sum(x)183        ! Data construct in function184        !$acc data copyin(x) copy(total)185        total = total + x186!       !$acc end data187        print *, "Function finished"188        !CHECK: acc-data-statement.f90:189        !CHECK-SAME: error: expected OpenACC end block directive190        !CHECK-NEXT: end function191        !CHECK-NEXT: ^ 192        !CHECK-NEXT: in the context: OpenACC construct193        !CHECK-NEXT: !$acc data copyin(x) copy(total)194        !CHECK-NEXT: ^195        !CHECK-NEXT: in the context: execution part196        !CHECK-NEXT: total = sum(x)197        !CHECK-NEXT: ^198    end function199end program acc_data_test