PGI User Forum
 SearchSearch   MemberlistMemberlist     RegisterRegister   ProfileProfile    Log inLog in 

CUDA-x86.

cudaMallocPitch compile error
Goto page Previous  1, 2
 
Post new topic   Reply to topic    PGI User Forum Forum Index -> Accelerator Programming
View previous topic :: View next topic  
Author Message
JDS7



Joined: 19 Aug 2011
Posts: 17

PostPosted: Tue Oct 25, 2011 1:26 pm    Post subject: Reply with quote

That was the problem. It wasn't happy about the fact that udev was not a 2-D array. It compiles when I use a 2-D array, even with pgfortran v. 10.2-0. Is there a way to allocate a 4-D array with padding to facilitate coalescing?

Code:

integer :: nx,ny,nz
integer :: r,pitch
real*4,allocatable,device :: udev(:,:,:,:)
Back to top
View user's profile
brentl



Joined: 20 Jul 2004
Posts: 132

PostPosted: Tue Oct 25, 2011 5:04 pm    Post subject: Reply with quote

The interfaces for all the cudaMallocPitch routines are like this, so they require a 2d array:

INTERFACE CUDAMALLOCPITCH
INTEGER FUNCTION CUDAMALLOCPITCHI1(devptr, pitch, width, height)
INTEGER*1, ALLOCATABLE, DEVICE, DIMENSION(:,:) :: devptr
INTEGER pitch, width, height
END FUNCTION

Except for this one:

INTEGER FUNCTION CUDAMALLOCPITCHCD(devptr, pitch, width, height)
IMPORT C_DEVPTR
TYPE(C_DEVPTR) :: devptr
INTEGER pitch, width, height
END FUNCTION

So, you can declare a variable of type(c_devptr), call cudaMallocPitch() with that variable and the appropriate pitch, width, and height, then "cast" the c_devptr into an allocatable device array of your choosing using our overloaded cuda fortran c_f_pointer function.

type(c_devptr) :: a_p
real, device, allocatable :: a_d(:,:,:,:)

call c_f_pointer(a_p, a_d, (/ 5, 10, 15, 20 /) )

pitch, width, and height have units of bytes when used with c_devptr, FYI.
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 Previous  1, 2
Page 2 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