Intel® oneAPI Math Kernel Library
Ask questions and share information with other developers who use Intel® Math Kernel Library.
7002 Discussions

Issue using mkl_service routines with mkl_rt library in Fortran

Towie__Ewan
New Contributor I
683 Views

Hi there,

I'm using MKL in a mixed-language environment (C/C++/Fortran) and to improve alignment of it's usage I'm transitioning to the MKL Single Dynamic Library (libmkl_rt).

For C/C++ codes I'm not having any issues with compiling/linking and I'm able to properly use the mkl_set_interface/threading_layer() functions.

The error I have encountered is using the mkl_set_interface/threading_layer() functions from Fortran. I've followed the MKL guide for Fortran and use the mkl_service module whilst including the pre-compiled Fortran module file during compilation. However, at the link stage where I specify '-lmkl_rt' and the library search path ('-L...'), the linker complains that:

error: undefined reference to 'mkl_set_interface_layer_'
error: undefined reference to 'mkl_set_threading_layer_'

 If I check what is available in libmkl_rt.so.2:

nm -D lib/libmkl_rt.so | grep mkl_set_
00000000002fd700 T mkl_set_dynamic
00000000002fd700 T mkl_set_dynamic_
00000000002fd7a0 T mkl_set_env_mode
00000000002fd7a0 T mkl_set_env_mode_
00000000002fd860 T mkl_set_exit_handler
00000000002fd860 T mkl_set_exit_handler_
00000000002fed60 T mkl_set_interface_layer
00000000002fd8e0 T mkl_set_memory_limit
00000000002fd8e0 T mkl_set_memory_limit_
00000000002fd9c0 T mkl_set_mpi
00000000002fd9c0 T mkl_set_mpi_
00000000002fdaa0 T mkl_set_num_stripes
00000000002fdaa0 T mkl_set_num_stripes_
00000000002fdb40 T mkl_set_num_threads
00000000002fdb40 T mkl_set_num_threads_
00000000002fdbe0 T mkl_set_num_threads_local
00000000002fdbe0 T mkl_set_num_threads_local_
00000000002fdca0 T mkl_set_pardiso_pivot
00000000002fdca0 T mkl_set_pardiso_pivot_
00000000002fdd00 T mkl_set_progress
00000000002fdd00 T mkl_set_progress_
00000000002fed10 T mkl_set_threading_layer
00000000002fdd60 T mkl_set_xerbla
00000000002fdd60 T mkl_set_xerbla_
00000000002fddc0 T mkl_set_xerbla_interface

It's clear that although many of the service functions offer an equivalent with a trailing underscore, these are not available for the interface and threading layer functions.

Is this an oversight in the libmkl_rt.so.2 library, or some mistake in the precompiled mkl_service.mod that is provided in the MKL package?

For reference, I'm using:

  • oneapi-v-2023.0.0.25339
  • Intel Fortran Compiler classic
  • GCC 9.5.0
  • Linux OS

Ewan

Labels (1)
0 Kudos
4 Replies
Towie__Ewan
New Contributor I
664 Views

I've done some more digging, and with the attached small test program I have repeated the behaviour I discuss above.

It's clear to me that the precompiled mkl_service module bundled in MKL includes a trailing underscore in the function names, and that libmkl_rt.s0.2 doesn't provide the corresponding symbol for the mkl_set_interface/threading_layer functions.

If I recompile the mkl_service.f90 module and set '-assume nounderscore' then I can get a version that works with mkl_rt.

Attached is an archive containing a sample program and the corresponding shell script to compile, link, and run the binary. The shell script will require modification to set the path to your MKL library.

 

0 Kudos
Gennady_F_Intel
Moderator
615 Views

Ewan,

it looks like the problem. May we ask you to check the latest 2024.0?

--Gennady

0 Kudos
Towie__Ewan
New Contributor I
606 Views

Hi Gennady,

I have tried both the 2023.2 release and now the 2024.0 release. Both show the same error at the link command.

Ewan

0 Kudos
Gennady_F_Intel
Moderator
573 Views

Thanks Ewan.

Yes, I confirmed the problem on oneMKL end and we will fix it into one of the next release/updates. I will keep you informed the status.

--Gennandy


Reply