File: reusable.ispc.test.yml

package info (click to toggle)
ispc 1.28.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 97,620 kB
  • sloc: cpp: 77,067; python: 8,303; yacc: 3,337; lex: 1,126; ansic: 631; sh: 475; makefile: 17
file content (195 lines) | stat: -rw-r--r-- 8,978 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
# Copyright 2025, Intel Corporation
# SPDX-License-Identifier: BSD-3-Clause

name: Reusable ISPC test workflow

permissions: read-all

on:
  workflow_call:
    inputs:
      platform:
        description: 'Platform to test on (linux, macos, windows)'
        required: true
        type: string
      architecture:
        description: 'Architecture to test (x86, x86-64, aarch64)'
        required: true
        type: string
      artifact_name:
        description: 'Name of the artifact to test'
        required: true
        type: string
      targets:
        description: 'JSON array of targets to test'
        required: false
        type: string
        default: '["avx2-i32x8"]'
      optsets:
        description: 'Optimization sets to test'
        required: false
        type: string
        default: '-O2'
      enable_lto:
        description: 'Was the build using LTO'
        required: false
        type: boolean
        default: false
      enable_xe:
        description: 'Was the build with XE support'
        required: false
        type: boolean
        default: false
      enable_debug:
        description: 'Enable debug mode for tests'
        required: false
        type: boolean
        default: false
      calling_conv:
        description: 'Optional calling convention to test (Windows only)'
        required: false
        type: string
        default: ''
      ispc_extra_flags:
        description: 'Additional ISPC flags to pass'
        required: false
        type: string
        default: ''

env:
  LLVM_HOME: ${{ inputs.platform == 'windows' && 'C:\\projects\\llvm' || github.workspace }}
  ISPC_HOME: ${{ github.workspace }}
  INSTALL_COMPUTE_RUNTIME: ${{ inputs.enable_xe && '1' || '' }}
  COMPUTE_RUNTIME_GITHUB_RELEASE: ${{ inputs.enable_xe && '1' || '' }}

jobs:
  test:
    name: ${{ inputs.platform }} (${{ inputs.architecture }}, ${{ matrix.target }}, ${{ inputs.optsets }})
    runs-on: ${{ inputs.platform == 'macos' && (inputs.architecture == 'aarch64' && 'macos-14' || 'macos-13') || (inputs.platform == 'windows' && (inputs.architecture == 'aarch64' && 'windows-11-arm' || 'windows-2022')) || (inputs.architecture == 'aarch64' && 'ubuntu-22.04-arm') || 'ubuntu-22.04' }}
    continue-on-error: false
    strategy:
      fail-fast: false
      matrix:
        target: ${{ fromJson(inputs.targets) }}

    steps:
    - uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1

    - name: Download package
      uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
      with:
        name: ${{ inputs.artifact_name }}

    - name: Install dependencies and unpack artifacts
      shell: bash
      run: |
        if [ "${{ inputs.platform }}" == "linux" ]; then
          bash .github/workflows/scripts/install-test-deps.sh
        elif [ "${{ inputs.platform }}" == "macos" ]; then
          if [[ "${{ inputs.enable_lto }}" == "true" ]]; then
            tar xf ispc-trunk-macOS.universal.tar.gz
            echo "$GITHUB_WORKSPACE/ispc-trunk-macOS.universal/bin" >> "$GITHUB_PATH"
          else
            tar xf ispc-trunk-macos.tar.gz
            echo "$GITHUB_WORKSPACE/ispc-trunk-macos/bin" >> "$GITHUB_PATH"
          fi
          echo "ISPC_HOME=$GITHUB_WORKSPACE" >> "$GITHUB_ENV"
          echo "LLVM_HOME=$GITHUB_WORKSPACE" >> "$GITHUB_ENV"
        else
          pwsh .github/workflows/scripts/install-test-deps.ps1
        fi

    - name: Running tests on Linux/macOS (alloy mode)
      # See issue #2818 for more details about skipping avx512, avx10 and avx2vnni targets. It's SDE problem running on AMD runner.
      # Unfortunately it's not possible to do this on job level, so we need to do it on step level.
      if: (inputs.platform == 'linux' || inputs.platform == 'macos') && inputs.architecture != 'aarch64' && inputs.architecture != 'wasm32' && inputs.architecture != 'wasm64' && !(inputs.architecture == 'x86' && (contains(matrix.target, 'avx2vnni') || contains(matrix.target, 'avx512') || contains(matrix.target, 'avx10')))
      shell: bash
      run: |
        echo "PATH=${PATH}"
        if [ "${{ inputs.enable_debug }}" = "true" ]; then
          ./scripts/alloy.py -r --only="stability ${{ inputs.architecture }} current debug ${{ inputs.optsets }}" --only-targets="${{ matrix.target }}" --time --update-errors=FP --ispc-flags="${{ inputs.ispc_extra_flags }}"
        else
          ./scripts/alloy.py -r --only="stability ${{ inputs.architecture }} current ${{ inputs.optsets }}" --only-targets="${{ matrix.target }}" --time --update-errors=FP --ispc-flags="${{ inputs.ispc_extra_flags }}"
        fi

    - name: Running tests on Linux/macOS (run_tests mode)
      if: (inputs.platform == 'linux' || inputs.platform == 'macos') && (inputs.architecture == 'aarch64' || inputs.architecture == 'wasm32' || inputs.architecture == 'wasm64')
      shell: bash
      run: |
        if [ "${{ inputs.architecture }}" == "wasm32" ] || [ "${{ inputs.architecture }}" == "wasm64" ]; then
          source scripts/install_emscripten.sh && emcc --version
        fi

        echo "PATH=${PATH}"
        IFS=' ' read -ra OPT_LEVELS <<< "${{ inputs.optsets }}"

        for opt in "${OPT_LEVELS[@]}"; do
          # Remove dashes from each option
          opt_no_dash="${opt//-/}"
          echo "About to execute run_tests.py with opt: $opt_no_dash"
          ./scripts/run_tests.py -t "${{ matrix.target }}" -a "${{ inputs.architecture }}" -o "$opt_no_dash" --time --update-errors=FP --ispc-flags="${{ inputs.ispc_extra_flags }}"
          echo "Finished executing run_tests.py with opt: $opt_no_dash"
        done

    - name: Running tests on Windows (alloy mode)
      if: inputs.platform == 'windows' && inputs.calling_conv == '' && inputs.architecture != 'aarch64'
      run: |
        $env:ISPC_HOME = "$pwd"
        .github/workflows/scripts/load-vs-env.ps1 "${{ inputs.architecture }}"
        if ("${{ inputs.enable_debug }}" -eq "true") {
          python .\scripts\alloy.py -r --only="stability ${{ inputs.architecture }} current debug ${{ inputs.optsets }}" --only-targets="${{ matrix.target }}" --time --update-errors=FP --ispc-flags="${{ inputs.ispc_extra_flags }}"
        } else {
          python .\scripts\alloy.py -r --only="stability ${{ inputs.architecture }} current ${{ inputs.optsets }}" --only-targets="${{ matrix.target }}" --time --update-errors=FP --ispc-flags="${{ inputs.ispc_extra_flags }}"
        }
        Write-Host "Finished executing alloy.py"
      shell: pwsh

    - name: Running tests on Windows (run_tests mode)
      if: inputs.platform == 'windows' && (inputs.calling_conv != '' || inputs.architecture == 'aarch64')
      run: |
        $env:ISPC_HOME = "$pwd"
        .github/workflows/scripts/load-vs-env.ps1 "${{ inputs.architecture }}"

        # Split optsets and run tests for each optimization level
        $optLevels = "${{ inputs.optsets }}".Split(" ", [System.StringSplitOptions]::RemoveEmptyEntries)
        Write-Host "optLevels array created: $($optLevels -join ', ')"

        foreach ($opt in $optLevels) {
          $optNoDash = $opt -replace "-", ""
          Write-Host "About to execute run_tests.py with opt: $optNoDash"
          if ("${{ inputs.calling_conv }}" -ne "" -and "${{ inputs.architecture }}" -ne "aarch64") {
            python .\scripts\run_tests.py --calling_conv=${{ inputs.calling_conv }} --target=${{ matrix.target }} --arch=${{ inputs.architecture }} --opt=$optNoDash --ispc-flags="${{ inputs.ispc_extra_flags }}"
          } else {
            python .\scripts\run_tests.py --target=${{ matrix.target }} --arch=${{ inputs.architecture }} --opt=$optNoDash --ispc-flags="${{ inputs.ispc_extra_flags }}"
          }
          Write-Host "Finished executing run_tests.py with opt: $optNoDash"
        }
      shell: pwsh

    - name: Set artifact name prefix
      id: set-artifact-name
      shell: bash
      run: |
        TIMESTAMP=$(date +"%Y%m%d-%H%M%S")
        if [ "${{ inputs.enable_debug }}" == "true" ]; then
          echo "name_prefix=${{ inputs.artifact_name }}.debug.${{ inputs.architecture }}.${{ matrix.target }}.${TIMESTAMP}" >> "$GITHUB_ENV"
        else
          echo "name_prefix=${{ inputs.artifact_name }}.${{ inputs.architecture }}.${{ matrix.target }}.${TIMESTAMP}" >> "$GITHUB_OUTPUT"
        fi
    - name: Check
      run: |
        # Print fails to the log.
        git diff --exit-code
    - name: Upload fail_db.txt
      uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4.6.0
      if: failure()
      with:
        name: fail_db.${{ steps.set-artifact-name.outputs.name_prefix }}.txt
        path: tests/fail_db.txt

    - name: Upload alloy logs
      uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4.6.0
      if: failure() && inputs.architecture != 'aarch64'
      with:
        name: alloy_results.${{ steps.set-artifact-name.outputs.name_prefix }}
        path: alloy_results_*