Skip to content

Commit 6c72039

Browse files
Correct DPCPP detection in setup (#1699) (#1703)
* disable IPO for onedal_py_dpc on Windows * Completely replace DPCPPROOT in setup scripts (cherry picked from commit 805b7b8) Co-authored-by: Alexander Andreev <[email protected]>
1 parent 8496857 commit 6c72039

File tree

4 files changed

+18
-13
lines changed

4 files changed

+18
-13
lines changed

daal4py/oneapi/__init__.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
if "Windows" in platform.system():
2020
import os
21+
import shutil
2122
import sys
2223
import sysconfig
2324

@@ -26,15 +27,14 @@
2627
sitepackages_path = sysconfig.get_paths()["purelib"]
2728
installed_package_path = os.path.join(sitepackages_path, "daal4py", "oneapi")
2829
if sys.version_info.minor >= 8:
29-
if "DPCPPROOT" in os.environ:
30-
dpcpp_rt_root_bin = os.path.join(os.environ["DPCPPROOT"], "windows", "bin")
31-
dpcpp_rt_root_redist = os.path.join(
32-
os.environ["DPCPPROOT"], "windows", "redist", "intel64_win", "compiler"
33-
)
34-
if os.path.exists(dpcpp_rt_root_bin):
35-
os.add_dll_directory(dpcpp_rt_root_bin)
36-
if os.path.exists(dpcpp_rt_root_redist):
37-
os.add_dll_directory(dpcpp_rt_root_redist)
30+
dpc_path = shutil.which("icpx")
31+
if dpc_path is not None:
32+
dpc_bin_dir = os.path.dirname(dpc_path)
33+
dpc_compiler_dir = os.path.join(dpc_bin_dir, "compiler")
34+
if os.path.exists(dpc_bin_dir):
35+
os.add_dll_directory(dpc_bin_dir)
36+
if os.path.exists(dpc_compiler_dir):
37+
os.add_dll_directory(dpc_compiler_dir)
3838
os.add_dll_directory(current_path)
3939
if os.path.exists(installed_package_path):
4040
os.add_dll_directory(installed_package_path)

scripts/CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,11 @@ if(IFACE STREQUAL "host")
108108
elseif(IFACE STREQUAL "dpc")
109109
set(TARGET "_onedal_py_dpc")
110110

111+
# FIXME: icx>=2024.1 and pybind11 don't work correctly with IPO
112+
if(WIN32)
113+
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION OFF)
114+
endif()
115+
111116
if(CMAKE_CXX_COMPILER MATCHES ".*icpx" OR CMAKE_CXX_COMPILER MATCHES ".*icx")
112117
set(CMAKE_CXX_FLAGS "-fsycl ${CMAKE_CXX_FLAGS}")
113118
endif()

setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
# System imports
2222
import os
2323
import pathlib
24+
import shutil
2425
import sys
2526
import time
2627
from concurrent.futures import Future, ThreadPoolExecutor
@@ -84,8 +85,7 @@
8485
no_dist = True if "NO_DIST" in os.environ and os.environ["NO_DIST"] in trues else False
8586
no_stream = "NO_STREAM" in os.environ and os.environ["NO_STREAM"] in trues
8687
mpi_root = None if no_dist else os.environ["MPIROOT"]
87-
dpcpp = True if "DPCPPROOT" in os.environ else False
88-
dpcpp_root = None if not dpcpp else os.environ["DPCPPROOT"]
88+
dpcpp = shutil.which("icpx") is not None
8989

9090
use_parameters_lib = (not IS_WIN) and (ONEDAL_VERSION >= 20240000)
9191

setup_sklearnex.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
# System imports
1919
import os
20+
import shutil
2021
import sys
2122
import time
2223

@@ -51,8 +52,7 @@
5152

5253
trues = ["true", "True", "TRUE", "1", "t", "T", "y", "Y", "Yes", "yes", "YES"]
5354
no_dist = True if "NO_DIST" in os.environ and os.environ["NO_DIST"] in trues else False
54-
dpcpp = True if "DPCPPROOT" in os.environ else False
55-
dpcpp_root = None if not dpcpp else os.environ["DPCPPROOT"]
55+
dpcpp = shutil.which("icpx") is not None
5656

5757
try:
5858
import dpctl

0 commit comments

Comments
 (0)