Skip to content

Write merged input yaml to output dir #38

Write merged input yaml to output dir

Write merged input yaml to output dir #38

Workflow file for this run

name: Build and test
on:
workflow_dispatch:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
build-and-test:
runs-on: ubuntu-latest
# Fetch docker image with specific gcc version prebuilt
container: gcc:${{ matrix.gcc }}
strategy:
matrix:
gcc: [11.2, 14.3]
steps:
- name: Detect CPU count
run: echo "NPROC=$(nproc)" >> "$GITHUB_ENV"
- uses: actions/checkout@v6
with:
submodules: 'recursive'
- name: Install dependencies
run: |
apt-get update
apt-get install -y cmake curl zip unzip tar
- name: Cache vcpkg binary cache
uses: actions/cache@v5
with:
path: vcpkg-binary-cache
key: vcpkg-bincache-${{ runner.os }}-gcc${{ matrix.gcc }}-${{ hashFiles('Code.v05-00/vcpkg.json') }}
# For some reason we need to specify the working directory AND create the vcpkg-binary-cache/ directory
# in this step otherwise vcpkg will fail during CMake configure when there are no cached files on the
# GitHub Actions Cache (if there are cached files, it works...).
# The error being that the VCPKG_DEFAULT_BINARY_CACHE variable is not a directory.
# This is unclear to me why it does not work, and might be related to Docker things...
- name: Configure CMake
working-directory: ${{ github.workspace }}
env:
VCPKG_DEFAULT_BINARY_CACHE: ${{ github.workspace }}/vcpkg-binary-cache
run: |
mkdir -p vcpkg-binary-cache
cmake -B build -S Code.v05-00 -DCMAKE_BUILD_TYPE=Release
# Build with the detected number of CPUs or 1 if detection failed
- name: Build
run: cmake --build build -j"${NPROC:-1}"
- name: Run tests
working-directory: ./build
run: ctest --output-on-failure
# Additional multithreading reproducibility step for one build (no need to do it for both)
- name: Install uv for multithreading reproducibility test
if: strategy.job-index == 0
uses: astral-sh/setup-uv@v9.0.0
- name: Multithreading reproducibility test
if: strategy.job-index == 0
shell: bash
timeout-minutes: 15
env:
PYTHONUNBUFFERED: "1"
# Run steps:
# Define where the test is and where its inputs are
# Run APCEMM twice, using a base.yaml overridden by a second yaml setting the thread count to 1 or 4
# Use tee to also write stdout to a log file
# grep the log to ensure that APCEMM correctly ran with the expected number of threads
# Run the comparison script with uv to ensure they are bitwise identical
run: |
TEST_DIR="$GITHUB_WORKSPACE/Code.v05-00/tests/multithreading"
INPUTS="$TEST_DIR/inputs"
"$GITHUB_WORKSPACE/build/APCEMM" "$INPUTS/base.yaml" "$INPUTS/1_thread.yaml" | tee run_1_thread.log
"$GITHUB_WORKSPACE/build/APCEMM" "$INPUTS/base.yaml" "$INPUTS/4_threads.yaml" | tee run_4_threads.log
grep -q ">>> APCEMM OpenMP Num Threads is set to 1$" run_1_thread.log
grep -q ">>> APCEMM OpenMP Num Threads is set to 4$" run_4_threads.log
uv run "$TEST_DIR/compare_outputs.py" "$TEST_DIR/APCEMM_out_1_thread/" "$TEST_DIR/APCEMM_out_4_threads/"