From 29f70920a581a4a6f42264f533335112098c3e66 Mon Sep 17 00:00:00 2001 From: Robert Maynard Date: Fri, 12 Mar 2021 20:59:46 -0500 Subject: [PATCH] CMAKE_CUDA_ARCHITECTURES doesn't change when build-system invokes cmake (#7579) Consider the following: ``` cmake -DCMAKE_CUDA_ARCHITECTURES="" . #build for detected touch /cpp/CMakeLists.txt ninja #should be build for detected cmake -DCMAKE_CUDA_ARCHITECTURES= . #build for all touch /cpp/CMakeLists.txt ninja #should be build for all cmake -DCMAKE_CUDA_ARCHITECTURES="" . #build for detected touch /cpp/CMakeLists.txt ninja #should be build for detected ``` Before these changes the invocations of `ninja` would always go back to building for all when ever `ninja` was invoked. The issue is that once a CMake cache variable exists it can't be removed via `-DCMAKE_CUDA_ARCHITECTURES=` and therefore becomes sticky. To resolve the issue you can now pass `-DCMAKE_CUDA_ARCHITECTURES=ALL` to consistently get all archs, and now the build-system should not change what CUDA archs you are building for. Authors: - Robert Maynard (@robertmaynard) Approvers: - Keith Kraus (@kkraus14) URL: https://github.com/rapidsai/cudf/pull/7579 --- build.sh | 2 +- cpp/CMakeLists.txt | 3 +-- cpp/cmake/thirdparty/CUDF_GetRMM.cmake | 1 - 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/build.sh b/build.sh index d75053f8849..5eb404d02a8 100755 --- a/build.sh +++ b/build.sh @@ -135,7 +135,7 @@ if hasArg clean; then fi if (( ${BUILD_ALL_GPU_ARCH} == 0 )); then - CUDF_CMAKE_CUDA_ARCHITECTURES="-DCMAKE_CUDA_ARCHITECTURES=" + CUDF_CMAKE_CUDA_ARCHITECTURES="-DCMAKE_CUDA_ARCHITECTURES=ALL" echo "Building for the architecture of the GPU in the system..." else CUDF_CMAKE_CUDA_ARCHITECTURES="" diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt index 2e0c12d683a..2a51ad5e55a 100644 --- a/cpp/CMakeLists.txt +++ b/cpp/CMakeLists.txt @@ -22,10 +22,9 @@ cmake_minimum_required(VERSION 3.18 FATAL_ERROR) # This needs to be run before enabling the CUDA language due to the default initialization behavior # of `CMAKE_CUDA_ARCHITECTURES`, https://gitlab.kitware.com/cmake/cmake/-/issues/21302 -if(NOT DEFINED CMAKE_CUDA_ARCHITECTURES) +if(NOT DEFINED CMAKE_CUDA_ARCHITECTURES OR CMAKE_CUDA_ARCHITECTURES STREQUAL "ALL") set(CUDF_BUILD_FOR_ALL_ARCHS TRUE) elseif(CMAKE_CUDA_ARCHITECTURES STREQUAL "") - unset(CMAKE_CUDA_ARCHITECTURES CACHE) set(CUDF_BUILD_FOR_DETECTED_ARCHS TRUE) endif() diff --git a/cpp/cmake/thirdparty/CUDF_GetRMM.cmake b/cpp/cmake/thirdparty/CUDF_GetRMM.cmake index ccefaf2ff33..16c8a2b39f4 100644 --- a/cpp/cmake/thirdparty/CUDF_GetRMM.cmake +++ b/cpp/cmake/thirdparty/CUDF_GetRMM.cmake @@ -43,7 +43,6 @@ function(find_and_configure_rmm VERSION) OPTIONS "BUILD_TESTS OFF" "BUILD_BENCHMARKS OFF" "CUDA_STATIC_RUNTIME ${CUDA_STATIC_RUNTIME}" - "CMAKE_CUDA_ARCHITECTURES ${CMAKE_CUDA_ARCHITECTURES}" "DISABLE_DEPRECATION_WARNING ${DISABLE_DEPRECATION_WARNING}" ) cudf_restore_if_enabled(BUILD_TESTS)