|
21 | 21 | ) |
22 | 22 |
|
23 | 23 |
|
| 24 | +def linux_native_cpu_toolchain_root() -> Path: |
| 25 | + return Path(require_env("RUNNER_TEMP")) / "intel-nativecpu-toolchain" / "install" |
| 26 | + |
| 27 | + |
| 28 | +def linux_native_cpu_toolchain_ready(toolchain_root: Path) -> bool: |
| 29 | + if not toolchain_root.exists(): |
| 30 | + return False |
| 31 | + compiler_candidates = [ |
| 32 | + toolchain_root / "bin" / "clang++", |
| 33 | + toolchain_root / "bin" / "compiler" / "clang++", |
| 34 | + ] |
| 35 | + has_compiler = any(path.exists() for path in compiler_candidates) |
| 36 | + has_runtime = find_file([toolchain_root], "libsycl.so") is not None |
| 37 | + has_native_cpu_libspirv = ( |
| 38 | + find_file([toolchain_root], "remangled-l64-signed_char.libspirv-native_cpu.bc") |
| 39 | + is not None |
| 40 | + ) |
| 41 | + return has_compiler and has_runtime and has_native_cpu_libspirv |
| 42 | + |
| 43 | + |
24 | 44 | def configure_platform(platform: str) -> None: |
25 | 45 | settings = { |
26 | 46 | "linux-x86_64": { |
@@ -62,56 +82,86 @@ def setup_linux_runtime() -> None: |
62 | 82 | "g++-13", |
63 | 83 | "gcc-13", |
64 | 84 | "git", |
| 85 | + "libzstd-dev", |
| 86 | + "ninja-build", |
65 | 87 | "python3", |
66 | 88 | "zstd", |
67 | 89 | ] |
68 | 90 | ) |
69 | | - key_url = "https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB" |
70 | | - key_path = Path(require_env("RUNNER_TEMP")) / "oneapi-intel-key.pub" |
71 | | - armored_key_path = Path(require_env("RUNNER_TEMP")) / "oneapi-archive-keyring.gpg" |
72 | | - download(key_url, key_path) |
73 | | - run( |
74 | | - [ |
75 | | - "gpg", |
76 | | - "--dearmor", |
77 | | - "--output", |
78 | | - str(armored_key_path), |
79 | | - str(key_path), |
80 | | - ] |
81 | | - ) |
82 | | - run( |
83 | | - [ |
84 | | - *command_prefix, |
85 | | - "cp", |
86 | | - str(armored_key_path), |
87 | | - "/usr/share/keyrings/oneapi-archive-keyring.gpg", |
88 | | - ] |
89 | | - ) |
90 | | - run( |
91 | | - [*command_prefix, "tee", "/etc/apt/sources.list.d/oneAPI.list"], |
92 | | - input_text=( |
93 | | - "deb [signed-by=/usr/share/keyrings/oneapi-archive-keyring.gpg] " |
94 | | - "https://apt.repos.intel.com/oneapi all main\n" |
95 | | - ), |
96 | | - ) |
97 | | - run([*command_prefix, "apt-get", "update"]) |
98 | | - run( |
99 | | - [ |
100 | | - *command_prefix, |
101 | | - "apt-get", |
102 | | - "install", |
103 | | - "-y", |
104 | | - "intel-oneapi-compiler-dpcpp-cpp", |
105 | | - ] |
106 | | - ) |
107 | | - |
108 | 91 | write_env("ITLABAI_GCC_INSTALL_DIR", "/usr/lib/gcc/x86_64-linux-gnu/13") |
109 | | - write_env("SYCL_ROOT", "/opt/intel/oneapi/compiler/latest") |
| 92 | + |
| 93 | + |
| 94 | +def build_linux_native_cpu_toolchain() -> Path: |
| 95 | + toolchain_root = linux_native_cpu_toolchain_root() |
| 96 | + if linux_native_cpu_toolchain_ready(toolchain_root): |
| 97 | + write_env("SYCL_ROOT", str(toolchain_root)) |
| 98 | + return toolchain_root |
| 99 | + |
| 100 | + toolchain_base = toolchain_root.parent |
| 101 | + source_dir = toolchain_base / "src" |
| 102 | + build_dir = toolchain_base / "build" |
| 103 | + llvm_tag = require_env("INTEL_LLVM_TAG") |
| 104 | + |
| 105 | + toolchain_base.mkdir(parents=True, exist_ok=True) |
| 106 | + if not (source_dir / ".git").exists(): |
| 107 | + run( |
| 108 | + [ |
| 109 | + "git", |
| 110 | + "clone", |
| 111 | + "--depth", |
| 112 | + "1", |
| 113 | + "--branch", |
| 114 | + llvm_tag, |
| 115 | + "https://github.com/intel/llvm.git", |
| 116 | + str(source_dir), |
| 117 | + ] |
| 118 | + ) |
| 119 | + |
| 120 | + configure_stamp = build_dir / "CMakeCache.txt" |
| 121 | + if not configure_stamp.exists(): |
| 122 | + build_dir.mkdir(parents=True, exist_ok=True) |
| 123 | + run( |
| 124 | + [ |
| 125 | + "python3", |
| 126 | + str(source_dir / "buildbot" / "configure.py"), |
| 127 | + "-w", |
| 128 | + str(toolchain_base), |
| 129 | + "-s", |
| 130 | + str(source_dir), |
| 131 | + "-o", |
| 132 | + str(build_dir), |
| 133 | + "-t", |
| 134 | + "Release", |
| 135 | + "--native_cpu", |
| 136 | + "--cmake-gen", |
| 137 | + "Ninja", |
| 138 | + "--use-zstd", |
| 139 | + "-DCMAKE_C_COMPILER=gcc-13", |
| 140 | + "-DCMAKE_CXX_COMPILER=g++-13", |
| 141 | + "-DCMAKE_C_COMPILER_LAUNCHER=ccache", |
| 142 | + "-DCMAKE_CXX_COMPILER_LAUNCHER=ccache", |
| 143 | + f"-DCMAKE_INSTALL_PREFIX={toolchain_root}", |
| 144 | + "-DSYCL_ENABLE_BACKENDS=native_cpu", |
| 145 | + "-DSYCL_INCLUDE_TESTS=OFF", |
| 146 | + "-DLLVM_INSTALL_UTILS=ON", |
| 147 | + ] |
| 148 | + ) |
| 149 | + |
| 150 | + run(["cmake", "--build", str(build_dir), "--target", "sycl-toolchain", "--parallel"]) |
| 151 | + |
| 152 | + if not linux_native_cpu_toolchain_ready(toolchain_root): |
| 153 | + main_error( |
| 154 | + "Intel SYCL native_cpu toolchain build completed, but required files " |
| 155 | + "were not installed" |
| 156 | + ) |
| 157 | + |
| 158 | + write_env("SYCL_ROOT", str(toolchain_root)) |
| 159 | + return toolchain_root |
110 | 160 |
|
111 | 161 |
|
112 | 162 | def prepare_sycl_toolchain() -> Path: |
113 | 163 | if require_env("RUNNER_OS") == "Linux" and not os.environ.get("TOOLCHAIN_ASSET"): |
114 | | - return Path(require_env("SYCL_ROOT")) |
| 164 | + return build_linux_native_cpu_toolchain() |
115 | 165 |
|
116 | 166 | runner_os = require_env("RUNNER_OS") |
117 | 167 | runner_temp = require_env("RUNNER_TEMP") |
|
0 commit comments