Remove the GSL dependency from sss and xlqc - #321
Merged
Conversation
…g its path GSL is GPL, so a redistributed binary that links it together with the CUDA or HIP runtime cannot satisfy both licenses. Reported in #319 The SCF driver only needs a handful of GSL entry points: matrix and vector allocation and element access, dgemm, the symmetric eigensolver, and an LU solve for DIIS. gsl_compat.h maps exactly those onto Eigen (MPL2, header-only), keeping the existing gsl_* call sites in main, scf.cc and basis.cc unchanged. The header lives in xlqc-cuda and is shared by the hip, omp and sycl variants, which already compile those sources through -I../xlqc-cuda. Eigen's SelfAdjointEigenSolver returns ascending eigenvalues like gsl_eigen_symmv_sort, and PartialPivLU matches the pivoting of gsl_linalg_LU_decomp, so the SCF trajectory is preserved. The Makefiles carried the same "/path/to/..." placeholder that #305 replaces for GSL, so apply that fix to Eigen: EIGEN_INC defaults to `pkg-config --cflags eigen3` and a missing Eigen stops the build with an actionable message instead of a bare missing-header error. Eigen is header-only, so there is no library counterpart to GSL_LIB and LDFLAGS becomes empty. The check is skipped for `clean` so the tree can be cleaned without Eigen installed. CMake gains find_package(Eigen3) and guards xlqc on the Eigen3::Eigen imported target rather than a _FOUND variable, since that target is what carries the include path. xlqc-omp additionally never compiled the shared scf.cc, basis.cc and int_lib sources or unpacked its example data, so it could not link; both are fixed here. Co-authored-by: Cursor <cursoragent@cursor.com>
…x kernel data races GSL is GPL, so distributing sss binaries built from CUDA/HIP sources conflicts with the CUDA EULA (#319). sss only used GSL for a Mersenne Twister stream and one semi-infinite integral, so replace it with a self-contained gsl_compat.h that reproduces mt19937 with GSL's 2002 Knuth seeding and implements adaptive Gauss-Kronrod (QK15) quadrature from the public domain QUADPACK algorithm. The RNG stream is bit-identical to GSL 2.7.1 and the integral agrees to ~1e-12, so results are unchanged. sss now builds with no external dependency, so drop the GSL discovery and the guards that skipped the benchmark when GSL was absent. Deduplicate the variants: the files that carry no GPU API calls now live only in sss-cuda and are pulled in through an include path, removing about 4500 lines of copies. Only main, kernels, and DPmixGGM_SSSmoves stay per-variant, and sss-cuda/kernels.cu is now shared with sss-hip since the two were identical and it uses no CUDA-only names. Add the missing barriers in CanDeleteEdge and CanAddEdge. Both kernels let every thread write shared state and then had thread 0 read all of it without a barrier, and CanDeleteEdge tested a thread-0-only counter for its loop exit, so threads could leave the loop divergently. This was benign on NVIDIA, where a 32-thread block is one warp in lockstep, but on gfx908 thread 0 read stale values: sss-hip scored -5721.97 and reported num_allModels=2731275 against -5675.31 and 12504300 elsewhere, converging on a worse optimum after 4.6x fewer iterations and so also reporting a misleadingly short run time. All three variants now reproduce the CPU reference path iteration for iteration and write identical output. Also fix two sss-sycl reporting bugs: the stopwatch was restarted on every search restart, so wall_time only covered the final restart (0.0036s instead of 35s), and the initial progress line printed k before it was assigned. Co-authored-by: Cursor <cursoragent@cursor.com>
Geekdude
approved these changes
Aug 13, 2026
There was a problem hiding this comment.
Pull request overview
Removes GSL from sss and xlqc, resolving the license conflict while retaining default builds.
Changes:
- Adds self-contained GSL-compatible RNG/quadrature for
sss. - Replaces
xlqclinear algebra with an Eigen-backed compatibility layer. - Consolidates duplicated sources and updates dependency discovery and documentation.
Reviewed changes
Copilot reviewed 54 out of 54 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
src/xlqc-sycl/README.md |
Documents Eigen dependency. |
src/xlqc-sycl/Makefile |
Replaces GSL flags with Eigen discovery. |
src/xlqc-sycl/main.cpp |
Uses compatibility layer and preserves cleanup on failure. |
src/xlqc-sycl/CMakeLists.txt |
Links Eigen target. |
src/xlqc-omp/README.md |
Documents Eigen dependency. |
src/xlqc-omp/Makefile.nvc |
Configures Eigen for NVHPC. |
src/xlqc-omp/Makefile.aomp |
Configures Eigen for AOMP. |
src/xlqc-omp/Makefile |
Configures Eigen for OpenMP. |
src/xlqc-omp/main.cpp |
Uses compatibility layer and returns validation status. |
src/xlqc-omp/CMakeLists.txt |
Builds shared XLQC sources with Eigen. |
src/xlqc-hip/README.md |
Documents Eigen dependency. |
src/xlqc-hip/Makefile |
Replaces GSL and adjusts HIP compilation. |
src/xlqc-hip/main.cu |
Uses compatibility layer and preserves cleanup. |
src/xlqc-hip/CMakeLists.txt |
Links Eigen for HIP. |
src/xlqc-cuda/scf.cc |
Routes SCF operations through compatibility APIs. |
src/xlqc-cuda/README.md |
Documents Eigen setup. |
src/xlqc-cuda/Makefile |
Replaces GSL flags with Eigen flags. |
src/xlqc-cuda/main.cu |
Uses compatibility layer and returns validation status. |
src/xlqc-cuda/gsl_compat.h |
Implements Eigen-backed GSL subset. |
src/xlqc-cuda/CMakeLists.txt |
Links Eigen for CUDA. |
src/xlqc-cuda/basis.cc |
Removes obsolete GSL includes. |
src/sss-sycl/utilities.cpp |
Removes duplicated utility implementation. |
src/sss-sycl/README.md |
Documents dependency-free compatibility layer. |
src/sss-sycl/Makefile |
Uses shared CUDA host sources. |
src/sss-sycl/main.cpp |
Uses local GSL replacement and fixes initialization timing. |
src/sss-sycl/kernels.cpp |
Adds work-group synchronization. |
src/sss-sycl/gwish.cpp |
Removes duplicated implementation. |
src/sss-sycl/graph.h |
Removes duplicated declarations. |
src/sss-sycl/graph.cpp |
Removes duplicated graph implementation. |
src/sss-sycl/DPmixGGM.cpp |
Removes duplicated sampler implementation. |
src/sss-sycl/DPmixGGM_Lists.cpp |
Removes duplicated list implementation. |
src/sss-sycl/CMakeLists.txt |
Removes GSL and includes shared sources. |
src/sss-hip/utilities.cpp |
Removes duplicated utility implementation. |
src/sss-hip/README.md |
Documents dependency-free compatibility layer. |
src/sss-hip/Makefile |
Uses shared CUDA host sources. |
src/sss-hip/main.cu |
Uses local GSL replacement. |
src/sss-hip/kernels.cu |
Removes duplicated kernel implementation. |
src/sss-hip/gwish.cpp |
Removes duplicated implementation. |
src/sss-hip/graph.h |
Removes duplicated declarations. |
src/sss-hip/graph.cpp |
Removes duplicated graph implementation. |
src/sss-hip/DPmixGGM.cpp |
Removes duplicated sampler implementation. |
src/sss-hip/DPmixGGM_Lists.cpp |
Removes duplicated list implementation. |
src/sss-hip/CMakeLists.txt |
Removes GSL and includes shared sources. |
src/sss-cuda/README.md |
Documents self-contained dependencies. |
src/sss-cuda/Makefile |
Removes GSL build flags. |
src/sss-cuda/main.cu |
Uses local GSL replacement. |
src/sss-cuda/kernels.cu |
Adds block synchronization. |
src/sss-cuda/gwish.cpp |
Adds required math declarations. |
src/sss-cuda/gsl_compat.h |
Implements MT19937 and adaptive quadrature. |
src/sss-cuda/DPmixGGM.cpp |
Adds required math declarations. |
src/sss-cuda/CMakeLists.txt |
Removes GSL dependency. |
README.md |
Replaces GSL dependency listing with Eigen. |
CMakeLists.txt |
Discovers Eigen instead of GSL. |
cmake/modules/BenchmarkMacros.cmake |
Skips XLQC when Eigen is unavailable. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| ------------ | ||
| None beyond a C++17 compiler. The uniform random number generator (MT19937) and | ||
| the adaptive Gauss-Kronrod quadrature the sampler needs are implemented in | ||
| `gsl_compat.h` in this folder. |
Collaborator
Author
There was a problem hiding this comment.
The file was updated. Thanks.
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.
Resolves the GPL/CUDA-EULA license clash reported in #319 by taking option 1: both
sssandxlqcno longer depend on GSL, so they stay in the suite and keep building by default.sss
GSL was used only for a uniform random number generator (MT19937) and adaptive Gauss-Kronrod quadrature. Both are now implemented in a self-contained, dependency-free
gsl_compat.hundersrc/sss-cuda/, so the benchmark needs nothing beyond a C++17 compiler. Thegsl_*entry point names are kept so the surrounding sampler code is unchanged.While in here:
xlqc
The Hartree-Fock SCF driver needs a dense symmetric eigensolver, matrix products and a linear solve for DIIS. These now come from Eigen (header-only, MPL2) behind a thin
gsl_compat.hwrapper, replacing the GSL BLAS/eigen calls.Eigen is discovered rather than hardcoded: the Makefiles use
pkg-config --cflags eigen3and CMake usesfind_package(Eigen3), so a distro-installed Eigen (libeigen3-dev/eigen3-devel) needs no configuration. A non-standard prefix can be pointed at withPKG_CONFIG_PATHormake EIGEN_INC=-I/path/to/eigen3. If Eigen is absent, CMake skipsxlqcwith a message instead of failing.Build system and docs
find_package(GSL)and theDEPEND_ON_GSLlist are replaced byEigen3/DEPEND_ON_EIGEN(nowxlqconly, sincessshas no external dependency at all). The top-level README dependency table and the per-benchmark READMEs are updated accordingly.Testing
All four programming-model variants of both benchmarks were built and run, and their output was checked against the pre-change GSL-based versions.