PGI User Forum
 SearchSearch   MemberlistMemberlist     RegisterRegister   ProfileProfile    Log inLog in 

Free OpenACC Webinar

Programming with two languages (Please advise)
Goto page 1, 2, 3  Next
 
Post new topic   Reply to topic    PGI User Forum Forum Index -> Programming and Compiling
View previous topic :: View next topic  
Author Message
Torkin



Joined: 18 Apr 2012
Posts: 31

PostPosted: Sun Mar 09, 2014 8:57 am    Post subject: Programming with two languages (Please advise) Reply with quote

Hello

I have a very specific question. My fortran code produces a "Ax=b" matrix and vectors and I would like to solve it using a family of functions that is written in C which is also Cuda enabled.

How would I start to link my values from fortran to the solver on C using PGI?
Could you please guide me on where I might find the necessary steps?

Thank you!
Ahmed
Back to top
View user's profile
mkcolg



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

PostPosted: Mon Mar 10, 2014 8:56 am    Post subject: Reply with quote

Hi Torkin,

I would suggest start by reading Chapter 13, Inter-language Calling, of the PGI Compiler User's Guide. It give a good overview of the issues you may encounter.

Also, I'd recommend reading about the F2003 iso_c_binding intrinsic module. This module greatly simplifies interoperability with C.

Finally, calling CUDA C from CUDA Fortran follows the same Fortan to C conventions as above. However, I highly recommend using iso_c_binding if you're going to call CUDA C global kernels directly since you'll need an interface block describing the call. While this article I wrote is a bit old, it does have an example of CUDA Fortran calling CUDA C. See: http://www.pgroup.com/lit/articles/insider/v2n1a4.htm

- Mat
Back to top
View user's profile
Torkin



Joined: 18 Apr 2012
Posts: 31

PostPosted: Mon Mar 10, 2014 1:52 pm    Post subject: Reply with quote

Wonderful!
Thank you Mat
Back to top
View user's profile
Torkin



Joined: 18 Apr 2012
Posts: 31

PostPosted: Fri Mar 14, 2014 2:09 am    Post subject: Reply with quote

Hey Mat

As is obvious, I am new to coding. I am looking at the Monte Carlo Integration example and it is very helpful in understanding many things, I am grateful for all the support.

I am just lost in one thing..could you please tell me the exact steps of getting the makefile to start? Do I have to use PGI Bash (64) or will PGI Cmd (64) run it too? I call the directory where "pgi_mc_example" folder exists...and then?

Please help me.
Ahmed
Back to top
View user's profile
mkcolg



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

PostPosted: Fri Mar 14, 2014 8:44 am    Post subject: Reply with quote

Hi Ahmed,

On Windows, you'll want to use the Cygwin (bash) environment since DOS doesn't support Make.

I wrote that article with Linux in mind and don't think I tested it on Windows. Though, that's why we ship Cygwin, so folks a have Unix like environment and access to these tools. I don't think you'll have a problem with the code, but may need to adjust paths and make sure nvcc can be invoked (if you're doing the mixed CUDA C portion). Also, you'll most likely need to figure out what symbol name nvcc gives the random number generator routine.

I'm a bit swapped today but I can, I'll try the example myself on Windows and see what I encounter.

- Mat
Back to top
View user's profile
Display posts from previous:   
Post new topic   Reply to topic    PGI User Forum Forum Index -> Programming and Compiling All times are GMT - 7 Hours
Goto page 1, 2, 3  Next
Page 1 of 3

 
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