cannot convert ‘const std::complex<float>*’ to ‘const float*’

Issue #50 resolved
Robin Ruede created an issue

When I try to compile this with #define BLAZE_BLAS_MODE 1 and cblas.h from OpenBLAS

I get multiple errors because this library tries to pass const std::complex<float>*, but the library accepts a float*.

For example with cblas_cdotu_sub https://bitbucket.org/blaze-lib/blaze/src/dae360c344d84ee169332d1de163cc6c57fc763b/blaze/math/blas/dotu.h?at=master&fileviewer=file-view-default#dotu.h-150

I get

amunmt/src/3rd-party/blaze/math/blas/dot.h:156:47: error: cannot convert ‘const std::complex<float>*’ to ‘const float*’ for argument ‘2’ to ‘void cblas_cdotu_sub(blasint, const float*, blasint, const float*, blasint, openblas_complex_float*)’
    cblas_cdotu_sub( n, x, incX, y, incY, &tmp );

This also happens for other calls, like cblas_cgemm, cblas_zgemm, cblas_cgemv, cblas_ztrmm, cblas_ztrsm.

This might also be an issue with OpenBLAS?

Comments (7)

  1. Klaus Iglberger

    Hi!

    It unfortunately looks like OpenBLAS uses a different function signature. By default all BLAS functions should expect a const void* (see for instance the LAPACK reference, the Apple API reference, and the GNU GSL CBLAS library). Therefore it seems to be an issue with OpenBLAS.

    Nevertheless, the problem can be solved within the Blaze library by explicitly converting const complex<float>* to const float*. We will try to take care of the issue within the next 48h.

    Best regards,

    Klaus!

  2. Robin Ruede reporter

    I got my program working with the suggested change of simply casting the values given to the BLAS library. Here is the patch: https://bitbucket.org/karlsruhe-it-solutions/amunmt/commits/886bb53154d37854cf8515a93d74ba2a64f2155e

    Note that this patch applies to an older version of blaze from what I can see.

    Also note that it uses two instances of openblas_complex_float/double (typedeffed float _Complex) which are specific to openblas. Not sure how to make that generic.

    For my specific program though, blaze seems to run faster without BLAS than with either CBLAS or OpenBLAS. Are these benchmarks using Blaze with BLAS and if so which implementation?

  3. Klaus Iglberger

    Thanks for the link to the patch. Our fix was implemented based on your implementation. Blaze should now be fully compatible to OpenBLAS.

    Whether the Blaze kernels or BLAS kernels are faster depends on the size and the row/column ratio of the matrix. For small matrices and matrices with a very small or large row/column ratio the Blaze kernels prove to be more efficient, for large quadratic matrices BLAS kernels are usually better suited. Our benchmark results for the dense matrix multiplication were obtained with the MKL as underlying BLAS library.

    Thanks again, your help is highly appreciated!

    Best regards,

    Klaus!

  4. Klaus Iglberger

    The fix has been implemented and verified via tests. It is immediately available via cloning the Blaze repository and will be officially released in Blaze 3.1.

  5. Log in to comment