Intel® oneAPI Math Kernel Library
Ask questions and share information with other developers who use Intel® Math Kernel Library.

cblas_cdotu_sub and cblas_cdoc_sub

marc_d_
Beginner
554 Views

Hi,

I have noticed that the cblas functions cblas_cdotu_sub and cblas_cdotc_sub are returning 0 for the scalar product instead of the correct value. In earlier versions of MKL, the bug was also present for double precision functions (cblas_zdotu_sub and cblas_ztodc_sub). In the evaluation version for Linux I downloaded these last days, the bug is present only for single precision.

Best regards.

 

0 Kudos
5 Replies
mecej4
Honored Contributor III
554 Views

I see no errors when I run the two examples provided with MKL: cblas_cdotc_subx.c and cblas_cdotu_subx.c, with ICC 12.1.4 and ICC 14.0.2, on OpenSuse 12.3 x64.

Please provide references and/or test cases where you saw the errors that you reported.

0 Kudos
marc_d_
Beginner
554 Views

When I compile and run the following C++ code :

#include <iostream>
#include <complex>

#include "mkl_cblas.h"

using namespace std;

int main(int argc, char** argv)
{
  typedef float T;

  complex<T>* x, *y;
  complex<T> res;
  int n, incx, incy;

  n = 2;
  incx = 1;
  incy = 1;

  x = new complex<T>[2];
  y = new complex<T>[2];

  x[0] = complex<T>(0.43, 0.6);
  x[1] = complex<T>(0.5, 0.7);
  y[0] = complex<T>(0.8, 0.9);
  y[1] = complex<T>(0.9, 0.4);

  cblas_cdotu_sub(n, x, incx, y, incy, &res);

  cout << "resultat = " << res << endl;

  return 0;
}

I get (0, 0) as a result. Whereas if I set T as a double and use cblas_zdotu_sub I get the correct result.

I am using gcc 4.6.3 to compile the program with Ubuntu 12.04.4 LTS.

 

0 Kudos
mecej4
Honored Contributor III
554 Views

I ran the above program that you posted using g++ 4.7.2 and MKL 11.1 (32-bit and 64-bit) on OpenSuse 12.3. No problems.

[bash]

$ . mklvars.sh intel64

$ g++ marc.cpp -lmkl_rt -lpthread -lm

$ ./a.out

resultat = (-0.026,1.697)

[/bash]

0 Kudos
Murat_G_Intel
Employee
554 Views

I try the example code above with GCC 4.4.6 and didn't see any errors. Having said that, I think an array of std::complex<float> may not have complex numbers at the adjacent memory locations, which is a requirement for the cblas_cdotu_sub function. To make sure that this is not the issue here, can you please try to run the following code. Here, I modified your example to use native float data types instead of std::complex<float> :

#include <iostream>
#include <complex>

#include "mkl_cblas.h"

using namespace std;

int main(int argc, char** argv)
{
    typedef float T;
    float *x, *y;
    float res[2];
    int n, incx, incy;

    n = 2;
    incx = 1;
    incy = 1;

    x = new float[4];
    y = new float[4];

    x[0] = 0.43; x[1] = 0.6;
    x[2] = 0.5; x[3] = 0.7;

    y[0] = 0.8; y[1] = 0.9;
    y[2] = 0.9; y[3] = 0.4;

    cblas_cdotu_sub(n, x, incx, y, incy, &res[0]);

    cout << "resultat = (" << res[0] << "," << res[1] << ")" << endl;

    return 0;
}

If you see correct results with the above code, then this is most likely related to how compiler handels std::complex<float>.

 

Thank you

0 Kudos
TimP
Honored Contributor III
554 Views

I remember several years ago c99 complex was recommended.

Meyers and plum wrote an article in 2003 about combining. C99. And c++98 but I am concerned about changes in c++11.

0 Kudos
Reply