Skip to content

Fix and modernize the dormant GPU/cuSolver build#1416

Open
Prasanna163 wants to merge 1 commit into
grimme-lab:mainfrom
Prasanna163:gpu-build-resurrect
Open

Fix and modernize the dormant GPU/cuSolver build#1416
Prasanna163 wants to merge 1 commit into
grimme-lab:mainfrom
Prasanna163:gpu-build-resurrect

Conversation

@Prasanna163

Copy link
Copy Markdown

What

The optional GPU code path (WITH_GPU / cuSolver, originally added in 2020) had
bit-rotted and no longer configures or compiles. This PR restores the build
plumbing without touching the default CPU build — all GPU bits stay guarded.

Changes

  • src/mctc/lapack/eigensolve.F90 — fix an invalid local declaration
    real(dp) :: dummy(:) used for the cuSolver bufferSize query (a local
    assumed-shape array without allocatable/dummy status is not valid Fortran and
    broke the USE_CUSOLVER build). Replaced with dummy(1), a valid placeholder
    for a size-only query.
  • meson/meson.build — modernize deprecated NVIDIA HPC SDK flags for current
    nvfortran: -ta=tesla:ccNN-gpu=ccNN -acc, -Mcudalib-cudalib.
  • CMakeLists.txt — add WITH_GPU / GPU_ARCH / WITH_CUSOLVER options
    (CMake had no GPU support at all), mirroring the meson logic; Fortran-scoped
    flags; defines XTB_GPU / USE_CUSOLVER / USE_CUBLAS.

Testing

  • The default CPU build (meson + gfortran) and the unit suite are unaffected —
    every change is behind the (off-by-default) GPU options.
  • The cuSolver eigensolver path these flags enable was validated standalone on an
    RTX 3050: cusolverDnDsygvd vs LAPACK dsygvd agree to ~1e-14 eV on real
    GFN0 H/S matrices.

Heads-up for context: a full GPU build of xtb is currently blocked further
upstream by nvfortran internal compiler errors on the modern-Fortran
dependency tree (deferred-length character handling, first seen in toml-f).
This PR is just the build-system groundwork and is independent of that issue —
the default build is unchanged either way. Happy to adjust anything.

Comment thread src/mctc/lapack/eigensolve.F90 Outdated
The optional GPU code path (WITH_GPU / cuSolver) had bit-rotted and could not
be configured or compiled. This restores it without affecting the default CPU
build:

- src/mctc/lapack/eigensolve.F90: fix the invalid local `real(dp) :: dummy(:)`
  declaration used for the cuSolver bufferSize query (-> `dummy(1)`), which is
  not valid Fortran and broke the USE_CUSOLVER build.
- meson/meson.build: modernize deprecated NVIDIA flags for current nvfortran --
  `-ta=tesla:ccNN` -> `-gpu=ccNN -acc`, `-Mcudalib` -> `-cudalib`.
- CMakeLists.txt: add the WITH_GPU / GPU_ARCH / WITH_CUSOLVER options (CMake had
  no GPU support at all), mirroring meson; Fortran-scoped flags; define
  XTB_GPU / USE_CUSOLVER / USE_CUBLAS.

The default CPU build is unchanged (all GPU bits are guarded).

Signed-off-by: Prasanna163 <prasannakulkarni163@gmail.com>
@Prasanna163 Prasanna163 force-pushed the gpu-build-resurrect branch from b919624 to ff3a37f Compare June 24, 2026 06:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants