Skip to content

[Fix]Enable abacus to be compiled with CXX 17 & CUDA 13#6777

Merged
mohanchen merged 20 commits intodevelopfrom
ZhouXY-PKU-cuda13-dev-tmp
Dec 15, 2025
Merged

[Fix]Enable abacus to be compiled with CXX 17 & CUDA 13#6777
mohanchen merged 20 commits intodevelopfrom
ZhouXY-PKU-cuda13-dev-tmp

Conversation

@ZhouXY-PKU
Copy link
Collaborator

@ZhouXY-PKU ZhouXY-PKU commented Dec 12, 2025

Linked Issue

Fix #6752
See also conda-forge/abacus-feedstock#78

Unit Tests and/or Case Tests for my changes

  • This PR is a refactoring to improve maintainability and forward-compatibility. No new unit tests are added, as all existing functionality is intended to remain unchanged. The project's existing regression test suite is used to verify that this refactoring does not introduce any regressions across supported CUDA versions.

What's changed?

This PR introduces a CUDA compatibility layer to prepare the codebase for CUDA 13 support and centralize version-specific logic. The key changes are:

  1. New Compatibility Module: Modified and added source/source_base/module_device/cuda_compat.h and cuda_compat.cpp. This module acts as an abstraction layer to handle differences between CUDA versions.
  2. API Compatibility: It provides a version-agnostic implementation for cufftGetErrorString, which has removed error codes in CUDA 13.
  3. Code Refactoring: Deprecated CUDA device properties (like clockRate, memoryClockRate, etc) which were removed in CUDA 13 have been moved from output_device.cpp into the new compatibility layer. This cleans up the main application logic and isolates version-specific code.
  4. Build System Update: CMakeLists.txt was updated to include the new source files.
    The primary impact is that ABACUS can now be built with CUDA 13 without modifying the main application code. This also improves long-term maintainability by creating a dedicated place for future CUDA compatibility fixes.

Any changes of core modules? (ignore if not applicable)

There are no changes to the core solver modules (ESolver, HSolver, ElecState, Hamilt, Operator, or Psi). The changes are contained within the module_device infrastructure layer. The purpose of this refactoring is to abstract away hardware/driver-specific details from the core scientific modules, ensuring they remain unaffected by changes in the underlying CUDA toolkit.

@ZhouXY-PKU ZhouXY-PKU marked this pull request as draft December 12, 2025 09:02
@ZhouXY-PKU ZhouXY-PKU added GPU & DCU & HPC GPU and DCU and HPC related any issues Refactor Refactor ABACUS codes The Absolute Zero Reduce the "entropy" of the code to 0 Compile & CICD & Docs & Dependencies Issues related to compiling ABACUS Interfaces Interfaces with other packages and removed The Absolute Zero Reduce the "entropy" of the code to 0 labels Dec 13, 2025
@ZhouXY-PKU ZhouXY-PKU marked this pull request as ready for review December 13, 2025 09:24
@ZhouXY-PKU ZhouXY-PKU added the Bugs Bugs that only solvable with sufficient knowledge of DFT label Dec 13, 2025
@ZhouXY-PKU ZhouXY-PKU changed the title [Fix]Fix bugs when building with CUDA 13 [Fix]Enable abacus to be compiled with CUDA 13 Dec 13, 2025
@ZhouXY-PKU ZhouXY-PKU changed the title [Fix]Enable abacus to be compiled with CUDA 13 [Fix]Enable abacus to be compiled with CXX 17 & CUDA 13 Dec 13, 2025
Copy link
Collaborator

@Cstandardlib Cstandardlib left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice Job!

@mohanchen mohanchen merged commit ce25b0d into develop Dec 15, 2025
25 checks passed
@ZhouXY-PKU ZhouXY-PKU deleted the ZhouXY-PKU-cuda13-dev-tmp branch December 15, 2025 03:00
@Flying-dragon-boxing
Copy link
Collaborator

Current implementation of CMakeLists.txt doesn't really detect the CUDA version. The CUDA version is a manually-defined variable, making this CXX 17 issue not automatically solved.

  if(CUDA_VERSION VERSION_GREATER_EQUAL "13.0")
    message(STATUS "CUDA ${CUDA_VERSION} detected. Setting CMAKE_CUDA_STANDARD to 17.")
    set_if_higher(CMAKE_CXX_STANDARD 17)
  endif()

Actually when executing find_package(CUDAToolkit REQUIRED), CMake automatically introduces a variable CUDAToolkit_VERSION. Is there any difficulty introducing this variable in your situation?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Bugs Bugs that only solvable with sufficient knowledge of DFT Compile & CICD & Docs & Dependencies Issues related to compiling ABACUS GPU & DCU & HPC GPU and DCU and HPC related any issues Interfaces Interfaces with other packages Refactor Refactor ABACUS codes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CUDA 13 requires C++ 17

4 participants