Is the MKL Setting for MATLAB Version R2013b Running on an AMD System Also Tweakable from 'SSE' to 'AVX2'?

14 views (last 30 days)
Hello. I've been using MATLAB on Intel systems (Core 2 Duo, Core 2 Quad, Core i5 mobile 1st gen, Core i7 mobile 1st gen, Core i7 3rd gen, and Xeon) since the year 2008 until now (2020).
The laptop with Core i7 mobile 1st gen that I've been owning since 2008 is already becoming obsolete. Since the performance of the AMD CPUs and APUs (the Ryzen series) has becoming good lately, I have decided to go for AMD laptop for my new laptop this time. After discussing with a few wonderful people on a few computer fora (if you are not a native speaker, the word 'fora' is the plural version of the word 'forum') regarding which AMD laptop to buy, I have decided to try the Lenovo Legion 5 15" with Ryzen 7 4800H APU.
However, one of the members in one of the fora told me that MATLAB might perform slower on an AMD systems compared to an Intel system even though the AMD system is faster than the Intel system in most types of workload. That forum member told me that this thing is caused by the MKL setting.
This is the 1st time I know about the MKL thing. I am from engineering background, not computer science. There are many MATLAB users who are not from computer science background (including me), but I think the level of MATLAB knowledge for most of the non-computer science background users are not as high as the computer science background users. Therefore, I think not many non-computer science background users know about this MKL setting for MATLAB on an AMD system (expecially the beginners/non-experienced users).
I did some searching on Google about MKL. Based on my understanding as a beginner so far who are not from the computer science background, most of the websites that I found say that during the MATLAB installation process, the MATLAB installers for version R2019b and earlier set the MKL as 'Intel MKL' (the most optimsed MKL for Intel CPU) whenever the installers detect an Intel CPU and set the MKL as 'SSE' (not optimsed MKL for AMD CPU) whenever the installers detect an AMD CPU (even though there are other types of MKL that are more optimsed for AMD CPU such as the 'IA SSE4', 'AVX', and 'AVX2'). I also obtained 2 more findings: (1) The MATLAB installer for the version R2020a has been fixed to set the MKL as 'Intel MKL whenever the installer detects an Intel CPU but set the MKL as 'AVX2' whenever the installer detects an AMD CPU. For AMD users who uses the MATLAB version R2019b and earlier on an AMD system, there is a tweak to change the MKL setting from the slower 'SSE' to the more AMD-optimised 'AVX2'. However, I am still using the old MATLAB version R2013b and am not sure whether it is also possible to do the same tweaking for the old version like the R2013b.
The reason why I still use the R2013b version is because I have been keeping too many old MATLAB scripts since since I did masters in the year 2008. Every few years, some of the syntaxes in MATLAB are revised/updated for improvement. My old MATLAB scripts will no longer be compatible with the newer MATLAB version because of the syntaxes update. This problem can still be solved by updating the old syntaxes in my old MATLAB scripts to the new syntaxes so that the old scripts can be run error-free on the newer MATLAB version, but I am currently doing a PhD and have a little time to do that at the moment and decided to stick using the MATLAB version R2013b and only revised my existing codes with newer syntaxes after I graduate my PhD.
The reason why I make this post is to ask if anyone here knows whether the MKL for the old MATLAB version R2013b is also tweakable to 'AVX2' on an AMD system or not. If yes, I will proceed buying the Lenovo Legion 5 15" laptop that comes with the AMD Ryzen 7 4800H APU. Otherwise, I will just switch to the Lenovo Legion 5 15" laptop that comes with the Intel Core i7-10750H CPU. Thank you.
PS:
1) Please let me know if I should reply on an existing thread(s) to ask this question instead of opening this new thread to ask the same question.
2) The Lenovo Legion 5 15" laptop is available in both the AMD Ryzen APU and Intel Core iSeries CPU. All this time I have decided to go for the Ryzen 7 4800H version because it is cheaper but perform better than some of the more expensive Intel CPUs in some aspects, but I can change my mind spending a little bit extra buying the Core i7-10750H version if it is not confirmed whether the MATLAB version R2013b is tweakable to use the 'AVX2' or not.
3) Last but not least, I am also not a native English speaker. I only know the word 'fora' since the year 2013. Before that, I mistakenly used the word 'forums' as the plural version of the word 'forum' :-p
  8 Comments
SHAMSUL FAISAL
SHAMSUL FAISAL on 7 Sep 2020
@Rik, Do I have to check one by one the syntaxes that I always use to identify whether I have to rewite a lot of my code? If yes, I think the only time that I am able to do that is after I complete my research and submit my thesis/defending my thesis/correcting my thesis by the early of nest year. Sorry about that :-p
Thank you for informing me that many journals officially require usu to be able to reproduce our results for a period of 10 years. I never know about this before and this is a new knowledge for me.
Rik
Rik on 7 Sep 2020
You can simply install a newer release and try to run your code. If it errors, fix the error and retry. That is the alternative to checking line by what your dependencies are.

Sign in to comment.

Answers (1)

Ned Flanders
Ned Flanders on 7 Sep 2020
Edited: Ned Flanders on 7 Sep 2020
Which MKL version does 2013b come with?
The very first cpu that supported the avx2 codepath was Intel Hasswell which was released in 2013. Typically, Matlab lags about 0.5-1 year behind the latest MKL version in their release.
So it is possible that 2013b does not at all support avx2 (not in intel, not on AMD). But even if so, the support was in a relatively early phase.
You can check by asking
version -blas
But I can confirm, that the workaround existed already in 2013 as you can see by looking into this blog post published in may 2015
So yes, it will most likely work with Matlab 2013b
I think you could also test it on your current Intel System: Set the variable to 0 or 1 (SSE1 or SSE2) (MKL_DEBUG_CPU_TYPE=0) and use the integrated benchmark to see whether this slows down performance. If so, you know this works and you can set it to 4 or 5 on any system including an AMD system.
  7 Comments
SHAMSUL FAISAL
SHAMSUL FAISAL on 7 Sep 2020
Roger that. Please give me some time to do it, because I am a little bit busy with the thing that I have to do in my university (journal and conference manuscripts). Once I have done the 'bench(3)' thing, do you want me to post the result in here? If yes, please let me know whether you just want me to copy and paste the values of the numbers inside the matrix that come out after I type the 'bench(3)' and press enter or including the screenshots of the graphs that appears with the matrix?
One more thing. I used to try this 'bench(3)' thing just for fun many months ago and the result is not consistent for every run. Should I do a few runs for each possible debug variable because of this inconsistency?
I don't have any friend who can lend me an Ryzen system at this moment. If the difference of the different debug variable result from the AMD E1-2100 APU is not significant, I will just test it on my Intel system. If the difference of the different debug variable result from my Intel system is significant, I will assume that it might also work on a Ryzen system (but please advice if it is not a got idea for me to do this kind of assumption).
Thank you very much.
Ned Flanders
Ned Flanders on 7 Sep 2020
Edited: Ned Flanders on 7 Sep 2020
bench(3) runs the integrated benchmark 3 times. This will help you to identify outliers.
I am not familiar with the older AMD µArches, so I can't tell which kind of SIMD extensions they support.
The main question for you is simply whether you can enforce SIMD support of the mkl using the debug mode. If you can, you can do this entirely independent of the CPU used in your system. The mkl included with your version of ML is the version 11 according to the result of 'version -blas'. That one should support AVX2 = CPU_TYPE=5. In the worst case, you can use =4 for AVX(1) support. But this is exclusively limited by the old mkl not by your CPU.
Lets say you got an Intel Hasswell CPU and you enforce =1 (SSE2) that should result in a reduced performance and this you can measure. Alternative, to 'bench' you can also use the benchmark I inculded in the download link in my reddit post "how to enforce codepath usage". You don't need to be afraid to download it, I am a nice guy ;-)

Sign in to comment.

Categories

Find more on Introduction to Installation and Licensing in Help Center and File Exchange

Products


Release

R2013b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!