Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ message(STATUS "")
# #####################################################################
# ## CMAKE and CXX VERSION
# #####################################################################
cmake_minimum_required(VERSION 3.24) # require for the "native" value of CUDA_ARCHITECTURES
cmake_minimum_required(VERSION 3.25) # 3.25 added CUDA device LTO via INTERPROCEDURAL_OPTIMIZATION

set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules")
# Inria's morse_cmake provides an up-to-date FindLAPACKE (and helpers) that
Expand Down Expand Up @@ -185,7 +185,18 @@ project(CYTNX VERSION ${CYTNX_VERSION} LANGUAGES CXX C)

set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
if(USE_CUDA)
set(CMAKE_CUDA_ARCHITECTURES native)
# Default to a portable fat binary unless the caller picked architectures via
# -D, the cache, a preset's cacheVariables, or the CUDAARCHS environment
# variable. This must run before enable_language(CUDA): afterwards
# CMAKE_CUDA_ARCHITECTURES is never empty (CMake fills in its own default), so
# the "not specified" case can no longer be detected. enable_language(CUDA)
# reads CUDAARCHS on its own, so we only avoid shadowing it here, not copy it.
# The default embeds SASS for each supported real architecture (Volta sm_70 is
# the floor required by cuTENSOR/cuQuantum, up through Hopper sm_90) plus PTX
# of the newest (90-virtual) so the driver can JIT for newer/unknown GPUs.
if(NOT CMAKE_CUDA_ARCHITECTURES AND NOT DEFINED ENV{CUDAARCHS})
set(CMAKE_CUDA_ARCHITECTURES 70-real 75-real 80-real 86-real 89-real 90-real 90-virtual)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Gate CUDA architectures by toolkit version

When USE_CUDA=ON is configured with the documented CUDA v10+ dependency (docs/source/adv_install.rst:32) but without an explicit CMAKE_CUDA_ARCHITECTURES, this default now passes compute_89/compute_90 to nvcc. CUDA toolkits before 11.8 do not know those architectures, so CMake's CUDA compiler check or the first CUDA compile fails with nvcc fatal: Unsupported gpu architecture, even though those CUDA versions were previously supported via native. Please derive the default from CMAKE_CUDA_COMPILER_VERSION or keep the default to architectures supported by the minimum CUDA version.

Useful? React with 👍 / 👎.

endif()
enable_language(CUDA)
# Disable generation of "--option-file" flag in compile_commands.json.
# This workaround helps VSCode's cpptools extension correctly locate CUDA
Expand Down
Loading