reduction-5.f90 545 B

123456789101112131415161718192021222324252627282930313233
  1. ! { dg-do run }
  2. ! subroutine reduction
  3. program reduction
  4. integer, parameter :: n = 40, c = 10
  5. integer :: i, vsum, sum
  6. call redsub (sum, n, c)
  7. vsum = 0
  8. ! Verify the results
  9. do i = 1, n
  10. vsum = vsum + c
  11. end do
  12. if (sum.ne.vsum) call abort ()
  13. end program reduction
  14. subroutine redsub(sum, n, c)
  15. integer :: sum, n, c
  16. sum = 0
  17. !$acc parallel vector_length(n) copyin (n, c) num_gangs(1)
  18. !$acc loop reduction(+:sum)
  19. do i = 1, n
  20. sum = sum + c
  21. end do
  22. !$acc end parallel
  23. end subroutine redsub