I have a function pointer array which I use to call the appropriate cblas_xgemm
(e.g., cblas_dgemm
or cblas_sgemm
, etc., from ATLAS/CBLAS).
This works great when I tell it to use cblas_dgemm
by function pointer; dgemm gets called with the appropriate arguments and returns a correct result.
However, when I call cblas_sgemm
by function pointer, I get the following output:
ldc must be >= MAX(N,1): ldc=0 N=2Parameter 14 to routine cblas_sgemm was incorrect
I have written a short test program which demonstrates the problem. Calls to cblas_sgemm
without the function pointer work fine.
Note especially the following gcc warning (see also the gist linked above, which has the full gcc output):
test_cblas_sgemm.c:20:3: warning: initialization from incompatible pointer type [enabled by default]
If I comment out the cblas_sgemm
line in the function pointer array definition, I do not get such a warning, even for the cblas_dgemm
line. But that makes no sense because both of these functions should have the same return type!
Here are the appropriate lines from cblas.h
:
void cblas_sgemm(const enum CBLAS_ORDER Order, const enum CBLAS_TRANSPOSE TransA,
const enum CBLAS_TRANSPOSE TransB, const int M, const int N,
const int K, const float alpha, const float *A,
const int lda, const float *B, const int ldb,
const float beta, float *C, const int ldc);
void cblas_dgemm(const enum CBLAS_ORDER Order, const enum CBLAS_TRANSPOSE TransA,
const enum CBLAS_TRANSPOSE TransB, const int M, const int N,
const int K, const double alpha, const double *A,
const int lda, const double *B, const int ldb,
const double beta, double *C, const int ldc);
So what gives? Is it somehow getting one of the xgemm
functions from one header and the other from another? Or am I dealing with some weird function pointer issue?