Calling CUDA C libraries from CUDA Fortran

I’m evaluating whether I can use the CUDA Fortran and have a very basic question.

i.e. Within CUDA Fortran, would it be possible to write a kernel that calls a numerical library written in CUDA C.

I am a complete beginner to GPUs and CUDA so any advice would be appreciated.


CUDA Fortran host code is able to call a CUDA C kernel. You just need need to create an interface block using F2003 ISO_C_BINDING to ensure the kernel is called correctly. An example of this can be found in my PGinsider article: Tuning a Monte Carlo Algorithm on GPUs. See the section titled “Calling a CUDA C Random Number Generator”.

This article on using GPU enabled Math Libraries my also be of interest

At this time, there isn’t a way to call CUDA C device routines from within a CUDA Fortran global kernel or device routine. Currently in CUDA, in order to call a device routine, the routine must have the same file scope (or module scope) as the caller.

Hope this helps,