@@ -26,7 +26,8 @@ endif ()
2626option (SIMSIMD_BUILD_SHARED "Compile a dynamic library" ${SIMSIMD_IS_MAIN_PROJECT} )
2727option (SIMSIMD_BUILD_TESTS "Small compilation tests compile-time and run-time dispatch" OFF )
2828option (SIMSIMD_BUILD_BENCHMARKS "Compile micro-benchmarks for current ISA" OFF )
29- option (SIMSIMD_BUILD_BENCHMARKS_WITH_CBLAS "Include BLAS in micro-kernel benchmarks" OFF )
29+ option (SIMSIMD_BUILD_BENCHMARKS_WITH_CBLAS "Include OpenBLAS in micro-kernel benchmarks" OFF )
30+ option (SIMSIMD_BUILD_BENCHMARKS_WITH_MKL "Include Intel MKL in micro-kernel benchmarks" OFF )
3031
3132# Default to Release build type if not set
3233if (NOT CMAKE_BUILD_TYPE )
@@ -141,6 +142,34 @@ if (SIMSIMD_BUILD_BENCHMARKS)
141142 endif ()
142143 endif ()
143144
145+ if (SIMSIMD_BUILD_BENCHMARKS_WITH_MKL)
146+ # Use environment variable MKLROOT or standard MKL paths
147+ if (DEFINED ENV{MKLROOT})
148+ set (MKL_ROOT $ENV{MKLROOT} )
149+ else ()
150+ # Try common installation paths
151+ if (EXISTS "/opt/intel/oneapi/mkl/latest" )
152+ set (MKL_ROOT "/opt/intel/oneapi/mkl/latest" )
153+ elseif (EXISTS "/opt/intel/mkl" )
154+ set (MKL_ROOT "/opt/intel/mkl" )
155+ endif ()
156+ endif ()
157+
158+ if (MKL_ROOT)
159+ message (STATUS "MKL found at: ${MKL_ROOT} " )
160+ target_include_directories (simsimd_bench PRIVATE ${MKL_ROOT} /include )
161+ # Link against sequential MKL (single-threaded) for fair comparison
162+ target_link_libraries (simsimd_bench
163+ ${MKL_ROOT} /lib/intel64/libmkl_intel_lp64.a
164+ ${MKL_ROOT} /lib/intel64/libmkl_sequential.a
165+ ${MKL_ROOT} /lib/intel64/libmkl_core.a
166+ pthread m dl)
167+ target_compile_definitions (simsimd_bench PRIVATE SIMSIMD_BUILD_BENCHMARKS_WITH_MKL=1)
168+ else ()
169+ message (FATAL_ERROR "MKL not found. Set MKLROOT environment variable or install Intel oneAPI." )
170+ endif ()
171+ endif ()
172+
144173endif ()
145174
146175if (SIMSIMD_BUILD_TESTS)
0 commit comments