Skip to main content

Using MKL with COSMA8

By default, MKL (the Intel Math Kernel Library) does not select the best the best options when used on COSMA8, delivering significantly lower performance. For versions of MKL prior to 2020, setting MKL_DEBUG_CPU_TYPE=5 would force it to use the zen2 code path. However, for newer versions, this no longer works. Instead, the following workaround should be used:

cat <<EOF > amdmkl.c
int
mkl_serv_intel_cpu_true() { return 1; }

EOF

gcc -shared -fPIC -o libamdmkl.so amdmkl.c
export LD_PRELOAD=libamdmkl.so


Permanent fix

Rather than remembering to set LD_PRLOAD everytime you run your application, add this to your program using:

patchelf --add-needed libamdmkl.so yourbinary

The information here was taken from https://danieldk.eu/Posts/2020-08-31-MKL-Zen.html