Intel® oneAPI Math Kernel Library
Ask questions and share information with other developers who use Intel® Math Kernel Library.
Announcements
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.

lapack.f90 how to include correctly

DmitrySkachkov
Beginner
1,138 Views

Hello,

I included into the program

INCLUDE 'lapack.f90'

  Module myMKL
   include 'mkl_lapack.fi'
  end module myMKL

and also included "use" statements

   use F95_PRECISION
   use LAPACK95
   use myMKL


   call getrf(Gk1,ipvt,info)

 in the subroutine which call getrf subroutine

However, during the compilation I got an error:

ifxKSN7m7.i90:(.text+0x5690c): undefined reference to `zgetrf_f95_'
ifxKSN7m7.i90:(.text+0x569cc): undefined reference to `zgetri_f95_'
make: *** [all] Error 1

Could you please help

 

 

0 Kudos
5 Replies
mecej4
Honored Contributor III
1,069 Views

In addition to using the Lapack95 interfaces, you also need to link the Lapack-95 (and, if needed, the Blas95) libraries.

See the MKL Link Line Advisor for how to do this.

There is an older example code for ?GetRF in this forum. I built and ran that example code using the commands

 

ifx /Qmkl xgetrf.f90 mkl_lapack95_ilp64.lib
xgetrf

 

0 Kudos
DmitrySkachkov
Beginner
1,016 Views

Thank you!

I used the suggested options for compiler

-I${MKLROOT}/include/mkl/intel64/ilp64 -i8 -qmkl-ilp64=sequential

and for linker

-qmkl-ilp64=sequential ${MKLROOT}/lib/libmkl_blas95_ilp64.a ${MKLROOT}/lib/libmkl_lapack95_ilp64.a

However I got an error in compilation:

ifx -o "./bin/"wtb.x wtb_main.o module_input.o module_hamiltonian.o module_bse.o module_pce.o module_coulomb.o module_math.o module_berry.o module_optics.o module_tools.o module_kmesh.o -qmkl-ilp64=s
equential  /opt/shared/intel-oneapi/2024.2.0.634/mkl/2024.2/lib/libmkl_blas95_ilp64.a /opt/shared/intel-oneapi/2024.2.0.634/mkl/2024.2/lib/libmkl_lapack95_ilp64.a
/opt/shared/intel-oneapi/2024.0.1.46/compiler/2024.0/lib/libifcoremt.a(for_vm.o): In function `check_KMP':
for_vm.c:(.text+0x694): undefined reference to `__kmpc_global_thread_num'
for_vm.c:(.text+0x716): undefined reference to `__kmpc_global_thread_num'
for_vm.c:(.text+0x738): undefined reference to `__kmpc_global_thread_num'
module_bse.o: In function `module_bse_mp_dielbsep_':
ifxUx8Fwo.i90:(.text+0x1043): undefined reference to `__kmpc_fork_call'
module_bse.o: In function `module_bse_mp_dielbsev_':
ifxUx8Fwo.i90:(.text+0x10b7): undefined reference to `__kmpc_fork_call'
module_bse.o: In function `module_bse_mp_dielbseptemp_':
ifxUx8Fwo.i90:(.text+0x6955): undefined reference to `__kmpc_fork_call'
module_bse.o: In function `module_bse_mp_bsedielraw_':
ifxUx8Fwo.i90:(.text+0x69a1): undefined reference to `__kmpc_global_thread_num'
ifxUx8Fwo.i90:(.text+0x8af1): undefined reference to `__kmpc_for_static_init_8'
ifxUx8Fwo.i90:(.text+0x91dd): undefined reference to `__kmpc_for_static_fini'
ifxUx8Fwo.i90:(.text+0x91ee): undefined reference to `__kmpc_barrier'

 I am using Intel-oneapi-mkl/2024

0 Kudos
mecej4
Honored Contributor III
990 Views

Please check that you are specifying the correct openMP options when using the MKL Link Line advisor.

DmitrySkachkov
Beginner
971 Views

This is exactly what I want.

I would like to compile my code with OpenMP options, but MKL library to link as sequential.

Is it possible?

0 Kudos
Ruqiu_C_Intel
Moderator
909 Views

Suppose it's the similar topic as this thread https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Using-MKL-with-MKL-NUM-THREADS-1/m-p/1652980#M36782

 

And the solution is: 

For using oneMKL + OpenMP threading, we recommend you use intel OpenMP -liomp5 link option. For example,

 ${MKLROOT}/lib/libmkl_blas95_ilp64.a ${MKLROOT}/lib/libmkl_lapack95_ilp64.a -Wl,--start-group ${MKLROOT}/lib/libmkl_intel_ilp64.a ${MKLROOT}/lib/libmkl_intel_thread.a ${MKLROOT}/lib/libmkl_core.a -Wl,--end-group -liomp5 -lpthread -lm -ldl

More advisor, please check onemkl-link-line-advisor 

0 Kudos
Reply