reduction-4.f90 943 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. ! { dg-do run }
  2. ! complex reductions
  3. program reduction_4
  4. implicit none
  5. integer, parameter :: n = 10, vl = 32
  6. integer :: i
  7. complex :: vresult, result
  8. complex, dimension (n) :: array
  9. do i = 1, n
  10. array(i) = i
  11. end do
  12. result = 0
  13. vresult = 0
  14. ! '+' reductions
  15. !$acc parallel vector_length(vl) num_gangs(1)
  16. !$acc loop reduction(+:result)
  17. do i = 1, n
  18. result = result + array(i)
  19. end do
  20. !$acc end parallel
  21. ! Verify the results
  22. do i = 1, n
  23. vresult = vresult + array(i)
  24. end do
  25. if (result .ne. vresult) call abort
  26. result = 1
  27. vresult = 1
  28. ! ! '*' reductions
  29. !
  30. ! !$acc parallel vector_length(vl)
  31. ! !$acc loop reduction(*:result)
  32. ! do i = 1, n
  33. ! result = result * array(i)
  34. ! end do
  35. ! !$acc end parallel
  36. !
  37. ! ! Verify the results
  38. ! do i = 1, n
  39. ! vresult = vresult * array(i)
  40. ! end do
  41. !
  42. ! if (result.ne.vresult) call abort
  43. end program reduction_4