MATLAB MKL codepath tweak gives massive performance boost for AMD Ryzen CPUs

Posted on Monday, Nov 18 2019 @ 12:14 CET by Thomas De Maesschalck
AMD
TechPowerUp reports there's a small codepath tweak for MATLAB MKL that can provide up to a 250% performance boost on systems with an AMD Ryzen series processor. A couple of lines of batch code make the application use advanced instruction sets like AVX2, which results in a performance uplift of 25 percent to 250 percent, depending on the task.

The reason for the huge performance difference is because by default, MATLAB falls back to SSE1 when it detects an AMD processor. The application uses the Intel Math Kernel Library, which does not use SSE3-SSE4 or AVX1/2 extensions. Via a coupe of lines of code, users can ensure that MATLAB enforces AVX2, independent of the vendor string result. Details can be read at Reddit.
The tweak, meant to be manually applied by AMD Ryzen users, forces MKL to use AVX2 regardless of the CPU Vendor ID query result. The tweak is as simple as it is powerful. A simple 4-line Windows batch file with a set of arguments starts MKL in AVX2 mode. You can also make the tweak "permanent" by creating a system environment variable. The environment variable will apply to all instances of MATLAB, and not just those spawned by the batch file.
AMD MATLAB codepath tweak


About the Author

Thomas De Maesschalck

Thomas has been messing with computer since early childhood and firmly believes the Internet is the best thing since sliced bread. Enjoys playing with new tech, is fascinated by science, and passionate about financial markets. When not behind a computer, he can be found with running shoes on or lifting heavy weights in the weight room.



Loading Comments