CUDA Internals: cuModule & cuFunction

Do you know where the cuModule and cuFunction datatypes are declared? I am trying to figure-out how the binary code of the kernel is transferred to the GPU. I searched the CUDA documentation and the web as well, but I didn’t find them anywhere.

Thanks in advance!

CUmodule and CUfunction are typedefs declared in cuda.h:

...

typedef struct CUmod_st *CUmodule;                        /**< CUDA module */

typedef struct CUfunc_st *CUfunction;                     /**< CUDA function */

...

True! But it seems that ‘struct CUmod_st’ and ‘struct CUfunc_st’ are defined in private scope inside the driver. Do you know the fields of these structs and in what kind of memory do they allocated (device/host) ?

Oh sorry I don’t have a definite answer on that one. But as far as I can tell, CUfunctions are more or less just function pointers, while I believe the CUmodule will probably contain the cuda code of the file it loads. If you look at the JIT ptx compilation (namely, in the cudaDecodeGL project’s “cudaModuleMgr” class), you’ll see that they manually read the file (i.e. with fread) if it’s a .cubin file, and use the API call “cuModuleLoadDataEx” to construct the CUmodule. Not sure what you can glean from this, but it seems (to me) that CUmodules will contain the actual device code (from the .cu file) in some form or another. Naturally, I could be way the hell off on this too. Good luck