Skip to content

Commit e7741bc

Browse files
committed
Use Intel native CPU container for Linux SYCL
1 parent 55a85b0 commit e7741bc

2 files changed

Lines changed: 81 additions & 81 deletions

File tree

.github/workflows/sycl-ci.yml

Lines changed: 48 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,16 @@ env:
1414
ADAPTIVECPP_TAG: v25.10.0
1515

1616
jobs:
17-
build-sycl-x86:
18-
name: ${{ matrix.platform }} / ${{ matrix.build_type }}
19-
runs-on: ${{ matrix.platform == 'linux-x86_64' && 'ubuntu-latest' || 'windows-2025' }}
17+
build-sycl-linux-x86:
18+
name: linux-x86_64 / ${{ matrix.build_type }}
19+
runs-on: ubuntu-latest
20+
container:
21+
image: ghcr.io/intel/llvm/sycl_ubuntu2404_nightly:latest
22+
options: -u 0:0
2023
timeout-minutes: 360
2124
strategy:
2225
fail-fast: true
2326
matrix:
24-
platform:
25-
- linux-x86_64
26-
- windows-x86_64
2727
build_type:
2828
- Debug
2929
- Release
@@ -41,24 +41,61 @@ jobs:
4141
uses: seanmiddleditch/gha-setup-ninja@v6
4242

4343
- name: Setup ccache
44-
if: runner.os != 'Windows'
4544
uses: hendrikmuhs/ccache-action@v1.2
4645
with:
47-
key: ccache-${{ github.job }}-${{ matrix.platform }}-${{ matrix.build_type }}
46+
key: ccache-${{ github.job }}-${{ matrix.build_type }}
4847
max-size: 2G
4948

49+
- name: Prepare platform settings
50+
run: python3 ./scripts/ci/sycl_x86_setup.py linux-x86_64
51+
52+
- name: Configure
53+
run: python3 ./scripts/ci/sycl_configure.py "${{ matrix.build_type }}" "${ITLABAI_ENABLE_OPENCV_APPS}"
54+
55+
- name: Build
56+
run: cmake --build build --parallel
57+
58+
- name: Test
59+
run: |
60+
if [ -n "${DEVICE_SELECTOR}" ]; then
61+
ONEAPI_DEVICE_SELECTOR="${DEVICE_SELECTOR}" ctest --test-dir build --output-on-failure --parallel
62+
else
63+
ctest --test-dir build --output-on-failure --parallel
64+
fi
65+
66+
build-sycl-windows-x86:
67+
name: windows-x86_64 / ${{ matrix.build_type }}
68+
runs-on: windows-2025
69+
timeout-minutes: 360
70+
strategy:
71+
fail-fast: true
72+
matrix:
73+
build_type:
74+
- Debug
75+
- Release
76+
77+
defaults:
78+
run:
79+
shell: bash
80+
81+
steps:
82+
- uses: actions/checkout@v4
83+
with:
84+
submodules: true
85+
86+
- name: Setup Ninja
87+
uses: seanmiddleditch/gha-setup-ninja@v6
88+
5089
- name: Setup ccache
51-
if: runner.os == 'Windows'
5290
uses: Chocobo1/setup-ccache-action@v1
5391
with:
5492
windows_compile_environment: msvc
5593

5694
- name: Setup MSVC environment
57-
if: runner.os == 'Windows'
5895
uses: ilammy/msvc-dev-cmd@v1
5996

6097
- name: Prepare platform settings
61-
run: python3 ./scripts/ci/sycl_x86_setup.py "${{ matrix.platform }}"
98+
run: python3 ./scripts/ci/sycl_x86_setup.py windows-x86_64
6299

63100
- name: Configure
64101
run: python3 ./scripts/ci/sycl_configure.py "${{ matrix.build_type }}" "${ITLABAI_ENABLE_OPENCV_APPS}"

scripts/ci/sycl_x86_setup.py

Lines changed: 33 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@
2424
def configure_platform(platform: str) -> None:
2525
settings = {
2626
"linux-x86_64": {
27-
"toolchain_asset": "sycl_linux.tar.gz",
28-
"device_selector": "opencl:cpu",
27+
"toolchain_asset": "",
28+
"device_selector": "native_cpu:cpu",
2929
"opencv_apps": "ON",
30-
"sycl_targets": "spir64",
30+
"sycl_targets": "native_cpu",
3131
},
3232
"windows-x86_64": {
3333
"toolchain_asset": "sycl_windows.tar.gz",
@@ -48,87 +48,46 @@ def configure_platform(platform: str) -> None:
4848

4949

5050
def setup_linux_runtime() -> None:
51-
run(["sudo", "apt-get", "update"])
51+
command_prefix = [] if os.geteuid() == 0 else ["sudo"]
52+
run([*command_prefix, "apt-get", "update"])
5253
run(
5354
[
54-
"sudo",
55+
*command_prefix,
5556
"apt-get",
5657
"install",
5758
"-y",
5859
"build-essential",
60+
"ccache",
5961
"cmake",
6062
"g++-13",
6163
"gcc-13",
6264
"git",
63-
"ocl-icd-opencl-dev",
64-
"opencl-headers",
6565
"python3",
6666
"zstd",
6767
]
6868
)
69-
70-
key_url = "https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB"
71-
key_path = Path(require_env("RUNNER_TEMP")) / "oneapi-intel-key.pub"
72-
armored_key_path = Path(require_env("RUNNER_TEMP")) / "oneapi-archive-keyring.gpg"
73-
download(key_url, key_path)
74-
run(
75-
[
76-
"gpg",
77-
"--dearmor",
78-
"--output",
79-
str(armored_key_path),
80-
str(key_path),
81-
]
82-
)
83-
run(
84-
[
85-
"sudo",
86-
"cp",
87-
str(armored_key_path),
88-
"/usr/share/keyrings/oneapi-archive-keyring.gpg",
89-
]
90-
)
91-
run(
92-
["sudo", "tee", "/etc/apt/sources.list.d/oneAPI.list"],
93-
input_text=(
94-
"deb [signed-by=/usr/share/keyrings/oneapi-archive-keyring.gpg] "
95-
"https://apt.repos.intel.com/oneapi all main\n"
69+
clang_path = Path(capture(["bash", "-lc", "readlink -f \"$(command -v clang++)\""]))
70+
candidate_roots = [
71+
clang_path.parent.parent,
72+
clang_path.parent.parent.parent,
73+
]
74+
sycl_root = next(
75+
(
76+
root
77+
for root in candidate_roots
78+
if (root / "bin").is_dir() or (root / "bin" / "compiler").is_dir()
9679
),
80+
None,
9781
)
98-
run(["sudo", "apt-get", "update"])
99-
run(
100-
[
101-
"sudo",
102-
"apt-get",
103-
"install",
104-
"-y",
105-
"intel-oneapi-compiler-dpcpp-cpp",
106-
"intel-oneapi-runtime-opencl",
107-
]
108-
)
109-
110-
write_env("ITLABAI_GCC_INSTALL_DIR", "/usr/lib/gcc/x86_64-linux-gnu/13")
111-
112-
icd_dir = Path(require_env("RUNNER_TEMP")) / "intel-opencl-icd"
113-
icd_dir.mkdir(parents=True, exist_ok=True)
114-
115-
icd_file = None
116-
for candidate in Path("/etc/OpenCL/vendors").glob("*.icd"):
117-
try:
118-
if "intel" in candidate.read_text(encoding="utf-8").lower():
119-
icd_file = candidate
120-
break
121-
except OSError:
122-
continue
123-
124-
if icd_file is None:
125-
main_error("Unable to locate Intel OpenCL ICD file under /etc/OpenCL/vendors")
126-
127-
run(["cp", str(icd_file), str(icd_dir / icd_file.name)])
128-
write_env("OCL_ICD_VENDORS", str(icd_dir))
82+
if sycl_root is None:
83+
main_error(f"Unable to infer SYCL_ROOT from compiler path: {clang_path}")
84+
write_env("SYCL_ROOT", str(sycl_root))
12985

13086

13187
def prepare_sycl_toolchain() -> Path:
88+
if require_env("RUNNER_OS") == "Linux" and not os.environ.get("TOOLCHAIN_ASSET"):
89+
return Path(require_env("SYCL_ROOT"))
90+
13291
runner_os = require_env("RUNNER_OS")
13392
runner_temp = require_env("RUNNER_TEMP")
13493
runner_temp_dir = Path(cygpath("u", runner_temp) if runner_os == "Windows" else runner_temp)
@@ -204,19 +163,23 @@ def setup_unix_compilers(sycl_root: Path) -> None:
204163
sycl_runtime_dirs: list[Path] = []
205164

206165
if require_env("RUNNER_OS") == "Linux":
207-
compiler_root = Path("/opt/intel/oneapi/compiler/latest")
166+
compiler_root = Path(require_env("SYCL_ROOT"))
208167
cc_candidates = [
168+
compiler_root / "bin" / "icx",
169+
compiler_root / "bin" / "clang",
209170
compiler_root / "bin" / "compiler" / "icx",
210171
compiler_root / "bin" / "compiler" / "clang",
211172
*cc_candidates,
212173
]
213174
cxx_candidates = [
175+
compiler_root / "bin" / "icpx",
176+
compiler_root / "bin" / "clang++",
214177
compiler_root / "bin" / "compiler" / "icpx",
215178
compiler_root / "bin" / "compiler" / "clang++",
216179
*cxx_candidates,
217180
]
218-
prefix_paths = [compiler_root, sycl_root]
219-
library_roots = [compiler_root, sycl_root]
181+
prefix_paths = [compiler_root]
182+
library_roots = [compiler_root]
220183

221184
cc_path = find_first_existing(cc_candidates)
222185
cxx_path = find_first_existing(cxx_candidates)
@@ -253,9 +216,9 @@ def setup_unix_compilers(sycl_root: Path) -> None:
253216
write_env("ITLABAI_OPENMP_LIBRARY", str(openmp_library))
254217
write_env("ITLABAI_OPENMP_INCLUDE_DIR", str(openmp_header.parent))
255218

256-
libsycl = find_file(library_roots, "libsycl.so.8")
219+
libsycl = find_file(library_roots + [sycl_root], "libsycl.so.8")
257220
if libsycl is None:
258-
libsycl = find_file(library_roots, "libsycl.so")
221+
libsycl = find_file(library_roots + [sycl_root], "libsycl.so")
259222
if libsycl is not None:
260223
sycl_runtime_dirs.append(libsycl.parent)
261224

0 commit comments

Comments
 (0)