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

Using MKL with MKL_NUM_THREADS=1

DmitrySkachkov
Beginner
1,056 Views

Hello,

 

I am trying to use MKL to calculate on one core only, but within the cycle working in OpenMP parallel regime.

Program A


!OMP PARALLEL DO
 do k=1,N2
  ...
  call getrf(A,ipiv)         ! MKL subroutine to work on one core 
  call getrs(A,ipiv,B)       ! MKL subroutine to work on one core
  ...
 enddo
!OMP END PARALLEL DO

 In job submission script I set 

export OMP_NUM_THREADS=2

export MKL_NUM_THREADS=1

However this gives an error in MKL subroutines!

When I submit the job on one core only (OMP_NUM_THREADS=1) the MKL subroutines work correctly.

How to ask MKL library to calculate on one core correctly when the program runs in OpenMP parallel regime? 

 

0 Kudos
1 Solution
Ruqiu_C_Intel
Moderator
1,028 Views

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 

View solution in original post

0 Kudos
2 Replies
Ruqiu_C_Intel
Moderator
1,029 Views

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
DmitrySkachkov
Beginner
1,003 Views

Thank you!

With this options MKL works as necessary, in OpenMP regime MKL subroutine runs on one core without errors.

0 Kudos
Reply