nvcc 将动态并行cu文件编译成动态链接库

如果cuda程序没有使用动态并行,编译动态链接库为:

nvcc -arch=sm_60 -std=c+11 -O3 -rdc=true -Xcompiler -fPIC -c algorithm.cu -o algorithm.o

g++  algorithm.o -fPIC -shared -o libalgorithm.so

cuda文件中如果使用了动态并行,编译成动态链接库需要使用以下三步:

nvcc -arch=sm_60 -std=c+11 -O3 -rdc=true -Xcompiler -fPIC -c algorithm.cu -L/usr/local/cuda-10.1/lib64 -lcudart -lcudadevrt

nvcc -arch=sm_60 -Xcompiler -fPIC -dlink -o algorithm_link.o algorithm.o -L/usr/local/cuda-10.1/lib64 -lcudart -lcudadevrt

g++ algorithm_link.o algorithm.o -fPIC -shared -o libalgorithm.so -L/usr/local/cuda-10.1/lib64 -lcudart -lcudadevrt

你可能感兴趣的:(nvcc 将动态并行cu文件编译成动态链接库)