From 3ecb8655a292b6da4f17719756eac7cf1634fa8b Mon Sep 17 00:00:00 2001 From: "KOKO\\Mimi" Date: Tue, 20 Oct 2026 22:30:47 +0900 Subject: [PATCH] build: switch oneMKL threading layer to TBB --- CMakeLists.txt | 2 +- cmake/FesaDependencies.cmake | 9 +++++++++ msvc/Fesa.Common.props | 6 ++++-- msvc/Fesa.Runtime.targets | 9 +++++---- src/fesa/CMakeLists.txt | 12 ++++-------- tests/CMakeLists.txt | 12 ++++-------- 6 files changed, 27 insertions(+), 23 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1dbc94b..05d9010 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,7 +8,7 @@ set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>DLL") # Pin the original backend ABI/link/thread choices rather than package defaults. set(MKL_INTERFACE ilp64) set(MKL_LINK dynamic) -set(MKL_THREADING intel_thread) +set(MKL_THREADING tbb_thread) include(cmake/FesaDependencies.cmake) find_package(Doxygen QUIET) if(Doxygen_FOUND) diff --git a/cmake/FesaDependencies.cmake b/cmake/FesaDependencies.cmake index 0e025e3..474a23a 100644 --- a/cmake/FesaDependencies.cmake +++ b/cmake/FesaDependencies.cmake @@ -44,6 +44,15 @@ if(NOT TARGET TBB::tbb) message(FATAL_ERROR "The oneTBB CONFIG package did not define TBB::tbb") endif() +if(WIN32) + set(FESA_MKL_THREAD_TARGET MKL::mkl_tbb_thread) + if(CMAKE_BUILD_TYPE STREQUAL "Debug") + set(FESA_MKL_THREAD_TARGET MKL::mkl_tbb_threadd) + endif() + # HDF5 requires the Intel math runtime independently of MKL threading. + set(FESA_INTEL_MATH_RUNTIME "$ENV{FESA_OMP_ROOT}/bin/libmmd.dll") +endif() + # Prefer the packaged shared C runtime when both variants exist. The Windows # static archive may carry compiler-runtime requirements that are not part of # the HDF5 imported target's transitive link interface. diff --git a/msvc/Fesa.Common.props b/msvc/Fesa.Common.props index f8a2f99..e397a49 100644 --- a/msvc/Fesa.Common.props +++ b/msvc/Fesa.Common.props @@ -14,6 +14,8 @@ $(FesaBuildRoot)obj\$(MSBuildProjectName)\ fesa _debug + mkl_tbb_thread + mkl_tbb_threadd /external:I"$(FESA_MKL_ROOT)\include" /external:I"$(FESA_TBB_ROOT)\include" /external:I"$(FESA_HDF5_ROOT)\include" /external:W0 @@ -56,8 +58,8 @@ true true true - $(FESA_MKL_ROOT)\lib;$(FESA_OMP_ROOT)\lib;$(FESA_TBB_ROOT)\lib;$(FESA_HDF5_ROOT)\lib;%(AdditionalLibraryDirectories) - mkl_intel_ilp64_dll.lib;mkl_intel_thread_dll.lib;mkl_core_dll.lib;libiomp5md.lib;tbb12$(TbbSuffix).lib;hdf5.lib;shlwapi.lib;%(AdditionalDependencies) + $(FESA_MKL_ROOT)\lib;$(FESA_TBB_ROOT)\lib;$(FESA_HDF5_ROOT)\lib;%(AdditionalLibraryDirectories) + mkl_intel_ilp64_dll.lib;$(FesaMklThreadName)_dll.lib;mkl_core_dll.lib;tbb12$(TbbSuffix).lib;hdf5.lib;shlwapi.lib;%(AdditionalDependencies) diff --git a/msvc/Fesa.Runtime.targets b/msvc/Fesa.Runtime.targets index f4b18f1..14d9ba7 100644 --- a/msvc/Fesa.Runtime.targets +++ b/msvc/Fesa.Runtime.targets @@ -4,18 +4,19 @@ + - + - + - + - + diff --git a/src/fesa/CMakeLists.txt b/src/fesa/CMakeLists.txt index 7f70e0b..123a10c 100644 --- a/src/fesa/CMakeLists.txt +++ b/src/fesa/CMakeLists.txt @@ -159,11 +159,10 @@ target_link_options(fesa_cli PRIVATE unset(_fesa_target) if(WIN32) - if(NOT TARGET MKL::mkl_intel_thread OR NOT TARGET MKL::mkl_core OR - NOT OMP_DLL_DIR OR NOT OMP_DLLNAME) + if(NOT TARGET ${FESA_MKL_THREAD_TARGET} OR NOT TARGET MKL::mkl_core) message(FATAL_ERROR "The oneMKL runtime files required by fesa.exe were not resolved") endif() - if(NOT EXISTS "${OMP_DLL_DIR}/libmmd.dll") + if(NOT EXISTS "${FESA_INTEL_MATH_RUNTIME}") message(FATAL_ERROR "The Intel runtime required by the selected HDF5 DLL was not resolved") endif() @@ -182,16 +181,13 @@ if(WIN32) "$" "$" COMMAND "${CMAKE_COMMAND}" -E copy_if_different - "$" + "$" "$" COMMAND "${CMAKE_COMMAND}" -E copy_if_different "$" "$" COMMAND "${CMAKE_COMMAND}" -E copy_if_different - "${OMP_DLL_DIR}/${OMP_DLLNAME}" - "$" - COMMAND "${CMAKE_COMMAND}" -E copy_if_different - "${OMP_DLL_DIR}/libmmd.dll" + "${FESA_INTEL_MATH_RUNTIME}" "$" COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${_fesa_cli_mkl_dispatch_dll}" diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 1c81290..af52699 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -180,11 +180,10 @@ target_compile_definitions( ) if(WIN32) - if(NOT TARGET MKL::mkl_intel_thread OR NOT TARGET MKL::mkl_core OR - NOT OMP_DLL_DIR OR NOT OMP_DLLNAME) + if(NOT TARGET ${FESA_MKL_THREAD_TARGET} OR NOT TARGET MKL::mkl_core) message(FATAL_ERROR "The oneMKL runtime files required by tests were not resolved") endif() - if(NOT EXISTS "${OMP_DLL_DIR}/libmmd.dll") + if(NOT EXISTS "${FESA_INTEL_MATH_RUNTIME}") message(FATAL_ERROR "The Intel runtime required by the selected HDF5 DLL was not resolved") endif() @@ -205,16 +204,13 @@ if(WIN32) "$" "$" COMMAND "${CMAKE_COMMAND}" -E copy_if_different - "$" + "$" "$" COMMAND "${CMAKE_COMMAND}" -E copy_if_different "$" "$" COMMAND "${CMAKE_COMMAND}" -E copy_if_different - "${OMP_DLL_DIR}/${OMP_DLLNAME}" - "$" - COMMAND "${CMAKE_COMMAND}" -E copy_if_different - "${OMP_DLL_DIR}/libmmd.dll" + "${FESA_INTEL_MATH_RUNTIME}" "$" COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${_fesa_mkl_dispatch_dll}"