Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
7 Views

link to fortran function

Hello,

I have a function implemented in e.g. myfunc.f and this implementation invokes lapack functions e.g. DGEQRF, how can I ensure that the linking is done with MKL?

My ultimate goal is to reuse some fortran functions (QR update) from C and that all the invokations they do to e.g. LAPACK end up hitting MKL.

I am using cmake and this is what I do but I am not sure it is actually linking to MKL ... can anyone please confirm this is all I need to do to ensure that these fortran utilities are linked to MKL?

# >>>>>>>>>>>>>>> begin snippet CMakeLists.txt

set(HAVE_INTEL_MKL ${MKL_FOUND})
if (MKL_FOUND)
include_directories(${MKL_INCLUDE_DIRS})
link_directories(${MKL_LIBRARY_DIRS})
endif()

add_library(qr_updates
src/addcols.f
src/addcolsq.f
src/delcols.f
src/delcolsq.f
)

if (MKL_FOUND)
target_link_libraries(qr_updates ${MKL_LIBRARIES})
endif()

# <<<<<<<<<<<<<<<< end snippet CMakeLists.txt

TIA,
Best regards,
Giovanni


0 Kudos
2 Replies
Highlighted
Employee
7 Views

Hi Giovanni,

We usually use makefile, seldom use cmake to build MKL application. But i guess the compile and link model should be same.

A simplecommand to build a mkl application is like

ifort myprog.f -L$MKLPATH -I$MKLINCLUDE -lmkl_solver_lp64_sequential.a
-Wl,--start-group -lmkl_intel_lp64.a -lmkl_sequential.a
-lmkl_core.a-l-l-l -Wl,--end-group -lpthread
static linking of user code myprog.f, sequential version of sparse solver, and
sequential Intel MKL supporting LP64 interface.

You may modify themaccording to cmake syntax.

Some doc for your reference:
1. Intel Math Kernel Library Link Line Advisor

3. Linking Applications With Intel MKL Version 10.0

And mkl lapack fortran example and build custom dll example are under MKL install directory:
for example,
C:\Program Files (x86)\Intel\Composer XE 2011 SP1\mkl\tools\builder
C:\Program Files (x86)\Intel\Composer XE 2011 SP1\mkl\examples

Hope it helps,
Ying H.
0 Kudos
Highlighted
7 Views

Hi Ying,

Thank you for your answer.

I managed to get it working using CMake can call third party fortran routines from my C and those routines end up invoking MKL no problems.

Best Regards,
Giovanni
0 Kudos