Reddit users by the names 'nedflanders1976' and 'foreignrobot' have devised a simple tweak that massively boosts the performance of AMD Ryzen CPUs in MATLAB.
Apparently, when MATLAB and similar Intel MKL-based applications are run, they perform a vendor string query and upon detection of an AMD CPU (AuthenticAMD), these applications are executed using older SSE1 instruction, even if the said CPU supports newer SIMD extensions. AMD processors have had support for AVX2 instructions since the 'Excavator' architecture and this fix enforces the use of AVX2 instruction on supported AMD CPUs.
As expected, there is a significant performance boost to be had due to the use of this newer more efficient instruction.
In the case of Matrix manipulation, there is up to a 258% boost in performance.
The integrated MATLAB benchmark also sees a similar gain in performance by moving to AVX2.
To start MATLAB in an AVX2-enabled mode, the following batch file has to be created and run.
@echo off
set MKL_DEBUG_CPU_TYPE=5
call "%MKLROOT%\bin\mklvars.bat" MKL_DEBUG_CPU_TYPE=5
matlab.exe
To use this setting permanently, assuming there is no issue in your system post applying this tweak, the following "system environment variable" has to be created which can be found in the "Advanced" section of system properties.
The AVX2 mode can also be activated in the Linux environment by launching this terminal:
export MKL_DEBUG_CPU_TYPE=5
And to make the setting permanent in the Linux environment, type in the same thing by editing your shell's configuration script (~/.bashrc for bash, ~/.zshrc for zsh, etc.)
Source: Reddit
8 Comments - Add comment