Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
94 commits
Select commit Hold shift + click to select a range
f65e640
Implementing hierarchical distributor
ryanstocks00 Aug 22, 2025
2d0357e
Update leak suppressions
ryanstocks00 Aug 22, 2025
c05bfd1
A bit of cleanup
ryanstocks00 Aug 22, 2025
47b7362
Added missing include
ryanstocks00 Aug 22, 2025
7556b97
Hopefully make msvc happy
ryanstocks00 Aug 22, 2025
ce38e0f
Fix and test printing functions
ryanstocks00 Aug 23, 2025
c85918a
Small test improvements
ryanstocks00 Aug 23, 2025
206d592
Gather task counts
ryanstocks00 Aug 23, 2025
5c62ccb
Additonal assert
ryanstocks00 Aug 23, 2025
5878987
Test asserts
ryanstocks00 Aug 23, 2025
707656f
m_ for member variables
ryanstocks00 Aug 23, 2025
8eee9da
Fixing assert tests
ryanstocks00 Aug 23, 2025
6062b70
Added test for assert during throw
ryanstocks00 Aug 23, 2025
82d0ba0
Maybe not constexpr
ryanstocks00 Aug 23, 2025
369f707
Frontier benchmarking
ryanstocks00 Aug 24, 2025
5614551
Formatting fixes
ryanstocks00 Jan 13, 2026
e0b15cd
Fixed undefined variable
ryanstocks00 Jan 13, 2026
9fd8fb8
Small CI fixes
ryanstocks00 Jan 14, 2026
cc340c7
Code review fixes
ryanstocks00 Jan 14, 2026
ef1bca6
Bug fix
ryanstocks00 Jan 14, 2026
eadfc3a
Fix error handling
ryanstocks00 Jan 14, 2026
23751b7
Propogate errors properly
ryanstocks00 Jan 14, 2026
f8a37c2
Merge branch 'main' into hierarchical
ryanstocks00 Jan 14, 2026
3e1cc27
Maybe fixed deadlocking
ryanstocks00 Jan 14, 2026
e20968c
Fix unused variable and apache 2
ryanstocks00 Jan 14, 2026
9fbe32b
Maybe fixed?
ryanstocks00 Jan 14, 2026
39a6d8d
Fix stupid deadlock
ryanstocks00 Jan 14, 2026
f54a100
Hopefully fixed deadlock
ryanstocks00 Jan 19, 2026
e57ffd5
Hopefully fixed deadlock
ryanstocks00 Jan 19, 2026
6945633
Extend CI and no parallels
ryanstocks00 Jan 19, 2026
c05b22b
Less children per worker
ryanstocks00 Jan 19, 2026
a4b3627
Barrier after distribution
ryanstocks00 Jan 19, 2026
079c1f7
Don't run big tests in CI
ryanstocks00 Jan 19, 2026
2a525cd
Better cast
ryanstocks00 Jan 19, 2026
9e675dd
Fixes
ryanstocks00 Jan 19, 2026
8c5c2d4
Fix codacy issues
ryanstocks00 Jan 19, 2026
9c52611
Remove barrier
ryanstocks00 Jan 19, 2026
5d3b655
coverage
ryanstocks00 Jan 19, 2026
db2b477
Don't finalize inside error handling
ryanstocks00 Jan 19, 2026
57eb778
Aurora scripts
ryanstocks00 Jan 19, 2026
76c29af
Aurora scripts
ryanstocks00 Jan 19, 2026
1995d5a
Aurora scripts
ryanstocks00 Jan 19, 2026
8d749ed
aurora compile
ryanstocks00 Jan 19, 2026
d4ef865
aurora fixes
ryanstocks00 Jan 19, 2026
7c345a6
Update launch scripts
ryanstocks00 Jan 19, 2026
10d52ac
Write to different csv files
ryanstocks00 Jan 19, 2026
726fd88
First pass results
ryanstocks00 Jan 19, 2026
b2d9f8d
More strong scaling calcs
ryanstocks00 Jan 19, 2026
485aea7
Spin wait correct units
ryanstocks00 Jan 19, 2026
6023954
Specify frontier account
ryanstocks00 Jan 19, 2026
fa01286
Partial distributions
ryanstocks00 Jan 19, 2026
8f8ea16
Frontier use 56 ranks per node
ryanstocks00 Jan 19, 2026
4603f5b
Shift finalize
ryanstocks00 Jan 19, 2026
4a708d7
Shift finalize
ryanstocks00 Jan 19, 2026
3ebcaf6
New benchmark
ryanstocks00 Jan 20, 2026
be1ab38
Improved distribution benchmark
ryanstocks00 Jan 20, 2026
53e001c
Frontier results
ryanstocks00 Jan 20, 2026
3652a81
Test timer resolution and launch script
ryanstocks00 Jan 20, 2026
83cf773
CI fixes
ryanstocks00 Jan 20, 2026
f578b97
Better benchmark
ryanstocks00 Jan 20, 2026
372396d
More fixes
ryanstocks00 Jan 20, 2026
5dd2c7b
Frontier results
ryanstocks00 Jan 20, 2026
4941b77
Cleaning up duplications
ryanstocks00 Jan 20, 2026
96967d6
Naive distributer cleanup
ryanstocks00 Jan 20, 2026
1732ecd
Removed error handling for now
ryanstocks00 Jan 20, 2026
a1b6e02
Some refactoring
ryanstocks00 Jan 20, 2026
ac1e8f4
Naive distributer perf improvement?
ryanstocks00 Jan 20, 2026
1b7f803
Aurora strong scaling with software matching
ryanstocks00 Jan 20, 2026
f086935
Minor improvements
ryanstocks00 Jan 21, 2026
a85c92a
Remove return new results only
ryanstocks00 Jan 21, 2026
e750e41
Stop distributing benchmark
ryanstocks00 Jan 21, 2026
329bb78
Cleanup aurora scaling output
ryanstocks00 Jan 21, 2026
b84ce90
Use short job id
ryanstocks00 Jan 21, 2026
2e7d297
Fixed naive shutdown benchmark
ryanstocks00 Jan 21, 2026
0dde562
Frontier shutdown results
ryanstocks00 Jan 21, 2026
ff4f178
f
ryanstocks00 Jan 21, 2026
14418e1
First batch aurora shutdown
ryanstocks00 Jan 21, 2026
2ed2c4a
More auroras
ryanstocks00 Jan 21, 2026
cb4e475
Improved shutdown plot
ryanstocks00 Jan 21, 2026
b30700f
nodelocal
ryanstocks00 Jan 21, 2026
afce53c
More frontier results
ryanstocks00 Jan 21, 2026
9fe8a51
MPI C Bool
ryanstocks00 Jan 22, 2026
0071f22
Merge pull request #6 from ryanstocks00/nodelocal
ryanstocks00 Jan 22, 2026
da188e7
Safe MPI Group
ryanstocks00 Jan 23, 2026
521d084
Use groups for hierarchical
ryanstocks00 Jan 23, 2026
4739f1f
More testing
ryanstocks00 Jan 23, 2026
2daadcc
Merge branch 'main' into hierarchical
ryanstocks00 Feb 17, 2026
bef9929
Fix test ordering
ryanstocks00 Feb 17, 2026
20ef237
Print job submission commands
ryanstocks00 Feb 17, 2026
8e3717e
Better printing
ryanstocks00 Feb 17, 2026
8c38ba5
Adapt to aurora being difficult
ryanstocks00 Feb 17, 2026
444a915
Improving coverage and aurora being special
ryanstocks00 Feb 20, 2026
99b496e
Add cppcheck
ryanstocks00 Feb 20, 2026
a56b71d
Simplify process_incoming_message
ryanstocks00 Feb 20, 2026
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
2 changes: 1 addition & 1 deletion .github/workflows/codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ on:
jobs:
codecov:
runs-on: ubuntu-latest
timeout-minutes: 10
timeout-minutes: 5
steps:
- name: Checkout Repository
uses: actions/checkout@v4
Expand Down
7 changes: 5 additions & 2 deletions .github/workflows/linux-clang.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ env:
jobs:
linux-clang:
runs-on: ubuntu-latest
timeout-minutes: 10
strategy:
matrix:
clang-version: [14, 15, 16, 17, 18]
Expand Down Expand Up @@ -75,7 +76,8 @@ jobs:
-DCMAKE_C_COMPILER=$CC \
-DCMAKE_CXX_COMPILER=$CXX \
-DDYNAMPI_BUILD_TESTS=ON \
-DDYNAMPI_BUILD_BENCHMARKS=ON"
-DDYNAMPI_BUILD_BENCHMARKS=ON \
-DDYNAMPI_MAX_MPI_RANK=8"

if [ "$MPI_TYPE" == "MPICH" ]; then
CMAKE_ARGS="$CMAKE_ARGS -DMPI_C_COMPILER=$CC -DMPI_CXX_COMPILER=$CXX"
Expand All @@ -102,4 +104,5 @@ jobs:
fi
cd build
echo "Testing with $MPI_TYPE"
ctest --output-on-failure --parallel -C ${{ matrix.build-type }}
export DYNAMPI_MAX_MPI_RANK=8
ctest --output-on-failure -j 1 --timeout 180 -C ${{ matrix.build-type }}
7 changes: 5 additions & 2 deletions .github/workflows/linux-gcc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ env:
jobs:
linux-gcc:
runs-on: ubuntu-latest
timeout-minutes: 10
strategy:
matrix:
gcc-version: [11, 12, 13, 14]
Expand Down Expand Up @@ -77,7 +78,8 @@ jobs:
-DCMAKE_C_COMPILER=$CC \
-DCMAKE_CXX_COMPILER=$CXX \
-DDYNAMPI_BUILD_TESTS=ON \
-DDYNAMPI_BUILD_BENCHMARKS=ON"
-DDYNAMPI_BUILD_BENCHMARKS=ON \
-DDYNAMPI_MAX_MPI_RANK=8"
if [ "$MPI_TYPE" == "MPICH" ]; then
CMAKE_ARGS="$CMAKE_ARGS -DMPI_C_COMPILER=$MPI_C_COMPILER -DMPI_CXX_COMPILER=$MPI_CXX_COMPILER"
fi
Expand All @@ -97,4 +99,5 @@ jobs:
fi
cd build
echo "Testing with $MPI_TYPE"
ctest --output-on-failure --parallel -C ${{ matrix.build-type }}
export DYNAMPI_MAX_MPI_RANK=8
ctest --output-on-failure -j 1 --timeout 180 -C ${{ matrix.build-type }}
7 changes: 5 additions & 2 deletions .github/workflows/linux-intel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ env:
jobs:
linux-intel:
runs-on: ubuntu-latest
timeout-minutes: 10
strategy:
matrix:
build-type: [Debug, Release]
Expand All @@ -37,7 +38,8 @@ jobs:
-DCMAKE_C_COMPILER=icx \
-DCMAKE_CXX_COMPILER=icpx \
-DDYNAMPI_BUILD_TESTS=ON \
-DDYNAMPI_BUILD_BENCHMARKS=ON
-DDYNAMPI_BUILD_BENCHMARKS=ON \
-DDYNAMPI_MAX_MPI_RANK=8
- name: Build with Intel
shell: bash
run: |
Expand All @@ -49,4 +51,5 @@ jobs:
source /opt/intel/oneapi/setvars.sh
cd build
echo "Testing with $MPI_TYPE"
ctest --output-on-failure --parallel -C ${{ matrix.build-type }}
export DYNAMPI_MAX_MPI_RANK=8
ctest --output-on-failure -j 1 --timeout 180 -C ${{ matrix.build-type }}
5 changes: 4 additions & 1 deletion .github/workflows/macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ env:
jobs:
macos-clang:
runs-on: macos-latest
timeout-minutes: 5
strategy:
matrix:
build-type: [Debug, Release]
Expand All @@ -29,7 +30,8 @@ jobs:
cmake -B build \
-DCMAKE_BUILD_TYPE=${{ matrix.build-type }} \
-DDYNAMPI_BUILD_TESTS=ON \
-DDYNAMPI_BUILD_BENCHMARKS=ON
-DDYNAMPI_BUILD_BENCHMARKS=ON \
-DDYNAMPI_MAX_MPI_RANK=8
- name: Build on macOS
shell: bash
run: cmake --build build --config ${{ matrix.build-type }} --parallel
Expand All @@ -38,4 +40,5 @@ jobs:
run: |
cd build
echo "Testing with $MPI_TYPE"
export DYNAMPI_MAX_MPI_RANK=8
ctest --output-on-failure --parallel -C ${{ matrix.build-type }}
1 change: 1 addition & 0 deletions .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ on:
jobs:
pre-commit:
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- uses: actions/checkout@v4
with:
Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/sanitizers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ env:
jobs:
linux-debug-sanitizers:
runs-on: ubuntu-latest
timeout-minutes: 5
strategy:
matrix:
sanitizer: [address, undefined]
Expand All @@ -33,6 +34,7 @@ jobs:
-DCMAKE_CXX_COMPILER=g++-14 \
-DDYNAMPI_BUILD_TESTS=ON \
-DDYNAMPI_BUILD_BENCHMARKS=ON \
-DDYNAMPI_MAX_MPI_RANK=8 \
-DCMAKE_CXX_FLAGS="-fsanitize=${{ matrix.sanitizer }} -fno-omit-frame-pointer" \
-DCMAKE_C_FLAGS="-fsanitize=${{ matrix.sanitizer }} -fno-omit-frame-pointer" \
-DCMAKE_EXE_LINKER_FLAGS="-fsanitize=${{ matrix.sanitizer }}" \
Expand All @@ -46,4 +48,5 @@ jobs:
cd build
echo "Testing with $MPI_TYPE and ${{ matrix.sanitizer }} sanitizer"
export LSAN_OPTIONS=suppressions=${{ github.workspace }}/test/lsan.supp
ctest --output-on-failure --parallel -C Debug
export DYNAMPI_MAX_MPI_RANK=8
ctest --output-on-failure --verbose -C Debug
10 changes: 6 additions & 4 deletions .github/workflows/smpi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ on:
jobs:
smpi:
runs-on: ubuntu-latest
timeout-minutes: 10
timeout-minutes: 5
steps:
- name: Checkout Repository
uses: actions/checkout@v4
Expand Down Expand Up @@ -46,7 +46,8 @@ jobs:
-DMPIEXEC_EXECUTABLE=/usr/bin/smpirun \
-DMPIEXEC_PREFLAGS=-platform\;platform.xml \
-DDYNAMPI_BUILD_TESTS=ON \
-DDYNAMPI_BUILD_BENCHMARKS=OFF"
-DDYNAMPI_BUILD_BENCHMARKS=OFF \
-DDYNAMPI_MAX_MPI_RANK=8"

echo "CMAKE_ARGS: $CMAKE_ARGS"

Expand Down Expand Up @@ -81,7 +82,8 @@ jobs:
run: |
echo "Testing with $MPI_TYPE"
cp platform.xml ${{ steps.strings.outputs.build-output-dir }}/test
export DYNAMPI_MAX_MPI_RANK=8
ctest --output-on-failure --parallel

echo "Additionally running MPI tests with 100 ranks..."
smpirun -np 100 -platform platform.xml ./test/mpi_test
echo "Additionally running MPI tests with 8 ranks..."
smpirun -np 8 -platform platform.xml ./test/mpi_test
21 changes: 15 additions & 6 deletions .github/workflows/windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ jobs:
windows-msmpi:
name: Windows MS-MPI (MPI 3.1)
runs-on: windows-latest
timeout-minutes: 10
strategy:
matrix:
build-type: [Debug, Release]
Expand All @@ -34,7 +35,8 @@ jobs:
cmake -B build `
-DCMAKE_BUILD_TYPE=${{ matrix.build-type }} `
-DDYNAMPI_BUILD_TESTS=ON `
-DDYNAMPI_BUILD_BENCHMARKS=ON
-DDYNAMPI_BUILD_BENCHMARKS=ON `
-DDYNAMPI_MAX_MPI_RANK=8
- name: Build (MS-MPI)
shell: pwsh
run: cmake --build build --config ${{ matrix.build-type }} --parallel
Expand All @@ -43,10 +45,12 @@ jobs:
run: |
cd build
echo "Testing with Microsoft MPI (MPI 3.1 features)"
ctest --output-on-failure --parallel -C ${{ matrix.build-type }}
$env:DYNAMPI_MAX_MPI_RANK = "8"
ctest --output-on-failure -j 1 --timeout 180 -C ${{ matrix.build-type }}
windows-mingw:
name: Windows MinGW
runs-on: windows-latest
timeout-minutes: 10
strategy:
matrix:
build-type: [Debug, Release]
Expand Down Expand Up @@ -97,7 +101,8 @@ jobs:
-DMPI_C_LIBRARIES=/mingw64/lib/libmsmpi.a \
-DMPI_CXX_LIBRARIES=/mingw64/lib/libmsmpi.a \
-DDYNAMPI_BUILD_TESTS=ON \
-DDYNAMPI_BUILD_BENCHMARKS=ON
-DDYNAMPI_BUILD_BENCHMARKS=ON \
-DDYNAMPI_MAX_MPI_RANK=8
- name: Build (MinGW)
shell: msys2 {0}
run: cmake --build build --config ${{ matrix.build-type }} --parallel
Expand All @@ -106,10 +111,12 @@ jobs:
run: |
cd build
echo "Testing with $MPI_TYPE"
ctest --output-on-failure --parallel -C ${{ matrix.build-type }}
export DYNAMPI_MAX_MPI_RANK=8
ctest --output-on-failure -j 1 --timeout 180 -C ${{ matrix.build-type }}
windows-intel-mpi:
name: Windows Intel MPI (MPI 4.0)
runs-on: windows-latest
timeout-minutes: 10
strategy:
matrix:
build-type: [Debug, Release]
Expand All @@ -126,7 +133,8 @@ jobs:
cmake -B build `
-DCMAKE_BUILD_TYPE=${{ matrix.build-type }} `
-DDYNAMPI_BUILD_TESTS=ON `
-DDYNAMPI_BUILD_BENCHMARKS=ON
-DDYNAMPI_BUILD_BENCHMARKS=ON `
-DDYNAMPI_MAX_MPI_RANK=8
- name: Build (Intel MPI)
shell: pwsh
run: cmake --build build --config ${{ matrix.build-type }} --parallel
Expand All @@ -135,4 +143,5 @@ jobs:
run: |
cd build
echo "Testing with Intel MPI (MPI 4.0 support)"
ctest --output-on-failure --parallel -C ${{ matrix.build-type }}
$env:DYNAMPI_MAX_MPI_RANK = "8"
ctest --output-on-failure -j 1 --timeout 180 -C ${{ matrix.build-type }}
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,6 @@ bin
Testing
*.btr
commands.txt
core.*
__pycache__/
*.png
8 changes: 8 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,14 @@ repos:
rev: v20.1.8
hooks:
- id: clang-format
- repo: local
hooks:
- id: cppcheck
name: cppcheck
entry: cppcheck --enable=warning --suppress=missingIncludeSystem -I include
--std=c++20 --inline-suppr
language: system
types_or: [c, c++]
- repo: https://github.com/google/yamlfmt.git
rev: v0.17.2
hooks:
Expand Down
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ if(MSVC)
else()
add_compile_options(-Wall -Wextra -Wpedantic -Werror -fno-ms-extensions)
endif()
if(CMAKE_CXX_COMPILER_ID STREQUAL "IntelLLVM")
add_compile_options(-diag-disable=10430 -Wno-unknown-warning-option)
endif()

set(CMAKE_CXX_FLAGS_COVERAGE "-O0 -g -coverage -fprofile-arcs -ftest-coverage \
-fno-elide-constructors ${CMAKE_CXX_FLAGS_COVERAGE}")
Expand Down
13 changes: 13 additions & 0 deletions REUSE.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
version = 1

[[annotations]]
path = "benchmark/results/**.csv"
SPDX-FileCopyrightText = "2025 QDX Technologies"
SPDX-License-Identifier = "Apache-2.0"
SPDX-Comment = "Generated benchmark results."

[[annotations]]
path = "**.png"
SPDX-FileCopyrightText = "2025 QDX Technologies"
SPDX-License-Identifier = "Apache-2.0"
SPDX-Comment = "Generated result plots."
24 changes: 17 additions & 7 deletions benchmark/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,21 @@ FetchContent_Declare(
)
FetchContent_MakeAvailable(cxxopts)

add_executable(asymptotic_distribution_throughput
asymptotic_distribution_throughput.cpp
)
target_link_libraries(asymptotic_distribution_throughput
PRIVATE
dynampi
cxxopts::cxxopts
set(benchmarks
asymptotic_distribution_throughput
strong_scaling_distribution_rate
pingpong
timer_resolution
naive_shutdown_time
)

foreach(benchmark IN LISTS benchmarks)
add_executable(${benchmark}
${benchmark}.cpp
)
target_link_libraries(${benchmark}
PRIVATE
dynampi
cxxopts::cxxopts
)
endforeach()
14 changes: 8 additions & 6 deletions benchmark/asymptotic_distribution_throughput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,12 @@ static double run_single_benchmark(const BenchmarkOptions& opts) {
MPI_Barrier(MPI_COMM_WORLD);

using Task = size_t;
using Result = std::vector<std::byte>;
// using Result = std::vector<std::byte>;
using Result = size_t;

auto worker_task = [&opts](Task task) -> Result {
return std::vector<std::byte>(opts.message_size, std::byte(task));
};
// auto worker_task = [&opts](Task task) -> Result {
// return std::vector<std::byte>(opts.message_size, std::byte(task));
auto worker_task = [](Task task) -> Result { return task; };

dynampi::Timer dynamic_timer;
auto dynamic_communicator = make_dynamic_communicator(opts.remove_root_from_distribution);
Expand All @@ -103,8 +104,9 @@ static double run_single_benchmark(const BenchmarkOptions& opts) {
if (work_distributer.is_root_manager()) {
std::cout << "Dynamic task distribution completed successfully." << std::endl;
const auto& stats = work_distributer.get_statistics();
for (size_t i = 0; i < stats.worker_task_counts.size(); i++) {
std::cout << "Rank " << i << ": " << "Tasks: " << stats.worker_task_counts[i] << std::endl;
for (size_t i = 0; i < stats.worker_task_counts->size(); i++) {
std::cout << "Rank " << i << ": " << "Tasks: " << stats.worker_task_counts->at(i)
<< std::endl;
}
std::cout << "Total messages sent: " << stats.comm_statistics.send_count << std::endl;
std::cout << "Total messages received: " << stats.comm_statistics.recv_count << std::endl;
Expand Down
47 changes: 47 additions & 0 deletions benchmark/aurora/aurora_compile.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#!/usr/bin/env bash

# SPDX-FileCopyrightText: 2025 QDX Technologies. Authored by Ryan Stocks <ryan.stocks00@gmail.com>
# SPDX-License-Identifier: Apache-2.0

set -euo pipefail

module load cmake

# Default values
BUILD_DIR="build"
BUILD_TYPE="Release"

usage() {
echo "Usage: $0 [-d build_dir] [-t build_type] [--clean]"
echo
echo "Options:"
echo " -d DIR Build directory (default: build)"
echo " -t TYPE Build type: Release, Debug, RelWithDebInfo, MinSizeRel (default: Release)"
echo " --clean Remove build directory before configuring"
exit 1
}

# Parse args
CLEAN=0
while [[ $# -gt 0 ]]; do
case "$1" in
-d) BUILD_DIR="$2"; shift 2 ;;
-t) BUILD_TYPE="$2"; shift 2 ;;
--clean) CLEAN=1; shift ;;
-h|--help) usage ;;
*) echo "Unknown option: $1"; usage ;;
esac
done

if [[ $CLEAN -eq 1 && -d "$BUILD_DIR" ]]; then
echo "Cleaning $BUILD_DIR"
rm -rf "$BUILD_DIR"
fi

echo "Configuring with CMake..."
cmake -DCMAKE_BUILD_TYPE="$BUILD_TYPE" -B "$BUILD_DIR"

echo "Building..."
cmake --build "$BUILD_DIR" -- -j"$(nproc)"

echo "✅ Build finished in $BUILD_DIR ($BUILD_TYPE)"
Loading
Loading