Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7188829
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T19:10:09+00:00 2026-05-28T19:10:09+00:00

I have a function pointer array which I use to call the appropriate cblas_xgemm

  • 0

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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T19:10:12+00:00Added an answer on May 28, 2026 at 7:10 pm

    Your question seems to boil down to the fact that you have functions of differing signatures that you are trying to call from a function pointer array. I’ve never tried this myself, but from a little bit of research, it doesn’t look like this is possible. That makes sense, since a statically typed language would not be able to evaluate type safety of this maneuver.

    I’ve seen suggestions of using boost::variant, and other workarounds for this, but since you are linking to a library that is not our yown, I’m not sure there is much value in pursing those options.

    If you want to prove or disprove, you could remove CBLAS from your test program, and simply implement a class with multiple methods of signature, which differ only in datatype.

    On a side note, column major is a major pain.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a function in which I make use of a local array. I
I have a function that has an array pointer passed it to modify stuff
I have a pointer which points to a function. I would like to: if
I have a void pointer returned by dlsym(), I want to call the function
I have got a problem with calling a global function, which takes a pointer
I want to use SHA1 function from Linux libraries ( documentation ) which returns
I have this function which is called about 1000 times from main(). When i
I have a function which grows an array when trying to add an element
I have a simple C program which has a pointer to a character array.
I have a function which takes an int * and modifies the array that

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.