Why do cblas_dgemm and cblas_sgemm have different types of pointers in an array of function pointers?

I have an array of function pointers that I use to call the appropriate ones cblas_xgemm(e.g., cblas_dgemmor cblas_sgemm, etc. from ATLAS / CBLAS).

This works fine when I tell him to use cblas_dgemmfunction pointer; dgemm is called with the appropriate arguments and returns the correct result.

However, when I call cblas_sgemmthe 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 wrote a short test program that demonstrates the problem. Calling cblas_sgemmwithout a function pointer work well.

Note the following gcc warning (see also the gist linked above, which has full gcc output):

test_cblas_sgemm.c:20:3: warning: initialization from incompatible pointer type [enabled by default]

If I comment out a line cblas_sgemmin the definition of an array of function pointers, I do not get such a warning even for a line cblas_dgemm. But that makes no sense, because both of these functions must have the same return type!

Here are the relevant 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? Somehow he gets one of the functions xgemmfrom one header, and the other from another? Or am I dealing with some strange function pointer problem?

+5
source share
1 answer

, , , , . , , . , .

boost:: variant , , , , .

, CBLAS , .

, .

+1

All Articles