simd7.f90 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. ! { dg-do run }
  2. ! { dg-additional-options "-msse2" { target sse2_runtime } }
  3. ! { dg-additional-options "-mavx" { target avx_runtime } }
  4. subroutine foo (d, e, f, g, m, n)
  5. integer :: i, j, b(2:9), c(3:n), d(:), e(2:n), f(2:,3:), n
  6. integer, allocatable :: g(:), h(:), k, m
  7. logical :: l
  8. l = .false.
  9. allocate (h(2:7))
  10. i = 4; j = 4; b = 7; c = 8; d = 9; e = 10; f = 11; g = 12; h = 13; k = 14; m = 15
  11. !$omp simd linear(b)linear(c:2)linear(d:3)linear(e:4)linear(f:5)linear(g:6) &
  12. !$omp & linear(h:7)linear(k:8)linear(m:9) reduction(.or.:l)
  13. do i = 0, 63
  14. l = l .or. .not.allocated (g) .or. .not.allocated (h)
  15. l = l .or. .not.allocated (k) .or. .not.allocated (m)
  16. l = l .or. any (b /= 7 + i) .or. any (c /= 8 + 2 * i)
  17. l = l .or. any (d /= 9 + 3 * i) .or. any (e /= 10 + 4 * i)
  18. l = l .or. any (f /= 11 + 5 * i) .or. any (g /= 12 + 6 * i)
  19. l = l .or. any (h /= 13 + 7 * i) .or. (k /= 14 + 8 * i)
  20. l = l .or. (m /= 15 + 9 * i)
  21. l = l .or. (lbound (b, 1) /= 2) .or. (ubound (b, 1) /= 9)
  22. l = l .or. (lbound (c, 1) /= 3) .or. (ubound (c, 1) /= n)
  23. l = l .or. (lbound (d, 1) /= 1) .or. (ubound (d, 1) /= 17)
  24. l = l .or. (lbound (e, 1) /= 2) .or. (ubound (e, 1) /= n)
  25. l = l .or. (lbound (f, 1) /= 2) .or. (ubound (f, 1) /= 3)
  26. l = l .or. (lbound (f, 2) /= 3) .or. (ubound (f, 2) /= 5)
  27. l = l .or. (lbound (g, 1) /= 7) .or. (ubound (g, 1) /= 10)
  28. l = l .or. (lbound (h, 1) /= 2) .or. (ubound (h, 1) /= 7)
  29. b = b + 1; c = c + 2; d = d + 3; e = e + 4; f = f + 5; g = g + 6
  30. h = h + 7; k = k + 8; m = m + 9
  31. end do
  32. if (l .or. i /= 64) call abort
  33. if (any (b /= 7 + 64) .or. any (c /= 8 + 2 * 64)) call abort
  34. if (any (d /= 9 + 3 * 64) .or. any (e /= 10 + 4 * 64)) call abort
  35. if (any (f /= 11 + 5 * 64) .or. any (g /= 12 + 6 * 64)) call abort
  36. if (any (h /= 13 + 7 * 64) .or. (k /= 14 + 8 * 64)) call abort
  37. if (m /= 15 + 9 * 64) call abort
  38. if ((lbound (b, 1) /= 2) .or. (ubound (b, 1) /= 9)) call abort
  39. if ((lbound (c, 1) /= 3) .or. (ubound (c, 1) /= n)) call abort
  40. if ((lbound (d, 1) /= 1) .or. (ubound (d, 1) /= 17)) call abort
  41. if ((lbound (e, 1) /= 2) .or. (ubound (e, 1) /= n)) call abort
  42. if ((lbound (f, 1) /= 2) .or. (ubound (f, 1) /= 3)) call abort
  43. if ((lbound (f, 2) /= 3) .or. (ubound (f, 2) /= 5)) call abort
  44. if ((lbound (g, 1) /= 7) .or. (ubound (g, 1) /= 10)) call abort
  45. if ((lbound (h, 1) /= 2) .or. (ubound (h, 1) /= 7)) call abort
  46. i = 4; j = 4; b = 7; c = 8; d = 9; e = 10; f = 11; g = 12; h = 13; k = 14; m = 15
  47. !$omp simd linear(b)linear(c:2)linear(d:3)linear(e:4)linear(f:5)linear(g:6) &
  48. !$omp & linear(h:7)linear(k:8)linear(m:9) reduction(.or.:l) collapse(2)
  49. do i = 0, 7
  50. do j = 0, 7
  51. l = l .or. .not.allocated (g) .or. .not.allocated (h)
  52. l = l .or. .not.allocated (k) .or. .not.allocated (m)
  53. l = l .or. any (b /= 7 + (8 * i + j)) .or. any (c /= 8 + 2 * (8 * i + j))
  54. l = l .or. any (d /= 9 + 3 * (8 * i + j)) .or. any (e /= 10 + 4 * (8 * i + j))
  55. l = l .or. any (f /= 11 + 5 * (8 * i + j)) .or. any (g /= 12 + 6 * (8 * i + j))
  56. l = l .or. any (h /= 13 + 7 * (8 * i + j)) .or. (k /= 14 + 8 * (8 * i + j))
  57. l = l .or. (m /= 15 + 9 * (8 * i + j))
  58. l = l .or. (lbound (b, 1) /= 2) .or. (ubound (b, 1) /= 9)
  59. l = l .or. (lbound (c, 1) /= 3) .or. (ubound (c, 1) /= n)
  60. l = l .or. (lbound (d, 1) /= 1) .or. (ubound (d, 1) /= 17)
  61. l = l .or. (lbound (e, 1) /= 2) .or. (ubound (e, 1) /= n)
  62. l = l .or. (lbound (f, 1) /= 2) .or. (ubound (f, 1) /= 3)
  63. l = l .or. (lbound (f, 2) /= 3) .or. (ubound (f, 2) /= 5)
  64. l = l .or. (lbound (g, 1) /= 7) .or. (ubound (g, 1) /= 10)
  65. l = l .or. (lbound (h, 1) /= 2) .or. (ubound (h, 1) /= 7)
  66. b = b + 1; c = c + 2; d = d + 3; e = e + 4; f = f + 5; g = g + 6
  67. h = h + 7; k = k + 8; m = m + 9
  68. end do
  69. end do
  70. if (l .or. i /= 8 .or. j /= 8) call abort
  71. if (any (b /= 7 + 64) .or. any (c /= 8 + 2 * 64)) call abort
  72. if (any (d /= 9 + 3 * 64) .or. any (e /= 10 + 4 * 64)) call abort
  73. if (any (f /= 11 + 5 * 64) .or. any (g /= 12 + 6 * 64)) call abort
  74. if (any (h /= 13 + 7 * 64) .or. (k /= 14 + 8 * 64)) call abort
  75. if (m /= 15 + 9 * 64) call abort
  76. if ((lbound (b, 1) /= 2) .or. (ubound (b, 1) /= 9)) call abort
  77. if ((lbound (c, 1) /= 3) .or. (ubound (c, 1) /= n)) call abort
  78. if ((lbound (d, 1) /= 1) .or. (ubound (d, 1) /= 17)) call abort
  79. if ((lbound (e, 1) /= 2) .or. (ubound (e, 1) /= n)) call abort
  80. if ((lbound (f, 1) /= 2) .or. (ubound (f, 1) /= 3)) call abort
  81. if ((lbound (f, 2) /= 3) .or. (ubound (f, 2) /= 5)) call abort
  82. if ((lbound (g, 1) /= 7) .or. (ubound (g, 1) /= 10)) call abort
  83. if ((lbound (h, 1) /= 2) .or. (ubound (h, 1) /= 7)) call abort
  84. i = 4; j = 4; b = 7; c = 8; d = 9; e = 10; f = 11; g = 12; h = 13; k = 14; m = 15
  85. !$omp parallel do simd linear(b)linear(c:2)linear(d:3)linear(e:4)linear(f:5) &
  86. !$omp & linear(g:6)linear(h:7)linear(k:8)linear(m:9) reduction(.or.:l)
  87. do i = 0, 63
  88. l = l .or. .not.allocated (g) .or. .not.allocated (h)
  89. l = l .or. .not.allocated (k) .or. .not.allocated (m)
  90. l = l .or. any (b /= 7 + i) .or. any (c /= 8 + 2 * i)
  91. l = l .or. any (d /= 9 + 3 * i) .or. any (e /= 10 + 4 * i)
  92. l = l .or. any (f /= 11 + 5 * i) .or. any (g /= 12 + 6 * i)
  93. l = l .or. any (h /= 13 + 7 * i) .or. (k /= 14 + 8 * i)
  94. l = l .or. (m /= 15 + 9 * i)
  95. l = l .or. (lbound (b, 1) /= 2) .or. (ubound (b, 1) /= 9)
  96. l = l .or. (lbound (c, 1) /= 3) .or. (ubound (c, 1) /= n)
  97. l = l .or. (lbound (d, 1) /= 1) .or. (ubound (d, 1) /= 17)
  98. l = l .or. (lbound (e, 1) /= 2) .or. (ubound (e, 1) /= n)
  99. l = l .or. (lbound (f, 1) /= 2) .or. (ubound (f, 1) /= 3)
  100. l = l .or. (lbound (f, 2) /= 3) .or. (ubound (f, 2) /= 5)
  101. l = l .or. (lbound (g, 1) /= 7) .or. (ubound (g, 1) /= 10)
  102. l = l .or. (lbound (h, 1) /= 2) .or. (ubound (h, 1) /= 7)
  103. b = b + 1; c = c + 2; d = d + 3; e = e + 4; f = f + 5; g = g + 6
  104. h = h + 7; k = k + 8; m = m + 9
  105. end do
  106. if (l .or. i /= 64) call abort
  107. if (any (b /= 7 + 64) .or. any (c /= 8 + 2 * 64)) call abort
  108. if (any (d /= 9 + 3 * 64) .or. any (e /= 10 + 4 * 64)) call abort
  109. if (any (f /= 11 + 5 * 64) .or. any (g /= 12 + 6 * 64)) call abort
  110. if (any (h /= 13 + 7 * 64) .or. (k /= 14 + 8 * 64)) call abort
  111. if (m /= 15 + 9 * 64) call abort
  112. if ((lbound (b, 1) /= 2) .or. (ubound (b, 1) /= 9)) call abort
  113. if ((lbound (c, 1) /= 3) .or. (ubound (c, 1) /= n)) call abort
  114. if ((lbound (d, 1) /= 1) .or. (ubound (d, 1) /= 17)) call abort
  115. if ((lbound (e, 1) /= 2) .or. (ubound (e, 1) /= n)) call abort
  116. if ((lbound (f, 1) /= 2) .or. (ubound (f, 1) /= 3)) call abort
  117. if ((lbound (f, 2) /= 3) .or. (ubound (f, 2) /= 5)) call abort
  118. if ((lbound (g, 1) /= 7) .or. (ubound (g, 1) /= 10)) call abort
  119. if ((lbound (h, 1) /= 2) .or. (ubound (h, 1) /= 7)) call abort
  120. i = 4; j = 4; b = 7; c = 8; d = 9; e = 10; f = 11; g = 12; h = 13; k = 14; m = 15
  121. !$omp parallel do simd linear(b)linear(c:2)linear(d:3)linear(e:4)linear(f:5) &
  122. !$omp & linear(g:6)linear(h:7)linear(k:8)linear(m:9) reduction(.or.:l) collapse(2)
  123. do i = 0, 7
  124. do j = 0, 7
  125. l = l .or. .not.allocated (g) .or. .not.allocated (h)
  126. l = l .or. .not.allocated (k) .or. .not.allocated (m)
  127. l = l .or. any (b /= 7 + (8 * i + j)) .or. any (c /= 8 + 2 * (8 * i + j))
  128. l = l .or. any (d /= 9 + 3 * (8 * i + j)) .or. any (e /= 10 + 4 * (8 * i + j))
  129. l = l .or. any (f /= 11 + 5 * (8 * i + j)) .or. any (g /= 12 + 6 * (8 * i + j))
  130. l = l .or. any (h /= 13 + 7 * (8 * i + j)) .or. (k /= 14 + 8 * (8 * i + j))
  131. l = l .or. (m /= 15 + 9 * (8 * i + j))
  132. l = l .or. (lbound (b, 1) /= 2) .or. (ubound (b, 1) /= 9)
  133. l = l .or. (lbound (c, 1) /= 3) .or. (ubound (c, 1) /= n)
  134. l = l .or. (lbound (d, 1) /= 1) .or. (ubound (d, 1) /= 17)
  135. l = l .or. (lbound (e, 1) /= 2) .or. (ubound (e, 1) /= n)
  136. l = l .or. (lbound (f, 1) /= 2) .or. (ubound (f, 1) /= 3)
  137. l = l .or. (lbound (f, 2) /= 3) .or. (ubound (f, 2) /= 5)
  138. l = l .or. (lbound (g, 1) /= 7) .or. (ubound (g, 1) /= 10)
  139. l = l .or. (lbound (h, 1) /= 2) .or. (ubound (h, 1) /= 7)
  140. b = b + 1; c = c + 2; d = d + 3; e = e + 4; f = f + 5; g = g + 6
  141. h = h + 7; k = k + 8; m = m + 9
  142. end do
  143. end do
  144. if (l .or. i /= 8 .or. j /= 8) call abort
  145. if (any (b /= 7 + 64) .or. any (c /= 8 + 2 * 64)) call abort
  146. if (any (d /= 9 + 3 * 64) .or. any (e /= 10 + 4 * 64)) call abort
  147. if (any (f /= 11 + 5 * 64) .or. any (g /= 12 + 6 * 64)) call abort
  148. if (any (h /= 13 + 7 * 64) .or. (k /= 14 + 8 * 64)) call abort
  149. if (m /= 15 + 9 * 64) call abort
  150. if ((lbound (b, 1) /= 2) .or. (ubound (b, 1) /= 9)) call abort
  151. if ((lbound (c, 1) /= 3) .or. (ubound (c, 1) /= n)) call abort
  152. if ((lbound (d, 1) /= 1) .or. (ubound (d, 1) /= 17)) call abort
  153. if ((lbound (e, 1) /= 2) .or. (ubound (e, 1) /= n)) call abort
  154. if ((lbound (f, 1) /= 2) .or. (ubound (f, 1) /= 3)) call abort
  155. if ((lbound (f, 2) /= 3) .or. (ubound (f, 2) /= 5)) call abort
  156. if ((lbound (g, 1) /= 7) .or. (ubound (g, 1) /= 10)) call abort
  157. if ((lbound (h, 1) /= 2) .or. (ubound (h, 1) /= 7)) call abort
  158. end subroutine
  159. interface
  160. subroutine foo (d, e, f, g, m, n)
  161. integer :: d(:), e(2:n), f(2:,3:), n
  162. integer, allocatable :: g(:), m
  163. end subroutine
  164. end interface
  165. integer, parameter :: n = 8
  166. integer :: d(2:18), e(3:n+1), f(5:6,7:9)
  167. integer, allocatable :: g(:), m
  168. allocate (g(7:10))
  169. call foo (d, e, f, g, m, n)
  170. end