Skip to content

Potential CMake logic bugs with CUDAΒ #6807

@Flying-dragon-boxing

Description

@Flying-dragon-boxing

Describe the Code Quality Issue

Implementation in #6777 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?

Also, CUDA 13 has dropped the support for older architectures lower than 75, which is not properly dealt with in our CMake configuration, causing ABACUS with CUDA 13 to refuse to build.

set(CMAKE_CUDA_ARCHITECTURES
        60 # P100
        70 # V100
        # Add your CUDA arch here Check the Compute Capability version of your
        # GPU at: https://en.wikipedia.org/wiki/CUDA#GPUs_supported
    )

Besides, when defining CMAKE_CUDA_ARCHITECTURES, our CMake configuration does NOT find CUDAToolkit anymore. Why?

  if(NOT DEFINED CMAKE_CUDA_ARCHITECTURES)
    find_package(CUDAToolkit REQUIRED)

Additional Context

No response

Task list for Issue attackers (only for developers)

  • Identify the specific code file or section with the code quality issue.
  • Investigate the issue and determine the root cause.
  • Research best practices and potential solutions for the identified issue.
  • Refactor the code to improve code quality, following the suggested solution.
  • Ensure the refactored code adheres to the project's coding standards.
  • Test the refactored code to ensure it functions as expected.
  • Update any relevant documentation, if necessary.
  • Submit a pull request with the refactored code and a description of the changes made.

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions