[英]cuda dynamic parallelism linkage error extern c
I'm trying to link my CUDA Kepler's Dynamic Parallelism program as follows: 我正在尝试将CUDA开普勒的动态并行程序链接如下:
nvcc -m32 -arch=sm_35 -dc -Xcompiler '-fPIC' DFS_Solving.cu
nvcc -m32 -arch=sm_35 -Xcompiler '-fPIC' -dlink DFS_Solving.o -o link.o
gcc -shared -Wl,-soname,libdfs.so -o libdfs.so DFS_Solving.o link.o -L/usr/local/cuda/lib -lcudart
gcc -c proxy.c
gcc -o proxy proxy.o -L. -ldfs
And I aways get the following error: 而且我走了以下错误:
./libdfs.so: undefined reference to `__fatbinwrap_66_tmpxft_000015c6_00000000_12_cuda_device_runtime_compute_50_cpp1_ii_5f6993ef'
collect2: error: ld returned 1 exit status
But: when I do the same procedure to compile a CUDA code with no Dynamic Parellelism, the program works. 但是:当我执行相同的过程以编译没有动态Parellelism的CUDA代码时,该程序将运行。
Does anybody knows what can I do in order to make this compilation works? 有人知道我该怎么做才能使此编译工作正常吗?
It appears that you are missing the linkage against -lcudadevrt
. 看来您缺少与
-lcudadevrt
的链接。 CDP codes need to be linked against the device runtime . CDP代码需要针对设备运行时进行链接。
Here's a fully worked example. 这是一个完整的示例。 My compile sequence is not identical to yours, but pretty close:
我的编译顺序与您的不同,但是非常接近:
$ cat DFS_Solving.cu
#include <stdio.h>
extern "C"{
void cuda_test();
}
__global__ void child_kernel(){
printf("hello\n");
}
__global__ void parent_kernel(){
child_kernel<<<1,1>>>();
cudaDeviceSynchronize();
}
void cuda_test(){
parent_kernel<<<1,1>>>();
cudaDeviceSynchronize();
}
$ cat proxy.c
void cuda_test();
int main(){
cuda_test();
}
$ nvcc -arch=sm_35 -dc -Xcompiler '-fPIC' DFS_Solving.cu
$ nvcc -arch=sm_35 -Xcompiler '-fPIC' -dlink DFS_Solving.o -o link.o
$ gcc -shared -Wl,-soname,libdfs.so -o libdfs.so DFS_Solving.o link.o -L/usr/local/cuda/lib64 -lcudart -lcudadevrt
$ gcc -c proxy.c
$ g++ -o proxy proxy.o -L. -ldfs
$ ./proxy
hello
$
There are also various cuda sample codes that demonstrate how to compile and link CDP projects. 还有各种cuda示例代码 ,它们演示了如何编译和链接CDP项目。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.