PGI User Forum
 SearchSearch   MemberlistMemberlist     RegisterRegister   ProfileProfile    Log inLog in 

CUDA-x86.

Wrong values with acc update

 
Post new topic   Reply to topic    PGI User Forum Forum Index -> Accelerator Programming
View previous topic :: View next topic  
Author Message
xlapillonne



Joined: 16 Feb 2011
Posts: 69

PostPosted: Thu Sep 22, 2011 2:01 am    Post subject: Wrong values with acc update Reply with quote

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
View user's profile
mkcolg



Joined: 30 Jun 2004
Posts: 6134
Location: The Portland Group Inc.

PostPosted: Thu Sep 22, 2011 8:07 am    Post subject: Reply with quote

Hi xlapillonne,

Thanks for the report. I've sent this on to our engineers for further investigation (TPR#18192).

- Mat
Back to top
View user's profile
jtull



Joined: 30 Jun 2004
Posts: 438

PostPosted: Fri May 17, 2013 5:13 pm    Post subject: Reply with quote

xlapillonne,

TPR 18192 is fixed in the current 13.5 release, but may have been fixed earlier.

regards,
dave
Back to top
View user's profile
Display posts from previous:   
Post new topic   Reply to topic    PGI User Forum Forum Index -> Accelerator Programming All times are GMT - 7 Hours
Page 1 of 1

 
Jump to:  
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 © phpBB Group