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

MKLConfig.cmake needs updating

Zohar
Novice
631 Views

There's a find_package(TBB) on line 903, which fails since it's obsolete:

- There's no TBBConfig.cmake anymore.

- Installing standalone TBB does nothing.

You may also want to get your vcpkg port in order:

https://github.com/microsoft/vcpkg/discussions/41789

0 Kudos
1 Solution
Chao_Y_Intel
Moderator
370 Views

Thank you for confirming that TBB 2022 can work in that environment.

We have also fixed the CMakefile TBB issue in the latest oneMKL 2025 release. In the updated CMakefile:

 if(NOT TBB_FOUND)
   ....
    if(MKL_SYCL_THREADING STREQUAL "tbb_thread")
      set(SYCL_COMPILER OFF)
      mkl_message(WARNING "TBB not found for the specified MKL_SYCL_THREADING: ${MKL_SYCL_THREADING}. MKL::MKL_SYCL target will not be available.")
    endif()

A warning will be issued when using the Intel Compiler to build the code if TBB is NOT present.
This warning will indicate that some MKL functionalities (such as the SYCL interface) depend on TBB and cannot be used.

CMake Warning at /opt/intel/oneapi/mkl/2025.0/lib/cmake/mkl/MKLConfig.cmake:117 (message):
  TBB not found for the specified MKL_SYCL_THREADING: tbb_thread.
  MKL::MKL_SYCL target will not be available.

However, the code can still be built without any issues if this interface is not utilized.

btw, if you also want to format code, it can choose "..."(expand toolbar) >> "</>".

 

thanks,

Chao

View solution in original post

6 Replies
Chao_Y_Intel
Moderator
519 Views

Hi,


I can find the TBB configuration file:

>ls /opt/intel/oneapi/tbb/2021.13/lib/cmake/tbb/

TBBConfig.cmake TBBConfigVersion.cmake


To use the TBB cmake, have you set the TBB environment? 


Here is test CMakeList.txt :


project(MyProject VERSION 1.0)

find_package(MKL CONFIG REQUIRED)

add_executable(my_executable main.cpp)

target_link_libraries(my_executable MKL::MKL)


Only setting oneMKL environment, an error reported on finding TBB package: 


>source /opt/intel/oneapi/mkl/latest/env/vars.sh

>cmake -DMKL_THREADING=tbb_thread ..


....

 but it set MKL_FOUND to FALSE so package "MKL" is considered to be NOT

 FOUND. Reason given by package:

 TBB not found for the specified MKL_THREADING: tbb_thread

....



Both setting oneMKL and TBB enviroment, the TBB package is found: 

>source /opt/intel/oneapi/tbb/latest/env/vars.sh

>source /opt/intel/oneapi/mkl/latest/env/vars.sh

>cmake -DMKL_THREADING=tbb_thread ..


....

-- Found /opt/intel/oneapi/mkl/2025.0/lib/libmkl_scalapack_ilp64.so

-- Found /opt/intel/oneapi/mkl/2025.0/lib/libmkl_cdft_core.so

-- Found /opt/intel/oneapi/mkl/2025.0/lib/libmkl_intel_ilp64.so

-- Found /opt/intel/oneapi/mkl/2025.0/lib/libmkl_tbb_thread.so


thanks,

Chao


0 Kudos
Zohar
Novice
501 Views

As I said, the standalone tbb installation, weirdly, didn't install anything: there was no oneapi/tbb dir.

 

But let's say it did. If it's a dependency of MKL, then MKL should install it. But it's not. MKL already contains the tbb files, and if you comment out the find_package(TBB)  code from the MKL cmakefile, then it works fine.

0 Kudos
Chao_Y_Intel
Moderator
472 Views

Hi,


What is the version of the standalone oneTBB there? 


I checked the latest 2022 TBB standalone package, downloaded from here 

https://www.intel.com/content/www/us/en/developer/tools/oneapi/onetbb-download.html?operatingsystem=windows&distribution-windows=offline

The CMake files at Windows are available after installation: at C:\Program Files (x86)\Intel\oneAPI\tbb\2022.0\lib\cmake\tbb 

TBBConfig.cmake TBBConfigVersion.cmake


Similarly for Linux system as well. 


Regarding oneMKL in the oneMKL MKLConfig.cmake file:

....

if(MKL_THREADING STREQUAL "tbb_thread" OR MKL_SYCL_THREADING STREQUAL "tbb_thread")

 find_package(TBB CONFIG COMPONENTS tbb)

...


By default, MKL_THREADING is set to "intel_thread" in Cmake files. It is not expected to report any error, even without TBB installed.

 

Users need manually set MKL_THREADING to "tbb_thread" in their CMake files or linkage lines for MKLConfig.cmake to use TBB threading. 

If MKL_THREADING is set to "tbb_thread", TBB need to be installed first.



0 Kudos
Zohar
Novice
432 Views

I tried everything again.

I'm adding to MKLConfig.cmake before line 903:

message( "MKL_THREADING=${MKL_THREADING}" )
message( "MKL_SYCL_THREADING=${MKL_SYCL_THREADING}" )

My CMakeLists.txt is:

CMAKE_MINIMUM_REQUIRED( VERSION 3.30 )

project( prj )

find_package( MKL CONFIG REQUIRED )
link_libraries( MKL::MKL )

I'm running it like this:

mkdir build3
cd build3

call "C:/Program Files (x86)/Intel/oneAPI/compiler/2024.2/env/vars.bat"

cmake ^
-DCMAKE_BUILD_TYPE=Release ^
-DCMAKE_C_COMPILER=icx ^
-DCMAKE_CXX_COMPILER=icx ^
-DCMAKE_TOOLCHAIN_FILE=d:/vcpkg/scripts/buildsystems/vcpkg.cmake ^ -DVCPKG_TARGET_TRIPLET=x64-windows ^
-G Ninja ^
-Wno-dev ^
..

cd ..

The output is:

MKL_THREADING=intel_thread

MKL_SYCL_THREADING=tbb_thread
CMake Error at D:/vcpkg/scripts/buildsystems/vcpkg.cmake:859 (_find_package):
Could not find a package configuration file provided by "TBB" with any of
the following names:

TBBConfig.cmake
tbb-config.cmake

If I install tbb 2022 (worked this time) from here

https://www.intel.com/content/www/us/en/developer/tools/oneapi/onetbb-download.html

then it works fine since it finds tbb.

---

How to I format code when posting on the forum? Usually, it's done using backticks.

0 Kudos
Chao_Y_Intel
Moderator
371 Views

Thank you for confirming that TBB 2022 can work in that environment.

We have also fixed the CMakefile TBB issue in the latest oneMKL 2025 release. In the updated CMakefile:

 if(NOT TBB_FOUND)
   ....
    if(MKL_SYCL_THREADING STREQUAL "tbb_thread")
      set(SYCL_COMPILER OFF)
      mkl_message(WARNING "TBB not found for the specified MKL_SYCL_THREADING: ${MKL_SYCL_THREADING}. MKL::MKL_SYCL target will not be available.")
    endif()

A warning will be issued when using the Intel Compiler to build the code if TBB is NOT present.
This warning will indicate that some MKL functionalities (such as the SYCL interface) depend on TBB and cannot be used.

CMake Warning at /opt/intel/oneapi/mkl/2025.0/lib/cmake/mkl/MKLConfig.cmake:117 (message):
  TBB not found for the specified MKL_SYCL_THREADING: tbb_thread.
  MKL::MKL_SYCL target will not be available.

However, the code can still be built without any issues if this interface is not utilized.

btw, if you also want to format code, it can choose "..."(expand toolbar) >> "</>".

 

thanks,

Chao

Zohar
Novice
344 Views
0 Kudos
Reply