[英]Generating Relocatable Device Code using Nvidia Nsight
I'm trying to compile a dynamic parallelism example on CUDA and when i try to compile it gives and error saying, 我正在尝试在CUDA上编译一个动态并行性示例,当我尝试对其进行编译时会给出错误提示,
kernel launch from __device__ or __global__ functions requires separate compilation modes
Later found that I have to set the --relocatable-device-code
flag to true
. 后来发现我必须将--relocatable-device-code
标志设置为true
。 But, is there a flag to set in order to make the set relocatable-device-code
to true
in Nsight Eclipse? 但是,是否要设置一个标志,以使在Nsight Eclipse中将relocatable-device-code
为true
?
If you are not using makefile project, you could change the options passed to nvcc
of a Nsight project at the following position, starting from the menu. 如果不使用makefile项目,则可以从菜单开始在以下位置更改传递给Nsight项目的nvcc
的选项。
Project - Properties - Build - Settings - Tool Settings - NVCC Compiler 项目-属性-构建-设置-工具设置-NVCC编译器
As Nsight does not provide a rdc option for you to check, you could directly change 'Commnad' from 由于Nsight不提供rdc选项供您检查,因此您可以直接将“ Commnad”更改为
nvcc
to 至
nvcc -rdc=true
or change 'Command line pattern' from 或更改“命令行模式”
${COMMAND} ${FLAGS} ${OUTPUT_FLAG} ${OUTPUT_PREFIX} ${OUTPUT} ${INPUTS}
to 至
${COMMAND} ${FLAGS} -rdc=true ${OUTPUT_FLAG} ${OUTPUT_PREFIX} ${OUTPUT} ${INPUTS}
The second one is better. 第二个更好。
You may also want to change this for 'All configurations' rather than 'Debug' or 'Release' only. 您可能还希望仅针对“所有配置”而不是“调试”或“发布”更改此设置。
You should follow @RobertCrovella's instructions in the comment. 您应该在评论中遵循@RobertCrovella的说明。 It is the official way. 这是官方的方式。
After a project is created, you can also make this change by going to Project...Properties...Build...Settings. 创建项目后,还可以通过转到Project ... Properties ... Build ... Settings进行此更改。 Here you will see a page similar to the one mentioned above in the "Basic settings" dialog page. 在这里,您会看到与上述“基本设置”对话框页面中提到的页面相似的页面。 You can similarly change "Device linker mode:" on this page from "Whole program compilation" to "Separate compilation" in order to turn on generation of relocatable device code, after the project has already been created. 您可以类似地在此页面上将“设备链接器模式:”从“整个程序编译”更改为“单独编译”,以便在创建项目后打开可重定位设备代码的生成。
Credit goes to @robertcrovella. 归功于@robertcrovella。 This was actually the answer I was looking for, so I've made it a separate answer. 这实际上是我一直在寻找的答案,因此我将其作为单独的答案。
you can use nvcc option "-dc" or "-rdc=true", you can ref this as as sample. 您可以使用nvcc选项“ -dc”或“ -rdc = true”,您可以将其作为示例引用。
nvlink, relocatable device code and static device libraries nvlink,可重定位设备代码和静态设备库
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.