Is the MKL Setting for MATLAB Version R2013b Running on an AMD System Also Tweakable from 'SSE' to 'AVX2'?
Afficher commentaires plus anciens
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
Rik
le 6 Sep 2020
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.
SHAMSUL FAISAL
le 6 Sep 2020
Modifié(e) : SHAMSUL FAISAL
le 6 Sep 2020
Rik
le 6 Sep 2020
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.
Steven Lord
le 7 Sep 2020
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.
SHAMSUL FAISAL
le 7 Sep 2020
Modifié(e) : SHAMSUL FAISAL
le 7 Sep 2020
Rik
le 7 Sep 2020
@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.
SHAMSUL FAISAL
le 7 Sep 2020
Rik
le 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.
Réponses (1)
Ned Flanders
le 7 Sep 2020
Modifié(e) : Ned Flanders
le 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 commentaires
SHAMSUL FAISAL
le 7 Sep 2020
Modifié(e) : SHAMSUL FAISAL
le 7 Sep 2020
SHAMSUL FAISAL
le 7 Sep 2020
Ned Flanders
le 7 Sep 2020
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.
SHAMSUL FAISAL
le 7 Sep 2020
Ned Flanders
le 7 Sep 2020
Modifié(e) : Ned Flanders
le 7 Sep 2020
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.
SHAMSUL FAISAL
le 7 Sep 2020
Ned Flanders
le 7 Sep 2020
Modifié(e) : Ned Flanders
le 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 ;-)
Catégories
En savoir plus sur Startup and Shutdown dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!