Acceleration of Intel MKL on AMD Ryzen CPU's

Some of us use Intel MKL with Julia for improved performance.
Intel MKL is composed of few code paths for different features of the CPU (SSE2, SSE4, AVX2, AVX512, etc…).
One of the issues of MKL is it discriminate non Intel CPU’s and use the the generic SSE2 code path on AVX2 capable CPU’s.

This specifically hurts on Ryzen 3xxx series which have better AVX2 performance than Intel’s comparable CPU’s.

It seems people found a way around it. By defining System / Environment Variable users could enforce Intel MKL to use the AVX2 code path and skip the CPU Dispatching mechanism.

One could read about it:

Though the above targets MATLAB I think it should work on Julia + MKL.

In Windows it requires:

@echo off

set MKL_DEBUG_CPU_TYPE=5
matlab.exe 

It seems MKL_DEBUG_CPU_TYPE=5 suggests AVX2 capable CPU code path.
Where instead of launching MATLAB one should launch Julia.
The same should hols on other OS.

I wonder if one could integrate this trick into Juno (On Julia Pro for that matter).

6 Likes

How to Set the Environment Variable in Juno

In order to set the Environment Variable in Juno one could do:

  1. Create a Launcher for Juno
    One could create a script file or batch file to launch Juno and set the variable. For instance, In Windows, see the launcher defined in Guide: How to Create a Portable Julia Pro Installation for Windows.
  2. Edit the Init File of Juno
    • Open the Command Pane (Ctrl + Shift + p).
    • Type Init Script and choose: Application: Open Your Init Script.
    • A file named init.coffee or init.js will be opened. Add process.env["MKL_DEBUG_CPU_TYPE"] = "5" in its last line.
    • Save and restart Juno.

Admittign my ignorance here. I thought one had to do a compile and link of Julai from source in order to use Intel MKL.
I am sure an expert will be along soon to correct me…

1 Like