From 7c903b6a939fc2b5c01df87bdb3a4cab05c7b2aa Mon Sep 17 00:00:00 2001 From: Oleksandr Pavlyk Date: Sat, 14 Dec 2024 09:23:23 -0800 Subject: [PATCH] Simplified building of pybind11 example with MKL --- .github/workflows/conda-package.yml | 8 +---- examples/pybind11/onemkl_gemv/CMakeLists.txt | 35 +++++++------------- 2 files changed, 13 insertions(+), 30 deletions(-) diff --git a/.github/workflows/conda-package.yml b/.github/workflows/conda-package.yml index c00b156d47..55e90d8062 100644 --- a/.github/workflows/conda-package.yml +++ b/.github/workflows/conda-package.yml @@ -587,14 +587,8 @@ jobs: for d in $(find . -maxdepth 1 -type d -not -path ".") do pushd $d - export MKLROOT=${CONDA_PREFIX} - export TBBROOT=${CONDA_PREFIX} conda activate --stack build_env - CC=icx CXX=icpx python setup.py build_ext --inplace -G Ninja -- \ - -DTBB_LIBRARY_DIR=${TBBROOT}/lib \ - -DMKL_LIBRARY_DIR=${MKLROOT}/lib \ - -DMKL_INCLUDE_DIR=${MKLROOT}/include \ - -DTBB_INCLUDE_DIR=${TBBROOT}/include || exit 1 + CC=icx CXX=icpx python setup.py build_ext --inplace -G Ninja || exit 1 conda deactivate if [ -e tests ] then diff --git a/examples/pybind11/onemkl_gemv/CMakeLists.txt b/examples/pybind11/onemkl_gemv/CMakeLists.txt index 46709840fb..08dda0b288 100644 --- a/examples/pybind11/onemkl_gemv/CMakeLists.txt +++ b/examples/pybind11/onemkl_gemv/CMakeLists.txt @@ -27,28 +27,21 @@ FetchContent_MakeAvailable(pybind11) find_package(Python REQUIRED COMPONENTS Development.Module NumPy) find_package(Dpctl REQUIRED) -find_library(mkl_core NAMES mkl_core PATHS ${MKL_LIBRARY_DIR} REQUIRED) -find_library(mkl_sycl NAMES mkl_sycl PATHS ${MKL_LIBRARY_DIR} REQUIRED) -find_library(mkl_intel_ilp64 NAMES mkl_intel_ilp64 PATHS ${MKL_LIBRARY_DIR} REQUIRED) -find_library(mkl_tbb_thread NAMES mkl_tbb_thread PATHS ${MKL_LIBRARY_DIR} REQUIRED) -find_library(tbb NAMES tbb PATHS ${TBB_LIBRARY_DIR} REQUIRED) -find_library(OpenCL NAMES OpenCL REQUIRED) +find_package(TBB REQUIRED) + +set(MKL_ARCH "intel64") +set(MKL_LINK "dynamic") +set(MKL_THREADING "tbb_thread") +set(MKL_INTERFACE "ilp64") +find_package(MKL REQUIRED) set(py_module_name _onemkl) set(_sources sycl_gemm/_onemkl.cpp) -pybind11_add_module(${py_module_name} - MODULE - ${_sources} -) +pybind11_add_module(${py_module_name} MODULE ${_sources}) add_sycl_to_target(TARGET ${py_module_name} SOURCES ${_sources}) -target_compile_definitions(${py_module_name} PRIVATE -DMKL_ILP64) -target_include_directories(${py_module_name} - PUBLIC ${MKL_INCLUDE_DIR} sycl_gemm -) -target_link_libraries(${py_module_name} - PRIVATE ${mkl_sycl} ${mkl_intel_ilp64} ${mkl_tbb_thread} ${mkl_core} ${tbb} -) +target_include_directories(${py_module_name} PUBLIC sycl_gemm) +target_link_libraries(${py_module_name} PRIVATE MKL::MKL_SYCL) install(TARGETS ${py_module_name} DESTINATION sycl_gemm) target_include_directories(${py_module_name} PUBLIC ${Dpctl_INCLUDE_DIRS}) @@ -70,11 +63,7 @@ add_executable(standalone_cpp target_compile_options(standalone_cpp PRIVATE -O3 -Wno-deprecated-declarations ) -target_include_directories(standalone_cpp - PUBLIC ${MKL_INCLUDE_DIR} ${TBB_INCLUDE_DIR} sycl_gemm - ) -target_link_libraries(standalone_cpp - PRIVATE ${mkl_sycl} ${mkl_intel_ilp64} ${mkl_tbb_thread} ${mkl_core} ${tbb} ${OpenCL} -) +target_include_directories(standalone_cpp PUBLIC sycl_gemm) +target_link_libraries(standalone_cpp PRIVATE MKL::MKL_SYCL) set(ignoreMe "${SKBUILD}")