About cuLibraryLoadFromFile

I want to call this function, but I don’t know how to pass this parameter
If I write code like this, it will crash

CUlibrary library;
    CUkernel kernel;
    CUjit_option jitOptions[] = {
            CUjit_option::CU_JIT_MAX_REGISTERS,
    };
    void* jitOptionsValues[] = {
        NULL,
    };
    CUlibraryOption libraryOptions[] = {
        CUlibraryOption::CU_LIBRARY_HOST_UNIVERSAL_FUNCTION_AND_DATA_TABLE,
    };
    void* libraryOptionValues[] = {
        (void*)1, 
        (void*)0 
    };
    cuLibraryLoadFromFile(&library,"cu_kernel.cubin", jitOptions, jitOptionsValues, 1, libraryOptions, libraryOptionValues, 1);

It might help if you explained your use-case, and provide a complete example. I also am not sure what “crash” means, but I suspect the difficulty is with your actual options values. Each option value in the array of option values must be an actual pointer to a location which contains the option value. You do not specify an option value by casting it to a void pointer.

so try something like this:

int a = 1;
void* libraryOptionValues[] = {
    (void*)&a, 
    (void*)0 
};
1 Like