PGI User Forum
 SearchSearch   MemberlistMemberlist     RegisterRegister   ProfileProfile    Log inLog in 

CUDA-x86.

Few operations on the same variable

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



Joined: 29 Jun 2010
Posts: 26

PostPosted: Sat Oct 23, 2010 4:34 am    Post subject: Few operations on the same variable Reply with quote

Hello,

I have a piece of test code like that:

Code:

     do i=1,10
       do j=1,10
      vvect(i,j)=i
       enddo
     enddo

!$acc region do local(ijk)
         do ijk=1,10
        vvect(ijk,2)=vvect(ijk,1)+2
        vvect(ijk,2)=vvect(ijk,2)+2
         enddo 
!$acc end region

        do ijk=1,10
     write(*,*) vvect(ijk,2)
   enddo


And I don't know why the result is:
Quote:
3.0
4.0
5.0
6.0
7.0
8.0
9.0
10.0
11.0
12.0


instead of:
Quote:
5.0
6.0
7.0
...


Further, when I add a copy() directive:
Code:
!$acc region do local(ijk) copy(vvect)


The results are:
Quote:
1.0
2.0
3.0
...

So without any change...

What's wrong?
Back to top
View user's profile
szczelba



Joined: 29 Jun 2010
Posts: 26

PostPosted: Sat Oct 23, 2010 9:22 am    Post subject: Reply with quote

Additional problem. I have a loop like that:

Code:

!$acc region do
do ijk=imoj4,imoj5

              uhalfp=-dudp(ijk)*(vvect(ipjk,igfy)-vvect(ijk,igfy))

              vvect(ijk,igfyp1)=1.0

          enddo
!$acc end region
 


After executing this piece of code all values in vvect(:,igfyp1) are zero. Why is so? If I comment out the line with uhalfp variable, all values in vvect(:,igfyp1) are correctly 1.0.
Back to top
View user's profile
mkcolg



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

PostPosted: Mon Oct 25, 2010 4:59 pm    Post subject: Reply with quote

Hi szczelba,

For your first post, I wrote the following example:
Code:

     program testme
   
     implicit none
     integer :: i,j,ijk
     real, dimension(10,10) :: vvect

     do i=1,10
       do j=1,10
      vvect(i,j)=i
       enddo
     enddo

!$acc region copy(vvect)
         do ijk=1,10
        vvect(ijk,2)=vvect(ijk,1)+2
        vvect(ijk,2)=vvect(ijk,2)+2
         enddo
!$acc end region
        do ijk=1,10
     write(*,*) vvect(ijk,2)
   enddo

   end program testme


I was not able to reproduce the initial error (i.e. without copy(vvect) clause) but did see the second error in version 10.8. Version 10.9 does seem to get the correct answers.

Code:
% pgf90 test.f90 -ta=nvidia -Minfo=accel -V10.8; a.out
testme:
     14, Generating copy(vvect(:,:))
         Generating compute capability 1.0 binary
         Generating compute capability 1.3 binary
     15, Loop is parallelizable
         Accelerator kernel generated
         15, !$acc do parallel, vector(10)
             Cached references to size [10x2] block of 'vvect'
             CC 1.0 : 3 registers; 104 shared, 20 constant, 0 local memory bytes; 33 occupancy
             CC 1.3 : 3 registers; 104 shared, 20 constant, 0 local memory bytes; 25 occupancy
    1.000000   
    2.000000   
    3.000000   
    4.000000   
    5.000000   
    6.000000   
    7.000000   
    8.000000   
    9.000000   
    10.00000   
% pgf90 test.f90 -ta=nvidia -Minfo=accel -V10.9 ; a.out
testme:
     14, Generating copy(vvect(:,:))
         Generating compute capability 1.0 binary
         Generating compute capability 1.3 binary
     15, Loop is parallelizable
         Accelerator kernel generated
         15, !$acc do parallel, vector(10)
             Cached references to size [10x2] block of 'vvect'
             CC 1.0 : 5 registers; 104 shared, 20 constant, 0 local memory bytes; 33 occupancy
             CC 1.3 : 5 registers; 104 shared, 20 constant, 0 local memory bytes; 25 occupancy
    5.000000   
    6.000000   
    7.000000   
    8.000000   
    9.000000   
    10.00000   
    11.00000   
    12.00000   
    13.00000   
    14.00000   


For a second post, do you mind writing-up a small reproducing example?

Thanks,
Mat
Back to top
View user's profile
szczelba



Joined: 29 Jun 2010
Posts: 26

PostPosted: Tue Oct 26, 2010 6:30 am    Post subject: Reply with quote

I've upgraded to PGI 10.9 and it really solve the first problem. Thanks Mat. Although, it was really strange, that it didn't work in 10.8.

According to my second post - the case is really weird. When I tried to execute it again, the results were ok. Sometimes I have a feeling that some changes in code does not have any impact on the result. For example, if I at first run code with loop like in the second post I get only zeros. And then, after commenting out the first line in the loop I still get zeros. But another day I at first run code without this line and get 1.0s. The result is ok even after again adding this line.. For me it looks a bit undeterministic.
I'll try to investigate and give you may results.

Regards
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