问题描述
我可以使用PTX文件中包含的PTX功能作为外部设备功能将其链接到另一个应该调用该功能的.cu文件吗?
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?
这是另一个问题来自,其中函数本身不包含在。 cu文件,但我宁愿有一个PTX函数以某种方式链接
This is another question from CUDA - link kernels together where the function itself is not contained in a .cu file but I rather have a PTX function to be linked somehow
推荐答案
您可以加载包含PTX代码的文件在您自己的代码从文件系统 cuModuleLoad
和 cuModuleGetFunction
如下:
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);
您还可以将PTX代码直接作为字符串传递给CUDA驱动程序,请参阅。
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.
这篇关于CUDA - 将内核链接到PTX函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!