Few lines of code changed: AMD Ryzen Matlab performance soars by up to 258%

We know that the performance of a hardware product, not only depends on the design of the hardware itself, but also depends on the driver, software support and optimization, many times some simple optimization adjustment can bring unexpected results. For example, the popular, authoritative mathematical computing environment Matlab, on intel processor has a special optimization, detected is Intel processor will take advantage of Intel MKL (path kernel library, and call the AVX2 instruction set, to obtain the desired performance.

For non-Intel processors, such as AMD, Matlab uses only the old SSE instruction set, resulting in a difference in performance.

Few lines of code changed: AMD Ryzen Matlab performance soars by up to 258%

Reddit user Nedflanders 1976 research found that AMD Ryzen, thread tearer processor on The Matlab can also turn on the AVX2 instruction set, so as to get a performance spike!

According to the tutorial given by this netizen, the method is very simple. Under the Windows system, you can create a bat batch file with only four lines of code, through which AMD processor users can start Matlab and turn on the AVX2 instruction set.

@echo off

set MKL_DEBUG_CPU_TYPE s5

call “%MKLROOT% /?bin?mklvars.bat” MKL_DEBUG_CPU_TYPE s5

matlab.exe

Few lines of code changed: AMD Ryzen Matlab performance soars by up to 258%

The above is a temporary method, if you want to take effect permanently, simply find the MKL_DEBUG_CPU_TYPE in the advanced system properties and change the value of this environment variable to 5, but note that any program that uses MKL will be affected.

Few lines of code changed: AMD Ryzen Matlab performance soars by up to 258%

Linux users are also simple, the temporary method is to enter the following command and start Matlab, the permanent method is to edit the configuration script and add the following command:

export MKL_DEBUG_CPU_TYPE s5

According to the test, AMD Ryzen processor after such modifications, Matlab performance can be improved by 17%, more than 258%!

Few lines of code changed: AMD Ryzen Matlab performance soars by up to 258%

Few lines of code changed: AMD Ryzen Matlab performance soars by up to 258%

Add a Comment

Your email address will not be published. Required fields are marked *