本文介绍了将内核链接到PTX功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以使用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.

这篇关于将内核链接到PTX功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

05-16 20:41