MKL Tips

From Eigen
Jump to: navigation, search

Using MKL through environment module

A useful tip from rgriffin122 of the forum:


Using Eigen3.1.0 and MKL 10.3.7, I had to create two modules for proper compilation. The first one was an Intel_MKL module, designating the proper libraries and paths. The second was the Eigen module, which is doing the same thing as the Intel_MKL one, only for Eigen.

Example:
-----intel------
#%Module 1.0
2 #
3 # Intel module for use with 'environment-modules' package:
4 #
5 
6 ## MKL 
7 setenv MKLROOT /opt/mkl10.3.7/mkl
8 setenv MKL_TARGET_ARCH intel64
9 prepend-path LD_LIBRARY_PATH /opt/mkl10.3.7/mkl/lib/intel64
10 prepend-path LIBRARY_PATH /opt/mkl10.3.7/mkl/lib/intel64
11 prepend-path LD_LIBRARY_PATH /opt/mkl10.3.7/lib/intel64
12 prepend-path LIBRARY_PATH /opt/mkl10.3.7/lib/intel64
13 prepend-path NLSPATH /opt/mkl10.3.7/mkl/lib/intel64/locale/%l_%t/%N
14 prepend-path MANPATH /opt/mkl10.3.7/man/en_US
15 prepend-path INCLUDE /opt/mkl10.3.7/mkl/include
16 prepend-path CPATH /opt/mkl10.3.7/mkl/include

-----Eigen-----
1 #%Module 3.2
2 #
3 # Eigen with Intel MKL Blas and Lapack module
4 #
5 prereq intel-x86_64
6 prepend-path INCLUDE /opt/eigen3.1.0_MKL/include/eigen3
7 prepend-path CPATH /opt/eigen3.1.0_MKL/include/eigen3
8 prepend-path LD_LIBRARY_PATH /opt/eigen3.1.0_MKL/lib
9 prepend-path LIBRARY_PATH /opt/eigen3.1.0_MKL/lib
10 setenv EIGEN_ROOT /opt/eigen3.1.0_MKL/
11 setenv EIGEN_INFO eigen3.1.0_MKL

with these two modules loaded, in order 1.)intel 2.)eigen, you should be able to easily compile your Eigen code using MKL.... eg. g++ code.cpp -o outputfile

Sometimes you will need to add the flag -DEIGEN_USE_MKL_ALL in compilation to turn on the MKL features.