eyalroz / cuda-api-wrappers

Thin, unified, C++-flavored wrappers for the CUDA APIs
BSD 3-Clause "New" or "Revised" License
768 stars 79 forks source link

Support CUlibrary's and CUkernel's - CUDA driver low-level "library management" #565

Closed eyalroz closed 6 months ago

eyalroz commented 8 months ago

Beginning with CUDA 12.0, we now have access to several functions for handling "libraries" of context-less "kernels":

https://docs.nvidia.com/cuda/cuda-driver-api/group__CUDA__LIBRARY.html

One can get a context-associated module or kernel by calling cuKernelGetFunction() or cuLibraryGetModule().

Functions:

CUresult cuKernelGetAttribute ( int* pi, CUfunction_attribute attrib, CUkernel kernel, CUdevice dev );
CUresult cuKernelGetFunction ( CUfunction* pFunc, CUkernel kernel );
CUresult cuKernelGetName ( const char** name, CUkernel hfunc );
CUresult cuKernelSetAttribute ( CUfunction_attribute attrib, int  val, CUkernel kernel, CUdevice dev );
CUresult cuKernelSetCacheConfig ( CUkernel kernel, CUfunc_cache config, CUdevice dev );
CUresult cuLibraryGetGlobal ( CUdeviceptr* dptr, size_t* bytes, CUlibrary library, const char* name );
CUresult cuLibraryGetKernel ( CUkernel* pKernel, CUlibrary library, const char* name );
CUresult cuLibraryGetManaged ( CUdeviceptr* dptr, size_t* bytes, CUlibrary library, const char* name );
CUresult cuLibraryGetModule ( CUmodule* pMod, CUlibrary library );
CUresult cuLibraryGetUnifiedFunction ( void** fptr, CUlibrary library, const char* symbol );
CUresult cuLibraryLoadData ( CUlibrary* library, const void* code, CUjit_option* jitOptions, void** jitOptionsValues, unsigned int  numJitOptions, CUlibraryOption* libraryOptions, void** libraryOptionValues, unsigned int  numLibraryOptions );
CUresult cuLibraryLoadFromFile ( CUlibrary* library, const char* fileName, CUjit_option* jitOptions, void** jitOptionsValues, unsigned int  numJitOptions, CUlibraryOption* libraryOptions, void** libraryOptionValues, unsigned int  numLibraryOptions );
CUresult cuLibraryUnload ( CUlibrary library );