2424def 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
5050def 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
13187def 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