Skip to content

Commit 1ce686a

Browse files
committed
Add build option for AdaptiveCpp
Also fix some tests when building with level zero enabled by AdaptiveCpp
1 parent 33d599e commit 1ce686a

5 files changed

Lines changed: 47 additions & 19 deletions

File tree

‎.github/workflows/adaptivecpp-build.yml‎

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@ jobs:
5050
env:
5151
CACHE_NUMBER: 0 # Increase to reset cache
5252
with:
53-
path: ~/.conda/pkgs
53+
# the package directory that setup-miniconda configures
54+
path: ~/conda_pkgs_dir
5455
key:
5556
${{ runner.os }}-conda-acpp-${{ env.CACHE_NUMBER }}-python-${{ matrix.python }}-${{ hashFiles('.github/workflows/adaptivecpp-build.yml') }}
5657
restore-keys: |
@@ -65,10 +66,6 @@ jobs:
6566
channels: conda-forge
6667
conda-remove-defaults: true
6768

68-
- name: Set pkgs_dirs
69-
run: |
70-
echo "pkgs_dirs: [~/.conda/pkgs]" >> ~/.condarc
71-
7269
- name: Install AdaptiveCpp and build dependencies
7370
run: |
7471
# the Python build string selects the GIL or the free-threaded variant,
@@ -88,12 +85,7 @@ jobs:
8885
8986
- name: Build dpctl
9087
run: |
91-
# conda-forge builds AdaptiveCpp without the Level Zero backend
92-
python scripts/build_locally.py \
93-
--c-compiler="${CONDA_PREFIX}/bin/clang" \
94-
--cxx-compiler="${CONDA_PREFIX}/bin/acpp" \
95-
--no-level-zero \
96-
--cmake-opts="-DDPCTL_SYCL_PROVIDER=AdaptiveCpp"
88+
python scripts/build_locally.py --sycl-provider=AdaptiveCpp
9789
9890
- name: List platforms
9991
run: |

‎dpctl/tests/test_sycl_compiler.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,7 @@ def test_create_kernel_bundle_from_spirv_ocl():
244244
_check_multi_kernel_bundle(kb)
245245

246246

247+
@pytest.mark.unsupported_on_acpp
247248
def test_create_kernel_bundle_from_spirv_l0():
248249
q = _get_level_zero_queue_or_skip()
249250
spirv_file = get_spirv_abspath("multi_kernel.spv")

‎dpctl/tests/test_sycl_kernel_submit.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,7 @@ def get_spirv_abspath(fn):
315315
# the process for generating the .spv files in this test is documented in
316316
# libsyclinterface/tests/test_sycl_queue_submit_local_accessor_arg.cpp
317317
# in a comment starting on line 123
318+
@pytest.mark.unsupported_on_acpp
318319
def test_submit_local_accessor_arg():
319320
try:
320321
q = dpctl.SyclQueue("level_zero")

‎scripts/_build_helper.py‎

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,25 @@ def resolve_compilers(
2525
c_compiler: str,
2626
cxx_compiler: str,
2727
compiler_root: str,
28+
sycl_provider: str = "Intel",
2829
):
2930
is_linux = "linux" in sys.platform
3031

32+
if sycl_provider == "AdaptiveCpp":
33+
if oneapi:
34+
raise RuntimeError(
35+
"--oneapi is specific to DPC++ and can not be used with the "
36+
"AdaptiveCpp SYCL provider"
37+
)
38+
default_c_compiler, default_cxx_compiler = "clang", "acpp"
39+
else:
40+
default_c_compiler = "icx"
41+
default_cxx_compiler = "icpx" if is_linux else "icx"
42+
3143
if oneapi or (
3244
c_compiler is None and cxx_compiler is None and compiler_root is None
3345
):
34-
return "icx", ("icpx" if is_linux else "icx")
46+
return default_c_compiler, default_cxx_compiler
3547

3648
if (
3749
(c_compiler is None or not os.path.isabs(c_compiler))
@@ -45,19 +57,22 @@ def resolve_compilers(
4557

4658
# default values
4759
if c_compiler is None:
48-
c_compiler = "icx"
60+
c_compiler = default_c_compiler
4961
if cxx_compiler is None:
50-
cxx_compiler = "icpx" if is_linux else "icx"
62+
cxx_compiler = default_cxx_compiler
5163

5264
for name, opt_name in (
5365
(c_compiler, "--c-compiler"),
5466
(cxx_compiler, "--cxx-compiler"),
5567
):
5668
if os.path.isabs(name):
5769
path = name
58-
else:
70+
elif compiler_root:
5971
path = os.path.join(compiler_root, name)
60-
if not os.path.exists(path):
72+
else:
73+
# a default name with no compiler root is looked up in PATH
74+
path = shutil.which(name)
75+
if not path or not os.path.exists(path):
6176
raise RuntimeError(f"{opt_name} value {name} not found")
6277
return c_compiler, cxx_compiler
6378

@@ -92,6 +107,7 @@ def make_cmake_args(
92107
level_zero: bool = True,
93108
glog: bool = False,
94109
verbose: bool = False,
110+
sycl_provider: str = "Intel",
95111
other_opts: str = None,
96112
):
97113
args = [
@@ -100,6 +116,7 @@ def make_cmake_args(
100116
"-DDPCTL_ENABLE_L0_KERNEL_BUNDLE_CREATION="
101117
f"{'ON' if level_zero else 'OFF'}",
102118
f"-DDPCTL_ENABLE_GLOG:BOOL={'ON' if glog else 'OFF'}",
119+
f"-DDPCTL_SYCL_PROVIDER={sycl_provider}",
103120
]
104121

105122
if verbose:

‎scripts/build_locally.py‎

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,14 @@ def parse_args():
5151
help="Path to compiler installation root",
5252
)
5353

54+
p.add_argument(
55+
"--sycl-provider",
56+
type=str,
57+
choices=["Intel", "AdaptiveCpp"],
58+
default="Intel",
59+
help="SYCL implementation to build with (defaults to Intel).",
60+
)
61+
5462
p.add_argument(
5563
"--oneapi",
5664
dest="oneapi",
@@ -139,22 +147,31 @@ def main():
139147
setup_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
140148

141149
c_compiler, cxx_compiler = resolve_compilers(
142-
args.oneapi, args.c_compiler, args.cxx_compiler, args.compiler_root
150+
args.oneapi,
151+
args.c_compiler,
152+
args.cxx_compiler,
153+
args.compiler_root,
154+
sycl_provider=args.sycl_provider,
143155
)
144156

145157
# clean build dir if --clean set
146158
if args.clean:
147159
clean_build_dir(setup_dir)
148160

149-
# Level Zero state (on unless explicitly disabled)
150-
level_zero_enabled = False if args.no_level_zero else True
161+
# Level Zero state (on unless explicitly disabled), the backend is only
162+
# implemented for DPC++
163+
if args.sycl_provider == "AdaptiveCpp":
164+
level_zero_enabled = False
165+
else:
166+
level_zero_enabled = False if args.no_level_zero else True
151167

152168
cmake_args = make_cmake_args(
153169
c_compiler=c_compiler,
154170
cxx_compiler=cxx_compiler,
155171
level_zero=level_zero_enabled,
156172
glog=args.glog,
157173
verbose=args.verbose,
174+
sycl_provider=args.sycl_provider,
158175
other_opts=args.cmake_opts,
159176
)
160177

0 commit comments

Comments
 (0)