CUDA - 将内核链接到PTX函数 [英] CUDA - Linking a kernel to a PTX function

查看:434
本文介绍了CUDA - 将内核链接到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?

这是另一个问题来自 CUDA - 链接内核在一起,其中函数本身不包含在。 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驱动程序,请参阅直接将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函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆