I have installed the PGI Community Edition Version 17.10, and
these are my computer information :
OS: Windows 10
CPU: i7-5820K 3.30GHz
Video Card: NVIDIA GeForce GTX 1060 6GB
and then i use this command to compiler and execute the example Fortran code
pgfortran -acc -fast -o OpenACC OpenACC.f90
program picalc
implicit none
integer, parameter :: n=1000000000
integer :: i
real(kind=8) :: t,pi
real t1,t2
pi=0.0
call CPU_TIME(t1)
!$acc parallel loop
do i=0,n-1
t=(i+0.5)/n
pi=pi+4.0/(1.0+t*t)
enddo
!$acc end parallel loop
call CPU_TIME(t2)
print *,'-------Acc----------'
print *,'pi =',pi/n
print *,'time =',t2-t1
pi=0.0
call CPU_TIME(t1)
!$acc data copyout(pi)
!$acc parallel loop
do i=0,n-1
t=(i+0.5)/n
pi=pi+4.0/(1.0+t*t)
enddo
!$acc end parallel loop
!$acc end data
call CPU_TIME(t2)
print *,'-------Acc2----------'
print *,'pi =',pi/n
print *,'time =',t2-t1
pi=0.0
call CPU_TIME(t1)
!$acc kernels
do i=0,n-1
t=(i+0.5)/n
pi=pi+4.0/(1.0+t*t)
enddo
!$acc end kernels
call CPU_TIME(t2)
print *,'-------Kernels---------'
print *,'pi =',pi/n
print *,'time =',t2-t1
pi=0.0
call CPU_TIME(t1)
do i=0,n-1
t=(i+0.5)/n
pi=pi+4.0/(1.0+t*t)
enddo
call CPU_TIME(t2)
print *,'---------Normal--------'
print *,'pi =',pi/n
print *,'time =',t2-t1
end program picalc
and the results show
-------Acc----------
pi = 3.141592654592580
time = 3.073000
-------Acc2----------
pi = 3.141592654592580
time = 2.513000
-------Kernels---------
pi = 3.141592654592580
time = 2.529000
---------Normal--------
pi = 3.141592654592580
time = 2.531000
Why OpenACC doesn’t accelerate in my computer?
Thanks.