Skip to content

Commit c1a326e

Browse files
committed
Fix Intel SYCL example builds on x86 CI
1 parent 335cc4c commit c1a326e

2 files changed

Lines changed: 72 additions & 15 deletions

File tree

app/SYCL/CMakeLists.txt

Lines changed: 54 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,63 @@
11
add_executable(SYCL_Example
22
sycl_example.cpp
3-
sycl_kernel.cpp
43
)
54
target_link_libraries(SYCL_Example PRIVATE layers_lib)
6-
itlabai_add_sycl_to_target(TARGET SYCL_Example SOURCES
7-
sycl_kernel.cpp
5+
6+
set_source_files_properties(sycl_example.cpp PROPERTIES
7+
COMPILE_DEFINITIONS "SYCL_DISABLE_FSYCL_SYCLHPP_WARNING=1"
8+
COMPILE_OPTIONS "-Wno-deprecated-declarations"
89
)
910

11+
if(WIN32 AND ITLABAI_SYCL_IMPLEMENTATION STREQUAL "IntelLLVM")
12+
if(NOT ITLABAI_SYCL_ROOT OR NOT EXISTS "${ITLABAI_SYCL_ROOT}/bin/clang++.exe")
13+
message(FATAL_ERROR
14+
"Windows IntelLLVM SYCL build requires clang++.exe under ITLABAI_SYCL_ROOT")
15+
endif()
16+
17+
set(SYCL_EXAMPLE_KERNEL_OBJECT
18+
"${CMAKE_CURRENT_BINARY_DIR}/SYCL_Example.sycl_kernel.obj")
19+
set(SYCL_KERNEL_COMPILE_COMMAND
20+
"${ITLABAI_SYCL_ROOT}/bin/clang++.exe"
21+
-std=c++20
22+
-fsycl
23+
-I"${CMAKE_SOURCE_DIR}/include"
24+
-I"${ITLABAI_SYCL_ROOT}/include"
25+
-c
26+
"${CMAKE_CURRENT_SOURCE_DIR}/sycl_kernel.cpp"
27+
-o
28+
"${SYCL_EXAMPLE_KERNEL_OBJECT}"
29+
)
30+
if(ITLABAI_SYCL_TARGETS)
31+
list(APPEND SYCL_KERNEL_COMPILE_COMMAND
32+
"-fsycl-targets=${ITLABAI_SYCL_TARGETS}"
33+
)
34+
endif()
35+
36+
add_custom_command(
37+
OUTPUT "${SYCL_EXAMPLE_KERNEL_OBJECT}"
38+
COMMAND ${SYCL_KERNEL_COMPILE_COMMAND}
39+
DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/sycl_kernel.cpp"
40+
VERBATIM
41+
)
42+
target_sources(SYCL_Example PRIVATE "${SYCL_EXAMPLE_KERNEL_OBJECT}")
43+
set_source_files_properties("${SYCL_EXAMPLE_KERNEL_OBJECT}" PROPERTIES
44+
EXTERNAL_OBJECT TRUE
45+
GENERATED TRUE
46+
)
47+
target_include_directories(SYCL_Example PRIVATE "${ITLABAI_SYCL_ROOT}/include")
48+
target_link_options(SYCL_Example PRIVATE -fsycl)
49+
if(ITLABAI_SYCL_TARGETS)
50+
target_link_options(SYCL_Example PRIVATE
51+
-fsycl-targets=${ITLABAI_SYCL_TARGETS}
52+
)
53+
endif()
54+
else()
55+
target_sources(SYCL_Example PRIVATE sycl_kernel.cpp)
56+
itlabai_add_sycl_to_target(TARGET SYCL_Example SOURCES
57+
sycl_kernel.cpp
58+
)
59+
endif()
60+
1061
add_test(NAME SYCL.Example COMMAND SYCL_Example)
1162
set_tests_properties(SYCL.Example PROPERTIES
1263
LABELS "sycl;smoke"

scripts/ci/sycl_x86_setup.py

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from __future__ import annotations
44

55
import os
6+
import shutil
67
import sys
78
from pathlib import Path
89

@@ -276,6 +277,7 @@ def setup_unix_compilers(sycl_root: Path) -> None:
276277

277278
if require_env("RUNNER_OS") == "Linux":
278279
export_openmp_include_dir = True
280+
openmp_header = None
279281
openmp_library = find_file([sycl_root, Path("/opt/intel/oneapi")], "libiomp5.so")
280282
openmp_library_name = "iomp5"
281283
openmp_flags = "-fopenmp=libiomp5"
@@ -289,27 +291,31 @@ def setup_unix_compilers(sycl_root: Path) -> None:
289291
gcc_openmp_header = find_file([gcc_include_root], "omp.h")
290292
gcc_openmp_library = Path(capture(["gcc-13", "-print-file-name=libgomp.so"]))
291293
if gcc_openmp_header is not None and gcc_openmp_library.exists():
294+
staged_openmp_include_dir = Path(require_env("RUNNER_TEMP")) / "gcc-openmp-include"
295+
staged_openmp_include_dir.mkdir(parents=True, exist_ok=True)
296+
shutil.copy2(gcc_openmp_header, staged_openmp_include_dir / "omp.h")
292297
openmp_library = gcc_openmp_library
293298
openmp_library_name = "gomp"
294299
openmp_flags = "-fopenmp=libgomp"
295-
export_openmp_include_dir = False
300+
openmp_header = staged_openmp_include_dir / "omp.h"
296301
if openmp_library is None and not source_built_linux_toolchain:
297302
main_error("Unable to locate an Intel toolchain OpenMP runtime library")
298303

299-
resource_dir = Path(capture([str(cxx_path), "-print-resource-dir"]))
300-
openmp_header = find_file(
301-
[
302-
resource_dir / "include",
303-
sycl_root,
304-
Path("/opt/intel/oneapi"),
305-
],
306-
"omp.h",
307-
)
308-
if openmp_header is None and source_built_linux_toolchain:
304+
if openmp_library_name != "gomp":
305+
resource_dir = Path(capture([str(cxx_path), "-print-resource-dir"]))
306+
openmp_header = find_file(
307+
[
308+
resource_dir / "include",
309+
sycl_root,
310+
Path("/opt/intel/oneapi"),
311+
],
312+
"omp.h",
313+
)
314+
if openmp_library_name != "gomp" and openmp_header is None and source_built_linux_toolchain:
309315
gcc_root = Path(require_env("ITLABAI_GCC_INSTALL_DIR"))
310316
openmp_header = find_file([gcc_root / "include"], "omp.h")
311317
export_openmp_include_dir = False
312-
if openmp_header is None and not source_built_linux_toolchain:
318+
if openmp_library_name != "gomp" and openmp_header is None and not source_built_linux_toolchain:
313319
main_error(
314320
"Unable to locate Intel-provided omp.h under the SYCL toolchain"
315321
)

0 commit comments

Comments
 (0)