Actually, that's quite exciting. I'm not there yet but I think I'm one step further.
OK, I build a simple CUDA example by hand using this Makefile:
all: julia_cpu julia_gpu
clean:
rm -f julia_cpu julia_gpu *.linkinfo
GSL_LIBS = $(shell gsl-config --libs)
julia_cpu: julia_cpu.cu
nvcc -lglut --use_fast_math $+ -o $@ $(GSL_LIBS)
julia_gpu: julia_gpu.cu
nvcc -lglut --use_fast_math $+ -o $@ $(GSL_LIBS)
which when run shows this being executed:
mark@c2stable ~/CODE/code/chapter04 $ make
nvcc -lglut --use_fast_math julia_cpu.cu -o julia_cpu -L/usr/lib64 -lgsl -lgslcblas -lm
nvcc -lglut --use_fast_math julia_gpu.cu -o julia_gpu -L/usr/lib64 -lgsl -lgslcblas -lm
I found the Advanced Compiler & Debugger stuff and made a *.cu extension , and then added the following:
nvcc -arch sm_20 --use_fast_math $includes -c $file -o $object
which seems to work correctly.
Compiling: main.cu
Process terminated with status 0 (0 minutes, 0 seconds)
0 errors, 0 warnings
An object file, main.o, is generated. Big step forward! Thanks!!!!
OK, so now I need to add the stuff that gets linked, which is (I think) this stuff from the command line:
-lglut
-L/usr/lib64
-lgsl
-lgslcblas
-lm
All of these seem to be located in /usr/lib64/. I tried adding them to Project -> Build Options -> Link Settings but I haven't gotten it right. I have these on the left
glut
gsl
gslcblas
m
and on the right I have
-L/usr/lib64
but it doesn't link. Here's the Build log:
-------------- Build: Debug in julia_gpu ---------------
Compiling: main.cu
Linking console executable: bin/Debug/julia_gpu
obj/Debug/main.o: In function `HandleError(cudaError, char const*, int)':
tmpxft_000005e1_00000000-1_main.cudafe1.cpp:(.text+0x1e): undefined reference to `cudaGetErrorString'
obj/Debug/main.o: In function `start_thread(void* (*)(void*), void*)':
tmpxft_000005e1_00000000-1_main.cudafe1.cpp:(.text+0x198): undefined reference to `pthread_create'
obj/Debug/main.o: In function `end_thread(unsigned long)':
tmpxft_000005e1_00000000-1_main.cudafe1.cpp:(.text+0x1bb): undefined reference to `pthread_join'
obj/Debug/main.o: In function `destroy_thread(unsigned long)':
tmpxft_000005e1_00000000-1_main.cudafe1.cpp:(.text+0x1d5): undefined reference to `pthread_cancel'
obj/Debug/main.o: In function `main':
tmpxft_000005e1_00000000-1_main.cudafe1.cpp:(.text+0x27f): undefined reference to `cudaMalloc'
tmpxft_000005e1_00000000-1_main.cudafe1.cpp:(.text+0x2f2): undefined reference to `cudaConfigureCall'
tmpxft_000005e1_00000000-1_main.cudafe1.cpp:(.text+0x334): undefined reference to `cudaMemcpy'
tmpxft_000005e1_00000000-1_main.cudafe1.cpp:(.text+0x351): undefined reference to `cudaFree'
obj/Debug/main.o: In function `__cudaUnregisterBinaryUtil()':
tmpxft_000005e1_00000000-1_main.cudafe1.cpp:(.text+0x3c1): undefined reference to `__cudaUnregisterFatBinary'
obj/Debug/main.o: In function `__device_stub__Z14float_to_colorPhPKf(unsigned char*, float const*)':
tmpxft_000005e1_00000000-1_main.cudafe1.cpp:(.text+0x14cf): undefined reference to `cudaSetupArgument'
tmpxft_000005e1_00000000-1_main.cudafe1.cpp:(.text+0x14f4): undefined reference to `cudaSetupArgument'
obj/Debug/main.o: In function `__device_stub__Z14float_to_colorP6uchar4PKf(uchar4*, float const*)':
tmpxft_000005e1_00000000-1_main.cudafe1.cpp:(.text+0x1573): undefined reference to `cudaSetupArgument'
tmpxft_000005e1_00000000-1_main.cudafe1.cpp:(.text+0x1598): undefined reference to `cudaSetupArgument'
obj/Debug/main.o: In function `__device_stub__Z6kernelPh(unsigned char*)':
tmpxft_000005e1_00000000-1_main.cudafe1.cpp:(.text+0x1613): undefined reference to `cudaSetupArgument'
obj/Debug/main.o: In function `__sti____cudaRegisterAll_39_tmpxft_000005e1_00000000_4_main_cpp1_ii_68d40520()':
tmpxft_000005e1_00000000-1_main.cudafe1.cpp:(.text+0x1667): undefined reference to `__cudaRegisterFatBinary'
tmpxft_000005e1_00000000-1_main.cudafe1.cpp:(.text+0x16c8): undefined reference to `__cudaRegisterFunction'
tmpxft_000005e1_00000000-1_main.cudafe1.cpp:(.text+0x1718): undefined reference to `__cudaRegisterFunction'
tmpxft_000005e1_00000000-1_main.cudafe1.cpp:(.text+0x1768): undefined reference to `__cudaRegisterFunction'
obj/Debug/main.o: In function `cudaError cudaLaunch<char>(char*)':
tmpxft_000005e1_00000000-1_main.cudafe1.cpp:(.text._Z10cudaLaunchIcE9cudaErrorPT_[cudaError cudaLaunch<char>(char*)]+0x14): undefined reference to `cudaLaunch'
collect2: ld returned 1 exit status
Process terminated with status 1 (0 minutes, 1 seconds)
19 errors, 0 warnings
So it's clearly not finding things. How can I get these libraries linked in??
Thanks for the help so far. Neat little tools the way the program is put together.
Cheers,
Mark