pgcc and cuBLAS

Hello. I want to compile cublas using pgcc(pgcc 16.1-0 64-bit target on x86-64 Linux -tp nehalem) but it doesn’t seem to recognize the cublas function in the code. More specifically, I get the following message:

pgcc test.c -Mcuda
/tmp/pgccIUjfMafeccQw.o: In function main': /home/kspan/./test.c:42: undefined reference to cublasCreate_v2’
/home/kspan/./test.c:42: undefined reference to cublasSetMatrix' /home/kspan/./test.c:42: undefined reference to cublasSetVector’
/home/kspan/./test.c:42: undefined reference to cublasSetVector' /home/kspan/./test.c:42: undefined reference to cublasSgbmv_v2’
/home/kspan/./test.c:42: undefined reference to cublasGetVector' /home/kspan/./test.c:68: undefined reference to cublasDestroy_v2

What could be the problem?

Hi kspan,

You need to include the cuBLAS library on your link line. The easiest method is to add the flag “-Mcudalib=cublas”.

% pgcc -help -Mcudalib
-Mcudalib[=cublas|cufft|curand|cusparse]
                    Add appropriate versions of the CUDA-optimized libraries

Hope this helps,
Mat