Is it possible to load a module from two different cubin files?

Hello, Is it possible to load a module from two different cubin files? (so one kernal can call a function in another cubin file)

Actually you’re asking two different questions.

  1. Yes, it is possible to load more than one .cubin file into single context
  2. I don’t think kernel can call function from another .cubin file.

I dont think “device” functions have a representation in CUBIN. Only global functions have. Compiler takes care of INLINING device functions. And, that is why, you need to use “device” functions in HEADER files.

Put them in common header file and call it from all the kernels you would like.

btw,

A Kernel can NEVER call another kernel.

Also, There is no concept of function pointers in CUDA.

I see - this makes sense that there are no device functions to latch onto in the other cubin file and other kernels can never be called by another kernel. I’ll guess I’ll have to compile everything in one cubin file. FYI – The reason I was doing this is because during runtime I wanted to build a function in ptx code using ptxas.exe without re-building the calling code. Spasibo and thanks Andrei and Sarnath for your help.

Just FYI, you can now do this with JIT introduced in CUDA 2.1. No need to carry ptxas.exe around, everything can be done with API.