- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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 = 1.f; buf_y = 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); return 0; }
I get as an output 204 instead of 3.
Can anybody shed a light on this ?
Thank you.
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
That's a curious result. At first glance, everything looks correct. How did you link this case? and which version of mkl do you use?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I validated this case with the latest MKL 2019 u5.
I see no problems on our side.
compiling as icc -mkl test
MKL_VERBOSE Intel(R) MKL 2019.0 Update 5 Product build 20190808 for Intel(R) 64 architecture Intel(R) Advanced Vector Extensions (Intel(R) AVX) enabled processors, Lnx 2.80GHz lp64 intel_thread
MKL_VERBOSE SAXPY(10000,0x7ffe8f0a1658,0x23b7080,1,0x23c0cd0,1) 6.48ms CNR:OFF Dyn:1 FastMM:1 TID:0 NThr:20
3.000000, 3.000000, 3.000000, 3.000000, ...................
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page