Quantcast
Channel: Intel® oneAPI Math Kernel Library & Intel® Math Kernel Library
Viewing all articles
Browse latest Browse all 2652

MKL's cblas_saxpy outputs incorrect results

$
0
0

Hi,

I need to add two arrays in an efficient way, so I tried MKL's saxpy.

When I use the cblas_saxpy function on two dummy arrays with all values initialized to 1 and 2 respectively, I get totally wrong results. And I couldn't figure out what's wrong with my code.

(I omitted other includes)

#include "mkl.h"

#define SIZE 10000

int main()
{

        float* buf_x = (float*) malloc(SIZE * sizeof(float));
        float* buf_y = (float*) malloc(SIZE * sizeof(float));

        for (int i = 0; i<SIZE; i++){

            buf_x[i] = 1.f;

            buf_y[i] = 2.f;

        }

        cblas_saxpy ((MKL_INT)SIZE, 1, buf_x, (MKL_INT)1, buf_y, (MKL_INT)1);

        for (int i = 0; i<SIZE; i++)

            printf("%f, ", buf_y[i]);

        return 0;
}

I get as an output 204 instead of 3.

Can anybody shed a light on this ?

Thank you.


Viewing all articles
Browse latest Browse all 2652

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>