Skip to content

Commit 4892d14

Browse files
committed
Make: Add optional MKL benchmark baseline
1 parent cbc4254 commit 4892d14

File tree

1 file changed

+30
-1
lines changed

1 file changed

+30
-1
lines changed

CMakeLists.txt

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ endif ()
2626
option(SIMSIMD_BUILD_SHARED "Compile a dynamic library" ${SIMSIMD_IS_MAIN_PROJECT})
2727
option(SIMSIMD_BUILD_TESTS "Small compilation tests compile-time and run-time dispatch" OFF)
2828
option(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
3233
if (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+
144173
endif ()
145174

146175
if (SIMSIMD_BUILD_TESTS)

0 commit comments

Comments
 (0)