help for debug Device code!
One fotran program bench.f and one cuda interface Cuda_kernel.cu
When not adding ¨-G¨ there is no error during compiling.
For debugging device code, ¨-G¨ option is added as follows. But errors exist.

What is wrong?

mpif77 -c -g -O3 bench.f
nvcc -c -g -G -O3 Cuda_kernel.cu
mpif77 -o lxp-cuda bench.o Cuda_kernel.o -L/usr/local/cuda/lib -lcudart
Cuda_kernel.o: In function `$$SymbolTable':
(.nv10Segment+0x80): undefined reference to `$gpu_registers'
Cuda_kernel.o: In function `$$SymbolTable':
(.nv10Segment+0x110): undefined reference to `blockDim'
Cuda_kernel.o: In function `$$SymbolTable':
(.nv10Segment+0x11c): undefined reference to `gridDim'
Cuda_kernel.o: In function `$$SymbolTable':
(.nv10Segment+0x128): undefined reference to `blockIdx'
Cuda_kernel.o: In function `$$SymbolTable':
(.nv10Segment+0x134): undefined reference to `blockIdx'
collect2: ld return 1
make: *** [lxp-cuda] Error 1
One fotran program bench.f and one cuda interface Cuda_kernel.cu

When not adding ¨-G¨ there is no error during compiling.

For debugging device code, ¨-G¨ option is added as follows. But errors exist.



What is wrong?



mpif77 -c -g -O3 bench.f

nvcc -c -g -G -O3 Cuda_kernel.cu

mpif77 -o lxp-cuda bench.o Cuda_kernel.o -L/usr/local/cuda/lib -lcudart

Cuda_kernel.o: In function `$$SymbolTable':

(.nv10Segment+0x80): undefined reference to `$gpu_registers'

Cuda_kernel.o: In function `$$SymbolTable':

(.nv10Segment+0x110): undefined reference to `blockDim'

Cuda_kernel.o: In function `$$SymbolTable':

(.nv10Segment+0x11c): undefined reference to `gridDim'

Cuda_kernel.o: In function `$$SymbolTable':

(.nv10Segment+0x128): undefined reference to `blockIdx'

Cuda_kernel.o: In function `$$SymbolTable':

(.nv10Segment+0x134): undefined reference to `blockIdx'

collect2: ld return 1

make: *** [lxp-cuda] Error 1

#1
Posted 09/10/2008 09:25 AM   
[quote name='xinsan' post='437841' date='Sep 10 2008, 10:25 AM']One fotran program bench.f and one cuda interface Cuda_kernel.cu
When not adding ¨-G¨ there is no error during compiling.
For debugging device code, ¨-G¨ option is added as follows. But errors exist.

What is wrong?

mpif77 -c -g -O3 bench.f
nvcc -c -g -G -O3 Cuda_kernel.cu
mpif77 -o lxp-cuda bench.o Cuda_kernel.o -L/usr/local/cuda/lib -lcudart
Cuda_kernel.o: In function `$$SymbolTable':
(.nv10Segment+0x80): undefined reference to `$gpu_registers'
Cuda_kernel.o: In function `$$SymbolTable':
(.nv10Segment+0x110): undefined reference to `blockDim'
Cuda_kernel.o: In function `$$SymbolTable':
(.nv10Segment+0x11c): undefined reference to `gridDim'
Cuda_kernel.o: In function `$$SymbolTable':
(.nv10Segment+0x128): undefined reference to `blockIdx'
Cuda_kernel.o: In function `$$SymbolTable':
(.nv10Segment+0x134): undefined reference to `blockIdx'
collect2: ld return 1
make: *** [lxp-cuda] Error 1[/quote]

You need to compile ptxvars.cu and link with it. When you run nvcc in default mode it will compile, and link and do this automatically for you. If you only compile (-c) this is not done automatically. So what you need to do is :

nvcc "/usr/local/cuda/bin/ptxvars.cu" -g -G --host-compilation=c -c -define-always-macro __DEVICE_LAUNCH_PARAMETERS_H__ -Xptxas -fext -o "ptxvars.o"

and then:
mpif77 -o lxp-cuda bench.o Cuda_kernel.o ptxvars.o -L/usr/local/cuda/lib -lcudart
(same for if you use g++ to compile)

Hope this works for you!
Maybe there are more elegant solutions to this problem but i'm not aware of them.

Simon
[quote name='xinsan' post='437841' date='Sep 10 2008, 10:25 AM']One fotran program bench.f and one cuda interface Cuda_kernel.cu

When not adding ¨-G¨ there is no error during compiling.

For debugging device code, ¨-G¨ option is added as follows. But errors exist.



What is wrong?



mpif77 -c -g -O3 bench.f

nvcc -c -g -G -O3 Cuda_kernel.cu

mpif77 -o lxp-cuda bench.o Cuda_kernel.o -L/usr/local/cuda/lib -lcudart

Cuda_kernel.o: In function `$$SymbolTable':

(.nv10Segment+0x80): undefined reference to `$gpu_registers'

Cuda_kernel.o: In function `$$SymbolTable':

(.nv10Segment+0x110): undefined reference to `blockDim'

Cuda_kernel.o: In function `$$SymbolTable':

(.nv10Segment+0x11c): undefined reference to `gridDim'

Cuda_kernel.o: In function `$$SymbolTable':

(.nv10Segment+0x128): undefined reference to `blockIdx'

Cuda_kernel.o: In function `$$SymbolTable':

(.nv10Segment+0x134): undefined reference to `blockIdx'

collect2: ld return 1

make: *** [lxp-cuda] Error 1



You need to compile ptxvars.cu and link with it. When you run nvcc in default mode it will compile, and link and do this automatically for you. If you only compile (-c) this is not done automatically. So what you need to do is :



nvcc "/usr/local/cuda/bin/ptxvars.cu" -g -G --host-compilation=c -c -define-always-macro __DEVICE_LAUNCH_PARAMETERS_H__ -Xptxas -fext -o "ptxvars.o"



and then:

mpif77 -o lxp-cuda bench.o Cuda_kernel.o ptxvars.o -L/usr/local/cuda/lib -lcudart

(same for if you use g++ to compile)



Hope this works for you!

Maybe there are more elegant solutions to this problem but i'm not aware of them.



Simon

#2
Posted 02/13/2009 02:58 PM   
Scroll To Top