Skip to content

Commit 7777afd

Browse files
authored
Fix Windows pip mode by using intel-sycl-rt==2025.0.5 (#3424)
Signed-off-by: Anatoly Myachev <[email protected]>
1 parent c6a7673 commit 7777afd

File tree

4 files changed

+22
-15
lines changed

4 files changed

+22
-15
lines changed

.github/workflows/pip-test-windows.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ jobs:
8585
Invoke-BatchFile "C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvarsall.bat" x64
8686
cd ${{ env.NEW_WORKSPACE }}
8787
cd python
88-
pip install -U wheel pybind11 cython cmake 'setuptools>=65.6.1'
88+
pip install -U wheel pybind11 cython cmake 'setuptools>=65.6.1' intel-sycl-rt==2025.0.5
8989
python setup.py -v bdist_wheel
9090
pip install (Get-Item ${{ env.NEW_WORKSPACE }}\python\dist\*.whl)
9191

python/test/unit/tools/test_aot.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,15 +103,16 @@ def gen_kernel_library_xpu(dir, libname):
103103
cpp_files = glob.glob(os.path.join(dir, "*.cpp"))
104104
subprocess.run(
105105
["g++"] + cpp_files + ["-I" + include_dir for include_dir in COMPILATION_HELPER.include_dir] +
106-
["-L" + COMPILATION_HELPER.libsycl_dir, "-c", "-lsycl", "-fPIC"],
106+
["-L" + dir for dir in COMPILATION_HELPER.libsycl_dir] + ["-c", "-lsycl", "-fPIC"],
107107
check=True,
108108
cwd=dir,
109109
)
110110
o_files = glob.glob(os.path.join(dir, "*.o"))
111111

112112
subprocess.run(["g++"] + [*o_files, "-shared", "-o", libname] +
113113
["-L" + library_dir for library_dir in COMPILATION_HELPER.library_dir] +
114-
["-L" + COMPILATION_HELPER.libsycl_dir, "-lsycl", "-lze_loader"], check=True, cwd=dir)
114+
["-L" + dir
115+
for dir in COMPILATION_HELPER.libsycl_dir] + ["-lsycl", "-lze_loader"], check=True, cwd=dir)
115116

116117

117118
def gen_kernel_library(dir, libname):

python/triton/runtime/build.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ def is_xpu():
1111

1212
def _cc_cmd(cc, src, out, include_dirs, library_dirs, libraries):
1313
if "cl.EXE" in cc or "clang-cl" in cc:
14-
cc_cmd = [cc, "/Zc:__cplusplus", "/std:c++17", src, "/nologo", "/O2", "/LD", "/wd4996"]
14+
cc_cmd = [cc, "/Zc:__cplusplus", "/std:c++17", src, "/nologo", "/O2", "/LD", "/wd4996", "/MD", "/EHsc"]
1515
cc_cmd += [f"/I{dir}" for dir in include_dirs]
1616
cc_cmd += [f"/Fo{os.path.join(os.path.dirname(out), 'main.obj')}"]
1717
cc_cmd += ["/link"]

third_party/intel/backend/driver.py

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
__CACHE_VERSION = "1"
2121

2222

23-
def find_sycl(include_dir: list[str]) -> tuple[list[str], str]:
23+
def find_sycl(include_dir: list[str]) -> tuple[list[str], list[str]]:
2424
"""
2525
Looks for the sycl library in known places.
2626
@@ -34,7 +34,6 @@ def find_sycl(include_dir: list[str]) -> tuple[list[str], str]:
3434
AssertionError: if library was not found.
3535
"""
3636
include_dir = include_dir.copy()
37-
sycl_dir = None
3837
assertion_message = ("sycl headers not found, please install `icpx` compiler, "
3938
"or provide `ONEAPI_ROOT` environment "
4039
"or install `intel-sycl-rt>=2025.0.0` wheel")
@@ -44,7 +43,7 @@ def find_sycl(include_dir: list[str]) -> tuple[list[str], str]:
4443
compiler_root = os.path.abspath(f"{icpx_path}/../..")
4544
include_dir += [os.path.join(compiler_root, "include"), os.path.join(compiler_root, "include/sycl")]
4645
sycl_dir = os.path.join(compiler_root, "lib")
47-
return include_dir, sycl_dir
46+
return include_dir, [sycl_dir]
4847

4948
oneapi_root = os.getenv("ONEAPI_ROOT")
5049
if oneapi_root:
@@ -53,7 +52,7 @@ def find_sycl(include_dir: list[str]) -> tuple[list[str], str]:
5352
os.path.join(oneapi_root, "compiler/latest/include/sycl")
5453
]
5554
sycl_dir = os.path.join(oneapi_root, "compiler/latest/lib")
56-
return include_dir, sycl_dir
55+
return include_dir, [sycl_dir]
5756

5857
try:
5958
sycl_rt = importlib.metadata.metadata("intel-sycl-rt")
@@ -63,18 +62,21 @@ def find_sycl(include_dir: list[str]) -> tuple[list[str], str]:
6362
if sycl_rt.get("version", "0.0.0").startswith("2024"):
6463
raise AssertionError(assertion_message)
6564

65+
sycl_dirs = []
6666
for f in importlib.metadata.files("intel-sycl-rt"):
6767
# sycl/sycl.hpp and sycl/CL/sycl.hpp results in both folders
6868
# being add: include and include/sycl.
6969
if f.name == "sycl.hpp":
7070
include_dir += [str(f.locate().parent.parent.resolve())]
71-
if f.name in ["libsycl.so", "sycl8.dll"]:
71+
if f.name in ["libsycl.so", "sycl8.dll", "sycl8.lib"]:
7272
sycl_dir = str(f.locate().parent.resolve())
7373
# should we handle `_` somehow?
7474
if os.name == "nt":
7575
_ = os.add_dll_directory(sycl_dir)
76+
sycl_dirs.append(sycl_dir)
7677

77-
return include_dir, sycl_dir
78+
assert len(sycl_dirs) != 0
79+
return include_dir, sycl_dirs
7880

7981

8082
class CompilationHelper:
@@ -86,7 +88,11 @@ def __init__(self):
8688
self._library_dir = None
8789
self._include_dir = None
8890
self._libsycl_dir = None
89-
self.libraries = ['ze_loader', 'sycl']
91+
self.libraries = ['ze_loader']
92+
if os.name != "nt":
93+
self.libraries += ["sycl"]
94+
else:
95+
self.libraries += ['sycl8']
9096

9197
@property
9298
def inject_pytorch_dep(self):
@@ -100,7 +106,7 @@ def _compute_compilation_options_lazy(self):
100106
library_dir = []
101107
include_dir, self._libsycl_dir = find_sycl(include_dir)
102108
if self._libsycl_dir:
103-
library_dir += [self._libsycl_dir]
109+
library_dir += self._libsycl_dir
104110
if os.name == "nt":
105111
library_dir += [os.path.join(ze_root, "lib")]
106112

@@ -133,7 +139,7 @@ def include_dir(self) -> list[str]:
133139
return self._include_dir
134140

135141
@cached_property
136-
def libsycl_dir(self) -> str:
142+
def libsycl_dir(self) -> list[str]:
137143
self._compute_compilation_options_lazy
138144
return self._libsycl_dir
139145

@@ -217,9 +223,9 @@ def compile_module_from_src(src, name):
217223
extra_compiler_args = []
218224
if COMPILATION_HELPER.libsycl_dir:
219225
if os.name == "nt":
220-
extra_compiler_args += ["/LIBPATH:" + COMPILATION_HELPER.libsycl_dir]
226+
extra_compiler_args += ["/LIBPATH:" + dir for dir in COMPILATION_HELPER.libsycl_dir]
221227
else:
222-
extra_compiler_args += ["-Wl,-rpath," + COMPILATION_HELPER.libsycl_dir]
228+
extra_compiler_args += ["-Wl,-rpath," + dir for dir in COMPILATION_HELPER.libsycl_dir]
223229

224230
so = _build(name, src_path, tmpdir, COMPILATION_HELPER.library_dir, COMPILATION_HELPER.include_dir,
225231
COMPILATION_HELPER.libraries, extra_compile_args=extra_compiler_args)

0 commit comments

Comments
 (0)