Intel® Math Kernel Library 2018 Update 1 Developer Guide
Intel MKL provides both static and dynamic libraries for coprocessors based on Intel MIC Architecture, but the Single Dynamic Library is unavailable for the coprocessors.
See Selecting Libraries to Link with for libraries to list on your link line in the simplest case.
You can link either static or dynamic host-side libraries and either static or dynamic coprocessor-side libraries independently.
To run applications linked dynamically with the host-side and coprocessor-side libraries, perform the Scripts to Set Environment Variables Setting Environment Variables step of the Getting Started process. In addition to other environment variables, it sets:
LD_LIBRARY_PATH to contain <mkl directory>/lib/intel64_lin
To make Intel MKL functions available on the coprocessor side, provide the -offload-attribute-target=mic option on your link line.
Because Intel MKL provides both LP64 and ILP64 interfaces, ensure that the host and coprocessor-side executables use the same interface or cast all 64-bit integers to 32-bit integers (or vice-versa) before calling coprocessor-side functions in your application.
The following examples illustrate linking for compiler assisted offload to Intel Xeon Phi coprocessors.
The examples use a .f (Fortran) source file and Intel® Fortran Compiler. C/C++ users should instead specify a .cpp (C++) or .c (C) file and replace ifort with icc.
If you successfully completed the Scripts to Set Environment Variables Setting Environment Variables step of the Getting Started process, you can omit the -I$MKLROOT/include parameter in these examples:
Static linking of myprog.f, host-side and coprocessor-side libraries for parallel Intel MKL using LP64 interface:
ifort myprog.f
-I$MKLROOT/include -qoffload-attribute-target=mic
-Wl,--start-group
$MKLROOT/lib/intel64_lin/libmkl_intel_lp64.a
$MKLROOT/lib/intel64_lin/libmkl_intel_thread.a
$MKLROOT/lib/intel64_lin/libmkl_core.a -Wl,--end-group
qoffload-arch=mic-avx512
-qopenmp -lpthread -lm
-offload-option,mic,compiler,"-Wl,--start-group
$MKLROOT/lib/intel64_lin_/libmkl_intel_lp64.a
$MKLROOT/lib/intel64_lin_/libmkl_intel_thread.a
$MKLROOT/lib/intel64_lin_/libmkl_core.a
-Wl,--end-group"
or
ifort myprog.f -qoffload-attribute-target=mic -static-intel -mkl
Dynamic linking of myprog.f, host-side and coprocessor-side libraries for parallel Intel MKL using LP64 interface:
ifort myprog.f
-I$MKLROOT/include -qoffload-attribute-target=mic
-L$MKLROOT/lib/intel64_lin
-lmkl_intel_lp64
-lmkl_intel_thread
-lmkl_core
qoffload-arch=mic-avx512
-qopenmp
-lpthread -lm
-offload-option,mic,compiler,"-L$MKLROOT/lib/intel64_lin_
-lmkl_intel_lp64 -lmkl_intel_thread
-lmkl_core"
or
ifort myprog.f -qoffload-attribute-target=mic -mkl
Static linking of myprog.f, host-side and coprocessor-side libraries for parallel Intel MKL using ILP64 interface:
ifort myprog.f
-I$MKLROOT/include -qoffload-attribute-target=mic
-Wl,--start-group
$MKLROOT/lib/intel64_lin/libmkl_intel_ilp64.a
$MKLROOT/lib/intel64_lin/libmkl_intel_thread.a
$MKLROOT/lib/intel64_lin/libmkl_core.a -Wl,--end-group
qoffload-arch=mic-avx512
-openmp
-lpthread -lm
-offload-option,mic,compiler,"-Wl,--start-group
$MKLROOT/lib/intel64_lin_/libmkl_intel_ilp64.a
$MKLROOT/lib/intel64_lin_/libmkl_intel_thread.a
$MKLROOT/lib/intel64_lin_/libmkl_core.a
-Wl,--end-group"
Dynamic linking of myprog.f, host-side and coprocessor-side libraries for parallel Intel MKL using ILP64 interface:
ifort myprog.f
-I$MKLROOT/include -qoffload-attribute-target=mic
-L$MKLROOT/lib/intel64_lin
-lmkl_intel_ilp64
-lmkl_intel_thread
-lmkl_core -qopenmp -lpthread -lm
qoffload-arch=mic-avx512
-qoffload-option,mic,compiler,"-L$MKLROOT/lib/intel64_lin_ -lmkl_intel_ilp64
-lmkl_intel_thread
-lmkl_core"
Static linking of myprog.f, host-side and coprocessor-side libraries for sequential version of Intel MKL using LP64 interface:
ifort myprog.f
-I$MKLROOT/include -qoffload-attribute-target=mic
-Wl,--start-group
$MKLROOT/lib/intel64_lin/libmkl_intel_lp64.a
$MKLROOT/lib/intel64_lin/libmkl_sequential.a
$MKLROOT/lib/intel64_lin/libmkl_core.a -Wl,--end-group
-lm
qoffload-arch=mic-avx512
-qoffload-option,mic,compiler,"-Wl,--start-group
$MKLROOT/lib/intel64_lin_/libmkl_intel_lp64.a
$MKLROOT/lib/intel64_lin_/libmkl_sequential.a
$MKLROOT/lib/intel64_lin_/libmkl_core.a
-Wl,--end-group"
Dynamic linking of myprog.f, host-side and coprocessor-side libraries for sequential version of Intel MKL using LP64 interface:
ifort myprog.f
-I$MKLROOT/include -offload-attribute-target=mic
-L$MKLROOT/lib/intel64_lin
-lmkl_intel_lp64
-lmkl_sequential -lmkl_core -lm
qoffload-arch=mic-avx512
-qoffload-option,mic,compiler,"-L$MKLROOT/lib/intel64_lin_
-lmkl_intel_lp64 -lmkl_sequential
-lmkl_core"