Enlace de biblioteca compartida de cuda: referencia no definida a cudaRegisterLinkedBinary
Gol:
cree una biblioteca compartida que contenga mis núcleos CUDA que tenga un contenedor / encabezado libre de CUDA.crear untest
ejecutable para la biblioteca compartida.Problema
biblioteca compartidaMYLIB.so
Parece compilar bien. (No hay problema).Error al enlazar:./libMYLIB.so: undefined reference to __cudaRegisterLinkedBinary_39_tmpxft_000018cf_00000000_6_MYLIB_cpp1_ii_74c599a1
makefile simplificado:
libMYlib.so : MYLIB.o
g++ -shared -Wl,-soname,libMYLIB.so -o libMYLIB.so MYLIB.o -L/the/cuda/lib/dir -lcudart
MYLIB.o : MYLIB.cu MYLIB.h
nvcc -m64 -arch=sm_20 -dc -Xcompiler '-fPIC' MYLIB.cu -o MYLIB.o -L/the/cuda/lib/dir -lcudart
test : test.cpp libMYlib.so
g++ test.cpp -o test -L. -ldl -Wl,-rpath,. -lMYLIB -L/the/cuda/lib/dir -lcudart
en efecto
nm libMYLIB.so
muestra quetodos Las funciones de api de CUDA son "símbolos indefinidos":
U __cudaRegisterFunction
U __cudaRegisterLinkedBinary_39_tmpxft_0000598c_00000000_6_CUPA_cpp1_ii_74c599a1
U cudaEventRecord
U cudaFree
U cudaGetDevice
U cudaGetDeviceProperties
U cudaGetErrorString
U cudaLaunch
U cudaMalloc
U cudaMemcpy
Entonces CUDA de alguna manera no se vinculó a la biblioteca compartida MYLIB.so ¿Qué me estoy perdiendo?
CUDA ni siquiera se vinculó al archivo objeto de alguna manera:
nm MYLIB.o
U __cudaRegisterFunction
U __cudaRegisterLinkedBinary_39_tmpxft_0000598c_00000000_6_CUPA_cpp1_ii_74c599a1
U cudaEventRecord
U cudaFree
U cudaGetDevice
U cudaGetDeviceProperties
U cudaGetErrorString
U cudaLaunch
U cudaMalloc
U cudaMemcpy
(lo mismo que arriba)