brintos

brintos / llvm-project-archived public Read only

0
0
Text · 9.3 KiB · bf0f724 Raw
252 lines · plain
1! RUN: %python %S/../test_symbols.py %s %flang_fc1 -fopenmp2 3! 2.15.1.1 Predetermined rules for associated do-loops index variable4!   a) The loop iteration variable(s) in the associated do-loop(s) of a do,5!      parallel do, taskloop, or distribute construct is (are) private.6!   b) The loop iteration variable in the associated do-loop of a simd construct7!      with just one associated do-loop is linear with a linear-step that is the8!      increment of the associated do-loop.9!   c) The loop iteration variables in the associated do-loops of a simd10!      construct with multiple associated do-loops are lastprivate.11!   d) A loop iteration variable for a sequential loop in a parallel or task12!      generating construct is private in the innermost such construct that13!      encloses the loop.14!   - TBD15 16! All the tests assume that the do-loops association for collapse/ordered17! clause has been performed (the number of nested do-loops >= n).18 19! Rule a)20! TODO: nested constructs (k should be private too)21!DEF: /test_do (Subroutine) Subprogram22subroutine test_do23 implicit none24 !DEF: /test_do/a ObjectEntity REAL(4)25 real a(20,20,20)26 !DEF: /test_do/i ObjectEntity INTEGER(4)27 !DEF: /test_do/j ObjectEntity INTEGER(4)28 !DEF: /test_do/k ObjectEntity INTEGER(4)29 integer i, j, k30!$omp parallel31 !DEF: /test_do/OtherConstruct1/i (OmpShared) HostAssoc INTEGER(4)32 i = 9933!$omp do  collapse(2)34 !DEF: /test_do/OtherConstruct1/OtherConstruct1/i (OmpPrivate, OmpPreDetermined) HostAssoc INTEGER(4)35 do i=1,536  !DEF: /test_do/OtherConstruct1/OtherConstruct1/j (OmpPrivate, OmpPreDetermined) HostAssoc INTEGER(4)37  do j=6,1038   !DEF: /test_do/OtherConstruct1/OtherConstruct1/a HostAssoc REAL(4)39   a(1,1,1) = 0.40   !DEF: /test_do/OtherConstruct1/k (OmpPrivate, OmpPreDetermined) HostAssoc INTEGER(4)41   do k=11,1542    !REF: /test_do/OtherConstruct1/OtherConstruct1/a43    !DEF: /test_do/OtherConstruct1/OtherConstruct1/k HostAssoc INTEGER(4)44    !REF: /test_do/OtherConstruct1/OtherConstruct1/j45    !REF: /test_do/OtherConstruct1/OtherConstruct1/i46    a(k,j,i) = 1.47   end do48  end do49 end do50!$omp end parallel51end subroutine test_do52 53! Rule a)54!DEF: /test_pardo (Subroutine) Subprogram55subroutine test_pardo56 implicit none57 !DEF: /test_pardo/a ObjectEntity REAL(4)58 real a(20,20,20)59 !DEF: /test_pardo/i ObjectEntity INTEGER(4)60 !DEF: /test_pardo/j ObjectEntity INTEGER(4)61 !DEF: /test_pardo/k ObjectEntity INTEGER(4)62 integer i, j, k63!$omp parallel do  collapse(2) private(k) ordered(2)64 !DEF: /test_pardo/OtherConstruct1/i (OmpPrivate, OmpPreDetermined) HostAssoc INTEGER(4)65 do i=1,566   !DEF: /test_pardo/OtherConstruct1/j (OmpPrivate, OmpPreDetermined) HostAssoc INTEGER(4)67    do j=6,1068   !DEF: /test_pardo/OtherConstruct1/a (OmpShared) HostAssoc REAL(4)69   a(1,1,1) = 0.70   !DEF: /test_pardo/OtherConstruct1/k (OmpPrivate, OmpExplicit) HostAssoc INTEGER(4)71   do k=11,1572    !REF: /test_pardo/OtherConstruct1/a73    !REF: /test_pardo/OtherConstruct1/k74    !REF: /test_pardo/OtherConstruct1/j75    !REF: /test_pardo/OtherConstruct1/i76    a(k,j,i) = 1.77   end do78  end do79 end do80end subroutine test_pardo81 82! Rule a)83!DEF: /test_taskloop (Subroutine) Subprogram84subroutine test_taskloop85 implicit none86 !DEF: /test_taskloop/a ObjectEntity REAL(4)87 real a(5,5)88 !DEF: /test_taskloop/i ObjectEntity INTEGER(4)89 !DEF: /test_taskloop/j ObjectEntity INTEGER(4)90 integer i, j91!$omp taskloop  private(j)92 !DEF: /test_taskloop/OtherConstruct1/i (OmpPrivate, OmpPreDetermined) HostAssoc INTEGER(4)93 do i=1,594  !DEF: /test_taskloop/OtherConstruct1/j (OmpPrivate, OmpExplicit) HostAssoc INTEGER(4)95  !REF: /test_taskloop/OtherConstruct1/i96  do j=1,i97   !DEF: /test_taskloop/OtherConstruct1/a (OmpFirstPrivate, OmpImplicit) HostAssoc REAL(4)98   !REF: /test_taskloop/OtherConstruct1/j99   !REF: /test_taskloop/OtherConstruct1/i100   a(j,i) = 3.14101  end do102 end do103!$omp end taskloop104end subroutine test_taskloop105 106! Rule a); OpenMP 4.5 Examples teams.2.f90107! TODO: reduction; data-mapping attributes108!DEF: /dotprod (Subroutine) Subprogram109!DEF: /dotprod/b (OmpMapTo) ObjectEntity REAL(4)110!DEF: /dotprod/c (OmpMapTo) ObjectEntity REAL(4)111!DEF: /dotprod/n ObjectEntity INTEGER(4)112!DEF: /dotprod/block_size ObjectEntity INTEGER(4)113!DEF: /dotprod/num_teams ObjectEntity INTEGER(4)114!DEF: /dotprod/block_threads ObjectEntity INTEGER(4)115subroutine dotprod (b, c, n, block_size, num_teams, block_threads)116 implicit none117 !REF: /dotprod/n118 integer n119 !REF: /dotprod/b120 !REF: /dotprod/n121 !REF: /dotprod/c122 !DEF: /dotprod/sum (OmpMapToFrom) ObjectEntity REAL(4)123 real b(n), c(n), sum124 !REF: /dotprod/block_size125 !REF: /dotprod/num_teams126 !REF: /dotprod/block_threads127 !DEF: /dotprod/i ObjectEntity INTEGER(4)128 !DEF: /dotprod/i0 ObjectEntity INTEGER(4)129 integer block_size, num_teams, block_threads, i, i0130 !REF: /dotprod/sum131 sum = 0.0e0132!$omp target  map(to:b,c)  map(tofrom:sum)133!$omp teams num_teams(num_teams) thread_limit(block_threads) reduction(+: sum)134!$omp distribute135 !DEF: /dotprod/OtherConstruct1/OtherConstruct1/OtherConstruct1/i0 (OmpPrivate, OmpPreDetermined) HostAssoc INTEGER(4)136 !REF: /dotprod/n137 !REF: /dotprod/block_size138 do i0=1,n,block_size139!$omp parallel do  reduction(+: sum)140  !DEF: /dotprod/OtherConstruct1/OtherConstruct1/OtherConstruct1/OtherConstruct1/i (OmpPrivate, OmpPreDetermined) HostAssoc INTEGER(4)141  !DEF: /dotprod/OtherConstruct1/OtherConstruct1/OtherConstruct1/OtherConstruct1/i0 (OmpShared) HostAssoc INTEGER(4)142  !DEF: /dotprod/min ELEMENTAL, INTRINSIC, PURE (Function) ProcEntity143  !DEF: /dotprod/OtherConstruct1/OtherConstruct1/OtherConstruct1/OtherConstruct1/block_size (OmpShared) HostAssoc INTEGER(4)144  !DEF: /dotprod/OtherConstruct1/OtherConstruct1/OtherConstruct1/OtherConstruct1/n (OmpShared) HostAssoc INTEGER(4)145  do i=i0,min(i0+block_size, n)146   !DEF: /dotprod/OtherConstruct1/OtherConstruct1/OtherConstruct1/OtherConstruct1/sum (OmpReduction, OmpExplicit) HostAssoc REAL(4)147   !DEF: /dotprod/OtherConstruct1/OtherConstruct1/OtherConstruct1/OtherConstruct1/b (OmpShared) HostAssoc REAL(4)148   !REF: /dotprod/OtherConstruct1/OtherConstruct1/OtherConstruct1/OtherConstruct1/i149   !DEF: /dotprod/OtherConstruct1/OtherConstruct1/OtherConstruct1/OtherConstruct1/c (OmpShared) HostAssoc REAL(4)150   sum = sum+b(i)*c(i)151  end do152 end do153!$omp end teams154!$omp end target155 !REF: /dotprod/sum156 print *, sum157end subroutine dotprod158 159! Rule b)160! TODO: nested constructs (j, k should be private too)161!DEF: /test_simd (Subroutine) Subprogram162subroutine test_simd163 implicit none164 !DEF: /test_simd/a ObjectEntity REAL(4)165 real a(20,20,20)166 !DEF: /test_simd/i ObjectEntity INTEGER(4)167 !DEF: /test_simd/j ObjectEntity INTEGER(4)168 !DEF: /test_simd/k ObjectEntity INTEGER(4)169 integer i, j, k170!$omp parallel do simd171 !DEF: /test_simd/OtherConstruct1/i (OmpLinear, OmpPreDetermined) HostAssoc INTEGER(4)172 do i=1,5173  !DEF: /test_simd/OtherConstruct1/j (OmpPrivate, OmpPreDetermined) HostAssoc INTEGER(4)174  do j=6,10175   !DEF: /test_simd/OtherConstruct1/k (OmpPrivate, OmpPreDetermined) HostAssoc INTEGER(4)176   do k=11,15177    !DEF: /test_simd/OtherConstruct1/a (OmpShared) HostAssoc REAL(4)178    !REF: /test_simd/OtherConstruct1/k179    !REF: /test_simd/OtherConstruct1/j180    !REF: /test_simd/OtherConstruct1/i181    a(k,j,i) = 3.14182   end do183  end do184 end do185end subroutine test_simd186 187! Rule c)188!DEF: /test_simd_multi (Subroutine) Subprogram189subroutine test_simd_multi190 implicit none191 !DEF: /test_simd_multi/a ObjectEntity REAL(4)192 real a(20,20,20)193 !DEF: /test_simd_multi/i ObjectEntity INTEGER(4)194 !DEF: /test_simd_multi/j ObjectEntity INTEGER(4)195 !DEF: /test_simd_multi/k ObjectEntity INTEGER(4)196 integer i, j, k197!$omp parallel do simd  collapse(3)198 !DEF: /test_simd_multi/OtherConstruct1/i (OmpLastPrivate, OmpPreDetermined) HostAssoc INTEGER(4)199 do i=1,5200  !DEF: /test_simd_multi/OtherConstruct1/j (OmpLastPrivate, OmpPreDetermined) HostAssoc INTEGER(4)201  do j=6,10202   !DEF: /test_simd_multi/OtherConstruct1/k (OmpLastPrivate, OmpPreDetermined) HostAssoc INTEGER(4)203   do k=11,15204    !DEF: /test_simd_multi/OtherConstruct1/a (OmpShared) HostAssoc REAL(4)205    !REF: /test_simd_multi/OtherConstruct1/k206    !REF: /test_simd_multi/OtherConstruct1/j207    !REF: /test_simd_multi/OtherConstruct1/i208    a(k,j,i) = 3.14209   end do210  end do211 end do212end subroutine test_simd_multi213 214! Rule d)215!DEF: /test_seq_loop (Subroutine) Subprogram216subroutine test_seq_loop217  implicit none218  !DEF: /test_seq_loop/i ObjectEntity INTEGER(4)219  !DEF: /test_seq_loop/j ObjectEntity INTEGER(4)220  integer i, j221  !REF: /test_seq_loop/i222  i = -1223  !REF: /test_seq_loop/j224  j = -1225  !$omp parallel226  !DEF: /test_seq_loop/OtherConstruct1/i (OmpShared) HostAssoc INTEGER(4)227  !DEF: /test_seq_loop/OtherConstruct1/j (OmpShared) HostAssoc INTEGER(4)228  print *, i, j229  !$omp parallel230  !DEF: /test_seq_loop/OtherConstruct1/OtherConstruct1/i (OmpShared) HostAssoc INTEGER(4)231  !DEF: /test_seq_loop/OtherConstruct1/OtherConstruct1/j (OmpPrivate, OmpPreDetermined) HostAssoc INTEGER(4)232  print *, i, j233  !$omp do234  !DEF: /test_seq_loop/OtherConstruct1/OtherConstruct1/OtherConstruct1/i (OmpPrivate, OmpPreDetermined) HostAssoc INTEGER(4)235  do i=1,10236   !REF: /test_seq_loop/OtherConstruct1/OtherConstruct1/j237   do j=1,10238   end do239  end do240  !REF: /test_seq_loop/OtherConstruct1/OtherConstruct1/i241  !REF: /test_seq_loop/OtherConstruct1/OtherConstruct1/j242  print *, i, j243  !$omp end parallel244  !REF: /test_seq_loop/OtherConstruct1/i245  !REF: /test_seq_loop/OtherConstruct1/j246  print *, i, j247  !$omp end parallel248  !REF: /test_seq_loop/i249  !REF: /test_seq_loop/j250  print *, i, j251end subroutine test_seq_loop252