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
1 change: 1 addition & 0 deletions .bazelversion
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
9.2.0
7 changes: 7 additions & 0 deletions .bcr/metadata.template.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"homepage": "https://github.com/jhurliman/best-cpp",
"maintainers": [{"github": "jhurliman", "github_user_id": 195374}],
"repository": ["github:jhurliman/best-cpp"],
"versions": [],
"yanked_versions": {}
}
11 changes: 11 additions & 0 deletions .bcr/presubmit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
matrix:
platform: [ubuntu2404, macos_arm64]
bazel: ["9.*"]
tasks:
verify_targets:
name: Verify library and regression tests
platform: ${{ platform }}
bazel: ${{ bazel }}
build_flags: ["--cxxopt=-std=c++17"]
build_targets: ["@best_cpp//:best_cpp"]
test_targets: ["@best_cpp//:regression"]
27 changes: 27 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,30 @@ jobs:
- uses: actions/checkout@v4
- run: c++ -std=c++17 -O2 -Wall -Wextra -Wpedantic -pthread -Ibest tests/regression.cpp -o regression && ./regression
- run: c++ -std=c++17 -O1 -g -fsanitize=address,undefined -fno-omit-frame-pointer -pthread -Ibest tests/regression.cpp -o sanitized && ./sanitized

cmake:
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- run: cmake -S . -B build -DBEST_CPP_BUILD_TESTS=ON -DBEST_CPP_BUILD_CLI=ON -DBEST_CPP_BUILD_BENCHMARKS=ON -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=${{ github.workspace }}/install
- run: cmake --build build --config Release --parallel 4
- run: ctest --test-dir build -C Release --output-on-failure
- run: cmake --install build --config Release
- run: cmake -S examples/cmake-consumer -B consumer-build -DCMAKE_PREFIX_PATH=${{ github.workspace }}/install
- run: cmake --build consumer-build --config Release
- run: ctest --test-dir consumer-build -C Release --output-on-failure
bazel:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 24
- run: npm install --global @bazel/bazelisk@1.28.1
- run: bazelisk test //:regression --cxxopt=-std=c++17
- run: bazelisk test //:consumer --cxxopt=-std=c++17
working-directory: examples/bazel-consumer
- run: BAZEL=bazelisk python3 tools/test_bcr.py
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
build*/
install/
bazel-*
/bazel-*
/examples/bazel-consumer/bazel-*
.DS_Store
__pycache__/
regression
sanitized
12 changes: 12 additions & 0 deletions BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
load("@rules_cc//cc:cc_library.bzl", "cc_library")
load("@rules_cc//cc:cc_binary.bzl", "cc_binary")
load("@rules_cc//cc:cc_test.bzl", "cc_test")
cc_library(
name = "best_cpp",
hdrs = glob(["best/*.hpp", "best/*.inl"]),
strip_include_prefix = "best",
visibility = ["//visibility:public"],
)
cc_test(name = "regression", srcs = ["tests/regression.cpp"], deps = [":best_cpp"])
cc_binary(name = "best", srcs = ["best/main.cpp"], deps = [":best_cpp"], tags = ["manual"])
cc_binary(name = "benchmark", srcs = ["bench/sampler.cpp"], deps = [":best_cpp"], tags = ["manual"])
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Changelog

## Unreleased
## 1.0.0 (prepared, not published)

- Replace speculative parallel proposals with sequential adaptive Metropolis-within-Gibbs. Remove shared random-generator races and proposal-selection bias. Remove the thread-count argument from `AMWG::Init`; callers now pass only the starting state and log-posterior callback.
- `Sample(n)` records exactly n completed sweeps; `Burn(n)` advances without retaining samples. Adaptation tracks sweeps independently of chain storage. Reinitialization resets the seeded generator and adaptation. Sampling no longer prints progress.
Expand All @@ -11,3 +11,6 @@
- Compute population standard deviation without a temporary allocation. Add numerical, lifecycle, seeded-distribution and independent-chain regression checks.

These corrections change seeded sequences, inference results and invalid-input behavior. Old results should be recomputed. Reproducibility is within the same implementation and standard library; C++ random-distribution algorithms are not portable bit-for-bit.

- Add CMake install/export targets, Bzlmod library and renamed-repository consumers, archive-based registry tests, standalone header checks, optional CLI/benchmark targets and Linux/macOS/Windows CI.
- Clamp initial group scales to both prior bounds, including highly imbalanced group sizes.
48 changes: 48 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
cmake_minimum_required(VERSION 3.16)
project(best_cpp VERSION 1.0.0 LANGUAGES CXX)
include(GNUInstallDirs)
include(CMakePackageConfigHelpers)
add_library(best_cpp INTERFACE)
add_library(best_cpp::best_cpp ALIAS best_cpp)
target_compile_features(best_cpp INTERFACE cxx_std_17)
target_include_directories(best_cpp INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/best>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/best_cpp>)
option(BEST_CPP_BUILD_TESTS "Build regression tests" OFF)
option(BEST_CPP_BUILD_CLI "Build file comparison example" OFF)
option(BEST_CPP_BUILD_BENCHMARKS "Build sampler benchmark" OFF)
if(BEST_CPP_BUILD_TESTS)
enable_testing()
find_package(Threads REQUIRED)
add_executable(best-regression tests/regression.cpp)
target_link_libraries(best-regression PRIVATE best_cpp::best_cpp Threads::Threads)
add_test(NAME regression COMMAND best-regression)
foreach(header amwg.hpp best.hpp stats.hpp version.hpp)
string(REPLACE "." "_" target ${header})
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/${target}.cpp "#include <${header}>\n")
add_library(header_${target} OBJECT ${CMAKE_CURRENT_BINARY_DIR}/${target}.cpp)
target_link_libraries(header_${target} PRIVATE best_cpp::best_cpp)
endforeach()
endif()
if(BEST_CPP_BUILD_CLI)
add_executable(best best/main.cpp)
target_link_libraries(best PRIVATE best_cpp::best_cpp)
if(BEST_CPP_BUILD_TESTS)
add_test(NAME cli-errors COMMAND ${CMAKE_COMMAND} -DCLI=$<TARGET_FILE:best> -P ${CMAKE_CURRENT_SOURCE_DIR}/tests/cli-errors.cmake)
endif()
endif()
if(BEST_CPP_BUILD_BENCHMARKS)
add_executable(best-benchmark bench/sampler.cpp)
target_link_libraries(best-benchmark PRIVATE best_cpp::best_cpp)
endif()
install(TARGETS best_cpp EXPORT best_cppTargets)
install(DIRECTORY best/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/best_cpp FILES_MATCHING PATTERN "*.hpp" PATTERN "*.inl")
install(FILES LICENSE DESTINATION ${CMAKE_INSTALL_DATADIR}/licenses/best_cpp)
install(EXPORT best_cppTargets NAMESPACE best_cpp:: DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/best_cpp)
configure_package_config_file(cmake/best_cppConfig.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/best_cppConfig.cmake INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/best_cpp)
write_basic_package_version_file(${CMAKE_CURRENT_BINARY_DIR}/best_cppConfigVersion.cmake VERSION ${PROJECT_VERSION} COMPATIBILITY SameMajorVersion ARCH_INDEPENDENT)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/best_cppConfig.cmake ${CMAKE_CURRENT_BINARY_DIR}/best_cppConfigVersion.cmake DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/best_cpp)

if(BEST_CPP_BUILD_TESTS)
add_test(NAME architecture-independent-version COMMAND ${CMAKE_COMMAND} -DVERSION_FILE=${CMAKE_CURRENT_BINARY_DIR}/best_cppConfigVersion.cmake -P ${CMAKE_CURRENT_SOURCE_DIR}/tests/architecture-version.cmake)
endif()
2 changes: 2 additions & 0 deletions MODULE.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
module(name = "best_cpp", version = "1.0.0")
bazel_dep(name = "rules_cc", version = "0.2.22")
Loading
Loading