Linking a kernel to a PTX function

前端 未结 1 1659
花落未央
花落未央 2021-01-22 05:01

Can I use a PTX function contained in a PTX file as an external device function to link it to another .cu file which should call that function?

This is another question

1条回答
  •  后悔当初
    2021-01-22 05:27

    You can load the file containing PTX code in your own code from the filesystem by cuModuleLoad and cuModuleGetFunction as follows:

    CUmodule module;
    CUfunction function;
    
    const char* module_file = "my_ptx_file.ptx";
    const char* kernel_name = "my_kernel_name";
    
    err = cuModuleLoad(&module, module_file);
    err = cuModuleGetFunction(&function, module, kernel_name);
    

    You can also pass the PTX code to the CUDA driver directly as a string, see Passing the PTX program to the CUDA driver directly.

    0 讨论(0)
提交回复
热议问题