Shared Cuda Fortran libraries?


I have an existing Fortran library I would like to be able to run using cuda, but call from existing C Cuda code using shared libraries. Is this possible and if so, can I get a basic outline of how to compile the Fortran code such that it’s useable?



Hi drp,

If you’re calling the Fortran library from host code, then it’s the same as calling Fortran from C. However, you can only call device routines from device code.

  • Mat

So there currently exists no way to call a Fortran Device method from a C kernal?



For both CUDA Fortran and CUDA C, there isn’t a linker for device code. Hence, there is no way to call external device routines from other device routines. Device calls must be inlined at compile time, so must be in the same file scope in CUDA C and module scope in CUDA Fortran.

You can call a CUDA Fortran global kernel from CUDA C host code as well as CUDA C global kernels from CUDA Fortran host code.

  • Mat