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

Switch thrust over to use rapids-cmake patches #265

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
23 changes: 12 additions & 11 deletions rapids-cmake/cpm/nvcomp.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -93,17 +93,6 @@ function(rapids_cpm_nvcomp)
include("${rapids-cmake-dir}/cpm/detail/get_proprietary_binary.cmake")
rapids_cpm_get_proprietary_binary(nvcomp ${version})

# Remove incorrect public dependency on the static cuda runtime We have to modify the
# nvcomp-targets.cmake since these entries will cause a failure when rapids_cpm_find is called.
if(nvcomp_proprietary_binary AND ${version} VERSION_EQUAL "2.3.2")
set(target_file "${nvcomp_ROOT}/lib/cmake/nvcomp/nvcomp-targets.cmake")
if(EXISTS "${target_file}")
file(READ "${target_file}" file_contents)
string(REPLACE "CUDA::cudart_static" "" file_contents "${file_contents}")
file(WRITE "${target_file}" "${file_contents}")
endif()
endif()

# Record the nvcomp_DIR so that if USE_PROPRIETARY_BINARY is disabled we can safely clear the
# nvcomp_DIR value
if(nvcomp_proprietary_binary)
Expand All @@ -120,6 +109,14 @@ function(rapids_cpm_nvcomp)
endif()
endif()

include("${rapids-cmake-dir}/cpm/detail/generate_patch_command.cmake")
rapids_cpm_generate_patch_command(nvcomp ${version} patch_command)

# Apply any patch commands to the proprietary binary
if(nvcomp_proprietary_binary AND patch_command)
execute_process(COMMAND ${patch_command} WORKING_DIRECTORY ${nvcomp_ROOT})
vyasr marked this conversation as resolved.
Show resolved Hide resolved
endif()

include("${rapids-cmake-dir}/cpm/find.cmake")
rapids_cpm_find(nvcomp ${version} ${_RAPIDS_UNPARSED_ARGUMENTS}
GLOBAL_TARGETS nvcomp::nvcomp
Expand All @@ -128,9 +125,13 @@ function(rapids_cpm_nvcomp)
GIT_TAG ${tag}
GIT_SHALLOW ${shallow}
EXCLUDE_FROM_ALL ${to_exclude}
PATCH_COMMAND ${patch_command}
OPTIONS "BUILD_STATIC ON" "BUILD_TESTS OFF" "BUILD_BENCHMARKS OFF"
"BUILD_EXAMPLES OFF")

include("${rapids-cmake-dir}/cpm/detail/display_patch_status.cmake")
rapids_cpm_display_patch_status(nvcomp)

# 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)
Expand Down
22 changes: 22 additions & 0 deletions rapids-cmake/cpm/patches/Thrust/install_rules.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
diff --git a/cmake/ThrustInstallRules.cmake b/cmake/ThrustInstallRules.cmake
index 93084c1..bf6c195 100644
--- a/cmake/ThrustInstallRules.cmake
+++ b/cmake/ThrustInstallRules.cmake
@@ -13,7 +13,7 @@ install(DIRECTORY "${Thrust_SOURCE_DIR}/thrust"

install(DIRECTORY "${Thrust_SOURCE_DIR}/thrust/cmake/"
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/thrust"
- PATTERN thrust-header-search EXCLUDE
+ REGEX thrust-header-search.* EXCLUDE
)
# Need to configure a file to store the infix specified in
# CMAKE_INSTALL_INCLUDEDIR since it can be defined by the user
@@ -39,7 +39,7 @@ if (THRUST_INSTALL_CUB_HEADERS)
# Need to configure a file to store THRUST_INSTALL_HEADER_INFIX
install(DIRECTORY "${Thrust_SOURCE_DIR}/dependencies/cub/cub/cmake/"
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/cub"
- PATTERN cub-header-search EXCLUDE
+ REGEX cub-header-search.* EXCLUDE
)
set(install_location "${CMAKE_INSTALL_LIBDIR}/cmake/cub")
configure_file("${Thrust_SOURCE_DIR}/dependencies/cub/cub/cmake/cub-header-search.cmake.in"
30 changes: 10 additions & 20 deletions rapids-cmake/cpm/thrust.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,14 @@ Result Variables
function(rapids_cpm_thrust NAMESPACE namespaces_name)
list(APPEND CMAKE_MESSAGE_CONTEXT "rapids.cpm.thrust")

set(to_install OFF)
if(INSTALL_EXPORT_SET IN_LIST ARGN)
set(to_install ON)
# Make sure we install thrust into the `include/rapids` subdirectory instead of the default
include(GNUInstallDirs)
set(CMAKE_INSTALL_INCLUDEDIR "${CMAKE_INSTALL_INCLUDEDIR}/rapids")
endif()

include("${rapids-cmake-dir}/cpm/detail/package_details.cmake")
rapids_cpm_package_details(Thrust version repository tag shallow exclude)

Expand All @@ -70,7 +78,8 @@ function(rapids_cpm_thrust NAMESPACE namespaces_name)
GIT_TAG ${tag}
GIT_SHALLOW ${shallow}
PATCH_COMMAND ${patch_command}
EXCLUDE_FROM_ALL ${exclude})
EXCLUDE_FROM_ALL ${exclude}
OPTIONS "THRUST_ENABLE_INSTALL_RULES ${to_install}")

include("${rapids-cmake-dir}/cpm/detail/display_patch_status.cmake")
rapids_cpm_display_patch_status(Thrust)
Expand All @@ -87,25 +96,6 @@ function(rapids_cpm_thrust NAMESPACE namespaces_name)
${_RAPIDS_BUILD_EXPORT_SET})
endif()

if(Thrust_SOURCE_DIR AND _RAPIDS_INSTALL_EXPORT_SET AND NOT exclude)
# Make sure we install thrust into the `include/rapids` subdirectory instead of the default
include(GNUInstallDirs)
set(CMAKE_INSTALL_INCLUDEDIR "${CMAKE_INSTALL_INCLUDEDIR}/rapids")

# Thrust 1.17 has a bug where it doesn't generate proper exclude rules for the
# `[cub|thrust]-header-search` files, which causes the build tree version to be installed
# instead of the install version
if(NOT EXISTS "${Thrust_BINARY_DIR}/cmake/ThrustInstallRulesForRapids.cmake")
file(READ "${Thrust_SOURCE_DIR}/cmake/ThrustInstallRules.cmake" contents)
string(REPLACE "PATTERN cub-header-search EXCLUDE" "REGEX cub-header-search.* EXCLUDE"
contents "${contents}")
string(REPLACE "PATTERN thrust-header-search EXCLUDE" "REGEX thrust-header-search.* EXCLUDE"
contents "${contents}")
file(WRITE "${Thrust_BINARY_DIR}/cmake/ThrustInstallRulesForRapids.cmake" ${contents})
endif()
include("${Thrust_BINARY_DIR}/cmake/ThrustInstallRulesForRapids.cmake")
endif()

if(NOT TARGET ${namespaces_name}::Thrust)
thrust_create_target(${namespaces_name}::Thrust FROM_OPTIONS)
set_target_properties(${namespaces_name}::Thrust PROPERTIES IMPORTED_NO_SYSTEM ON)
Expand Down
9 changes: 8 additions & 1 deletion rapids-cmake/cpm/versions.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,14 @@
"Thrust" : {
"version" : "1.17.2",
"git_url" : "https://github.com/NVIDIA/thrust.git",
"git_tag" : "${version}"
"git_tag" : "${version}",
"patches" : [
{
"file" : "Thrust/install_rules.diff",
"issue" : "Thrust 1.X installs incorrect files [https://github.com/NVIDIA/thrust/issues/1790]",
"fixed_in" : "2.0"
}
]
},
"libcudacxx" : {
"version" : "1.8.0",
Expand Down