So I have this code that's suppose to compute the dot product of a matrix in different ways (one of which is to use blas in a c++), but when I try to use nvcc to compile the code, it doesn't work and it says that I have an undefined reference to ddot. This is weird because I'm pretty sure I'm using the calling notation referenced here for cublas: http://www.sdsc.edu/us/training/assets/docs/NVIDIA-03-Toolkit.pdf
Can anyone help me? Here's a snip of code I'm having trouble with:
#include <cublas.h> //just some included files here. No problems with these
#include <fstream>
#include <string>
#include <sstream>
using namespace std;
extern "C" //This is where I mention the cublas functions are external.
//I think this is necessary since I also have cuda pieces of code
{
double cublasDDOT_(int *n, double *A, int *incA, double *B, int *incB);
void cublasDAXPY_(int *n, double *a, double *A, int *incA, double *B, int *incB);
}
//Stuff happens here
C[i][t]=cublasDDOT_(&n, partA, &incA, partB, &incB); //This is a piece of my function and where the compiler chokes up
This is weird to me. I've also tried removing the "_"'s with no luck.
Here's the compile command I use: nvcc program
Do I need to mention the cublas library during the compile somehow? I have the cuda toolkit installed, but I don't know how to reference the library other than with
#include <cublas.h>
New update
It turns out I get the same output whether I include the cublas.h header or not
I also get the same output whether I type -lcublas or not
Here's the output, which is garbage for all compiles (with/without cublas.h & with/without -lcublas)
nvcc project4.cu -lcublas
/tmp/tmpxft_000051cb_00000000-14_project4.o: In function `ddot(int&, int&, int&, double**&, double**&, double**&, double*&, double*&, int&, int&, double&, double&, double*)':
tmpxft_000051cb_00000000-3_project4.cudafe1.cpp:(.text+0xda1): undefined reference to `cublasDDOT'
/tmp/tmpxft_000051cb_00000000-14_project4.o: In function `daxpy(int&, int&, int&, double**&, double**&, double**&, double**&, double*&, double*&, int&, int&, double&, double&, double*)':
tmpxft_000051cb_00000000-3_project4.cudafe1.cpp:(.text+0xff3): undefined reference to `cublasDAXPY'
collect2: ld returned 1 exit status