simd4.f90 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. ! { dg-do run }
  2. ! { dg-additional-options "-msse2" { target sse2_runtime } }
  3. ! { dg-additional-options "-mavx" { target avx_runtime } }
  4. integer :: a(1024), b(1024), k, m, i, s, t
  5. k = 4
  6. m = 2
  7. t = 1
  8. do i = 1, 1024
  9. a(i) = i - 513
  10. b(i) = modulo (i - 52, 39)
  11. if (i.lt.52.and.b(i).ne.0) b(i) = b(i) - 39
  12. end do
  13. s = foo (b)
  14. do i = 1, 1024
  15. if (a(i).ne.((i - 513) * b(i))) call abort
  16. if (i.lt.52.and.modulo (i - 52, 39).ne.0) then
  17. if (b(i).ne.(modulo (i - 52, 39) - 39)) call abort
  18. else
  19. if (b(i).ne.(modulo (i - 52, 39))) call abort
  20. end if
  21. a(i) = i - 513
  22. end do
  23. if (k.ne.(4 + 3 * 1024).or.s.ne.1596127) call abort
  24. k = 4
  25. m = 2
  26. t = 1
  27. s = bar (b)
  28. do i = 1, 1024
  29. if (a(i).ne.((i - 513) * b(i))) call abort
  30. if (i.lt.52.and.modulo (i - 52, 39).ne.0) then
  31. if (b(i).ne.(modulo (i - 52, 39) - 39)) call abort
  32. else
  33. if (b(i).ne.(modulo (i - 52, 39))) call abort
  34. end if
  35. a(i) = i - 513
  36. end do
  37. if (k.ne.(4 + 3 * 1024).or.s.ne.1596127) call abort
  38. k = 4
  39. m = 2
  40. t = 1
  41. s = baz (b)
  42. do i = 1, 1024
  43. if (a(i).ne.((i - 513) * b(i))) call abort
  44. if (i.lt.52.and.modulo (i - 52, 39).ne.0) then
  45. if (b(i).ne.(modulo (i - 52, 39) - 39)) call abort
  46. else
  47. if (b(i).ne.(modulo (i - 52, 39))) call abort
  48. end if
  49. end do
  50. if (k.ne.(4 + 3 * 1024).or.s.ne.1596127) call abort
  51. contains
  52. function foo (p)
  53. integer :: p(1024), u, v, i, s, foo
  54. s = 0
  55. !$omp parallel do simd linear(k : m + 1) reduction(+: s) &
  56. !$omp & lastprivate(u, v) schedule (static, 32)
  57. do i = 1, 1024
  58. a(i) = a(i) * p(i)
  59. u = p(i) + k
  60. k = k + m + 1
  61. v = p(i) + k
  62. s = s + p(i) + k
  63. end do
  64. !$omp end parallel do simd
  65. if (i.ne.1025) call abort
  66. if (u.ne.(36 + 4 + 3 * 1023).or.v.ne.(36 + 4 + 3 * 1024)) call abort
  67. foo = s
  68. end function foo
  69. function bar (p)
  70. integer :: p(1024), u, v, i, s, bar
  71. s = 0
  72. !$omp parallel do simd linear(k : m + 1) reduction(+: s) &
  73. !$omp & lastprivate(u, v) schedule (dynamic, 32)
  74. do i = 1, 1024, t
  75. a(i) = a(i) * p(i)
  76. u = p(i) + k
  77. k = k + m + 1
  78. v = p(i) + k
  79. s = s + p(i) + k
  80. end do
  81. !$omp endparalleldosimd
  82. if (i.ne.1025) call abort
  83. if (u.ne.(36 + 4 + 3 * 1023).or.v.ne.(36 + 4 + 3 * 1024)) call abort
  84. bar = s
  85. end function bar
  86. function baz (p)
  87. integer :: p(1024), u, v, i, s, baz
  88. s = 0
  89. !$omp parallel do simd linear(k : m + 1) reduction(+: s) &
  90. !$omp & lastprivate(u, v) linear(i : t) schedule (static, 8)
  91. do i = 1, 1024, t
  92. a(i) = a(i) * p(i)
  93. u = p(i) + k
  94. k = k + m + 1
  95. v = p(i) + k
  96. s = s + p(i) + k
  97. end do
  98. if (i.ne.1025) call abort
  99. if (u.ne.(36 + 4 + 3 * 1023).or.v.ne.(36 + 4 + 3 * 1024)) call abort
  100. baz = s
  101. end function baz
  102. end