|
2 | 2 |
|
3 | 3 | from __future__ import annotations |
4 | 4 |
|
5 | | -import shutil |
6 | 5 | import os |
7 | 6 | import subprocess |
8 | 7 | import sys |
9 | | -from pathlib import Path |
10 | | - |
11 | | -from common import find_file |
12 | | - |
13 | | - |
14 | | -def prepare_windows_opencl_runtime() -> None: |
15 | | - if os.environ.get("RUNNER_OS") != "Windows": |
16 | | - return |
17 | | - |
18 | | - icd_path = os.environ.get("OCL_ICD_FILENAMES") |
19 | | - if not icd_path: |
20 | | - return |
21 | | - |
22 | | - runtime_dir = Path(icd_path).resolve().parent |
23 | | - runtime_opencl = runtime_dir / "OpenCL.dll" |
24 | | - if not runtime_opencl.exists(): |
25 | | - return |
26 | | - |
27 | | - example_binary = find_file([Path("build").resolve()], "SYCL_Example.exe") |
28 | | - if example_binary is None: |
29 | | - return |
30 | | - |
31 | | - staged_opencl = example_binary.parent / runtime_opencl.name |
32 | | - shutil.copy2(runtime_opencl, staged_opencl) |
33 | | - print( |
34 | | - f"+ staged {runtime_opencl} next to {example_binary}", |
35 | | - flush=True, |
36 | | - ) |
37 | 8 |
|
38 | 9 |
|
39 | 10 | def run_command(command: list[str], env: dict[str, str]) -> int: |
40 | 11 | print("+", " ".join(command), flush=True) |
41 | 12 | return subprocess.run(command, check=False, env=env).returncode |
42 | 13 |
|
43 | 14 |
|
44 | | -def run_windows_sycl_diagnostics(env: dict[str, str]) -> None: |
45 | | - sycl_ls = find_file([Path("build").resolve(), Path(env.get("SYCL_ROOT", ""))], "sycl-ls.exe") |
46 | | - if sycl_ls is None: |
47 | | - return |
48 | | - |
49 | | - for arguments in ([str(sycl_ls)], [str(sycl_ls), "--verbose"]): |
50 | | - run_command(arguments, env) |
51 | | - |
52 | | - |
53 | 15 | def main() -> int: |
54 | | - prepare_windows_opencl_runtime() |
55 | | - |
56 | 16 | env = os.environ.copy() |
57 | 17 |
|
58 | | - device_selector = env.get("DEVICE_SELECTOR", "") |
59 | | - if device_selector: |
60 | | - env["ONEAPI_DEVICE_SELECTOR"] = device_selector |
61 | | - |
62 | | - if os.environ.get("RUNNER_OS") == "Windows": |
63 | | - run_windows_sycl_diagnostics(env) |
64 | | - |
65 | | - example_command = [ |
66 | | - "ctest", |
67 | | - "--test-dir", |
68 | | - "build", |
69 | | - "--output-on-failure", |
70 | | - "-R", |
71 | | - "^SYCL\\.Example$", |
72 | | - ] |
73 | | - example_result = run_command(example_command, env) |
74 | | - if example_result != 0: |
75 | | - return example_result |
76 | | - |
77 | | - remaining_command = [ |
78 | | - "ctest", |
79 | | - "--test-dir", |
80 | | - "build", |
81 | | - "--output-on-failure", |
82 | | - "-E", |
83 | | - "^SYCL\\.Example$", |
84 | | - "--parallel", |
85 | | - ] |
86 | | - return run_command(remaining_command, env) |
87 | | - |
88 | | - command = ["ctest", "--test-dir", "build", "--output-on-failure", "--parallel"] |
| 18 | + command = [ |
| 19 | + "ctest", |
| 20 | + "--test-dir", |
| 21 | + "build", |
| 22 | + "--output-on-failure", |
| 23 | + "-E", |
| 24 | + "^SYCL\\.Example$", |
| 25 | + "--parallel", |
| 26 | + ] |
89 | 27 | return run_command(command, env) |
90 | 28 |
|
91 | 29 |
|
|
0 commit comments