|
| 1 | +name: Advanced Vulkan Compute CI |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + types: [ opened, synchronize, reopened ] |
| 6 | + paths: |
| 7 | + - 'attachments/compute/**' |
| 8 | + - '.github/workflows/compute_ci.yml' |
| 9 | + push: |
| 10 | + branches: [ main ] |
| 11 | + paths: |
| 12 | + - 'attachments/compute/**' |
| 13 | + - '.github/workflows/compute_ci.yml' |
| 14 | + workflow_dispatch: |
| 15 | + |
| 16 | +jobs: |
| 17 | + build: |
| 18 | + strategy: |
| 19 | + fail-fast: false |
| 20 | + matrix: |
| 21 | + os: [ubuntu-latest, windows-latest] |
| 22 | + include: |
| 23 | + - os: ubuntu-latest |
| 24 | + ccache: ccache |
| 25 | + vulkan-install: | |
| 26 | + VULKAN_VERSION=$(curl -s https://vulkan.lunarg.com/sdk/latest/linux.txt) |
| 27 | + echo "Using Vulkan SDK version: $VULKAN_VERSION" |
| 28 | +
|
| 29 | + mkdir -p vulkan-sdk |
| 30 | + cd vulkan-sdk |
| 31 | +
|
| 32 | + curl -O "https://sdk.lunarg.com/sdk/download/$VULKAN_VERSION/linux/vulkansdk-linux-x86_64-$VULKAN_VERSION.tar.xz" |
| 33 | +
|
| 34 | + tar -xJf vulkansdk-linux-x86_64-$VULKAN_VERSION.tar.xz |
| 35 | +
|
| 36 | + ln -sfn "$PWD/$VULKAN_VERSION" "$PWD/latest" |
| 37 | +
|
| 38 | + echo "VULKAN_SDK=$PWD/latest/x86_64" >> $GITHUB_ENV |
| 39 | + echo "PATH=$PWD/latest/x86_64/bin:$PATH" >> $GITHUB_ENV |
| 40 | + echo "LD_LIBRARY_PATH=$PWD/latest/x86_64/lib:$LD_LIBRARY_PATH" >> $GITHUB_ENV |
| 41 | + echo "VK_LAYER_PATH=$PWD/latest/x86_64/etc/vulkan/explicit_layer.d" >> $GITHUB_ENV |
| 42 | +
|
| 43 | + cd .. |
| 44 | + deps-install: | |
| 45 | + chmod +x attachments/compute/install_dependencies_linux.sh |
| 46 | + ./attachments/compute/install_dependencies_linux.sh --skip-clspv-clvk |
| 47 | + test-cmd: | |
| 48 | + for sample in \ |
| 49 | + 02_compute_architecture/02_compute_architecture \ |
| 50 | + 03_memory_models/03_memory_models \ |
| 51 | + 04_subgroup_operations/04_subgroup_operations \ |
| 52 | + 05_opencl_on_vulkan/05_opencl_on_vulkan \ |
| 53 | + 06_advanced_data_structures/06_advanced_data_structures \ |
| 54 | + 07_gpu_driven_pipelines/07_gpu_driven_pipelines \ |
| 55 | + 08_async_compute/08_async_compute \ |
| 56 | + 09_specialized_math/09_specialized_math \ |
| 57 | + 10_performance_optimization/10_performance_optimization; do |
| 58 | + if [ -f "$sample" ]; then |
| 59 | + echo "$sample built successfully" |
| 60 | + else |
| 61 | + echo "$sample build failed" |
| 62 | + exit 1 |
| 63 | + fi |
| 64 | + done |
| 65 | +
|
| 66 | + - os: windows-latest |
| 67 | + ccache: sccache |
| 68 | + vulkan-install: | |
| 69 | + if (Test-Path "C:\VulkanSDK") { |
| 70 | + Write-Host "Using cached Vulkan SDK" |
| 71 | + } else { |
| 72 | + Write-Host "Downloading Vulkan SDK..." |
| 73 | + choco install -y aria2 |
| 74 | + aria2c --split=16 --max-connection-per-server=16 --min-split-size=1M --dir="$env:TEMP" --out="vulkan-sdk.exe" "https://sdk.lunarg.com/sdk/download/latest/windows/vulkan-sdk.exe" |
| 75 | +
|
| 76 | + Write-Host "Installing minimal Vulkan SDK components..." |
| 77 | + try { |
| 78 | + Start-Process -FilePath "$env:TEMP\vulkan-sdk.exe" -ArgumentList "--accept-licenses --default-answer --confirm-command install --components VulkanRT,VulkanSDK64,VulkanDXC,VulkanTools" -Wait -NoNewWindow |
| 79 | + if (-not (Test-Path "C:\VulkanSDK")) { |
| 80 | + Write-Host "Vulkan SDK installation failed: C:\VulkanSDK directory not found" |
| 81 | + Write-Host "Attempting to install without specifying components..." |
| 82 | + Start-Process -FilePath "$env:TEMP\vulkan-sdk.exe" -ArgumentList "--accept-licenses --default-answer --confirm-command install" -Wait -NoNewWindow |
| 83 | + } |
| 84 | + } catch { |
| 85 | + Write-Host "Error installing Vulkan SDK: $_" |
| 86 | + Start-Process -FilePath "$env:TEMP\vulkan-sdk.exe" -ArgumentList "--accept-licenses --default-answer --confirm-command install" -Wait -NoNewWindow |
| 87 | + } |
| 88 | + } |
| 89 | +
|
| 90 | + $vulkanPath = "" |
| 91 | + if (Test-Path "C:\VulkanSDK") { |
| 92 | + if (Test-Path "C:\VulkanSDK\Latest") { |
| 93 | + $vulkanPath = "C:\VulkanSDK\Latest" |
| 94 | + } elseif (Test-Path "C:\VulkanSDK\latest") { |
| 95 | + $vulkanPath = "C:\VulkanSDK\latest" |
| 96 | + } else { |
| 97 | + $vulkanPath = Get-ChildItem "C:\VulkanSDK" | Where-Object { $_.PSIsContainer } | Sort-Object -Property Name -Descending | Select-Object -First 1 -ExpandProperty FullName |
| 98 | + } |
| 99 | + } |
| 100 | + if (-not $vulkanPath) { |
| 101 | + Write-Host "Warning: Vulkan SDK not found. Creating a temporary directory structure." |
| 102 | + New-Item -ItemType Directory -Force -Path "C:\VulkanSDK\latest\Include\vulkan" | Out-Null |
| 103 | + New-Item -ItemType Directory -Force -Path "C:\VulkanSDK\latest\Lib" | Out-Null |
| 104 | + New-Item -ItemType Directory -Force -Path "C:\VulkanSDK\latest\Bin" | Out-Null |
| 105 | + New-Item -ItemType File -Force -Path "C:\VulkanSDK\latest\Include\vulkan\vulkan.h" | Out-Null |
| 106 | + New-Item -ItemType File -Force -Path "C:\VulkanSDK\latest\Lib\vulkan-1.lib" | Out-Null |
| 107 | + $vulkanPath = "C:\VulkanSDK\latest" |
| 108 | + } |
| 109 | +
|
| 110 | + echo "VULKAN_SDK=$vulkanPath" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append |
| 111 | + echo "$vulkanPath\Bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append |
| 112 | + echo "CMAKE_PREFIX_PATH=$vulkanPath" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append |
| 113 | + echo "Vulkan_INCLUDE_DIR=$vulkanPath\Include" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append |
| 114 | + echo "Vulkan_LIBRARY=$vulkanPath\Lib\vulkan-1.lib" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append |
| 115 | +
|
| 116 | + Write-Host "Vulkan SDK path: $vulkanPath" |
| 117 | + deps-install: | |
| 118 | + .\attachments\compute\install_dependencies_windows.bat |
| 119 | + echo "CMAKE_TOOLCHAIN_FILE=$env:VCPKG_INSTALLATION_ROOT/scripts/buildsystems/vcpkg.cmake" >> $env:GITHUB_ENV |
| 120 | + test-cmd: | |
| 121 | + $samples = @( |
| 122 | + "02_compute_architecture", |
| 123 | + "03_memory_models", |
| 124 | + "04_subgroup_operations", |
| 125 | + "05_opencl_on_vulkan", |
| 126 | + "06_advanced_data_structures", |
| 127 | + "07_gpu_driven_pipelines", |
| 128 | + "08_async_compute", |
| 129 | + "09_specialized_math", |
| 130 | + "10_performance_optimization" |
| 131 | + ) |
| 132 | + foreach ($s in $samples) { |
| 133 | + if (Test-Path "$s/Release/$s.exe") { |
| 134 | + echo "$s built successfully" |
| 135 | + } else { |
| 136 | + echo "$s build failed" |
| 137 | + exit 1 |
| 138 | + } |
| 139 | + } |
| 140 | +
|
| 141 | + runs-on: ${{ matrix.os }} |
| 142 | + |
| 143 | + steps: |
| 144 | + - uses: actions/checkout@v3 |
| 145 | + |
| 146 | + - name: Cache vcpkg packages (Windows) |
| 147 | + if: runner.os == 'Windows' |
| 148 | + uses: actions/cache@v3 |
| 149 | + with: |
| 150 | + path: | |
| 151 | + ${{ env.VCPKG_INSTALLATION_ROOT }}/installed |
| 152 | + ${{ env.VCPKG_INSTALLATION_ROOT }}/packages |
| 153 | + ${{ env.VCPKG_INSTALLATION_ROOT }}/buildtrees |
| 154 | + ${{ env.VCPKG_INSTALLATION_ROOT }}/downloads |
| 155 | + ${{ runner.temp }}/vcpkg-cache |
| 156 | + key: ${{ runner.os }}-vcpkg-compute-${{ hashFiles('attachments/compute/install_dependencies_windows.bat', 'attachments/compute/CMakeLists.txt') }} |
| 157 | + restore-keys: | |
| 158 | + ${{ runner.os }}-vcpkg-compute- |
| 159 | + ${{ runner.os }}-vcpkg- |
| 160 | +
|
| 161 | + - name: Cache Vulkan SDK (Windows) |
| 162 | + if: runner.os == 'Windows' |
| 163 | + uses: actions/cache@v3 |
| 164 | + with: |
| 165 | + path: C:\VulkanSDK |
| 166 | + key: ${{ runner.os }}-vulkan-sdk-compute-${{ hashFiles('attachments/compute/CMakeLists.txt', 'attachments/compute/**/*.cpp') }} |
| 167 | + restore-keys: | |
| 168 | + ${{ runner.os }}-vulkan-sdk-compute- |
| 169 | + ${{ runner.os }}-vulkan-sdk- |
| 170 | +
|
| 171 | + - name: Cache apt packages (Ubuntu) |
| 172 | + if: runner.os == 'Linux' |
| 173 | + uses: actions/cache@v3 |
| 174 | + with: |
| 175 | + path: /var/cache/apt/archives |
| 176 | + key: ${{ runner.os }}-apt-compute-${{ hashFiles('.github/workflows/compute_ci.yml') }} |
| 177 | + restore-keys: | |
| 178 | + ${{ runner.os }}-apt-compute- |
| 179 | + ${{ runner.os }}-apt- |
| 180 | +
|
| 181 | + - name: Cache ccache files |
| 182 | + uses: actions/cache@v3 |
| 183 | + with: |
| 184 | + path: | |
| 185 | + ~/.ccache |
| 186 | + ~/.cache/sccache |
| 187 | + key: ${{ runner.os }}-${{ matrix.ccache }}-compute-${{ github.sha }} |
| 188 | + restore-keys: | |
| 189 | + ${{ runner.os }}-${{ matrix.ccache }}-compute- |
| 190 | + ${{ runner.os }}-${{ matrix.ccache }}- |
| 191 | +
|
| 192 | + - name: Cache Vulkan SDK (Ubuntu) |
| 193 | + if: runner.os == 'Linux' |
| 194 | + uses: actions/cache@v3 |
| 195 | + with: |
| 196 | + path: ${{ github.workspace }}/vulkan-sdk |
| 197 | + key: ${{ runner.os }}-vulkan-sdk-compute-${{ hashFiles('attachments/compute/CMakeLists.txt') }} |
| 198 | + restore-keys: | |
| 199 | + ${{ runner.os }}-vulkan-sdk-compute- |
| 200 | + ${{ runner.os }}-vulkan-sdk- |
| 201 | +
|
| 202 | + - name: Install ccache (Ubuntu) |
| 203 | + if: runner.os == 'Linux' |
| 204 | + run: | |
| 205 | + sudo apt-get update |
| 206 | + sudo apt-get install -y ccache |
| 207 | + ccache --max-size=2G |
| 208 | + ccache -z |
| 209 | + echo "CCACHE_DIR=$HOME/.ccache" >> $GITHUB_ENV |
| 210 | + echo "PATH=/usr/lib/ccache:$PATH" >> $GITHUB_ENV |
| 211 | +
|
| 212 | + - name: Cache sccache binary (Windows) |
| 213 | + if: runner.os == 'Windows' |
| 214 | + id: cache-sccache |
| 215 | + uses: actions/cache@v3 |
| 216 | + with: |
| 217 | + path: ${{ runner.temp }}/sccache |
| 218 | + key: ${{ runner.os }}-sccache-0.5.4 |
| 219 | + |
| 220 | + - name: Install sccache (Windows) |
| 221 | + if: runner.os == 'Windows' |
| 222 | + run: | |
| 223 | + if (Test-Path "$env:RUNNER_TEMP\sccache\sccache.exe") { |
| 224 | + Write-Host "Using cached sccache binary" |
| 225 | + $sccachePath = "$env:RUNNER_TEMP\sccache" |
| 226 | + } else { |
| 227 | + Write-Host "Downloading and installing sccache..." |
| 228 | + New-Item -ItemType Directory -Force -Path "$env:RUNNER_TEMP\sccache" |
| 229 | + aria2c --split=8 --max-connection-per-server=8 --min-split-size=1M --dir="$env:RUNNER_TEMP" --out="sccache.tar.gz" "https://github.com/mozilla/sccache/releases/download/v0.5.4/sccache-v0.5.4-x86_64-pc-windows-msvc.tar.gz" |
| 230 | + tar -xzf "$env:RUNNER_TEMP\sccache.tar.gz" --strip-components=1 -C "$env:RUNNER_TEMP\sccache" "sccache-v0.5.4-x86_64-pc-windows-msvc/sccache.exe" |
| 231 | + $sccachePath = "$env:RUNNER_TEMP\sccache" |
| 232 | + } |
| 233 | +
|
| 234 | + echo "$sccachePath" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append |
| 235 | + echo "SCCACHE_DIR=$HOME/.cache/sccache" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append |
| 236 | + echo "SCCACHE_CACHE_SIZE=4G" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append |
| 237 | + echo "SCCACHE_ERROR_LOG=$HOME/.cache/sccache/sccache.log" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append |
| 238 | + echo "SCCACHE_LOG=info" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append |
| 239 | + echo "RUST_LOG=sccache=info" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append |
| 240 | +
|
| 241 | + New-Item -ItemType Directory -Force -Path "$HOME/.cache/sccache" |
| 242 | + & "$sccachePath\sccache.exe" --version |
| 243 | +
|
| 244 | + - name: Install dependencies |
| 245 | + run: ${{ matrix.deps-install }} |
| 246 | + |
| 247 | + - name: Install Vulkan SDK |
| 248 | + run: ${{ matrix.vulkan-install }} |
| 249 | + |
| 250 | + - name: Verify Vulkan SDK (Linux) |
| 251 | + if: runner.os == 'Linux' |
| 252 | + run: | |
| 253 | + if [ -d "$VULKAN_SDK" ]; then |
| 254 | + echo "Vulkan SDK found at: $VULKAN_SDK" |
| 255 | + slangc --version || echo "Warning: slangc not found in PATH" |
| 256 | + else |
| 257 | + echo "Vulkan SDK not found!" |
| 258 | + exit 1 |
| 259 | + fi |
| 260 | +
|
| 261 | + - name: Verify Vulkan SDK (Windows) |
| 262 | + if: runner.os == 'Windows' |
| 263 | + run: | |
| 264 | + if (Test-Path $env:VULKAN_SDK) { |
| 265 | + echo "Vulkan SDK found at: $env:VULKAN_SDK" |
| 266 | + $criticalPaths = @( |
| 267 | + "$env:VULKAN_SDK\Include", |
| 268 | + "$env:VULKAN_SDK\Lib", |
| 269 | + "$env:VULKAN_SDK\Bin", |
| 270 | + "$env:VULKAN_SDK\Include\vulkan\vulkan.h", |
| 271 | + "$env:VULKAN_SDK\Lib\vulkan-1.lib" |
| 272 | + ) |
| 273 | + $allPathsExist = $true |
| 274 | + foreach ($path in $criticalPaths) { |
| 275 | + if (Test-Path $path) { echo "Found: $path" } |
| 276 | + else { echo "Missing: $path"; $allPathsExist = $false } |
| 277 | + } |
| 278 | + if (-not $allPathsExist) { |
| 279 | + echo "Warning: Vulkan SDK installation is incomplete, but continuing." |
| 280 | + } |
| 281 | + } else { |
| 282 | + echo "Warning: Vulkan SDK not found." |
| 283 | + } |
| 284 | +
|
| 285 | + - name: Configure CMake (Linux) |
| 286 | + if: runner.os == 'Linux' |
| 287 | + working-directory: ${{ github.workspace }}/attachments/compute |
| 288 | + run: | |
| 289 | + export CC="clang" |
| 290 | + export CXX="clang++" |
| 291 | + rm -rf build |
| 292 | + cmake -B build -G Ninja -DCMAKE_BUILD_TYPE=Release \ |
| 293 | + -DCMAKE_C_COMPILER_LAUNCHER=ccache \ |
| 294 | + -DCMAKE_CXX_COMPILER_LAUNCHER=ccache |
| 295 | +
|
| 296 | + - name: Configure CMake (Windows) |
| 297 | + if: runner.os == 'Windows' |
| 298 | + working-directory: ${{ github.workspace }}/attachments/compute |
| 299 | + run: | |
| 300 | + if (Test-Path "build") { Remove-Item -Recurse -Force "build" } |
| 301 | + cmake -B build -DCMAKE_BUILD_TYPE=Release ` |
| 302 | + -DVulkan_INCLUDE_DIR="$env:Vulkan_INCLUDE_DIR" ` |
| 303 | + -DVulkan_LIBRARY="$env:Vulkan_LIBRARY" ` |
| 304 | + -DCMAKE_PREFIX_PATH="$env:VULKAN_SDK" ` |
| 305 | + -DCMAKE_PROGRAM_PATH="$env:VULKAN_SDK\Bin" ` |
| 306 | + -DCMAKE_TOOLCHAIN_FILE="$env:CMAKE_TOOLCHAIN_FILE" ` |
| 307 | + -DCMAKE_C_COMPILER_LAUNCHER=sccache ` |
| 308 | + -DCMAKE_CXX_COMPILER_LAUNCHER=sccache ` |
| 309 | + -DCMAKE_CXX_FLAGS="/MP /EHsc /W3 /O2" |
| 310 | +
|
| 311 | + - name: Build |
| 312 | + working-directory: ${{ github.workspace }}/attachments/compute |
| 313 | + run: cmake --build build --config Release --parallel 4 |
| 314 | + |
| 315 | + - name: ccache statistics |
| 316 | + if: runner.os == 'Linux' |
| 317 | + run: ccache -s |
| 318 | + |
| 319 | + - name: sccache statistics |
| 320 | + if: runner.os == 'Windows' |
| 321 | + run: sccache -s |
| 322 | + |
| 323 | + - name: Test Build Output |
| 324 | + working-directory: ${{ github.workspace }}/attachments/compute/build |
| 325 | + run: ${{ matrix.test-cmd }} |
0 commit comments