Verify C++ project template with CUDA #9
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: verify_cpp_cuda_template | |
| run-name: Verify C++ project template with CUDA | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| enable_optix: | |
| description: "Enable OptiX (requires SDK on runner)" | |
| required: true | |
| default: "false" | |
| type: choice | |
| options: | |
| - "false" | |
| - "true" | |
| enable_tbb: | |
| description: "Enable oneTBB (requires TBB on runner)" | |
| required: true | |
| default: "false" | |
| type: choice | |
| options: | |
| - "false" | |
| - "true" | |
| push: | |
| tags: | |
| - "v*.*.*" | |
| concurrency: | |
| group: cuda-ci-${{ github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| build: | |
| if: ${{ vars.CI_USE_SELF_HOSTED == 'true' }} | |
| runs-on: | |
| - self-hosted | |
| - Linux | |
| - X64 | |
| - gpu | |
| - cuda | |
| timeout-minutes: 90 | |
| env: | |
| BUILD_DIR: build_cuda_ci | |
| BUILD_TYPE: RelWithDebInfo | |
| CTEST_OUTPUT_ON_FAILURE: 1 | |
| ENABLE_OPTIX: ${{ github.event.inputs.enable_optix == 'true' && 'ON' || 'OFF' }} | |
| ENABLE_TBB: ${{ github.event.inputs.enable_tbb == 'true' && 'ON' || 'OFF' }} | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Validate CUDA prerequisites | |
| run: | | |
| command -v cmake | |
| command -v ninja | |
| command -v g++ | |
| command -v ccache | |
| command -v nvcc | |
| command -v nvidia-smi | |
| command -v python3 | |
| python3 -m pytest --version | |
| python3 -c 'import yaml' | |
| command -v doxygen | |
| command -v dot | |
| nvidia-smi | |
| nvcc --version | |
| - name: Verify dormant workflow templates | |
| id: workflow_contracts | |
| run: python3 -m pytest -q tests/template_test/testWorkflowTemplates.py | |
| - name: Restore compiler cache | |
| uses: actions/cache@v4 | |
| with: | |
| path: ~/.ccache | |
| key: ccache-cuda-${{ runner.os }}-${{ github.ref_name }}-${{ hashFiles('CMakeLists.txt', 'cmake/**', 'src/**', 'tests/**', '.github/workflows/build_linux_cuda.yml', '.github/workflows/build_linux_cuda.yml.tpl') }} | |
| restore-keys: | | |
| ccache-cuda-${{ runner.os }}-${{ github.ref_name }}- | |
| ccache-cuda-${{ runner.os }}- | |
| - name: Materialize tailored CUDA project | |
| id: materialize_tailored_project | |
| shell: bash | |
| run: | | |
| set -Eeuo pipefail | |
| ./tailor_template_cleanup.sh --apply --yes --project-namespace tailored_project | |
| test -z "$(find .github/workflows -maxdepth 1 -name '*.tpl' -print -quit)" | |
| python3 -c 'import pathlib, yaml; [yaml.safe_load(path.read_text()) for path in pathlib.Path(".github/workflows").glob("*.yml")]' | |
| - name: Configure | |
| run: | | |
| # Build artifacts are tested in a separate job, so keep CPU flags portable. | |
| cmake -S . -B "${BUILD_DIR}" -GNinja \ | |
| -DCMAKE_BUILD_TYPE="${BUILD_TYPE}" \ | |
| -DCMAKE_EXPORT_COMPILE_COMMANDS=ON \ | |
| -DENABLE_TESTS=ON \ | |
| -DENABLE_CUDA=ON \ | |
| -DENABLE_OPTIX="${ENABLE_OPTIX}" \ | |
| -DENABLE_TBB="${ENABLE_TBB}" \ | |
| -DENABLE_OPENGL=OFF \ | |
| -DCPU_ENABLE_NATIVE_TUNING=OFF \ | |
| -DCUDA_ENABLE_FMAD=ON \ | |
| -DCUDA_ENABLE_EXTRA_DEVICE_VECTORIZATION=ON \ | |
| -DCMAKE_C_COMPILER_LAUNCHER=ccache \ | |
| -DCMAKE_CXX_COMPILER_LAUNCHER=ccache | |
| - name: Build | |
| run: cmake --build "${BUILD_DIR}" --parallel 4 | |
| - name: Verify project CUDA source graph | |
| shell: bash | |
| run: | | |
| set -Eeuo pipefail | |
| compile_commands="${BUILD_DIR}/compile_commands.json" | |
| test -f "${compile_commands}" | |
| if ! grep -Fq "src/template_src_kernels/placeholder.cu" "${compile_commands}"; then | |
| echo "Project CUDA source is absent from the compiled target graph." >&2 | |
| exit 1 | |
| fi | |
| if grep -Fq "placeholder_to_ptx.ptx.cu" "${compile_commands}"; then | |
| echo "OptiX PTX input entered ordinary CUDA compilation." >&2 | |
| exit 1 | |
| fi | |
| - name: Show ccache stats | |
| run: ccache --show-stats || true | |
| - name: Upload build artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: cmake-build-tree-cuda | |
| path: ${{ env.BUILD_DIR }} | |
| if-no-files-found: error | |
| retention-days: 3 | |
| test: | |
| needs: build | |
| if: ${{ vars.CI_USE_SELF_HOSTED == 'true' }} | |
| runs-on: | |
| - self-hosted | |
| - Linux | |
| - X64 | |
| - gpu | |
| - cuda | |
| timeout-minutes: 45 | |
| env: | |
| BUILD_DIR: build_cuda_ci | |
| CTEST_OUTPUT_ON_FAILURE: 1 | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Validate test prerequisites | |
| run: | | |
| command -v ctest | |
| command -v python3 | |
| python3 -m pytest --version | |
| python3 -c 'import yaml' | |
| command -v doxygen | |
| command -v dot | |
| - name: Match tailored project source tree | |
| shell: bash | |
| run: | | |
| set -Eeuo pipefail | |
| ./tailor_template_cleanup.sh --apply --yes --project-namespace tailored_project | |
| test -z "$(find .github/workflows -maxdepth 1 -name '*.tpl' -print -quit)" | |
| - name: Download build artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: cmake-build-tree-cuda | |
| path: ${{ env.BUILD_DIR }} | |
| - name: Resolve downloaded build tree | |
| run: | | |
| if [ -d "${BUILD_DIR}/CMakeFiles" ]; then | |
| echo "CTEST_DIR=${BUILD_DIR}" >> "$GITHUB_ENV" | |
| elif [ -d "${BUILD_DIR}/${BUILD_DIR}/CMakeFiles" ]; then | |
| echo "CTEST_DIR=${BUILD_DIR}/${BUILD_DIR}" >> "$GITHUB_ENV" | |
| else | |
| echo "Could not find CMakeFiles under '${BUILD_DIR}' after artifact download." | |
| find "${BUILD_DIR}" -maxdepth 3 -type d | sort || true | |
| exit 1 | |
| fi | |
| - name: Restore test executable permissions | |
| run: | | |
| # GitHub artifact download may drop executable bits from binaries. | |
| find "${CTEST_DIR}" -type f -path "*/tests/*" -exec chmod +x {} + || true | |
| - name: Test | |
| run: ctest --test-dir "${CTEST_DIR}" --output-on-failure --parallel 2 --no-tests=error |