I have a code by name mexCodeCuda.cu which uses dynamic parallelism. In the matlab interface, when I try to execute the following commands, I get the following error :
system('nvcc --compile mexCodeCuda.cu -o mexCodeCuda.o --compiler-options -fPIC -m64 -rdc=true -gencode arch=compute_35,code=sm_35 -O3 -lineinfo -use_fast_math -lcudadevrt -I/cm/shared/apps/MATLAB/extern/include')
system('nvcc -arch=sm_35 -dlink mexCodeCuda.o -o dlink.o')
eval('mex mexCodeCuda.o dlink.o -L'CUDA_LIB_PATH '-lcudart')
It gives the following error :
Error using mex
/usr/bin/ld: dlink.o: relocation R_X86_64_32S against `__nv_module_id' can
not be used when making a shared object; recompile with -fPIC
dlink.o: could not read symbols: Bad value
collect2: error: ld returned 1 exit status
Can anyone help me ? Thanks in advance...
mexand the othernvccwith-fPIC? - chappjc--compiler-options -fPIC- Tom__cudaRegisterLinkedBinary_65_tmpxft_00007d13_00000000_9_cuda_device_runtime_compute_50_cpp1_ii_5f6993ef': link.stub:(.text+0xab): undefined reference to__fatbinwrap_65_tmpxft_00007d13_00000000_9_cuda_device_runtime_compute_50_cpp1_ii_5f6993ef' collect2: error: ld returned 1 exit status - Jagannathcudadevrtruntime option on themexcommand, just as you have with the firstnvcccall. And you may need to add-fPICto the mex linking viaLDCXXFLAGSorLDFLAGS. - chappjc