PGI User Forum
 SearchSearch   MemberlistMemberlist     RegisterRegister   ProfileProfile    Log inLog in 

Free OpenACC Webinar

return a device pointer from a C function call back to Fortr

 
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: Sun Oct 03, 2010 9:59 pm    Post subject: return a device pointer from a C function call back to Fortr Reply with quote

Hi,
I have a C functions, that allocate memory on CUDA device, and then return back the pointer to that device memory. There are two possible ways for this C functions:
1. a function with a double** argument
2. a function return double*

It's easy to implement in C. However, as I read that Fortran is not easy to handle pointer-to-pointer, I chose the second one. For the second interface, I tried using type(c_ptr), yet it doesn't work

in C:
Code:

double* foofuunc() {...}

Fortran interface:
Code:
type(c_ptr) foofunc() bind(c)

and then I try to cast to a device memory variable in Fortran, declared with
Code:
double precision, dimension(:), allocatable, device :: a
I got "illegal number of type of argument"

Code:
type(c_ptr) :: c_a
c_f_pointer(c_a, a)


Could someone give me an advice.

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



Joined: 11 Jun 2009
Posts: 233

PostPosted: Wed Oct 06, 2010 9:48 am    Post subject: Reply with quote

Any one can help me, please.
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