Skip to content

Commit 42a6f0b

Browse files
Simplified building of pybind11 example with MKL
1 parent bbba4b7 commit 42a6f0b

File tree

2 files changed

+13
-30
lines changed

2 files changed

+13
-30
lines changed

.github/workflows/conda-package.yml

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -587,14 +587,8 @@ jobs:
587587
for d in $(find . -maxdepth 1 -type d -not -path ".")
588588
do
589589
pushd $d
590-
export MKLROOT=${CONDA_PREFIX}
591-
export TBBROOT=${CONDA_PREFIX}
592590
conda activate --stack build_env
593-
CC=icx CXX=icpx python setup.py build_ext --inplace -G Ninja -- \
594-
-DTBB_LIBRARY_DIR=${TBBROOT}/lib \
595-
-DMKL_LIBRARY_DIR=${MKLROOT}/lib \
596-
-DMKL_INCLUDE_DIR=${MKLROOT}/include \
597-
-DTBB_INCLUDE_DIR=${TBBROOT}/include || exit 1
591+
CC=icx CXX=icpx python setup.py build_ext --inplace -G Ninja || exit 1
598592
conda deactivate
599593
if [ -e tests ]
600594
then

examples/pybind11/onemkl_gemv/CMakeLists.txt

Lines changed: 12 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -27,28 +27,21 @@ FetchContent_MakeAvailable(pybind11)
2727
find_package(Python REQUIRED COMPONENTS Development.Module NumPy)
2828
find_package(Dpctl REQUIRED)
2929

30-
find_library(mkl_core NAMES mkl_core PATHS ${MKL_LIBRARY_DIR} REQUIRED)
31-
find_library(mkl_sycl NAMES mkl_sycl PATHS ${MKL_LIBRARY_DIR} REQUIRED)
32-
find_library(mkl_intel_ilp64 NAMES mkl_intel_ilp64 PATHS ${MKL_LIBRARY_DIR} REQUIRED)
33-
find_library(mkl_tbb_thread NAMES mkl_tbb_thread PATHS ${MKL_LIBRARY_DIR} REQUIRED)
34-
find_library(tbb NAMES tbb PATHS ${TBB_LIBRARY_DIR} REQUIRED)
35-
find_library(OpenCL NAMES OpenCL REQUIRED)
30+
find_package(TBB REQUIRED)
31+
32+
set(MKL_ARCH "intel64")
33+
set(MKL_LINK "dynamic")
34+
set(MKL_THREADING "tbb_thread")
35+
set(MKL_INTERFACE "ilp64")
36+
find_package(MKL REQUIRED)
3637

3738
set(py_module_name _onemkl)
3839

3940
set(_sources sycl_gemm/_onemkl.cpp)
40-
pybind11_add_module(${py_module_name}
41-
MODULE
42-
${_sources}
43-
)
41+
pybind11_add_module(${py_module_name} MODULE ${_sources})
4442
add_sycl_to_target(TARGET ${py_module_name} SOURCES ${_sources})
45-
target_compile_definitions(${py_module_name} PRIVATE -DMKL_ILP64)
46-
target_include_directories(${py_module_name}
47-
PUBLIC ${MKL_INCLUDE_DIR} sycl_gemm
48-
)
49-
target_link_libraries(${py_module_name}
50-
PRIVATE ${mkl_sycl} ${mkl_intel_ilp64} ${mkl_tbb_thread} ${mkl_core} ${tbb}
51-
)
43+
target_include_directories(${py_module_name} PUBLIC sycl_gemm)
44+
target_link_libraries(${py_module_name} PRIVATE MKL::MKL_SYCL)
5245

5346
install(TARGETS ${py_module_name} DESTINATION sycl_gemm)
5447
target_include_directories(${py_module_name} PUBLIC ${Dpctl_INCLUDE_DIRS})
@@ -70,11 +63,7 @@ add_executable(standalone_cpp
7063
target_compile_options(standalone_cpp
7164
PRIVATE -O3 -Wno-deprecated-declarations
7265
)
73-
target_include_directories(standalone_cpp
74-
PUBLIC ${MKL_INCLUDE_DIR} ${TBB_INCLUDE_DIR} sycl_gemm
75-
)
76-
target_link_libraries(standalone_cpp
77-
PRIVATE ${mkl_sycl} ${mkl_intel_ilp64} ${mkl_tbb_thread} ${mkl_core} ${tbb} ${OpenCL}
78-
)
66+
target_include_directories(standalone_cpp PUBLIC sycl_gemm)
67+
target_link_libraries(standalone_cpp PRIVATE MKL::MKL_SYCL)
7968

8069
set(ignoreMe "${SKBUILD}")

0 commit comments

Comments
 (0)