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

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 commentaires

You can try the suggestion from here and see if it makes any difference to your performance. Unless you have a specific workflow that you so often a few seconds already matter I would not let it influence the purchasing decision.
The best solution is probably to create testers for your functions. That way you can easily verify everything is working as intended. I personally write my code in the newest release. If I plan on sharing the code I make sure it is compatible with Matlab 6.5 and GNU Octave. That doesn't tend to take a lot of time, so updating your functions might be worth it.
If performance is so important to you: I would urge you to try a newer release as well. Some workflows have massive boosts in performance. Have a look at the comparison I posted here.
Thank you very much for your reply.
1) I will spend some time to go through your comparison that you gave in the link above.
2) I am expected to complete my research and submit my thesis by the 31st of January 2021, so I think it is safer for me to stick to the R2013b at the moment. I will only migrate to the latest MATLAB version and update my existing scripts with the latest syntaxes compatible with the latest MATLAB and GNU Octave version after I graduate.
3) Most of my current MATLAB scripts take a few hours to run. If the performance difference (in terms of execution time) is really significant, it will give an advantage for me if the execution time can be reduced.
4) I have a friend who installs version R2013b on his AMD laptop. I don't memorise his CPU model, but it is older and cheaper than the Ryzen series. However, I think I can borrow his laptop for a while whenever he is free to see if the MKL on the MATLAB R2013b of his laptop can be configured to 'AVX2' or not.
Just a side-note: Matlab 6.5 is really old (2002) and GNU Octave is a 'mostly compatible' alternative. Both tend to be slower but have their own applications.
Also, what kind of speedup do you expect from this instruction set change? I doubt it will be more than a few percent. Just to manage your expectations. The performance gain by switching to a newer system with a higher clock and better IPC will be a much larger jump.
FYI release R13 and release R2013b are two separate releases. They were released over a decade apart.
MATLAB 6.5 is release R13 and was released in summer 2002. [I think it was the first release of MATLAB released after I started working at MathWorks; I think I started days after the previous release.] That release predates the R20xxy [xx are digits, y is a or b] naming system (which started with release R2006a in spring 2006.)
MATLAB 8.2 is release R2013b and was released in the fall of 2013.
I just realised about that 'R13' vs 'R2013b' thing. Steven Lord is correct. What I mean is MATLAB 8.2 which is release R2013b and was released in the fall of 2013. Thank you very much for pointing this out.
Regarding the kind of speedup that I expect from this instruction set change (if we are talking about R2013, not R13), I still have no idea. The only kind of answer that I can give at this moment is if the MKL on the MATLAB version R2013b installed on an AMD system cannot be changed from the default 'SSE' to 'AVX2' and its performance is significantly slower than the same MATLAB version installed on an Intel system and using the 'Intel MKL' MKL, then I will definitely buy a new laptop with Core i7-10750H instead of Ryzen 7 4800H.
@Steven R13 was released on 18th June 2002 according to the splash. To prevent this very same confusion I tend to stick to calling it v6.5.
@Shamsul You could explore which newer release allows the instruction set change and doesn't require you to rewrite a lot of your code. Note that many journals officially require you to be able to reproduce your results for a period of 10 years (including any bugs) so your current setup might require you to get R2013b working in 2030.
@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.
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.

Connectez-vous pour commenter.

Réponses (1)

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 commentaires

I use the following syntax that I got from the other threads in this forum, which is below:
version('-blas')
Just now, I have also tried the syntax that you gave below, but so far I see the outcome is still the same:
version -blas
Below is what happen when I did the checking on the MATLAB R2013b installed on my desktop with an Intel Core i7-3770 CPU and installed with MATLAB R2013b
>> version('-blas')
ans =
Intel(R) Math Kernel Library Version 11.0.2 Product Build 20130124 for Intel(R) 64 architecture applications
Please ignore the the purple colour of the words after the word 'Math' above. It should be black, but it automatically becomes purple when I type it in here.
Co-incidentally, I have a friend who installed MATLAB R2013b on his laptop with an AMD E1-2100 APU. I borrowed his laptop a few hours ago to do the following initial checking and the result is still the same:
>> version('-blas')
ans =
Intel(R) Math Kernel Library Version 11.0.2 Product Build 20130124 for Intel(R) 64 architecture applications
I have no idea whether it is normal for the MKL result to appear as 'Intel(R) Math Kernel Library ...' during the checking for an AMD APU/CPU or not.
Then, I created a Matlab-AVX2.bat file using a text editor with the following content (without the bullets, of course :-p ):
  • @echo off
  • set MKL_DEBUG_CPU_TYPE=5
  • matlab.exe
When I clicked the Matlab-AVX2.bat file above on my friend's AMD laptop and let the MATLAB software opened automatically, I did the same checking, but the result is still the same:
>> version('-blas')
ans =
Intel(R) Math Kernel Library Version 11.0.2 Product Build 20130124 for Intel(R) 64 architecture applications
I have no idea whether the result should be like this or not for a system with an AMD APU.
If the result should display something related to 'SSE' or 'AVX2' for the AMD CPU/APU, I suspect my result above happens because of one of the following reasons:
  1. MATLAB R2013b might not be tweakable with this MKL setting on an AMD system.
  2. The 'SSE' and 'AVX2' thing might not be settable for MATLAB R2013b installed on an AMD system with E1-2100 APU (I don't know any friend that can lend me a Ryzen system for checking this MATLAB MKL setting at the moment).
  3. The way I do the setting using the 'version('-blas')' syntax might be wrong.
  4. The content of my 'Matlab-AVX2.bat' file and the way I execute it might be wrong.
Just in case the way I do the checking (the 'version('-blas')' syntax that I use or the content of the 'Matlab-AVX2.bat' that I created) is wrong or the software (the MATLAB R2013b) / hardware (the AMD E1-2100 APU) does not support this MKF tweaking, please advise/inform me.
I just tried to change the 'set MKL_DEBUG_CPU_TYPE=5' in my created Matlab-AVX2.bat file to 0 and 1, then double-clicked it on my MATLAB R2013b installed on my desktop with Intel Core i7-3770, but the result is still the same:
>> version('-blas')
ans =
Intel(R) Math Kernel Library Version 11.0.2 Product Build 20130124 for Intel(R) 64 architecture applications
You would not see whether it worked or not using version -blas
Given the MKL Version 11.02 and the details from the blogpost linked earlier which tested the workaround in version 10.x I would clearly think it works.
Also, Intel MKL 11.0 and following is fully supporting Intel AVX2
As said, simply test it via 'bench' on your intel. If you can slow down your Intel CPU by setting the debug variable to 1, you can also accelerate AMD cpus by setting it to 5.
Thats the most simple way to go ahead.
All right, I understood your first three statements above crystal clear.
Regarding the 4th statement, mat I know how to do the 'bench' thing on my intel system? Can I just run any of my existing lengthy and time-consuming codes by using different debug variables, then see the time difference taken while running the code using the different debug variables?
Thank you.
You simply type
bench(3)
As a note. Your little AMD E1 xxx Sys is a very old Excavator µArch. Don't expect a dramatic change. The change will be much more substantial on the newer Ryzen.
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.
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 ;-)

Connectez-vous pour commenter.

Catégories

En savoir plus sur Startup and Shutdown dans Centre d'aide et File Exchange

Produits

Version

R2013b

Community Treasure Hunt

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

Start Hunting!

Translated by