Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- Intel Community
- Software
- Software Development SDKs and Libraries
- Intel® oneAPI Math Kernel Library
- Difference between C++ code with Blas/Lapack and Matlab

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page

Tianyi__Darren__L_

Beginner

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

09-27-2015
12:06 AM

141 Views

Difference between C++ code with Blas/Lapack and Matlab

Hi All!

I am trying to implement one Linear programming algorithm in C++. For the matrix multiplication, I use Blas and Lapack. However, I find C++ code performs worse than Matlab as the size of problem is large. Indeed, the difference becomes significant as the size increases.

I am wondering if it is caused by the optimization tricks of matlab use to call Intel MKL. Could some one help explain why Matlab sometimes outperform C++ with Blas/Lapack? Is there any way to improve this version of C++ code, or any option to optimize compiling?

Thank you for your time!

Link Copied

5 Replies

TimP

Black Belt

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

09-27-2015
02:02 AM

141 Views

Tianyi__Darren__L_

Beginner

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

09-27-2015
11:31 PM

141 Views

Hi, Tim.

Thank you for your reply!

Would you like to tell me what affinity settings in Matlab mean? I am not familiar with this. Furthermore, could you tell me how I modify my C++ code to improve the performance?

Thank you for your time!

Tianyi__Darren__L_

Beginner

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

10-06-2015
12:48 AM

141 Views

Ying_H_Intel

Employee

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

10-07-2015
10:26 PM

141 Views

Hi Tianyi,

Could you provide some details, like a test code and test result, compile option, test processor, matlab version, MKL version to explain what the problem you are seeing? otherwise, it is hard to say something.

Regarding MKL and Matlab, you may have known that , Matlab matrix multiply should call MKL. You may check this by enter command in matlab command windows,

version -blas

https://software.intel.com/en-us/articles/using-intel-mkl-with-matlab

Best Regards,

Ying

Gennady_F_Intel

Moderator

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

10-07-2015
11:37 PM

141 Views

two my cents just for info -- Matlab R2015b uses MKL version 11.1.

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

For more complete information about compiler optimizations, see our Optimization Notice.