|
10 | 10 | # * Dawn : Google's official nightly prebuilt, downloaded directly from |
11 | 11 | # github.com/google/dawn/releases (pinned tag+rev+sha256) -- the same |
12 | 12 | # "fetch a pinned upstream prebuilt" pattern used for other CI deps. |
13 | | -# * SwiftShader : built from source at a pinned rev compatible with the Dawn |
14 | | -# above (the ossci prebuilt is from 2020, too old for current Dawn). No S3. |
| 13 | +# * SwiftShader : a cached prebuilt (gha-artifacts, keyed by rev) when present, |
| 14 | +# else built from source at a pinned rev compatible with the Dawn above |
| 15 | +# (the ossci prebuilt is from 2020, too old for current Dawn). |
15 | 16 | # Dawn (Chrome's WebGPU impl; its WGSL compiler Tint is the spec reference) on |
16 | 17 | # SwiftShader gives a headless, deterministic, spec-faithful CLI backend. |
17 | 18 | # |
|
75 | 76 | # current Dawn; build a matching modern SwiftShader instead. Self-contained |
76 | 77 | # cmake build (vendored LLVM); the ICD lands under build/<OS>/. |
77 | 78 | if [[ ! -d "${_ss_dir}/build" ]]; then |
78 | | - if [[ ! -d "${_ss_dir}/.git" ]]; then |
79 | | - git clone https://github.com/google/swiftshader "${_ss_dir}" |
| 79 | + # Try a cached prebuilt (keyed by rev) before the expensive from-source build; |
| 80 | + # mirrors the gha-artifacts download-or-build pattern in .ci/scripts/utils.sh. |
| 81 | + _ss_key="swiftshader-${SWIFTSHADER_REV}-ubuntu-latest" |
| 82 | + _ss_cache_url="https://gha-artifacts.s3.us-east-1.amazonaws.com/cached_artifacts/pytorch/executorch/webgpu/${_ss_key}.tar.gz" |
| 83 | + if curl --silent --show-error --location --fail --retry 3 --retry-all-errors \ |
| 84 | + --output "/tmp/${_ss_key}.tar.gz" "${_ss_cache_url}"; then |
| 85 | + # Cache hit: restore the prebuilt build/ tree (ICD + libs). |
| 86 | + mkdir -p "${_ss_dir}/build" |
| 87 | + tar -C "${_ss_dir}/build" -xzf "/tmp/${_ss_key}.tar.gz" |
| 88 | + else |
| 89 | + # Cache miss: build from source. After a rev bump, seed the key in S3 |
| 90 | + # (tar -C build/ . -> the cache URL above) to skip this next run. |
| 91 | + if [[ ! -d "${_ss_dir}/.git" ]]; then |
| 92 | + git clone https://github.com/google/swiftshader "${_ss_dir}" |
| 93 | + fi |
| 94 | + git -C "${_ss_dir}" checkout "${SWIFTSHADER_REV}" |
| 95 | + # vk_swiftshader's deps are vendored in-tree; tolerate unreachable |
| 96 | + # disabled-feature submodules (angle, test-only) failing to fetch. |
| 97 | + git -C "${_ss_dir}" submodule update --init --recursive || true |
| 98 | + cmake -S "${_ss_dir}" -B "${_ss_dir}/build" -DCMAKE_BUILD_TYPE=Release \ |
| 99 | + -DSWIFTSHADER_BUILD_TESTS=OFF -DSWIFTSHADER_BUILD_PVR=OFF \ |
| 100 | + -DSWIFTSHADER_BUILD_BENCHMARKS=OFF |
| 101 | + cmake --build "${_ss_dir}/build" --parallel "$(nproc)" --target vk_swiftshader |
80 | 102 | fi |
81 | | - git -C "${_ss_dir}" checkout "${SWIFTSHADER_REV}" |
82 | | - # vk_swiftshader's deps are vendored in-tree; tolerate unreachable |
83 | | - # disabled-feature submodules (angle, test-only) failing to fetch. |
84 | | - git -C "${_ss_dir}" submodule update --init --recursive || true |
85 | | - cmake -S "${_ss_dir}" -B "${_ss_dir}/build" -DCMAKE_BUILD_TYPE=Release \ |
86 | | - -DSWIFTSHADER_BUILD_TESTS=OFF -DSWIFTSHADER_BUILD_PVR=OFF \ |
87 | | - -DSWIFTSHADER_BUILD_BENCHMARKS=OFF |
88 | | - cmake --build "${_ss_dir}/build" --parallel "$(nproc)" --target vk_swiftshader |
89 | 103 | fi |
90 | 104 | _ss_icd="$(find "${_ss_dir}/build" -name vk_swiftshader_icd.json 2>/dev/null | head -1)" |
91 | 105 | [[ -n "${_ss_icd}" ]] || { echo "ERROR: SwiftShader ICD not found after build" >&2; exit 1; } |
|
0 commit comments