-
Notifications
You must be signed in to change notification settings - Fork 47
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 rapids_cpm_nvcomp with prebuilt binary support #190
Merged
rapids-bot
merged 23 commits into
rapidsai:branch-22.06
from
robertmaynard:add_cpm_nvcomp
May 16, 2022
Merged
Changes from all commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
c518023
Add rapids_cpm_nvcomp with prebuilt binary support
robertmaynard c2fb8cc
Update rapids_cpm_nvcomp with install rules
robertmaynard d33f602
fix style issues found by ci
robertmaynard a78e8ef
Update testing/cpm/cpm_nvcomp-override-clears-proprietary_binary.cmake
robertmaynard 853ead1
Update testing/cpm/cpm_nvcomp-invalid-arch.cmake
robertmaynard 20d9cb3
Update testing/cpm/cpm_nvcomp-export.cmake
robertmaynard 71a30dd
Update docs/packages/rapids_cpm_versions.rst
robertmaynard c4d4450
Update docs/packages/rapids_cpm_versions.rst
robertmaynard 2dc013a
Update docs/packages/rapids_cpm_versions.rst
robertmaynard 6e37baa
Update docs/packages/rapids_cpm_versions.rst
robertmaynard 632bbf9
Update rapids-cmake/cpm/detail/get_proprietary_binary.cmake
robertmaynard d40c14d
simplify rapids_cpm_get_proprietary_binary as found in code review
robertmaynard b8ffa15
Update rapids-cmake/cpm/nvcomp.cmake
robertmaynard b638b29
Update rapids-cmake/cpm/nvcomp.cmake
robertmaynard cdc697d
Update rapids-cmake/cpm/nvcomp.cmake
robertmaynard 9b94e88
Update comment to be correct
robertmaynard 93d3e04
Update rapids-cmake/cpm/nvcomp.cmake
robertmaynard 0819a38
reorder so exclude variable exists
robertmaynard ae4fab0
Remove unneeded build export set logic
robertmaynard 453f1f9
Encode json loading from global properties in a function
robertmaynard 94b241e
change license file location
robertmaynard 4073c7f
Improve USE_PROPRIETARY_BINARY docs
robertmaynard 8429f0a
Correct style issues found by CI
robertmaynard File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
|
||
{ | ||
"proprietary_binary" : { | ||
"aarch64-linux" : "<url>", | ||
"x86_64-linux" : "<url>" | ||
} | ||
} |
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 @@ | ||
.. cmake-module:: ../../rapids-cmake/cpm/nvcomp.cmake |
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,31 @@ | ||
#============================================================================= | ||
# 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. | ||
#============================================================================= | ||
include_guard(GLOBAL) | ||
|
||
#[=======================================================================[.rst: | ||
get_default_json | ||
-------------------------- | ||
|
||
. code-block:: cmake | ||
|
||
get_default_json(package_name output_variable) | ||
|
||
#]=======================================================================] | ||
function(get_default_json package_name output_variable) | ||
list(APPEND CMAKE_MESSAGE_CONTEXT "rapids.cpm.get_default_json") | ||
get_property(json_data GLOBAL PROPERTY rapids_cpm_${package_name}_json) | ||
set(${output_variable} "${json_data}" PARENT_SCOPE) | ||
endfunction() |
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,31 @@ | ||
#============================================================================= | ||
# 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. | ||
#============================================================================= | ||
include_guard(GLOBAL) | ||
|
||
#[=======================================================================[.rst: | ||
get_override_json | ||
-------------------------- | ||
|
||
. code-block:: cmake | ||
|
||
get_override_json(package_name output_variable) | ||
|
||
#]=======================================================================] | ||
function(get_override_json package_name output_variable) | ||
list(APPEND CMAKE_MESSAGE_CONTEXT "rapids.cpm.get_override_json") | ||
get_property(json_data GLOBAL PROPERTY rapids_cpm_${package_name}_override_json) | ||
set(${output_variable} "${json_data}" PARENT_SCOPE) | ||
endfunction() |
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,79 @@ | ||
#============================================================================= | ||
# Copyright (c) 2022, 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: | ||
get_proprietary_binary | ||
------------------- | ||
|
||
.. versionadded:: v22.06.00 | ||
|
||
Download the associated proprietary binary for the given project based on | ||
the current CPU target architecture ( x86_64, aarch64, etc ) | ||
|
||
.. note:: | ||
if override => the proprietary entry only in the override will be evaluated | ||
if no override => the proprietary entry only in the default will be evaluated | ||
|
||
|
||
#]=======================================================================] | ||
function(rapids_cpm_get_proprietary_binary package_name version) | ||
list(APPEND CMAKE_MESSAGE_CONTEXT "rapids.cpm.rapids_cpm_get_proprietary_binary") | ||
|
||
include("${rapids-cmake-dir}/cpm/detail/get_default_json.cmake") | ||
include("${rapids-cmake-dir}/cpm/detail/get_override_json.cmake") | ||
get_default_json(${package_name} json_data) | ||
get_override_json(${package_name} override_json_data) | ||
|
||
# need to search the `proprietary_binary` dictionary for a key with the same name as | ||
# lower_case(`CMAKE_SYSTEM_PROCESSOR-CMAKE_SYSTEM_NAME`). | ||
set(key "${CMAKE_SYSTEM_PROCESSOR}-${CMAKE_SYSTEM_NAME}") | ||
string(TOLOWER ${key} key) | ||
if(override_json_data) | ||
string(JSON proprietary_binary ERROR_VARIABLE have_error GET "${override_json_data}" | ||
"proprietary_binary" "${key}") | ||
else() | ||
string(JSON proprietary_binary ERROR_VARIABLE have_error GET "${json_data}" | ||
"proprietary_binary" "${key}") | ||
endif() | ||
|
||
if(have_error) | ||
message(VERBOSE | ||
"${package_name} requested usage of a proprietary_binary but none exist for ${CMAKE_SYSTEM_PROCESSOR}" | ||
) | ||
return() | ||
endif() | ||
|
||
if(NOT DEFINED rapids-cmake-version) | ||
include("${rapids-cmake-dir}/rapids-version.cmake") | ||
endif() | ||
|
||
# Evaluate any magic placeholders in the proprietary_binary value including the | ||
# `rapids-cmake-version` value | ||
cmake_language(EVAL CODE "set(proprietary_binary ${proprietary_binary})") | ||
robertmaynard marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
if(proprietary_binary) | ||
# download and extract the binaries since they don't exist on the machine | ||
include(FetchContent) | ||
set(pkg_name "${package_name}_proprietary_binary") | ||
FetchContent_Declare(${pkg_name} URL ${proprietary_binary}) | ||
FetchContent_MakeAvailable(${pkg_name}) | ||
|
||
# Tell the subsequent rapids_cpm_find where to search so that it uses this binary | ||
set(${package_name}_ROOT "${${pkg_name}_SOURCE_DIR}" PARENT_SCOPE) | ||
set(${package_name}_proprietary_binary ON PARENT_SCOPE) | ||
endif() | ||
endfunction() |
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,146 @@ | ||
#============================================================================= | ||
# 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. | ||
#============================================================================= | ||
include_guard(GLOBAL) | ||
|
||
#[=======================================================================[.rst: | ||
rapids_cpm_nvcomp | ||
----------------- | ||
|
||
.. versionadded:: v22.06.00 | ||
|
||
Allow projects to find or build `nvComp` via `CPM` with built-in | ||
tracking of these dependencies for correct export support. | ||
|
||
Uses the version of nvComp :ref:`specified in the version file <cpm_versions>` for consistency | ||
across all RAPIDS projects. | ||
|
||
.. code-block:: cmake | ||
|
||
rapids_cpm_nvcomp( [BUILD_EXPORT_SET <export-name>] | ||
robertmaynard marked this conversation as resolved.
Show resolved
Hide resolved
|
||
[INSTALL_EXPORT_SET <export-name>] | ||
[USE_PROPRIETARY_BINARY <ON|OFF>] | ||
) | ||
|
||
``BUILD_EXPORT_SET`` | ||
Record that a :cmake:command:`CPMFindPackage(<PackageName> ...)` call needs to occur as part of | ||
our build directory export set. | ||
|
||
``INSTALL_EXPORT_SET`` | ||
Record a :cmake:command:`find_dependency(<PackageName> ...) <cmake:module:CMakeFindDependencyMacro>` call needs to occur as part of | ||
our build directory export set. | ||
|
||
.. note:: | ||
Installation of nvcomp will occur if an INSTALL_EXPORT_SET is provided, and nvcomp | ||
is added to the project via :cmake:command:`add_subdirectory <cmake:command:add_subdirectory>` by CPM. | ||
|
||
``USE_PROPRIETARY_BINARY`` | ||
By enabling this flag and using the software, you agree to fully comply with the terms and conditions of | ||
nvcomp's NVIDIA Software License Agreement. Found at https://developer.download.nvidia.com/compute/nvcomp/2.3/LICENSE.txt | ||
|
||
NVComp offers pre-built proprietary version of the library ( for x86_64 only ) that offer more features compared to the | ||
open source version. Since NVComp currently doesn't offer pre-built versions for all platforms, callers should verify | ||
the the request for a proprietary binary was fulfilled by checking the :cmake:variable:`nvcomp_proprietary_binary` | ||
variable after calling :cmake:command:`rapids_cpm_nvcomp`. | ||
|
||
.. note:: | ||
If an override entry exists for the nvcomp package it MUST have a proprietary_binary entry for this to | ||
flag to do anything. Any override without this entry is considered to invalidate the existin proprietary | ||
binary entry. | ||
|
||
Result Targets | ||
^^^^^^^^^^^^^^ | ||
nvcomp::nvcomp target will be created | ||
|
||
Result Variables | ||
^^^^^^^^^^^^^^^^ | ||
:cmake:variable:`nvcomp_SOURCE_DIR` is set to the path to the source directory of nvcomp. | ||
:cmake:variable:`nvcomp_BINARY_DIR` is set to the path to the build directory of nvcomp. | ||
:cmake:variable:`nvcomp_ADDED` is set to a true value if nvcomp has not been added before. | ||
:cmake:variable:`nvcomp_VERSION` is set to the version of nvcomp specified by the versions.json. | ||
:cmake:variable:`nvcomp_proprietary_binary` is set to ON if the proprietary binary is being used | ||
|
||
#]=======================================================================] | ||
function(rapids_cpm_nvcomp) | ||
list(APPEND CMAKE_MESSAGE_CONTEXT "rapids.cpm.nvcomp") | ||
|
||
set(options) | ||
set(one_value USE_PROPRIETARY_BINARY BUILD_EXPORT_SET INSTALL_EXPORT_SET) | ||
set(multi_value) | ||
cmake_parse_arguments(RAPIDS "${options}" "${one_value}" "${multi_value}" ${ARGN}) | ||
|
||
# Fix up RAPIDS_UNPARSED_ARGUMENTS to have EXPORT_SETS as this is need for rapids_cpm_find | ||
if(RAPIDS_INSTALL_EXPORT_SET) | ||
list(APPEND RAPIDS_UNPARSED_ARGUMENTS INSTALL_EXPORT_SET ${RAPIDS_INSTALL_EXPORT_SET}) | ||
endif() | ||
if(RAPIDS_BUILD_EXPORT_SET) | ||
list(APPEND RAPIDS_UNPARSED_ARGUMENTS BUILD_EXPORT_SET ${RAPIDS_BUILD_EXPORT_SET}) | ||
endif() | ||
|
||
include("${rapids-cmake-dir}/cpm/detail/package_details.cmake") | ||
rapids_cpm_package_details(nvcomp version repository tag shallow exclude) | ||
set(to_exclude OFF) | ||
if(NOT RAPIDS_INSTALL_EXPORT_SET OR exclude) | ||
robertmaynard marked this conversation as resolved.
Show resolved
Hide resolved
|
||
set(to_exclude ON) | ||
endif() | ||
|
||
# first see if we have a proprietary pre-built binary listed in versions.json and it if requested. | ||
set(nvcomp_proprietary_binary OFF) # will be set to true by rapids_cpm_get_proprietary_binary | ||
if(RAPIDS_USE_PROPRIETARY_BINARY) | ||
include("${rapids-cmake-dir}/cpm/detail/get_proprietary_binary.cmake") | ||
rapids_cpm_get_proprietary_binary(nvcomp ${version}) | ||
endif() | ||
|
||
include("${rapids-cmake-dir}/cpm/find.cmake") | ||
rapids_cpm_find(nvcomp ${version} ${RAPIDS_UNPARSED_ARGUMENTS} | ||
GLOBAL_TARGETS nvcomp::nvcomp | ||
CPM_ARGS | ||
GIT_REPOSITORY ${repository} | ||
GIT_TAG ${tag} | ||
GIT_SHALLOW ${shallow} | ||
EXCLUDE_FROM_ALL ${to_exclude} | ||
OPTIONS "BUILD_STATIC ON" "BUILD_TESTS OFF" "BUILD_BENCHMARKS OFF" | ||
"BUILD_EXAMPLES OFF") | ||
|
||
# provice consistent targets between a found nvcomp and one building from source | ||
if(NOT TARGET nvcomp::nvcomp AND TARGET nvcomp) | ||
add_library(nvcomp::nvcomp ALIAS nvcomp) | ||
endif() | ||
|
||
# Propagate up variables that CPMFindPackage provide | ||
set(nvcomp_SOURCE_DIR "${nvcomp_SOURCE_DIR}" PARENT_SCOPE) | ||
set(nvcomp_BINARY_DIR "${nvcomp_BINARY_DIR}" PARENT_SCOPE) | ||
set(nvcomp_ADDED "${nvcomp_ADDED}" PARENT_SCOPE) | ||
set(nvcomp_VERSION ${version} PARENT_SCOPE) | ||
set(nvcomp_proprietary_binary ${nvcomp_proprietary_binary} PARENT_SCOPE) | ||
|
||
# Set up up install rules when using the proprietary_binary. When building from source, nvcomp | ||
# will set the correct install rules | ||
include("${rapids-cmake-dir}/export/find_package_root.cmake") | ||
if(RAPIDS_INSTALL_EXPORT_SET AND nvcomp_proprietary_binary) | ||
include(GNUInstallDirs) | ||
install(DIRECTORY "${nvcomp_ROOT}/lib/" DESTINATION ${CMAKE_INSTALL_LIBDIR}) | ||
install(DIRECTORY "${nvcomp_ROOT}/include/" DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) | ||
# place the license information in the location that conda uses | ||
install(FILES "${nvcomp_ROOT}/NOTICE" DESTINATION info/ RENAME NVCOMP_NOTICE) | ||
install(FILES "${nvcomp_ROOT}/LICENSE" DESTINATION info/ RENAME NVCOMP_LICENSE) | ||
endif() | ||
|
||
if(RAPIDS_BUILD_EXPORT_SET AND nvcomp_proprietary_binary) | ||
# point our consumers to where they can find the pre-built version | ||
rapids_export_find_package_root(BUILD nvcomp "${nvcomp_ROOT}" ${RAPIDS_BUILD_EXPORT_SET}) | ||
endif() | ||
|
||
endfunction() |
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we fail harder here? Or at least, propagate sufficient information for the parent scope to fail harder? As it stands now, if a user passes
USE_PROPERIETARY_BINARY
torapids_cpm_nvcomp
and no binary is found, there will just be a small message. Shouldn'trapids_cpm_nvcomp
fail in that scenario (even ifrapids_cpm_get_proprietary_binary
shouldn't)?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could implement it that way.
My concern is that since nvcomp doesn't have arm binaries, projects like cudf would need to somehow query rapids-cmake to see if the platform they are running on has binary support and if so request
USE_PROPERIETARY_BINARY
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After talking with vysar offline we agreed more documentation is needed in
USE_PROPRIETARY_BINARY
to explain the behavior of the command when an override exists, or if no binary exists for platform ( arm / windows / etc ).