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

why do mkl::gemm get wrong result

might
Beginner
1,719 Views

Hi , guys , I’m using oneapi mkl blas with dpcpp ,I met some problems , when i use eigen to compute gemm(col-major),i get right result ,but when i use mkl with dpcpp(col-major) ,i get wrong result ,i test the data translation ,this part is no problem,so i think the only reason is gemm function.I really hope somebody could help me fix it , I will appreciate it a lot.

the code is below:

this is eigen code which get right result.053CD901-E9C3-4CED-B40E-E22A57393B93.jpeg

this is mkl code , its input value is as same as eigen code,and please ignore the if statement, I use it to make sure pointer only init once when in loop , and i think it is no problem.

ACF36B3D-FFDC-4C88-A49D-79F177E9D4A2.jpeg

forgive me , I don’t get computer here ,so the picture is screenshot of ssh ,

I was plagued by this for a weeks , and I really want to use mkl , If you could help me , I will appreciate it a lot. 

0 Kudos
8 Replies
might
Beginner
1,680 Views

I want to update this question , mkl  gemm with dpcpp can get right result when device is selected as cpu,however when device is set intel Xe hpg gpu ,the result is wrong .

might_2-1668348972618.png

the infomation of system:

might_0-1668348877242.png

might_1-1668348916806.png

I am sure that my code is right (because when I change gpu_selector to cpu_selector , the result is right), the problem is gemm or intel gpu , I still want to know how to fix it ,thanks!

0 Kudos
might
Beginner
1,676 Views

By the way , the compiler is Intel(R) oneAPI DPC++/C++ Compiler 2022.1.0 (2022.1.0.20220316)

the OS is Ubuntu20.04.4 LTS

oneapi version 2022.1.0

0 Kudos
might
Beginner
1,674 Views

And the datatype is float ,data scale is m=100000,n=1024,k=25000

0 Kudos
VidyalathaB_Intel
Moderator
1,656 Views

Hi Hansen,


Thanks for reaching out to us.

Could you please try running the sample code gemm_usm.cpp from MKL examples located under /opt/intel/oneapi/mkl/latest/examples/dpcpp/blas/source and see if you still get incorrect results on your GPU?


If possible please attach your test code here so that we can try reproducing the issue from our end as well.


Regards,

Vidya.


0 Kudos
might
Beginner
1,649 Views

Yes , I think the reason is that the data is size to big , mkl::gemm can get right result when data is small , but if the data size is like my data , wrong result will be get. 

0 Kudos
VidyalathaB_Intel
Moderator
1,627 Views

Hi Hansen,


Could you please let us know if working with oneMKL examples with your data also gives incorrect results?


Could you please try adding the sample reproducer here in the forum so that we can do a quick check and proceed further in this case?


Regards,

Vidya.


0 Kudos
VidyalathaB_Intel
Moderator
1,599 Views

Hi Hansen,


As we haven't heard back from you, could you please provide us with an update regarding the issue?


Regards,

Vidya.


0 Kudos
VidyalathaB_Intel
Moderator
1,559 Views

Hi Hansen,


As we haven't heard back from you, we are closing this thread. Please post a new question if you need any additional assistance from Intel as this thread will no longer be monitored.


Regards,

Vidya.


0 Kudos
Reply