diff --git a/.github/workflows/spirv-ci-linux.yml b/.github/workflows/spirv-ci-linux.yml index e0ddca66b..a58e42796 100644 --- a/.github/workflows/spirv-ci-linux.yml +++ b/.github/workflows/spirv-ci-linux.yml @@ -19,6 +19,8 @@ jobs: timeout-minutes: 120 container: image: ghcr.io/rocm/therock_build_manylinux_x86_64@sha256:702a5133851e6d1daf1207d2c9fbb01c2667914a5b6dc5a01faeb3ce66ea6421 + outputs: + llvm_project_sha: ${{ steps.resolve_llvm_sha.outputs.sha }} steps: # ---- Checkout --------------------------------------------------------- @@ -34,6 +36,17 @@ jobs: fetch-depth: 1 persist-credentials: false + # Capture the resolved amd-staging SHA so test jobs can pin to the + # exact commit this build used. Without this, test jobs re-resolve + # `amd-staging` and may land on a newer commit if upstream merged + # mid-run, triggering a cascade rebuild against an older build.ninja. + - name: Resolve llvm-project SHA + id: resolve_llvm_sha + run: | + SHA=$(git -C llvm-project rev-parse HEAD) + echo "sha=$SHA" >> "$GITHUB_OUTPUT" + echo "Pinned llvm-project SHA for test jobs: $SHA" + - name: Checkout SPIRV-LLVM-Translator (PR head) uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 with: @@ -130,11 +143,11 @@ jobs: pull-requests: write # for the baseline-diff sticky comment steps: - - name: Checkout llvm-project (amd-staging) + - name: Checkout llvm-project (pinned to Build job SHA) uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 with: repository: ROCm/llvm-project - ref: amd-staging + ref: ${{ needs.build.outputs.llvm_project_sha }} path: llvm-project fetch-depth: 1 persist-credentials: false @@ -298,11 +311,11 @@ jobs: image: ghcr.io/rocm/therock_build_manylinux_x86_64@sha256:702a5133851e6d1daf1207d2c9fbb01c2667914a5b6dc5a01faeb3ce66ea6421 steps: - - name: Checkout llvm-project (amd-staging) + - name: Checkout llvm-project (pinned to Build job SHA) uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 with: repository: ROCm/llvm-project - ref: amd-staging + ref: ${{ needs.build.outputs.llvm_project_sha }} path: llvm-project fetch-depth: 1 persist-credentials: false @@ -341,11 +354,11 @@ jobs: image: ghcr.io/rocm/therock_build_manylinux_x86_64@sha256:702a5133851e6d1daf1207d2c9fbb01c2667914a5b6dc5a01faeb3ce66ea6421 steps: - - name: Checkout llvm-project (amd-staging) + - name: Checkout llvm-project (pinned to Build job SHA) uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 with: repository: ROCm/llvm-project - ref: amd-staging + ref: ${{ needs.build.outputs.llvm_project_sha }} path: llvm-project fetch-depth: 1 persist-credentials: false diff --git a/.github/workflows/spirv-ci-windows.yml b/.github/workflows/spirv-ci-windows.yml new file mode 100644 index 000000000..c4513fdb4 --- /dev/null +++ b/.github/workflows/spirv-ci-windows.yml @@ -0,0 +1,441 @@ +# Windows variant of the SPIRV CI: builds LLVM/Clang/translator/Comgr in +# one job and runs SPIRV-relevant test suites in parallel test jobs that +# consume a GHA artifact uploaded by the build job. Mirrors spirv-ci-linux.yml +# in shape; differs in runner, MSVC env setup, no container, no strip. + +name: SPIRV Compiler CI - Windows + +on: + workflow_call: + +jobs: + # ===================================================================== + # Build LLVM + Clang + amd-llvm-spirv + device-libs + Comgr. + # ===================================================================== + build: + name: Build + runs-on: azure-windows-scale-rocm + timeout-minutes: 180 + defaults: + run: + shell: bash + outputs: + llvm_project_sha: ${{ steps.resolve_llvm_sha.outputs.sha }} + + steps: + # Long path support for the deep llvm-project tree under runner workspace. + - name: Enable git long paths + run: git config --global core.longpaths true + + # Pinned ninja 1.12.1 — TheRock pins this version because 1.13.0 has a bug. + - name: Install ninja + run: choco install -y ninja --version 1.12.1 + + # MSVC environment so cmake -GNinja can find cl.exe + link.exe. + - name: Configure MSVC + uses: ilammy/msvc-dev-cmd@0b201ec74fa43914dc39ae48a89fd1d8cb592756 # v1.13.0 + + # zstd dev libs for clang-offload-bundler compression support. Two + # vcpkg installs exist on this runner: C:\vcpkg (classic mode, what + # `vcpkg` in PATH resolves to) and the MSVC-bundled one at $VCPKG_ROOT + # (manifest-mode only — no `vcpkg install ` support). We use + # C:\vcpkg for both install and toolchain lookup so they match. + - name: Install zstd via vcpkg + run: vcpkg install zstd:x64-windows + + - name: Checkout llvm-project (amd-staging) + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + with: + repository: ROCm/llvm-project + ref: amd-staging + path: llvm-project + fetch-depth: 1 + persist-credentials: false + + # Capture the resolved amd-staging SHA so test jobs can pin to the + # exact commit this build used. Without this, test jobs re-resolve + # `amd-staging` and may land on a newer commit if upstream merged + # mid-run, triggering a cascade rebuild against an older build.ninja. + - name: Resolve llvm-project SHA + id: resolve_llvm_sha + run: | + SHA=$(git -C llvm-project rev-parse HEAD) + echo "sha=$SHA" >> "$GITHUB_OUTPUT" + echo "Pinned llvm-project SHA for test jobs: $SHA" + + - name: Checkout SPIRV-LLVM-Translator (PR head) + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + with: + path: llvm-project/llvm/projects/SPIRV-LLVM-Translator + fetch-depth: 1 + persist-credentials: false + + # CMAKE_TOOLCHAIN_FILE points cmake at the C:\vcpkg find_package + # shims so LLVM_ENABLE_ZSTD=FORCE_ON locates the vcpkg-installed + # zstd. FORCE_ON makes the configure fail loudly if zstd is missing + # rather than silently building clang-offload-bundler without + # compression. + - name: Configure LLVM + run: | + cmake -G Ninja -S llvm-project/llvm -B build \ + -DCMAKE_BUILD_TYPE=Release \ + -DCMAKE_TOOLCHAIN_FILE="C:/vcpkg/scripts/buildsystems/vcpkg.cmake" \ + -DLLVM_ENABLE_ASSERTIONS=ON \ + -DLLVM_ENABLE_PROJECTS="clang;lld" \ + -DLLVM_TARGETS_TO_BUILD="AMDGPU;X86;SPIRV" \ + -DLLVM_ENABLE_ZSTD=FORCE_ON \ + -DLLVM_INCLUDE_TESTS=ON \ + -DLLVM_INSTALL_GTEST=ON \ + -DLLVM_LIT_ARGS="-sv --no-progress-bar" + + - name: Build LLVM + Clang + amd-llvm-spirv + test deps + run: ninja -C build llvm-test-depends clang-test-depends amd-llvm-spirv + + # Use $(pwd -W) for cmake -D paths: in MSYS bash $PWD is Unix-style + # (/c/...) which cmake's find_package can't traverse on Windows. + # pwd -W returns Windows-style with forward slashes (C:/...). + # Pass CMAKE_TOOLCHAIN_FILE here too: LLVM exports LLVMSupport + # linking against zstd::libzstd_shared, and consumers like + # find_package(LLVM) in device-libs/Comgr need the vcpkg toolchain + # loaded so that imported zstd target is defined. + - name: Configure device-libs + run: | + PWD_WIN=$(pwd -W) + cmake -G Ninja -S llvm-project/amd/device-libs -B build-device-libs \ + -DCMAKE_BUILD_TYPE=Release \ + -DCMAKE_TOOLCHAIN_FILE="C:/vcpkg/scripts/buildsystems/vcpkg.cmake" \ + -DCMAKE_PREFIX_PATH=$PWD_WIN/build \ + -DLLVM_DIR=$PWD_WIN/build/lib/cmake/llvm + + - name: Build device-libs + run: ninja -C build-device-libs + + - name: Configure Comgr + run: | + PWD_WIN=$(pwd -W) + cmake -G Ninja -S llvm-project/amd/comgr -B build-comgr \ + -DCMAKE_BUILD_TYPE=Release \ + -DCMAKE_TOOLCHAIN_FILE="C:/vcpkg/scripts/buildsystems/vcpkg.cmake" \ + -DCMAKE_PREFIX_PATH="$PWD_WIN/build;$PWD_WIN/build-device-libs" \ + -DLLVM_DIR=$PWD_WIN/build/lib/cmake/llvm \ + -DAMDDeviceLibs_DIR=$PWD_WIN/build-device-libs/lib/cmake/AMDDeviceLibs \ + -DLLVM_EXTERNAL_SPIRV_LLVM_TRANSLATOR_SOURCE_DIR=$PWD_WIN/llvm-project/llvm/projects/SPIRV-LLVM-Translator \ + -DBUILD_TESTING=ON + + - name: Build Comgr + run: ninja -C build-comgr amd_comgr + + # No strip on Windows: PE/COFF debug info lives in separate .pdb files + # rather than embedded in the .exe/.dll, so the binaries themselves are + # already stripped. Tar directly. + - name: Tar build trees + run: tar -cf windows-build-tree.tar build build-comgr build-device-libs + + - name: Upload build tree artifact + uses: actions/upload-artifact@v4 + with: + name: windows-build-tree + path: windows-build-tree.tar + retention-days: 1 + compression-level: 6 + if-no-files-found: error + + # ===================================================================== + # Test - SPIRV translator lit (with PR-head vs amd-staging baseline diff) + # ===================================================================== + test_translator_lit: + name: Test SPIRV translator lit + needs: build + runs-on: azure-windows-scale-rocm + timeout-minutes: 30 + permissions: + contents: read + pull-requests: write # for the baseline-diff sticky comment + defaults: + run: + shell: bash + + steps: + - name: Enable git long paths + run: git config --global core.longpaths true + + - name: Install ninja + run: choco install -y ninja --version 1.12.1 + + - name: Configure MSVC + uses: ilammy/msvc-dev-cmd@0b201ec74fa43914dc39ae48a89fd1d8cb592756 # v1.13.0 + + # zstd must be present at the same C:\vcpkg path the build job used, + # because build.ninja embeds C:/vcpkg/installed/.../zstd.lib as a + # build-edge input that ninja validates at planning time. + - name: Install zstd via vcpkg + run: vcpkg install zstd:x64-windows + + - name: Checkout llvm-project (pinned to Build job SHA) + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + with: + repository: ROCm/llvm-project + ref: ${{ needs.build.outputs.llvm_project_sha }} + path: llvm-project + fetch-depth: 1 + persist-credentials: false + + - name: Checkout SPIRV-LLVM-Translator (PR head) + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + with: + path: llvm-project/llvm/projects/SPIRV-LLVM-Translator + fetch-depth: 1 + persist-credentials: false + + - name: Download build tree artifact + uses: actions/download-artifact@v4 + with: + name: windows-build-tree + + # touch build.ninja so it's newer than CMakeCache.txt — without it + # tar -m's per-file mtimes can trigger a cmake regen + cascade rebuild. + - name: Untar build trees + run: | + tar -xmf windows-build-tree.tar + touch build/build.ninja build-comgr/build.ninja build-device-libs/build.ninja + + - name: Test - SPIRV Translator (check-amd-llvm-spirv) [PR head] + id: check_spirv_xlator + continue-on-error: true + run: | + set -o pipefail + ninja -C build check-amd-llvm-spirv 2>&1 | tee build/check-amd-llvm-spirv.log + + - name: Capture PR head translator failures + if: always() + run: | + grep -oE '^FAIL: LLVM_SPIRV :: \S+' build/check-amd-llvm-spirv.log \ + | sort -u > build/spirv-fails-pr.txt || true + echo "PR head failures:"; cat build/spirv-fails-pr.txt + + - name: Switch translator to amd-staging tip for baseline + if: always() + run: | + cd llvm-project/llvm/projects/SPIRV-LLVM-Translator + git fetch --depth=1 origin amd-staging + git checkout FETCH_HEAD + + - name: Test - SPIRV Translator [baseline amd-staging] + if: always() + id: check_spirv_baseline + continue-on-error: true + run: | + set -o pipefail + cmake -G Ninja -S llvm-project/llvm -B build + ninja -C build check-amd-llvm-spirv 2>&1 \ + | tee build/check-amd-llvm-spirv-baseline.log + + - name: Capture baseline translator failures + if: always() + run: | + grep -oE '^FAIL: LLVM_SPIRV :: \S+' build/check-amd-llvm-spirv-baseline.log \ + | sort -u > build/spirv-fails-baseline.txt || true + echo "Baseline failures:"; cat build/spirv-fails-baseline.txt + + - name: Post translator lit summary to PR + if: always() + uses: actions/github-script@v7 + with: + script: | + const fs = require('fs'); + const marker = ''; + const read = (p) => { + try { return fs.readFileSync(p, 'utf8').split('\n').filter(Boolean); } + catch { return null; } + }; + const prList = read('build/spirv-fails-pr.txt'); + const baseList = read('build/spirv-fails-baseline.txt'); + const runUrl = `${context.serverUrl}/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`; + const fmt = (xs) => xs.length ? '```\n' + xs.join('\n') + '\n```' : '_(none)_'; + + let body; + if (!prList) { + body = `${marker}\n⚠️ **SPIRV translator lit suite (Windows)**: PR run did not produce a result (see [run](${runUrl})).`; + } else if (!baseList) { + body = prList.length === 0 + ? `${marker}\n✅ **SPIRV translator lit suite (Windows)**: all tests passing on PR head. (Baseline comparison unavailable.)` + : `${marker}\n⚠️ **SPIRV translator lit suite (Windows)**: ${prList.length} failing on PR head; baseline comparison unavailable (see [run](${runUrl})).\n\n
Failing tests\n\n${fmt(prList)}\n
`; + } else { + const prSet = new Set(prList); + const baseSet = new Set(baseList); + const newFails = prList.filter(t => !baseSet.has(t)); + const fixed = baseList.filter(t => !prSet.has(t)); + const common = prList.filter(t => baseSet.has(t)); + + let headline; + if (newFails.length === 0 && fixed.length === 0 && common.length === 0) { + headline = `✅ **SPIRV translator lit suite (Windows)**: clean on both PR head and \`amd-staging\` baseline.`; + } else if (newFails.length > 0) { + headline = `🔴 **${newFails.length} new translator lit failure${newFails.length === 1 ? '' : 's'} (Windows)** introduced by this PR (non-blocking; see [run](${runUrl})).`; + } else if (fixed.length > 0 && common.length === 0) { + headline = `🟢 **SPIRV translator lit suite (Windows)**: this PR fixes ${fixed.length} test${fixed.length === 1 ? '' : 's'} that fail on \`amd-staging\`. No remaining failures.`; + } else if (fixed.length > 0) { + headline = `🟢 This PR fixes ${fixed.length} translator lit test${fixed.length === 1 ? '' : 's'} on Windows (vs \`amd-staging\` baseline). ${common.length} pre-existing failure${common.length === 1 ? '' : 's'} remain.`; + } else { + headline = `⚠️ **${common.length} pre-existing translator lit failure${common.length === 1 ? '' : 's'} (Windows)** on baseline; not caused by this PR (see [run](${runUrl})).`; + } + + body = `${marker}\n${headline}\n\n` + + ` 0 ? ' open' : ''}>🔴 New failures (${newFails.length}) — likely caused by this PR\n\n${fmt(newFails)}\n\n\n` + + `
🟢 Fixed by this PR (${fixed.length}) — failing on baseline, passing here\n\n${fmt(fixed)}\n
\n\n` + + `
⚠️ Pre-existing on \`amd-staging\` (${common.length})\n\n${fmt(common)}\n
`; + } + + const { data: comments } = await github.rest.issues.listComments({ + owner: context.repo.owner, repo: context.repo.repo, + issue_number: context.payload.pull_request.number, + }); + const existing = comments.find(c => c.body && c.body.includes(marker)); + if (existing) { + await github.rest.issues.updateComment({ + owner: context.repo.owner, repo: context.repo.repo, + comment_id: existing.id, body, + }); + } else { + await github.rest.issues.createComment({ + owner: context.repo.owner, repo: context.repo.repo, + issue_number: context.payload.pull_request.number, body, + }); + } + + - name: Gate - new translator lit failures + if: always() + run: | + if [ ! -f build/spirv-fails-pr.txt ] || [ ! -f build/spirv-fails-baseline.txt ]; then + echo "::warning::Could not compute new-failure delta (missing pr.txt or baseline.txt); not gating." + exit 0 + fi + new=$(comm -23 build/spirv-fails-pr.txt build/spirv-fails-baseline.txt) + if [ -n "$new" ]; then + count=$(printf '%s\n' "$new" | wc -l) + echo "::error::$count new translator lit failure(s) introduced by this PR (Windows):" + printf '%s\n' "$new" | sed 's/^/::error:: /' + exit 1 + fi + echo "No new translator lit failures vs amd-staging baseline." + + # ===================================================================== + # Test - LLVM SPIRV codegen lit suite + # ===================================================================== + test_codegen: + name: Test LLVM SPIRV codegen + needs: build + runs-on: azure-windows-scale-rocm + timeout-minutes: 15 + defaults: + run: + shell: bash + + steps: + - name: Enable git long paths + run: git config --global core.longpaths true + + - name: Install ninja + run: choco install -y ninja --version 1.12.1 + + - name: Configure MSVC + uses: ilammy/msvc-dev-cmd@0b201ec74fa43914dc39ae48a89fd1d8cb592756 # v1.13.0 + + # zstd must be present at the same C:\vcpkg path the build job used, + # because build.ninja embeds C:/vcpkg/installed/.../zstd.lib as a + # build-edge input that ninja validates at planning time. + - name: Install zstd via vcpkg + run: vcpkg install zstd:x64-windows + + - name: Checkout llvm-project (pinned to Build job SHA) + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + with: + repository: ROCm/llvm-project + ref: ${{ needs.build.outputs.llvm_project_sha }} + path: llvm-project + fetch-depth: 1 + persist-credentials: false + + - name: Checkout SPIRV-LLVM-Translator (PR head) + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + with: + path: llvm-project/llvm/projects/SPIRV-LLVM-Translator + fetch-depth: 1 + persist-credentials: false + + - name: Download build tree artifact + uses: actions/download-artifact@v4 + with: + name: windows-build-tree + + # touch build.ninja so it's newer than CMakeCache.txt — without it + # tar -m's per-file mtimes can trigger a cmake regen + cascade rebuild. + - name: Untar build trees + run: | + tar -xmf windows-build-tree.tar + touch build/build.ninja build-comgr/build.ninja build-device-libs/build.ninja + + - name: Test - LLVM SPIRV backend (check-llvm-codegen-spirv) + run: ninja -C build check-llvm-codegen-spirv + + # ===================================================================== + # Test - Comgr (lit + gtest + ctest) + # ===================================================================== + test_comgr: + name: Test Comgr + needs: build + runs-on: azure-windows-scale-rocm + timeout-minutes: 30 + defaults: + run: + shell: bash + + steps: + - name: Enable git long paths + run: git config --global core.longpaths true + + - name: Install ninja + run: choco install -y ninja --version 1.12.1 + + - name: Configure MSVC + uses: ilammy/msvc-dev-cmd@0b201ec74fa43914dc39ae48a89fd1d8cb592756 # v1.13.0 + + # zstd must be present at the same C:\vcpkg path the build job used, + # because build.ninja embeds C:/vcpkg/installed/.../zstd.lib as a + # build-edge input that ninja validates at planning time. + - name: Install zstd via vcpkg + run: vcpkg install zstd:x64-windows + + - name: Checkout llvm-project (pinned to Build job SHA) + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + with: + repository: ROCm/llvm-project + ref: ${{ needs.build.outputs.llvm_project_sha }} + path: llvm-project + fetch-depth: 1 + persist-credentials: false + + - name: Checkout SPIRV-LLVM-Translator (PR head) + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + with: + path: llvm-project/llvm/projects/SPIRV-LLVM-Translator + fetch-depth: 1 + persist-credentials: false + + - name: Download build tree artifact + uses: actions/download-artifact@v4 + with: + name: windows-build-tree + + # touch build.ninja so it's newer than CMakeCache.txt — without it + # tar -m's per-file mtimes can trigger a cmake regen + cascade rebuild. + - name: Untar build trees + run: | + tar -xmf windows-build-tree.tar + touch build/build.ninja build-comgr/build.ninja build-device-libs/build.ninja + + - name: Test - Comgr (check-comgr) + id: check_comgr + env: + AMD_COMGR_REDIRECT_LOGS: stderr + run: ninja -C build-comgr check-comgr diff --git a/.github/workflows/spirv-ci.yml b/.github/workflows/spirv-ci.yml index 26ebe6c02..5be81d7b7 100644 --- a/.github/workflows/spirv-ci.yml +++ b/.github/workflows/spirv-ci.yml @@ -23,3 +23,8 @@ jobs: name: Linux::release uses: ./.github/workflows/spirv-ci-linux.yml secrets: inherit + + windows_release: + name: Windows::release + uses: ./.github/workflows/spirv-ci-windows.yml + secrets: inherit