Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add deprecation warnings for usage of ALL #339

Merged
Merged
Show file tree
Hide file tree
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
10 changes: 10 additions & 0 deletions cmake-format-rapids-cmake.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,16 @@
"nargs": 3
}
},
"rapids_cmake_policy": {
"pargs": {
"nargs": 0
},
"kwargs": {
"DEPRECATED_IN": 1,
"REMOVED_IN": 1,
"MESSAGE": 1
}
},
"rapids_cmake_support_conda_env": {
"pargs": {
"nargs": 1,
Expand Down
50 changes: 50 additions & 0 deletions rapids-cmake/cmake/detail/policy.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#=============================================================================
# Copyright (c) 2023, 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.
#=============================================================================
include_guard(GLOBAL)

#[=======================================================================[.rst:
rapids_cmake_policy
-------------------

.. versionadded:: v23.02.00

Prints rapids-cmake deprecated warnings

.. code-block:: cmake

rapids_cmake_policy( DEPRECATED_IN <version> REMOVED_IN <version> MESSAGE <content>)

#]=======================================================================]
function(rapids_cmake_policy)
set(options "")
set(one_value DEPRECATED_IN REMOVED_IN MESSAGE)
set(multi_value "")
cmake_parse_arguments(_RAPIDS_POLICY "${options}" "${one_value}" "${multi_value}" ${ARGN})

set(_RAPIDS_POLICY_CALLERS_VERSION ${rapids-cmake-version})

set(policy_context_text
"rapids-cmake policy [deprecated=${_RAPIDS_POLICY_DEPRECATED_IN} removed=${_RAPIDS_POLICY_REMOVED_IN}]:"
)
set(policy_upgrade_text "")
if(_RAPIDS_POLICY_CALLERS_VERSION VERSION_LESS ${_RAPIDS_POLICY_DEPRECATED_IN})
set(policy_upgrade_text
"You are currently requesting rapids-cmake ${_RAPIDS_POLICY_CALLERS_VERSION} please upgrade to ${_RAPIDS_POLICY_DEPRECATED_IN}."
)
endif()
message(DEPRECATION "${policy_context_text} ${_RAPIDS_POLICY_MESSAGE} ${policy_upgrade_text}")

endfunction()
55 changes: 55 additions & 0 deletions rapids-cmake/cuda/detail/architectures_policy.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#=============================================================================
# Copyright (c) 2023, 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.
#=============================================================================
include_guard(GLOBAL)

#[=======================================================================[.rst:
rapids_cuda_architectures_policy
--------------------------------

.. versionadded:: v23.02.00

Maps deprecated mode values to new supported values and outputs rapids-cmake
deprecation warnings.

.. code-block:: cmake

rapids_cuda_architectures_policy( (FROM_INIT|FROM_SET) mode_variable )

#]=======================================================================]
function(rapids_cuda_architectures_policy called_from mode_variable)
list(APPEND CMAKE_MESSAGE_CONTEXT "rapids.cuda.architectures_policy")

include("${rapids-cmake-dir}/cmake/detail/policy.cmake")

set(value ${${mode_variable}})
set(new_value ${value})
if(value STREQUAL "ALL")
set(new_value "RAPIDS")
if(called_from STREQUAL "FROM_INIT")
rapids_cmake_policy(DEPRECATED_IN 23.02
REMOVED_IN 23.06
MESSAGE "Usage of `ALL` as value for `CMAKE_CUDA_ARCHITECTURES` or the env variable `CUDAARCHS` has been deprecated, use `RAPIDS` instead."
)
elseif(called_from STREQUAL "FROM_SET")
rapids_cmake_policy(DEPRECATED_IN 23.02
REMOVED_IN 23.06
MESSAGE "Usage of `ALL` as value passed to `rapids_cuda_set_architectures` has been deprecated, use `RAPIDS` instead."
)
endif()
endif()

set(${mode_variable} ${new_value} PARENT_SCOPE)
endfunction()
12 changes: 8 additions & 4 deletions rapids-cmake/cuda/init_architectures.cmake
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#=============================================================================
# Copyright (c) 2021, NVIDIA CORPORATION.
# Copyright (c) 2021-2023, NVIDIA CORPORATION.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -22,7 +22,7 @@ rapids_cuda_init_architectures
.. versionadded:: v21.06.00

Extends :cmake:variable:`CMAKE_CUDA_ARCHITECTURES <cmake:variable:CMAKE_CUDA_ARCHITECTURES>`
to include support for `ALL` and `NATIVE` to make CUDA architecture compilation easier.
to include support for `RAPIDS` and `NATIVE` to make CUDA architecture compilation easier.

.. code-block:: cmake

Expand Down Expand Up @@ -68,16 +68,20 @@ Example on how to properly use :cmake:command:`rapids_cuda_init_architectures`:
# cmake-lint: disable=W0105
function(rapids_cuda_init_architectures project_name)
list(APPEND CMAKE_MESSAGE_CONTEXT "rapids.cuda.init_architectures")

include(${CMAKE_CURRENT_FUNCTION_LIST_DIR}/detail/architectures_policy.cmake)
# If `CMAKE_CUDA_ARCHITECTURES` is not defined, build for all supported architectures. If
# `CMAKE_CUDA_ARCHITECTURES` is set to an empty string (""), build for only the current
# architecture. If `CMAKE_CUDA_ARCHITECTURES` is specified by the user, use user setting.
if(DEFINED ENV{CUDAARCHS} AND ("$ENV{CUDAARCHS}" STREQUAL "RAPIDS" OR "$ENV{CUDAARCHS}" STREQUAL
"ALL"))
set(cuda_arch_mode "RAPIDS")
set(cuda_arch_mode "$ENV{CUDAARCHS}")
rapids_cuda_architectures_policy(FROM_INIT cuda_arch_mode)
elseif(DEFINED ENV{CUDAARCHS} AND "$ENV{CUDAARCHS}" STREQUAL "NATIVE")
set(cuda_arch_mode "NATIVE")
elseif(CMAKE_CUDA_ARCHITECTURES STREQUAL "RAPIDS" OR CMAKE_CUDA_ARCHITECTURES STREQUAL "ALL")
set(cuda_arch_mode "RAPIDS")
set(cuda_arch_mode "${CMAKE_CUDA_ARCHITECTURES}")
rapids_cuda_architectures_policy(FROM_INIT cuda_arch_mode)
elseif(CMAKE_CUDA_ARCHITECTURES STREQUAL "" OR CMAKE_CUDA_ARCHITECTURES STREQUAL "NATIVE")
set(cuda_arch_mode "NATIVE")
elseif(NOT (DEFINED ENV{CUDAARCHS} OR DEFINED CMAKE_CUDA_ARCHITECTURES))
Expand Down
9 changes: 6 additions & 3 deletions rapids-cmake/cuda/set_architectures.cmake
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#=============================================================================
# Copyright (c) 2021, NVIDIA CORPORATION.
# Copyright (c) 2021-2023, NVIDIA CORPORATION.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -25,7 +25,7 @@ Sets up :cmake:variable:`CMAKE_CUDA_ARCHITECTURES` based on the requested mode

.. code-block:: cmake

rapids_cuda_set_architectures( (NATIVE|ALL) )
rapids_cuda_set_architectures( (NATIVE|RAPIDS) )

Establishes what CUDA architectures that will be compiled for, overriding
any existing :cmake:variable:`CMAKE_CUDA_ARCHITECTURES` value.
Expand Down Expand Up @@ -60,7 +60,10 @@ function(rapids_cuda_set_architectures mode)
list(REMOVE_ITEM supported_archs "90")
endif()

if(${mode} STREQUAL "RAPIDS" OR ${mode} STREQUAL "ALL")
include(${CMAKE_CURRENT_FUNCTION_LIST_DIR}/detail/architectures_policy.cmake)
rapids_cuda_architectures_policy(FROM_SET mode)

if(${mode} STREQUAL "RAPIDS")

# 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.
Expand Down
7 changes: 6 additions & 1 deletion testing/cuda/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#=============================================================================
# Copyright (c) 2021, NVIDIA CORPORATION.
# Copyright (c) 2021-2023, NVIDIA CORPORATION.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -40,3 +40,8 @@ add_cmake_config_test( set_arch-existing.cmake )
add_cmake_config_test( set_arch-invalid-mode.cmake )
add_cmake_config_test( set_arch-native.cmake )
add_cmake_config_test( set_arch-rapids.cmake )

set(deprecated_message "rapids-cmake policy [deprecated=23.02 removed=23.06]: Usage of `ALL`")
add_cmake_config_test( init_arch-all-via-env-deprecated.cmake SHOULD_FAIL "${deprecated_message}")
add_cmake_config_test( init_arch-all-deprecated.cmake SHOULD_FAIL "${deprecated_message}")
add_cmake_config_test( set_arch-all-deprecated.cmake SHOULD_FAIL "${deprecated_message}")
22 changes: 22 additions & 0 deletions testing/cuda/init_arch-all-deprecated.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#=============================================================================
# Copyright (c) 2023, 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.
#=============================================================================
include(${rapids-cmake-dir}/cuda/init_architectures.cmake)


set(CMAKE_ERROR_DEPRECATED ON)
set(CMAKE_CUDA_ARCHITECTURES "ALL")
rapids_cuda_init_architectures(rapids-project)
project(rapids-project LANGUAGES CUDA)
22 changes: 22 additions & 0 deletions testing/cuda/init_arch-all-via-env-deprecated.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#=============================================================================
# Copyright (c) 2023, 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.
#=============================================================================
include(${rapids-cmake-dir}/cuda/init_architectures.cmake)


set(ENV{CUDAARCHS} "ALL")
set(CMAKE_ERROR_DEPRECATED ON)
rapids_cuda_init_architectures(rapids-project)
project(rapids-project LANGUAGES CUDA)
18 changes: 18 additions & 0 deletions testing/cuda/set_arch-all-deprecated.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#=============================================================================
# Copyright (c) 2023, 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.
#=============================================================================
include(${rapids-cmake-dir}/cuda/set_architectures.cmake)
set(CMAKE_ERROR_DEPRECATED ON)
rapids_cuda_set_architectures(ALL)