CMake improvements#169
Merged
Merged
Conversation
…onfigured with OpenMP
…123::Random123 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
…ACE_LIBRARIES flag Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Contributor
Author
|
@mmelnich please review these changes for situational awareness. You'll likely need to update your RandLAPACK build script once you update it to use this or newer RandBLAS. |
Contributor
|
@rileyjmurray Looks good; will update RandLAPACK once this is merged. |
Merged
rileyjmurray
added a commit
that referenced
this pull request
May 25, 2026
This PR brought to you by a robot.
Replaces the four legacy CI workflows with a single matrix workflow plus
dedicated workflows for ThreadSanitizer, examples, downstream-consumer
smoke, and docs.
Adds a Docker dev image for running TSan locally on
Apple Silicon. Raises the documented minimum compiler floor.
### New workflows
- `core.yml` — single matrix replacing four legacy files. 11 cells:
Linux gcc/clang × OpenBLAS/MKL × Release/Debug × {none, ASan, UBSan};
macOS 14 Apple Clang (serial) + Homebrew LLVM (OpenMP) × Accelerate ×
{none, ASan}; macOS 15 Homebrew LLVM tracking the latest runner.
- *All OpenMP cells run `ctest` twice — `OMP_NUM_THREADS=1` and `=4` —
so the thread-independence invariant is actually exercised, not just
compiled.*
- *OpenBLAS and MKL are tested in separate Linux builds*, so the
`RandBLAS_HAS_MKL` codepaths get real coverage instead of "whichever
blaspp happened to pick."
- `thread-sanitizer.yml` — clang + libomp + `-fsanitize=thread` on
Linux. *Defends the thread-independence invariant on the RNG state
machinery that ASan can't catch.*
- `examples.yml` — builds `examples/` against an installed RandBLAS
(with `lapackpp` from the composite action). Catches downstream API
drift in real consumer code.
- `downstream-consumer.yml` + `test/downstream/` —
`find_package(RandBLAS)` from a tiny isolated consumer. Guards the
install/export rules in `RandBLAS/CMakeLists.txt`.
- `docs.yml` — `doxygen + sphinx-build`. *Shadow build for now (no `-W`)
— follow-up after the docstring warning backlog is cleared.*
- `.github/actions/setup-randblas-deps/` — composite action installing
system deps and building blaspp + Random123 (+ optionally lapackpp),
cached on upstream commit SHA. Eliminates the heavy copy-paste across
the old workflows.
### Removed
- The four legacy workflows (`core-linux.yaml`, `core-macos.yml`,
`openmp-macos.yaml`, `openmp-macos-15.yaml`). *The last two were
converging to the same job once `macos-latest` rolls to 15.*
### Local TSan tooling
- `docker/tsan/Dockerfile` + `run.sh` — Linux container with clang +
libomp + sanitizer runtimes + `llvm-symbolizer` + baked
blaspp/Random123. *Necessary because TSan can't run natively on Apple
Silicon (shadow-memory mapping fails at startup before TSan can even
print its banner).* Usage:
- `./docker/tsan/run.sh build-and-test` — full TSan ctest pass in one
shot.
- `./docker/tsan/run.sh` — interactive shell for iteration.
- `./docker/tsan/run.sh rebuild-image` — refresh blaspp / Random123
upstream.
### Hygiene
- `actions/checkout@v4` everywhere (three of four legacy files were on
deprecated `@v2`).
- `concurrency:` group with `cancel-in-progress: true` so superseded PR
runs auto-cancel.
- `push: branches: [main]` trigger so main's CI status reflects current
state, not just the merge-time check.
- `make -j$(nproc)` / `sysctl -n hw.logicalcpu` instead of `-j2`.
- blaspp / lapackpp / Random123 builds cached, keyed on upstream commit
SHA.
### Doc updates
- `CLAUDE.md` and `INSTALL.md`: documented minimum compiler raised gcc-9
→ gcc-13 to match `ubuntu-latest`. Old gcc-8.5 / `-fconcepts` workaround
note removed.
### Explicitly not in this PR
- *Windows / MSVC* — out of scope.
- *gcc-9 cell* — dropped in favor of raising the documented floor.
- *`-W` on docs* — deferred until the docstring warning baseline is
clean.
- *GCC-on-macOS cell* — easy follow-up if needed.
## Verification
- All 11 `core.yml` cells green on this branch.
- `thread-sanitizer.yml`: locally green via `docker/tsan/run.sh
build-and-test`. Instrumentation verified end-to-end by *planting a
deliberate harmless race in `dense_skops.hh` and confirming TSan caught
it*, then reverting — so the clean baseline isn't a
green-because-everything-is-suppressed.
- `examples.yml` and `downstream-consumer.yml` re-pointed at the new
CMake config layout from #169 (`<prefix>/lib/cmake/RandBLAS/`) and
switched to `-DCMAKE_PREFIX_PATH=<prefix>` per the new INSTALL.md
recommendation, so the same class of layout-change breakage can't recur.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR brought to you by back-and-forth with a robot.
Tightens the install machinery, the exported package, and assorted build-time UX so that both downstream
find_package(RandBLAS)consumers and RandBLAS' own developers get a cleaner, more modern, more predictable experience. Each change stands alone; the commit history reflects that grouping.Consumer-visible behavior
Before this PR, a downstream project that called
find_package(RandBLAS)could expect:-Wall,-Wextra,-Wno-commentsilently imposed on its own code — plus-fsanitize=address(on both compile and link lines) if RandBLAS happened to be built withSANITIZE_ADDRESS=ON. Consumers got ASan'd without opting in, often producing confusing link failures becauselibasanwasn't on the link line.blaspp'sfind_dependency(OpenMP)to incidentally pull OpenMP into scope, despite RandBLAS' own exported target referencingOpenMP::OpenMP_CXXdirectly.Random123target leaking into the consumer's global namespace.lib/cmake/, requiring consumers to set-DRandBLAS_DIR=<prefix>/lib/cmakeexplicitly because the layout didn't match CMake's package-auto-discovery search.After this PR:
RandBLAStarget carries noINTERFACE_COMPILE_OPTIONSorINTERFACE_LINK_OPTIONS. Build-time-only flags (warnings, sanitizers) are wrapped in$<BUILD_INTERFACE:...>so they apply in-tree and disappear from the installed export.cxx_std_20as a compile feature, so consumers automatically get-std=gnu++20(or equivalent) without having to setCMAKE_CXX_STANDARDthemselves.RandBLASConfig.cmakecallsfind_dependency(OpenMP COMPONENTS CXX)directly when RandBLAS was built with OpenMP. No more incidental dependence on blaspp's behavior.IMPORTEDtargetRandom123::Random123, recreated on the consumer side by RandBLAS' installedFindRandom123.cmake. The bareRandom123global target is gone.lib/cmake/RandBLAS/, the canonical layout.find_package(RandBLAS)resolves via-DCMAKE_PREFIX_PATH=<prefix>alone; theRandBLAS_DIRworkaround is no longer needed.3.12across the tree (top-level, examples, INSTALL.md snippets). This matches the actual feature set we depend on —target_compile_features(... cxx_std_20)was added in CMake 3.12 — and consumers of ourcxx_std_20feature need at least that.Build-time UX
BUILD_TESTSCMake option, defaultON.cmake -DBUILD_TESTS=OFF(or=no,=false, etc. — case-insensitive per CMake's own keyword handling) skips configuring thetest/subdirectory entirely. Useful for downstream packaging or quick configure-only sanity checks.CMAKE_BUILD_TYPEtoReleaseif none was supplied, instead of unconditionally settingCMAKE_CXX_FLAGS="-O1". The latter both overrode-O3from Release mode and stomped any flags the user explicitly passed. The new pattern preserves user overrides and produces properly optimized binaries by default.stat_testsbinary no longer depends on its current working directory at runtime. Previously the KAT vector file was copied to three destinations in the build tree, all of them wrong for the common dev workflow of invoking the binary directly. The file is now read via a compile-time-baked absolute path, so the test works whether invoked throughctest,cd bin && ./stat_tests,./bin/stat_testsfrom the build root, or via an absolute path from anywhere.Cleanups
CMake/blaspp.cmakeandCMake/Random123.cmake— dead modules that definedRandBLAS_blaspp/RandBLAS_Random123INTERFACE wrappers and were neverinclude()'d.-D __APPLE__install advice fromINSTALL.mdand the project'sCLAUDE.md; the related source-side workaround was already gone.EXPORT_LINK_INTERFACE_LIBRARIESargument from theinstall(EXPORT)call. It's only meaningful for CMake older than 2.8.12 and we require 3.12.list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/CMake")line fromexamples/CMakeLists.txt— it pointed at a directory that doesn't exist, and the file uses no custominclude()calls anyway.CMake/rb_build_options.cmake:option(BUILD_SHARED_LIBS OFF "Configure to build shared or static libraries")had the value and help-text positions swapped. After the fix, the cache entry is properly typed (BUILD_SHARED_LIBS:BOOL=OFF) with the intended help text.Verification
For each individual change:
find_package(RandBLAS)install was inspected to confirm the corresponding fix in the generatedRandBLAS.cmake/RandBLASConfig.cmakefiles.ctest) was re-run after each change. 429/429 tests pass.BUILD_TESTSoption, six values were exercised: default,OFF,yes,on,ON,True— all behave correctly via CMake's case-insensitive keyword coercion.stat_testscwd-independence change, the binary was invoked from four different working directories (bin/, build root,/tmp, and ctest's default cwd). All four pass.Potential follow-up work
git clone https://github.com/icl-utk-edu/blaspp.git(and Random123) atmainon every run. This makes CI non-reproducible against upstream churn AND wastes 1-3 minutes of build time per OS per PR. The right pattern is to pin each dep to a specific ref in the workflow, then useactions/cachekeyed on that ref. The same pattern would apply tofast_matrix_marketinexamples/CMakeLists.txt, which today isFetchContent_Declare'd atmain.CMake/MKL_sparse.cmakeis worth reviewing on a Linux + MKL host.CMakePresets.jsonfor one-line reproducible local build configurations (Release, Debug, Debug+ASan, etc.). Lets developers avoid memorizing the cmake command line that's currently spread acrossINSTALL.md.CMake/rb_version.cmakewith explicitgit describe/git rev-parseinvocations. The current approach scrapes a file with a regex; the git-based approach is more robust and self-documenting.blaspp::blaspptarget upstream. blaspp's installed Config exports a bare-namedblaspptarget, which is why our owntarget_link_libraries(... blaspp Random123::Random123 ...)is asymmetric. The right fix is an upstream PR addingadd_library(blaspp::blaspp ALIAS blaspp)to blaspp's install, after which we can use the namespaced name here too.-Wno-comment. The workaround was inherited from earlier code. If the underlying comment-related diagnostic in the headers no longer fires under current compilers, this flag can be deleted.SANITIZE_ADDRESSis plumbed. A more idiomatic alternative is to let users set-fsanitize=addressviaCMAKE_CXX_FLAGS(or a preset) and remove the bespoke option entirely. This is a behavior change worth its own discussion.