Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
287 changes: 287 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,287 @@
name: CI

on:
push:
branches: [main]
pull_request:
branches: [main]
workflow_dispatch:

permissions:
contents: read

concurrency:
group: ci-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

env:
CTEST_OUTPUT_ON_FAILURE: "1"
VCPKG_DISABLE_METRICS: "1"
VCPKG_DEFAULT_BINARY_CACHE: ${{ github.workspace }}/.cache/vcpkg-binaries

jobs:
build-test-install:
name: ${{ matrix.name }}
runs-on: ${{ matrix.os }}
timeout-minutes: 35
strategy:
fail-fast: false
matrix:
include:
- name: windows-msvc-release-tbb
os: windows-latest
compiler: msvc
build_type: Release
tbb: "ON"
cc: ""
cxx: ""
- name: linux-gcc-debug-no-tbb
os: ubuntu-latest
compiler: gcc
build_type: Debug
tbb: "OFF"
cc: gcc
cxx: g++
- name: linux-gcc-release-tbb
os: ubuntu-latest
compiler: gcc
build_type: Release
tbb: "ON"
cc: gcc
cxx: g++
- name: linux-clang-release-tbb
os: ubuntu-latest
compiler: clang
build_type: Release
tbb: "ON"
cc: clang
cxx: clang++
- name: macos-appleclang-release-tbb
os: macos-latest
compiler: appleclang
build_type: Release
tbb: "ON"
cc: clang
cxx: clang++

steps:
- name: Check out SmartParallel
uses: actions/checkout@v4

- name: Cache vcpkg binary packages
if: matrix.tbb == 'ON'
uses: actions/cache@v4
with:
path: .cache/vcpkg-binaries
key: vcpkg-binaries-${{ runner.os }}-${{ matrix.compiler }}-${{ hashFiles('vcpkg.json') }}
restore-keys: |
vcpkg-binaries-${{ runner.os }}-${{ matrix.compiler }}-

- name: Cache fallback vcpkg checkout
if: matrix.tbb == 'ON'
uses: actions/cache@v4
with:
path: .cache/vcpkg-source
key: vcpkg-source-${{ runner.os }}-2026-07

- name: Resolve vcpkg on Windows
if: matrix.tbb == 'ON' && runner.os == 'Windows'
shell: pwsh
run: |
$root = $env:VCPKG_INSTALLATION_ROOT
if (-not $root) {
$command = Get-Command vcpkg -ErrorAction SilentlyContinue
if ($command) {
$candidate = Split-Path -Parent $command.Source
if (Test-Path "$candidate/scripts/buildsystems/vcpkg.cmake") {
$root = $candidate
}
}
}
if (-not $root -or -not (Test-Path "$root/scripts/buildsystems/vcpkg.cmake")) {
$root = Join-Path $env:GITHUB_WORKSPACE ".cache/vcpkg-source"
if (-not (Test-Path "$root/.git")) {
git clone --depth 1 https://github.com/microsoft/vcpkg.git $root
}
& "$root/bootstrap-vcpkg.bat" -disableMetrics
}
$root = (Resolve-Path $root).Path.Replace('\', '/')
New-Item -ItemType Directory -Force $env:VCPKG_DEFAULT_BINARY_CACHE | Out-Null
"VCPKG_ROOT=$root" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append

- name: Resolve vcpkg on Unix
if: matrix.tbb == 'ON' && runner.os != 'Windows'
shell: bash
run: |
set -euo pipefail
root=""
candidates=(
"${VCPKG_INSTALLATION_ROOT:-}"
"/usr/local/share/vcpkg"
"/opt/homebrew/share/vcpkg"
)
if command -v vcpkg >/dev/null 2>&1; then
executable="$(python3 -c 'import os,sys; print(os.path.realpath(sys.argv[1]))' "$(command -v vcpkg)")"
candidates+=("$(dirname "$executable")")
fi
for candidate in "${candidates[@]}"; do
if [[ -n "$candidate" && -f "$candidate/scripts/buildsystems/vcpkg.cmake" ]]; then
root="$candidate"
break
fi
done
if [[ -z "$root" ]]; then
root="$GITHUB_WORKSPACE/.cache/vcpkg-source"
if [[ ! -d "$root/.git" ]]; then
rm -rf "$root"
git clone --depth 1 https://github.com/microsoft/vcpkg.git "$root"
fi
if [[ ! -x "$root/vcpkg" ]]; then
"$root/bootstrap-vcpkg.sh" -disableMetrics
fi
fi
mkdir -p "$VCPKG_DEFAULT_BINARY_CACHE"
echo "VCPKG_ROOT=$root" >> "$GITHUB_ENV"

- name: Configure on Windows
if: runner.os == 'Windows'
shell: pwsh
run: |
if ('${{ matrix.tbb }}' -eq 'OFF') {
Remove-Item Env:VCPKG_ROOT -ErrorAction SilentlyContinue
}
$arguments = @(
'-S', '.',
'-B', 'build/ci',
'-A', 'x64',
'-DSMARTPARALLEL_BUILD_VALIDATION=ON',
'-DSMARTPARALLEL_BUILD_BENCHMARKS=OFF',
'-DSMARTPARALLEL_BUILD_REAL_WORLD_BENCHMARKS=OFF',
'-DSMARTPARALLEL_INSTALL=ON',
'-DSMARTPARALLEL_ENABLE_TBB=${{ matrix.tbb }}',
'-DSMARTPARALLEL_REQUIRE_TBB=${{ matrix.tbb }}',
'-DCMAKE_INSTALL_PREFIX=${{ github.workspace }}/build/install'
)
if ('${{ matrix.tbb }}' -eq 'ON') {
$arguments += '-DVCPKG_INSTALLED_DIR=${{ github.workspace }}/build/vcpkg_installed'
}
cmake @arguments

- name: Configure on Unix
if: runner.os != 'Windows'
shell: bash
env:
CC: ${{ matrix.cc }}
CXX: ${{ matrix.cxx }}
run: |
set -euo pipefail
if [[ '${{ matrix.tbb }}' == 'OFF' ]]; then
unset VCPKG_ROOT VCPKG_INSTALLATION_ROOT
fi
arguments=(
-S .
-B build/ci
-G Ninja
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
-DSMARTPARALLEL_BUILD_VALIDATION=ON
-DSMARTPARALLEL_BUILD_BENCHMARKS=OFF
-DSMARTPARALLEL_BUILD_REAL_WORLD_BENCHMARKS=OFF
-DSMARTPARALLEL_INSTALL=ON
-DSMARTPARALLEL_ENABLE_TBB=${{ matrix.tbb }}
-DSMARTPARALLEL_REQUIRE_TBB=${{ matrix.tbb }}
-DCMAKE_INSTALL_PREFIX=${{ github.workspace }}/build/install
)
if [[ '${{ matrix.tbb }}' == 'ON' ]]; then
arguments+=("-DVCPKG_INSTALLED_DIR=${GITHUB_WORKSPACE}/build/vcpkg_installed")
fi
cmake "${arguments[@]}"

- name: Build SmartParallel
shell: bash
run: cmake --build build/ci --config ${{ matrix.build_type }} --parallel 2

- name: Run deterministic correctness tests
shell: bash
run: ctest --test-dir build/ci -C ${{ matrix.build_type }} --output-on-failure --parallel 2

- name: Install SmartParallel
shell: bash
run: cmake --install build/ci --config ${{ matrix.build_type }}

- name: Configure installed-package consumer on Windows
if: runner.os == 'Windows'
shell: pwsh
run: |
$arguments = @(
'-S', 'tests/package-consumer',
'-B', 'build/package-consumer',
'-A', 'x64',
'-DCMAKE_PREFIX_PATH=${{ github.workspace }}/build/install'
)
if ('${{ matrix.tbb }}' -eq 'ON') {
$arguments += "-DCMAKE_TOOLCHAIN_FILE=$env:VCPKG_ROOT/scripts/buildsystems/vcpkg.cmake"
$arguments += '-DVCPKG_INSTALLED_DIR=${{ github.workspace }}/build/vcpkg_installed'
}
cmake @arguments

- name: Configure installed-package consumer on Unix
if: runner.os != 'Windows'
shell: bash
env:
CC: ${{ matrix.cc }}
CXX: ${{ matrix.cxx }}
run: |
set -euo pipefail
arguments=(
-S tests/package-consumer
-B build/package-consumer
-G Ninja
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
-DCMAKE_PREFIX_PATH=${GITHUB_WORKSPACE}/build/install
)
if [[ '${{ matrix.tbb }}' == 'ON' ]]; then
arguments+=(
"-DCMAKE_TOOLCHAIN_FILE=${VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake"
"-DVCPKG_INSTALLED_DIR=${GITHUB_WORKSPACE}/build/vcpkg_installed"
)
fi
cmake "${arguments[@]}"

- name: Build installed-package consumer
shell: bash
run: cmake --build build/package-consumer --config ${{ matrix.build_type }} --parallel 2

- name: Test installed-package consumer
shell: bash
run: ctest --test-dir build/package-consumer -C ${{ matrix.build_type }} --output-on-failure

sanitizers:
name: linux-clang-debug-asan-ubsan
runs-on: ubuntu-latest
timeout-minutes: 25
env:
CC: clang
CXX: clang++
ASAN_OPTIONS: detect_leaks=1:halt_on_error=1
UBSAN_OPTIONS: print_stacktrace=1:halt_on_error=1
steps:
- name: Check out SmartParallel
uses: actions/checkout@v4

- name: Configure sanitizer build
shell: bash
run: |
cmake -S . -B build/sanitizers -G Ninja \
-DCMAKE_BUILD_TYPE=Debug \
-DSMARTPARALLEL_BUILD_VALIDATION=ON \
-DSMARTPARALLEL_BUILD_BENCHMARKS=OFF \
-DSMARTPARALLEL_BUILD_REAL_WORLD_BENCHMARKS=OFF \
-DSMARTPARALLEL_ENABLE_TBB=OFF \
-DSMARTPARALLEL_ENABLE_SANITIZERS=ON \
-DSMARTPARALLEL_INSTALL=OFF

- name: Build sanitizer targets
run: cmake --build build/sanitizers --parallel 2

- name: Run sanitizer correctness tests
run: ctest --test-dir build/sanitizers --output-on-failure --parallel 1
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ cmake_install.cmake

# Local dependencies
vcpkg_installed/
.cache/

# Compiled binaries and objects
*.exe
Expand Down
33 changes: 33 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,38 @@

All notable public changes to SmartParallel are documented here. Detailed internal milestone history is retained in [`docs/archive/v1.1-development/CHANGELOG_DEVELOPMENT_HISTORY.md`](docs/archive/v1.1-development/CHANGELOG_DEVELOPMENT_HISTORY.md).

## [1.3.0] — Cross-platform CI and portability

### Added

- GitHub Actions build and correctness-test coverage for Windows/MSVC, Linux/GCC, Linux/Clang, and macOS/Apple Clang.
- Required oneTBB validation on Windows, Linux Release, Clang Release, and macOS, plus a Linux Debug configuration with oneTBB disabled.
- AddressSanitizer and UndefinedBehaviorSanitizer validation with Linux Clang.
- Installed CMake package validation through a separate external consumer project.
- Persistent vcpkg binary caching and a cached fallback vcpkg checkout for hosted runners.
- Cross-platform CI, installation, and portability documentation.
- CI-focused CMake presets for TBB-disabled, TBB-required, and sanitizer builds.

### Fixed

- Exported the standard `Threads::Threads` dependency so installed-package consumers link portably on Unix-like systems.
- Added native hardware discovery on Linux using process affinity, sysfs CPU topology, cache descriptors, NUMA nodes, and `sysconf` page size.
- Added native hardware discovery on macOS using `sysctl` logical/physical CPU, cache, cache-line, and page-size values, with a conservative one-node NUMA fallback.
- Improved Linux and macOS processor-model metadata for manually run real-world benchmarks.
- Made the nested-frontier mechanics test independent of callback timing and exact frontier depth. It now verifies the invariant contract—defer underfilled outer levels, establish a bounded frontier at level 3 or 4, suppress descendants when level 3 is selected, execute exactly once, and stay within the root lease budget—without changing production scheduler behavior.

### Validation

- The final v1.3 pull-request workflow passed all six jobs: Windows/MSVC Release with oneTBB, Linux/GCC Debug without oneTBB, Linux/GCC Release with oneTBB, Linux/Clang Release with oneTBB, macOS/Apple Clang Release with oneTBB, and Linux/Clang ASan+UBSan.
- Each normal platform job passed the 16 deterministic CTest tests, installation, and the external installed-package consumer.
- Real-world performance benchmarks were not executed in CI.

### Compatibility

- Scheduler behavior, nested execution semantics, public APIs, and benchmark algorithms are unchanged. One validation assertion was made compiler- and platform-independent without changing its correctness intent.
- The installable target remains `SmartParallel::smart_parallel`.
- Real-world performance benchmarks remain manual and are not CI merge gates.

## [1.1.0] — Nested parallelism coordination

### Added
Expand Down Expand Up @@ -45,5 +77,6 @@ All notable public changes to SmartParallel are documented here. Detailed intern
- Added ThreadPool, StaticThread, oneTBB, and sequential execution paths.
- Added bounded runtime experience, diagnostics, validation programs, and the original OpenCV/scientific benchmark suite.

[1.3.0]: docs/v1.3/release-notes.md
[1.1.0]: docs/v1.1/release-notes.md
[1.0.0]: docs/v1.0/README.md
20 changes: 19 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,39 @@ endif()

project(
SmartParallel
VERSION 1.1.0
VERSION 1.3.0
DESCRIPTION "Adaptive parallel scheduling for modern C++"
LANGUAGES CXX
)

include(GNUInstallDirs)
include(CMakePackageConfigHelpers)

find_package(Threads REQUIRED)

list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")

option(SMARTPARALLEL_BUILD_EXAMPLES "Build the SmartParallel example" OFF)
option(SMARTPARALLEL_BUILD_VALIDATION "Build all validation and hardening targets" OFF)
option(SMARTPARALLEL_BUILD_BENCHMARKS "Build all benchmark targets" OFF)
option(SMARTPARALLEL_BUILD_ALL "Build examples, validation, and benchmarks" OFF)
option(SMARTPARALLEL_INSTALL "Generate SmartParallel install and package targets" ON)
option(SMARTPARALLEL_ENABLE_SANITIZERS
"Enable AddressSanitizer and UndefinedBehaviorSanitizer for local/CI validation"
OFF)

if(SMARTPARALLEL_ENABLE_SANITIZERS)
if(MSVC)
message(FATAL_ERROR
"SMARTPARALLEL_ENABLE_SANITIZERS currently supports GCC and Clang only")
elseif(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
add_compile_options(-fsanitize=address,undefined -fno-omit-frame-pointer)
add_link_options(-fsanitize=address,undefined)
else()
message(FATAL_ERROR
"SMARTPARALLEL_ENABLE_SANITIZERS is unsupported by ${CMAKE_CXX_COMPILER_ID}")
endif()
endif()

# Fine-grained compatibility options retained from the original build.
option(SMARTPARALLEL_BUILD_V1_PHASE1
Expand Down
Loading
Loading