Skip to content

Commit 8974e9e

Browse files
scripts/build_locally.py defaults to using oneAPI installation
1. Uses oneAPI python scripts/build_locally.py python scripts/build_locally.py --oneapi # this still worsk 2. Use non-standard oneAPI installation # compiler_root/bin/ and compiler_root/bin-llvm should exist python scripts/build_locally --compiler-root=/path/to/compiler_root 3. Use open-source bundle python scripts/build_locally --c-compiler=clang --cxx-compiler=clang++ --compiler_root=/path/to/dpcpp_compiler
1 parent 5b29265 commit 8974e9e

File tree

1 file changed

+39
-12
lines changed

1 file changed

+39
-12
lines changed

scripts/build_locally.py

Lines changed: 39 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -93,10 +93,16 @@ def run(
9393
help="Set the compilation mode to debugging",
9494
)
9595
driver.add_argument(
96-
"--compiler-root", type=str, help="Path to compiler home directory"
96+
"--compiler-root",
97+
type=str,
98+
help="Path to compiler home directory",
99+
default=None,
97100
)
98101
driver.add_argument(
99-
"--cmake-executable", type=str, help="Path to cmake executable"
102+
"--cmake-executable",
103+
type=str,
104+
help="Path to cmake executable",
105+
default=None,
100106
)
101107
driver.add_argument(
102108
"--no-level-zero",
@@ -112,26 +118,47 @@ def run(
112118
)
113119
args = parser.parse_args()
114120

115-
if args.oneapi:
121+
args_to_validate = [
122+
"c_compiler",
123+
"cxx_compiler",
124+
"compiler_root",
125+
]
126+
127+
if args.oneapi or (
128+
args.c_compiler is None
129+
and args.cxx_compiler is None
130+
and args.compiler_root is None
131+
):
116132
args.c_compiler = "icx"
117133
args.cxx_compiler = "icpx" if "linux" in sys.platform else "icx"
118134
args.compiler_root = None
119135
else:
136+
cr = args.compiler_root
137+
if isinstance(cr, str) and os.path.exists(cr):
138+
if args.c_compiler is None:
139+
args.c_compiler = "icx"
140+
if args.cxx_compiler is None:
141+
args.cxx_compiler = "icpx" if "linux" in sys.platform else "icx"
142+
else:
143+
raise RuntimeError(
144+
"Option 'compiler-root' must be provided when "
145+
"using non-default DPC++ layout."
146+
)
120147
args_to_validate = [
121148
"c_compiler",
122149
"cxx_compiler",
123-
"compiler_root",
124150
]
125151
for p in args_to_validate:
126-
arg = getattr(args, p, None)
127-
if not isinstance(arg, str):
128-
opt_name = p.replace("_", "-")
129-
raise RuntimeError(
130-
f"Option {opt_name} must be provided is "
131-
"using non-default DPC++ layout"
132-
)
152+
arg = getattr(args, p)
153+
assert isinstance(arg, str)
133154
if not os.path.exists(arg):
134-
raise RuntimeError(f"Path {arg} must exist")
155+
arg2 = os.path.join(cr, arg)
156+
if os.path.exists(arg2):
157+
arg = arg2
158+
setattr(args, p, arg)
159+
if not os.path.exists(arg):
160+
opt_name = p.replace("_", "-")
161+
raise RuntimeError(f"Option {opt_name} value {arg} must exist.")
135162

136163
run(
137164
use_oneapi=args.oneapi,

0 commit comments

Comments
 (0)