|
| View previous topic :: View next topic |
| Author |
Message |
xlapillonne
Joined: 16 Feb 2011 Posts: 69
|
Posted: Thu Sep 22, 2011 2:01 am Post subject: Wrong values with acc update |
|
|
Hi,
While investigating differences between GPU and CPU code, I have found that acc update gives wrong results with fortran array having indices not starting at 1.
I have reproduce the behavour in the following example:
| Code: |
module db_gpu
implicit none
contains
subroutine check_b(b,b_ref)
real*8 :: b(:,:),b_ref(:,:)
!$acc reflected(b)
!$acc update host(b)
print*, 'diff', sum(b-b_ref,1)
print*, 'b', sum(b,1)
print*, 'b_ref', sum(b_ref,1)
end subroutine check_b
end module db_gpu
program main
USE db_gpu
implicit none
integer*4 :: N,nlev,i,k,itime,nt
real*8, allocatable :: a(:,:), b(:,:), b_ref(:,:)
integer*4 :: dt1(8), dt2(8), t1, t2,istat
real*8 :: rt
N=1E3
nlev=4
nt=1000
allocate(a(N,nlev))
allocate(b(N,2:nlev+1),b_ref(N,2:nlev+1))
do k=1,nlev
do i=1,N
a(i,k)=cos(6.3*(k-1)/10.0)+(1.0*i)/N
b(i,k+1)=2*cos(6.3*(k-1)/10.0)+(1.0*i)/N
b_ref(i,k+1)=2*cos(6.3*(k-1)/10.0)+(1.0*i)/N
end do
end do
!$acc data region local(a,b)
!$acc update device(a,b)
call check_b(b,b_ref)
!$acc region do kernel
do i=1,N
do k=1,nlev
a(i,k)=a(i,k)*b(i,k+1)
end do
end do
!$acc end region
!$acc end data region
print*, 'sum(a)=',sum(a)
end program main
|
The problem is related here to array b with dimension: b(N,2:nlev+1).
The routine check_b compare and print differences between CPU reference values and array b after it was updated on device and then back on the host.
Here are the results:
| Code: |
> pgf90 -ta=nvidia -o test_error_ind test_error_ind.f90
> ./test_error_ind
diff 2605.891802042723 383.9451061487198
1004.421294629574 1239.255130857229
b 2500.500023603439 2500.500023603439
2116.554917454720 1112.133622825146
b_ref -105.3917784392834 2116.554917454720
1112.133622825146 -127.1215080320835
sum(a)= 3802.033573910594
|
As you can see values of b and b_ref differ although the only operation on b was acc update device and acc update host.
If you look carrefully at the lines showing sum of b and b_ref over first dimension, you can see that the values in b are shifted by 1 index !
Unless I am doing something wrong here I think this is quite a serious bug which should be adressed.
Regards,
Xavier
Note: pgi version 11.8 |
|
| Back to top |
|
 |
mkcolg
Joined: 30 Jun 2004 Posts: 4997 Location: The Portland Group Inc.
|
Posted: Thu Sep 22, 2011 8:07 am Post subject: |
|
|
Hi xlapillonne,
Thanks for the report. I've sent this on to our engineers for further investigation (TPR#18192).
- Mat |
|
| Back to top |
|
 |
jtull
Joined: 30 Jun 2004 Posts: 234
|
Posted: Fri May 17, 2013 5:13 pm Post subject: |
|
|
xlapillonne,
TPR 18192 is fixed in the current 13.5 release, but may have been fixed earlier.
regards,
dave |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2002 phpBB Group
|