Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nghiahsgs/2895b5f6ba1b502b1651908c30cfc1c9 to your computer and use it in GitHub Desktop.
Save nghiahsgs/2895b5f6ba1b502b1651908c30cfc1c9 to your computer and use it in GitHub Desktop.
test_quantum_parallell.f95
!/opt/pgi/linux86-64/19.10/bin/pgfortran -ta=tesla:cc75,host -Minfo test_quantum_basic.f95
program main
double precision, dimension(1000,1000):: C,B
double precision, dimension(1000) :: E
double precision :: total
integer:: n_loop,r,s,q
integer:: t1,t2,count_rate,count_max
n_loop=1000
call random_number(C)
call random_number(B)
call random_number(E)
open(unit=1,file='C_1000_1000.txt')
do i=1,1000
read(1,*) C(i,:)
end do
close(1)
open(unit=1,file='B_1000_1000.txt')
do i=1,1000
read(1,*) B(i,:)
end do
close(1)
open(unit=1,file='E_1000.txt')
do i=1,1000
read(1,*) E(i)
end do
close(1)
print *,'B(400,500)', B(400,500)
call system_clock(count_max=count_max, count_rate=count_rate)
call system_clock(t1)
total=0.d0
!$acc kernels loop reduction(+:total)
do r=1,n_loop
do s=1,n_loop
do q=1,n_loop
total=total+C(r,s)*B(s,q)*(cos(E(q)-E(r))-cos(E(s)-E(q)))/(10+E(s)-E(q)/2-E(r)/2)
enddo
enddo
enddo
!$acc end kernels
call system_clock(t2)
print *,"total time",real(t2-t1)/real(count_rate),'(seconds)'
print *,'total',total
end program main
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment