PGI User Forum
 SearchSearch   MemberlistMemberlist     RegisterRegister   ProfileProfile    Log inLog in 

CUDA-x86.

Calling CUDA C kernel from PGI Visual Fortran

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



Joined: 24 Oct 2012
Posts: 3

PostPosted: Mon Oct 07, 2013 12:48 pm    Post subject: Calling CUDA C kernel from PGI Visual Fortran Reply with quote

Hi,

I'm trying to call a CUDA C kernel from PGI CUDA Fortran, and I followed the instructions in this topic

http://www.pgroup.com/userforum/viewtopic.php?t=3169&start=0&postdays=0&postorder=asc&highlight=fortran+call+cuda

by using a similar Fortran interface statement as in http://www.pgroup.com/lit/articles/insider/v2n1a4.htm

Unfortunately, I get link-time errors in Visual Studio. What I did was to build a static C library containing the CUDA kernel as a function (I built the library using an NVIDIA project inside Visual Studio), and then link in the resulting library in my PGI Visual Fortran project. Here are the linker errors:

2>erfCuda.lib(erf_kernel.cu.obj) : error LNK2001: unresolved external symbol __imp_frexp
2>erfCuda.lib(erf_kernel.cu.obj) : error LNK2001: unresolved external symbol __imp_ldexp
2>erfCuda.lib(erf_kernel.cu.obj) : error LNK2001: unresolved external symbol __imp_modff

I've searched for these symbols online, but didn't find what libraries contain them. Has anybody here have any success in calling a CUDA C kernel from PGI Visual Fortran within MS Visual Studio? I've also tried building using "make" inside the PVF command prompt, but nvcc needs the Visual C compiler.

Thanks,
Chona
Back to top
View user's profile
mkcolg



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

PostPosted: Mon Oct 07, 2013 1:56 pm    Post subject: Reply with quote

Hi Chona,

These symbols are all C99 math library routines. Since Microsoft doesn't support C99, you may need to figure out what the Microsoft equivalent for them is or avoid using these routines. Does the code link if you remove these?

- Mat
Back to top
View user's profile
csg



Joined: 24 Oct 2012
Posts: 3

PostPosted: Mon Oct 07, 2013 2:08 pm    Post subject: Reply with quote

mkcolg wrote:
Hi Chona,

These symbols are all C99 math library routines. Since Microsoft doesn't support C99, you may need to figure out what the Microsoft equivalent for them is or avoid using these routines. Does the code link if you remove these?

- Mat


Hi Matt,

I'm not calling any of these routines, although the C kernel does use the CUDA function erf. Do you know why the kernel function needs these C99 math library routines?

To save time, will it be better if I package up my code along with the MSVS solution file, and send it to you?

Thanks,
Chona
Back to top
View user's profile
csg



Joined: 24 Oct 2012
Posts: 3

PostPosted: Mon Oct 07, 2013 3:29 pm    Post subject: Reply with quote

Hi Matt,

I solved the problem. It turns out that using the multithreaded runtime library in my static C library project does the trick; that is, I needed to set the /MT linker option in the Properties -> CUDA C/C++ -> Host. I had it set to "inherit from host" before.

I hope this thread can help other MSVS developers.

Chona
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