This is a post summarizing my experience trying to get Eigen to work with the MKL library. It turns out linking with MKL radically accelerates the application.
I was trying to use MKL backend for Eigen, which is used in my code for ALS in ligra in this repository
I first followed the directions here and added the flag
I got the problem that I can’t find mkl.h, so I added the flag
-DMKL_LP64 to the compile flag,
But then Eigen can’t find its own header, I realized I didn’t include the current directory in the include path
Then error start to show up unable to find MKL. I chose to dynamically link MKL, so I had to add (1) -L link flags , (2) I also need to add MKL to LD_LIBRARY_PATH
For (1), I used the tool here
I was using Linux, but for Eigen, one thing to note is that it only works with LP64 (32 bit integers), it doesn’t work with the ILP64 interface in MKL. I only use sequential MKL for now
mkl_link_advisor (the pdf file, screenshot of how I used the advisor to show me the dynamic flag)
Furthermore, to get the tool to work and since I am doing dynamic linking (which grabs the relevant code during runtime), I had to add MKL to the LD_LIBRARY_PATH.
The quickies way to do that is go to icc/mkl/bin and run mklvars.sh
source /data/scratch/yunming/icc/install/mkl/bin/mklvars.sh intel64 (this is my command to set up the variables easily).
Once I did that, I was able to run Eigen with MKL
Hope this helps!