AMD Ryzen/Threadripper CPUs perform excellent using Matlab since the 2020a Release, or if you perform a very simple tweak with the versions prior to 2020a.
Here is an example of several CPUs based on a matlab performance benchmark script you'll find in the link below.
As said, since Matlab 2020a, you'll have this performance out of the box. For Matlab versions prior to 2020a, please read the link below.
You should read it if you want to understand the background. If you ended up here because you are on an older Version on Matlab and have low performance with an AMD setup or you just want to apply the tweak, follow these steps: It will take less than a minute.
Solution 1 (Windows - no admin rights needed):
- Create a .bat file with the following lines to start Matlab in AVX2 Mode
This is straight forward. You open Notepad, copy and paste the above three lines and save the file as Matlab-AVX2. Notepad will save the file as Matlab-AVX2.txt. Now replace the extension ".txt" with ".bat".
If you double-click that file, Matlab will start the MKL in AVX2 Mode. If you start it the normal way, it will remain as always.
You can also download the .bat file from my highdrive if you trust me (which you of course should not, as I am a random guy in the Internet). If you delete the startup batch file provided in the download or the one you created yourself, its gone and your computer will be as it has been before.
Solution 2 (Windows - admin rights needed): If you are happy with the results (which you will be :-)), you should make the setting permanent by entering MKL_DEBUG_CPU_TYPE=5 into the System Environment Variables. This has several advantages, one of them being that it applies to all instances of Matlab and not just the one opened using the .bat file.
You can do this either by editing the Environmental Variables as shown above, or by opening a command prompt (CMD) with admin rights and typing in:
setx /M MKL_DEBUG_CPU_TYPE 5
Doing this will make the change permanent and available to ALL Programs using the MKL on your system until you delete the entry again from the variables.
LINUX: (Thanks to foreignrobot)
Simply type in a terminal:
and then run matlab from the same terminal.
For benchmarking, you can use this script:
Permanent solution for Linux:
echo 'export MKL_DEBUG_CPU_TYPE=5' >> ~/.profile
will apply the setting profile-wide, so you can launch it either through a terminal or the graphical launcher.