PGI User Forum
 SearchSearch   MemberlistMemberlist     RegisterRegister   ProfileProfile    Log inLog in 

CUDA-x86.

Compiler confusing arrays for functions
Goto page 1, 2  Next
 
Post new topic   Reply to topic    PGI User Forum Forum Index -> Accelerator Programming
View previous topic :: View next topic  
Author Message
urban



Joined: 17 May 2010
Posts: 4

PostPosted: Tue Aug 07, 2012 11:43 am    Post subject: Compiler confusing arrays for functions Reply with quote

We have a problem where the compiler is supressing acceleration becuase it believes some of our arrays are functions. At first I assumed this was due to it being a part of a large and complex code (MFIX), but we have boiled it down to the demonstration code below (which I would be happy to send through other channels). This code generates:

PGF90-W-0155-Accelerator region ignored; see -Minfo messages (test.f90: 51)
main:
51, Accelerator region ignored
56, Accelerator restriction: function/procedure calls are not supported
60, Accelerator restriction: function/procedure calls are not supported

If we simply comment out line 60 (array PFN), then it will generate a kernel. Grateful for any insight.

John

__________________________________________________________
!!! Update the list of particles contacting a given particle, by removing particles no longer in contact
!!! Compile with
!!! pgf90 -Munixlogical -o test test.f90
!!! or
!!! pgf90 -acc -ta=nvidia,time -Minfo=accel -Munixlogical -o test-gpu test.f90

PROGRAM MAIN

IMPLICIT NONE

INTEGER, DIMENSION(3,11) :: PN, PV
DOUBLE PRECISION, DIMENSION(3,11,2) :: PFN
INTEGER LL, NI, NLIM, MAXNEIGHBORS, MAX_PIP

!!! Extra variables needed for new algorithm
INTEGER CHK1, CHK2, SHIFT

!!! Input data for the test
MAX_PIP=3
MAXNEIGHBORS = 10

PN(1,:)=(/7, 5,11,33,20,17,35,4,-1,-1,-1/)
PV(1,:)=(/7, 1, 0, 1, 1, 0, 0,1, 0, 0, 0/)
PFN(1,:,1)=PN(1,:)
PFN(1,:,2)=PV(1,:)

PN(2,:)=(/10, 5,11,33,20,17,35,4,111,12,13/)
PV(2,:)=(/10, 0, 0, 0, 0, 0, 0,0, 1, 0, 0/)
PFN(2,:,1)=PN(1,:)
PFN(2,:,2)=PV(1,:)

PN(3,:)=(/2, 39,101,-1,-1,-1,-1,-1,-1,-1,-1/)
PV(3,:)=(/2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0/)
PFN(3,:,1)=PN(1,:)
PFN(3,:,2)=PV(1,:)
!!! End of input data

!!! Print the input data
PRINT *, 'Before update:'
PRINT *, '=============='
DO LL=1, MAX_PIP
WRITE (*,'(1X,I3,1X,A,I3)') &
PN(LL,1), ' particles in contact with particle ', LL
WRITE (*,'(A,$)') 'They are: '
DO NI=2,PN(LL,1)+1
WRITE (*,'(I4,1X,$)'), PN(LL,NI)
ENDDO
PRINT *,'\n\n'
ENDDO

!$acc kernels
DO LL=1,MAX_PIP !Loop over particles

!!! New update algorithm without if statement
SHIFT=0
DO NI=2,PN(LL,1)+1
CHK1 = (PV(LL,NI).EQ.0)
CHK2 = (PV(LL,NI).NE.0)
PN(LL,NI-SHIFT*CHK2)=PN(LL,NI)
PFN(LL,NI-SHIFT*CHK2,:)=PFN(LL,NI,:)
SHIFT=SHIFT+CHK1
ENDDO
PN(LL,1)=PN(LL,1)-SHIFT

ENDDO !Loop over particles
!$acc end kernels

!!! Print the results
PRINT *, 'After update:'
PRINT *, '============='
DO LL=1,MAX_PIP
WRITE (*,'(1X,I3,1X,A,I3)') &
PN(LL,1), " particles in contact with particle ", LL
WRITE (*,'(A,$)') "They are: "
DO NI=2,PN(LL,1)+1
WRITE (*,'(I4,1X,$)'), PN(LL,NI)
ENDDO
PRINT *,'\n'

! PRINT *, "The full arrays PN and PV are :"
! DO NI=2,MAX_NEIGHBOURS+1
! PRINT *, PN(LL,NI), " ",PV(LL,NI)
! ENDDO

ENDDO

END
Back to top
View user's profile
mkcolg



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

PostPosted: Wed Aug 08, 2012 3:26 pm    Post subject: Reply with quote

Hi Urban,

What's happening is the compiler is creating a temp array to hold the right-hand side evaluation of the "PVN=PVN" assignment. This causes an implicit allocate/deallocate in the loop and it's these routines that this preventing the creation of the accelerator region.

This is one of those cases were the compiler is being more safe than smart. The temp array isn't really needed but the compiler is doing it in case their is an overlap in the assignment. While ok (at least for CPU execution) it is at least a performance bug. Hence we have opened TPR#18865 to have it fixed.

For your code, you can work around the problem by pre-computing the second index before using it in the PVN assignment. For example:

Code:
#ifdef NOTEMP
idx=ni-shift*chk2
pfn(ll,idx,:)=pfn(ll,ni,:)
#else
pfn(ll,ni-shift*chk2,:)=pfn(ll,ni,:)
#endif


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



Joined: 17 May 2010
Posts: 4

PostPosted: Thu Aug 09, 2012 12:03 pm    Post subject: Reply with quote

Thanks, Mat.

Makes perfect sense and I suspect this workaround will be useful for similar code that lies ahead.

I would suggest that the offending "procedure" always be named. If we had seen a malloc reported here, it would have been a useful clue.

John
Back to top
View user's profile
mkcolg



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

PostPosted: Fri Aug 10, 2012 9:16 am    Post subject: Reply with quote

Quote:
I would suggest that the offending "procedure" always be named. If we had seen a malloc reported here, it would have been a useful clue.
Added a feature request, TPR#18875.

- Mat
Back to top
View user's profile
Senya



Joined: 20 Jun 2011
Posts: 58

PostPosted: Thu Aug 23, 2012 1:28 pm    Post subject: Reply with quote

I've got similar error on PGI 12.8.

With test file
Code:

Program test
real, device :: H(2,32,10), F(2,32,10)
!$cuf kernel do(1) <<< *, 32>>>     
Do i=1, 32
  H(1,i,1)=F(1,i,1)+12
End Do
end


I get error when trying to compile with some debug options:
Quote:

>
pgf95 -g -O0 -C -Mcuda=cc11 -ta=nvidia:cc11 -tp=amd64 -Minfo test.f95
PGF90-S-0155-Kernel region ignored; see -Minfo messages (test.f95: 3)
test:
4, Accelerator restriction: function/procedure calls are not supported
5, Accelerator restriction: function/procedure calls are not supported
0 inform, 0 warnings, 1 severes, 0 fatal for test

But when i remove -O0, this error goes away
Quote:
>
pgf95 -g -C -Mcuda=cc11 -ta=nvidia:cc11 -tp=amd64 -Minfo test.f95
PGF90-S-0155-Kernel region ignored; no parallel loops (test.f95: 3)
0 inform, 0 warnings, 1 severes, 0 fatal for test


In my large project, the same error produced with -C option enabled, instead of -O0. But i think, reason is similar.
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
Goto page 1, 2  Next
Page 1 of 2

 
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