Processors

Matlab: a reddit user increases the performance of amd ryzen mkl

Table of contents:

Anonim

Now, with MATLAB we can increase the performance of our Ryzen processors . All thanks to a Reddit user. Are you ready?

Before starting, MATLAB is a numerical computing system that is used by research institutes, engineering firms, universities or large technology companies. You may wonder why? It is a system whose purpose is to solve problems characterized by the existence of matrices and vectors.

In our case, MATLAB is used for the optimization of the Mathematical Kernel Library (MKL). Let's get started!

It all starts with a bad Ryzen optimization

Among other things, MATLAB is used to perform operations that benefit from Intel MKL, causing poor optimization for Ryzen processors. This was realized by the Reddit user Nedflanders1976, which managed to increase the performance of Ryzen and Ryzen Threadripper processors to 280% .

The question is how? Forcing MATLAB to use advanced instruction sets, such as AVX2. Until now, MKL was checking the processor manufacturer ID, but if it saw that the processor was AMD, it dropped to SSE, which means a clear drop in performance for Ryzen processors.

Does going down from AVX2 to SSE mean a performance drop? Yes, especially when AMD Ryzen has technologies such as SSE4, AVX or AVX2.

Guide to force MKL to use AVX2

The trick is simple and very powerful, but it has to be done manually by Ryzen users themselves. Simply, we have to create a .BAT file using notepad and saving as "all files".

Therefore, we open a notebook and write in it all the commands to start MKL in AVX2 mode . You have to write the following:

@echo off

set MKL_DEBUG_CPU_TYPE = 5

call "% MKLROOT% \ bin \ mklvars.bat" MKL_DEBUG_CPU_TYPE = 5

matlab.exe

We recommend reading the best processors on the market

Of course, this trick will not be permanent, but we can make it permanent by creating a variable environment system. The same user Nedflanders1976 uploaded the source code so that we can benchmark the performance impact of switching to AVX2. Will you try this "trick" on your Ryzen?

TechPowerUPReddit Font

Processors

Editor's choice

Back to top button