PGI User Forum
 SearchSearch   MemberlistMemberlist     RegisterRegister   ProfileProfile    Log inLog in 

CUDA-x86.

issue to call C function that accept pointer to device data

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



Joined: 11 Jun 2009
Posts: 233

PostPosted: Fri Oct 01, 2010 3:13 am    Post subject: issue to call C function that accept pointer to device data Reply with quote

I have a C function that accept a pointer, which is supposed to point to data on device memory

Code:
int c_foo_func (int * arr, int size) {
   ....
   //call kernel to process arr

}



Now, I want to call this function from Fortran. It's trivial to declare the interface
Code:
interface
  integer(c_int) function c_foo_func(arr, size) bind(c)
     integer(c_int) :: arr
     integer(c_int), value :: arr
  end function
end interface


However, an issue arise when I try to call and pass a device pointer to the function
Code:
integer, device, dimension(:), allocatable :: arr_d
integer :: size  = 100
allocate(arr_d(size))
x = c_foo_fuc(arr_d, size)

I always get the error type mismatch for the first argument of c_foo_func.

How could the issue be resolved?

Thanks,
Tuan
Back to top
View user's profile
Tuan



Joined: 11 Jun 2009
Posts: 233

PostPosted: Fri Oct 01, 2010 10:55 am    Post subject: Reply with quote

I think I found the solution

REAL(c_double), device :: arr(*)
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