-
Notifications
You must be signed in to change notification settings - Fork 915
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use CMAKE_CUDA_ARCHITECTURES (#7391)
When using CMake >= 3.18 you now don't get `CMP0104` warnings for each target that use CUDA. To correct this issue I have cherry-picked a collection of changes from #7107 which updated cudf to use `CMAKE_CUDA_ARCHITECTURES`. When using CMake < 3.18 cudf will transform `CMAKE_CUDA_ARCHITECTURES` into the correct flags and store it into `CMAKE_CUDA_FLAGS`. When I was porting this over from !7107 I noticed that when cudf is built for multi arch ( sm60, sm70, sm80, ... ) it only compiles compute for the newest arch. This behavior is preserved, and !7107 will need to be updated with this change. Authors: - Robert Maynard (@robertmaynard) - Paul Taylor (@trxcllnt) Approvers: - Mark Harris (@harrism) - Keith Kraus (@kkraus14) URL: #7391
- Loading branch information
1 parent
2ae7498
commit 7a6e60e
Showing
5 changed files
with
152 additions
and
98 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
#============================================================================= | ||
# Copyright (c) 2018-2021, NVIDIA CORPORATION. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
#============================================================================= | ||
|
||
# Auto-detect available GPU compute architectures | ||
|
||
include(${CUDA_DATAFRAME_SOURCE_DIR}/cmake/Modules/SetGPUArchs.cmake) | ||
message(STATUS "CUDF: Building CUDF for GPU architectures: ${CMAKE_CUDA_ARCHITECTURES}") | ||
|
||
if(CMAKE_CUDA_COMPILER_VERSION) | ||
# Compute the version. from CMAKE_CUDA_COMPILER_VERSION | ||
string(REGEX REPLACE "([0-9]+)\\.([0-9]+).*" "\\1" CUDA_VERSION_MAJOR ${CMAKE_CUDA_COMPILER_VERSION}) | ||
string(REGEX REPLACE "([0-9]+)\\.([0-9]+).*" "\\2" CUDA_VERSION_MINOR ${CMAKE_CUDA_COMPILER_VERSION}) | ||
set(CUDA_VERSION "${CUDA_VERSION_MAJOR}.${CUDA_VERSION_MINOR}") | ||
endif() | ||
|
||
message(VERBOSE "CUDF: CUDA_VERSION_MAJOR: ${CUDA_VERSION_MAJOR}") | ||
message(VERBOSE "CUDF: CUDA_VERSION_MINOR: ${CUDA_VERSION_MINOR}") | ||
message(STATUS "CUDF: CUDA_VERSION: ${CUDA_VERSION}") | ||
|
||
if(CMAKE_COMPILER_IS_GNUCXX) | ||
string(APPEND CMAKE_CXX_FLAGS " -Wall -Werror -Wno-unknown-pragmas -Wno-error=deprecated-declarations") | ||
if(CUDF_BUILD_TESTS OR CUDF_BUILD_BENCHMARKS) | ||
# Suppress parentheses warning which causes gmock to fail | ||
string(APPEND CMAKE_CUDA_FLAGS " -Xcompiler=-Wno-parentheses") | ||
endif() | ||
endif() | ||
|
||
string(APPEND CMAKE_CUDA_FLAGS " --expt-extended-lambda --expt-relaxed-constexpr") | ||
|
||
# set warnings as errors | ||
string(APPEND CMAKE_CUDA_FLAGS " -Werror=cross-execution-space-call") | ||
string(APPEND CMAKE_CUDA_FLAGS " -Xcompiler=-Wall,-Werror,-Wno-error=deprecated-declarations") | ||
|
||
if(DISABLE_DEPRECATION_WARNING) | ||
string(APPEND CMAKE_CXX_FLAGS " -Wno-deprecated-declarations") | ||
string(APPEND CMAKE_CUDA_FLAGS " -Xcompiler=-Wno-deprecated-declarations") | ||
endif() | ||
|
||
# Option to enable line info in CUDA device compilation to allow introspection when profiling / memchecking | ||
if(CMAKE_CUDA_LINEINFO) | ||
string(APPEND CMAKE_CUDA_FLAGS " -lineinfo") | ||
endif() | ||
|
||
# Debug options | ||
if(CMAKE_BUILD_TYPE MATCHES Debug) | ||
message(VERBOSE "CUDF: Building with debugging flags") | ||
string(APPEND CMAKE_CUDA_FLAGS " -G -Xcompiler=-rdynamic") | ||
endif() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
# ============================================================================= | ||
# Copyright (c) 2021, NVIDIA CORPORATION. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except | ||
# in compliance with the License. You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software distributed under the License | ||
# is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express | ||
# or implied. See the License for the specific language governing permissions and limitations under | ||
# the License. | ||
# ============================================================================= | ||
|
||
# Build the list of supported architectures | ||
|
||
set(SUPPORTED_CUDA_ARCHITECTURES "60" "62" "70" "72" "75" "80") | ||
|
||
# Check for embedded vs workstation architectures | ||
if(CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64") | ||
# This is being built for Linux4Tegra or SBSA ARM64 | ||
list(REMOVE_ITEM SUPPORTED_CUDA_ARCHITECTURES "60" "70") | ||
else() | ||
# This is being built for an x86 or x86_64 architecture | ||
list(REMOVE_ITEM SUPPORTED_CUDA_ARCHITECTURES "62" "72") | ||
endif() | ||
|
||
if(CMAKE_CUDA_COMPILER_VERSION VERSION_LESS 11) | ||
list(REMOVE_ITEM SUPPORTED_CUDA_ARCHITECTURES "80") | ||
endif() | ||
if(CMAKE_CUDA_COMPILER_VERSION VERSION_LESS 10) | ||
list(REMOVE_ITEM SUPPORTED_CUDA_ARCHITECTURES "75") | ||
endif() | ||
if(CMAKE_CUDA_COMPILER_VERSION VERSION_LESS 9) | ||
list(REMOVE_ITEM SUPPORTED_CUDA_ARCHITECTURES "70") | ||
endif() | ||
|
||
if(${PROJECT_NAME}_BUILD_FOR_ALL_ARCHS) | ||
set(CMAKE_CUDA_ARCHITECTURES ${SUPPORTED_CUDA_ARCHITECTURES}) | ||
elseif(${PROJECT_NAME}_BUILD_FOR_DETECTED_ARCHS) | ||
include(${PROJECT_SOURCE_DIR}/cmake/EvalGpuArchs.cmake) | ||
evaluate_gpu_archs(CMAKE_CUDA_ARCHITECTURES) | ||
endif() | ||
|
||
if (CMAKE_VERSION VERSION_GREATER_EQUAL 3.18) | ||
# CMake architecture list entry of "80" means to build compute and sm. | ||
# What we want is for the newest arch only to build that way | ||
# while the rest built only for sm. | ||
list(SORT CMAKE_CUDA_ARCHITECTURES ORDER ASCENDING) | ||
list(POP_BACK CMAKE_CUDA_ARCHITECTURES latest_arch) | ||
list(TRANSFORM CMAKE_CUDA_ARCHITECTURES APPEND "-real") | ||
list(APPEND CMAKE_CUDA_ARCHITECTURES ${latest_arch}) | ||
else() | ||
foreach(arch IN LISTS CMAKE_CUDA_ARCHITECTURES) | ||
string(APPEND CMAKE_CUDA_FLAGS " -gencode=arch=compute_${arch},code=sm_${arch}") | ||
endforeach() | ||
|
||
list(GET CMAKE_CUDA_ARCHITECTURES -1 ptx) | ||
string(APPEND CMAKE_CUDA_FLAGS " -gencode=arch=compute_${ptx},code=compute_${ptx}") | ||
unset(CMAKE_CUDA_ARCHITECTURES) | ||
endif() |