Skip to content

Commit c7529c6

Browse files
Added script to drive setup.py develop for use of OS DPC++ sycl bundle
Usage: ``` python scripts/build_sycl_nightly.py --c-compiler=$(which clang) --cxx-compiler=$(which clang++) --compiler-root=$(dirname $(dirname $(which clang))) ``` Option `--cmake-executable` can be used to use newer cmake
1 parent 1ccf193 commit c7529c6

File tree

2 files changed

+115
-5
lines changed

2 files changed

+115
-5
lines changed

scripts/build_sycl_nightly.py

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
import os
2+
import subprocess
3+
import sys
4+
5+
6+
def run(
7+
use_oneapi=True,
8+
c_compiler=None,
9+
cxx_compiler=None,
10+
level_zero=True,
11+
compiler_root=None,
12+
cmake_executable=None,
13+
):
14+
IS_LIN = False
15+
16+
if "linux" in sys.platform:
17+
IS_LIN = True
18+
elif sys.platform in ["win32", "cygwin"]:
19+
pass
20+
else:
21+
assert False, sys.platform + " not supported"
22+
23+
if not IS_LIN:
24+
raise RuntimeError(
25+
"This scripts only supports coverage collection on Linux"
26+
)
27+
setup_dir = os.path.dirname(os.path.dirname(__file__))
28+
cmake_args = [
29+
sys.executable,
30+
"setup.py",
31+
"develop",
32+
]
33+
if cmake_executable:
34+
cmake_args += [
35+
"--cmake-executable=" + cmake_executable,
36+
]
37+
cmake_args += [
38+
"--",
39+
"-G",
40+
"Unix Makefiles",
41+
"-DCMAKE_BUILD_TYPE=Debug",
42+
"-DCMAKE_C_COMPILER:PATH=" + c_compiler,
43+
"-DCMAKE_CXX_COMPILER:PATH=" + cxx_compiler,
44+
"-DDPCTL_ENABLE_LO_PROGRAM_CREATION=" + ("ON" if level_zero else "OFF"),
45+
"-DDPCTL_DPCPP_FROM_ONEAPI:BOOL=" + ("ON" if use_oneapi else "OFF"),
46+
]
47+
if compiler_root:
48+
cmake_args += [
49+
"-DDPCTL_DPCPP_HOME_DIR:PATH=" + compiler_root,
50+
]
51+
subprocess.check_call(
52+
cmake_args, shell=False, cwd=setup_dir, env=os.environ
53+
)
54+
55+
56+
if __name__ == "__main__":
57+
import argparse
58+
59+
parser = argparse.ArgumentParser(
60+
description="Driver to build dpctl for in-place installation"
61+
)
62+
driver = parser.add_argument_group(title="Coverage driver arguments")
63+
driver.add_argument("--c-compiler", help="Name of C compiler", default=None)
64+
driver.add_argument(
65+
"--cxx-compiler", help="Name of C++ compiler", default=None
66+
)
67+
driver.add_argument(
68+
"--oneapi",
69+
help="Is one-API installation",
70+
dest="oneapi",
71+
action="store_true",
72+
)
73+
driver.add_argument(
74+
"--compiler-root", type=str, help="Path to compiler home directory"
75+
)
76+
driver.add_argument(
77+
"--cmake-executable", type=str, help="Path to cmake executable"
78+
)
79+
driver.add_argument(
80+
"--no-level-zero",
81+
help="Enable Level Zero support",
82+
dest="level_zero",
83+
action="store_false",
84+
)
85+
args = parser.parse_args()
86+
87+
if args.oneapi:
88+
args.c_compiler = "icx"
89+
args.cxx_compiler = "icpx"
90+
args.compiler_root = None
91+
else:
92+
args_to_validate = [
93+
"c_compiler",
94+
"cxx_compiler",
95+
"compiler_root",
96+
]
97+
for p in args_to_validate:
98+
arg = getattr(args, p, None)
99+
if not isinstance(arg, str):
100+
opt_name = p.replace("_", "-")
101+
raise RuntimeError(
102+
f"Option {opt_name} must be provided is "
103+
"using non-default DPC++ layout"
104+
)
105+
if not os.path.exists(arg):
106+
raise RuntimeError(f"Path {arg} must exist")
107+
108+
run(
109+
use_oneapi=args.oneapi,
110+
c_compiler=args.c_compiler,
111+
cxx_compiler=args.cxx_compiler,
112+
level_zero=args.level_zero,
113+
compiler_root=args.compiler_root,
114+
cmake_executable=args.cmake_executable,
115+
)

scripts/environment.yml

Lines changed: 0 additions & 5 deletions
This file was deleted.

0 commit comments

Comments
 (0)