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

Upgrade nvcomp to 4.0.1 #633

Merged
merged 19 commits into from
Sep 5, 2024
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
58 changes: 35 additions & 23 deletions rapids-cmake/cpm/nvcomp.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,10 @@ across all RAPIDS projects.
Result Targets
^^^^^^^^^^^^^^
nvcomp::nvcomp target will be created
nvcomp::nvcomp_gdeflate target will be created
nvcomp::nvcomp_bitcomp target will be created
nvcomp::nvcomp_cpu target will be created
nvcomp::nvcomp_device_static target will be created
nvcomp::nvcomp_static target might be created
nvcomp::nvcomp_cpu_static target might be created

Result Variables
^^^^^^^^^^^^^^^^
Expand Down Expand Up @@ -93,9 +95,8 @@ function(rapids_cpm_nvcomp)
# first search locally if `rapids_cmake_always_download` is false
if(NOT rapids_cmake_always_download)
include("${rapids-cmake-dir}/find/package.cmake")
rapids_find_package(nvcomp ${version}
GLOBAL_TARGETS nvcomp::nvcomp nvcomp::nvcomp_gdeflate nvcomp::nvcomp_bitcomp
${_RAPIDS_EXPORT_ARGUMENTS} FIND_ARGS QUIET)
rapids_find_package(nvcomp ${version} GLOBAL_TARGETS nvcomp::nvcomp ${_RAPIDS_EXPORT_ARGUMENTS}
FIND_ARGS QUIET)
if(nvcomp_FOUND)
# report where nvcomp was found
message(STATUS "Found nvcomp: ${nvcomp_DIR} (found version ${nvcomp_VERSION})")
Expand All @@ -119,10 +120,7 @@ function(rapids_cpm_nvcomp)
endif()

if(nvcomp_proprietary_binary)
# Replace ${_IMPORT_PREFIX}/lib/ with ${_IMPORT_PREFIX}/${lib_dir}/ in
# nvcomp-release-targets.cmake. Guarded in an EXISTS check so we only try to do this on the
# first configuration pass
if(NOT EXISTS "${nvcomp_ROOT}/${lib_dir}/cmake/nvcomp/nvcomp-targets-release.cmake")
if(NOT EXISTS "${nvcomp_ROOT}/${lib_dir}/cmake/nvcomp/nvcomp-config.cmake")
include(GNUInstallDirs)
cmake_path(GET lib_dir PARENT_PATH lib_dir_parent)
cmake_path(GET CMAKE_INSTALL_INCLUDEDIR PARENT_PATH include_dir_parent)
Expand All @@ -131,13 +129,29 @@ function(rapids_cpm_nvcomp)
)
endif()

# Replace ${_IMPORT_PREFIX}/lib/ with ${_IMPORT_PREFIX}/${lib_dir}/ in
# nvcomp-release-targets.cmake. Guarded in an EXISTS check so we only try to do this on the
# first configuration pass
cmake_path(GET lib_dir FILENAME lib_dir_name)
file(READ "${nvcomp_ROOT}/lib/cmake/nvcomp/nvcomp-targets-release.cmake" FILE_CONTENTS)
string(REPLACE "\$\{_IMPORT_PREFIX\}/lib/" "\$\{_IMPORT_PREFIX\}/${lib_dir_name}/"
FILE_CONTENTS ${FILE_CONTENTS})
file(WRITE "${nvcomp_ROOT}/lib/cmake/nvcomp/nvcomp-targets-release.cmake" ${FILE_CONTENTS})
set(nvcomp_list_of_target_files
"nvcomp-targets-common-release.cmake"
"nvcomp-targets-common.cmake"
"nvcomp-targets-dynamic-release.cmake"
"nvcomp-targets-dynamic.cmake"
"nvcomp-targets-release.cmake"
"nvcomp-targets-static-release.cmake"
"nvcomp-targets-static.cmake")
foreach(filename IN LISTS nvcomp_list_of_target_files)
if(EXISTS "${nvcomp_ROOT}/lib/cmake/nvcomp/${filename}")
file(READ "${nvcomp_ROOT}/lib/cmake/nvcomp/${filename}" FILE_CONTENTS)
string(REPLACE "\$\{_IMPORT_PREFIX\}/lib/" "\$\{_IMPORT_PREFIX\}/${lib_dir_name}/"
FILE_CONTENTS ${FILE_CONTENTS})
file(WRITE "${nvcomp_ROOT}/lib/cmake/nvcomp/${filename}" ${FILE_CONTENTS})
endif()
endforeach()
file(MAKE_DIRECTORY "${nvcomp_ROOT}/${lib_dir_parent}")
file(RENAME "${nvcomp_ROOT}/lib/" "${nvcomp_ROOT}/${lib_dir}/")
# Move the `include` dir if necessary as well
file(RENAME "${nvcomp_ROOT}/include/" "${nvcomp_ROOT}/${CMAKE_INSTALL_INCLUDEDIR}/")
endif()

Expand Down Expand Up @@ -174,7 +188,7 @@ function(rapids_cpm_nvcomp)

include("${rapids-cmake-dir}/cpm/find.cmake")
rapids_cpm_find(nvcomp ${version} ${_RAPIDS_UNPARSED_ARGUMENTS}
GLOBAL_TARGETS nvcomp::nvcomp nvcomp::nvcomp_gdeflate nvcomp::nvcomp_bitcomp
GLOBAL_TARGETS nvcomp::nvcomp
CPM_ARGS
GIT_REPOSITORY ${repository}
GIT_TAG ${tag}
Expand All @@ -187,15 +201,13 @@ function(rapids_cpm_nvcomp)
rapids_cpm_display_patch_status(nvcomp)

# provide 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()
if(NOT TARGET nvcomp::nvcomp_gdeflate AND TARGET nvcomp_gdeflate)
add_library(nvcomp::nvcomp_gdeflate ALIAS nvcomp_gdeflate)
endif()
if(NOT TARGET nvcomp::nvcomp_bitcomp AND TARGET nvcomp_bitcomp)
add_library(nvcomp::nvcomp_bitcomp ALIAS nvcomp_bitcomp)
endif()
set(nvcomp_possible_target_names nvcomp nvcomp_cpu nvcomp_cpu_static nvcomp_device_static
nvcomp_static)
foreach(name IN LISTS nvcomp_possible_target_names)
if(NOT TARGET nvcomp::${name} AND TARGET ${name})
add_library(nvcomp::${name} ALIAS ${name})
endif()
endforeach()

# Propagate up variables that CPMFindPackage provide
set(nvcomp_SOURCE_DIR "${nvcomp_SOURCE_DIR}" PARENT_SCOPE)
Expand Down
6 changes: 3 additions & 3 deletions rapids-cmake/cpm/versions.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,16 @@
"git_tag": "555d628e9b250868c9da003e4407087ff1982e8e"
},
"nvcomp": {
"version": "3.0.6",
"version": "4.0.1",
"git_url": "https://github.com/NVIDIA/nvcomp.git",
"git_tag": "v2.2.0",
"proprietary_binary_cuda_version_mapping": {
"11": "11.x",
"12": "12.x"
},
"proprietary_binary": {
"x86_64-linux": "https://developer.download.nvidia.com/compute/nvcomp/${version}/local_installers/nvcomp_${version}_x86_64_${cuda-toolkit-version-mapping}.tgz",
"aarch64-linux": "https://developer.download.nvidia.com/compute/nvcomp/${version}/local_installers/nvcomp_${version}_SBSA_${cuda-toolkit-version-mapping}.tgz"
"x86_64-linux": "https://developer.download.nvidia.com/compute/nvcomp/${version}/local_installers/nvcomp-linux-x86_64-${version}-cuda${cuda-toolkit-version-mapping}.tar.gz",
"aarch64-linux": "https://developer.download.nvidia.com/compute/nvcomp/${version}/local_installers/nvcomp-linux-sbsa-${version}-cuda${cuda-toolkit-version-mapping}.tar.gz"
}
},
"nvtx3": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,25 @@ if(NOT nvcomp_proprietary_binary)
message(FATAL_ERROR "Ignored nvcomp override file failed to get proprietary binary version")
endif()

# Check the contents of the nvcomp-targets-release.cmake file to ensure that
# Check the contents of the nvcomp cmake files to ensure that
# every line containing "_IMPORT_PREFIX" also contains "${CMAKE_INSTALL_LIBDIR}"
file(STRINGS "${CMAKE_CURRENT_BINARY_DIR}/_deps/nvcomp_proprietary_binary-src/${CMAKE_INSTALL_LIBDIR}/cmake/nvcomp/nvcomp-targets-release.cmake" nvcomp_targets_release_contents)
foreach(line IN LISTS nvcomp_targets_release_contents)
string(FIND "${line}" "_IMPORT_PREFIX" _IMPORT_PREFIX_INDEX)
if(_IMPORT_PREFIX_INDEX EQUAL -1)
continue()
endif()
cmake_path(GET CMAKE_INSTALL_LIBDIR FILENAME lib_dir_name)
string(FIND "${line}" "${lib_dir_name}" _LIBDIR_INDEX)
if(_LIBDIR_INDEX EQUAL -1)
message(FATAL_ERROR "nvcomp-targets-release.cmake file does not contain ${lib_dir_name}")
endif()
set(nvcomp_list_of_target_files
"nvcomp-targets-common-release.cmake"
"nvcomp-targets-dynamic-release.cmake"
"nvcomp-targets-static-release.cmake")
foreach(filename IN LISTS nvcomp_list_of_target_files)
file(STRINGS "${CMAKE_CURRENT_BINARY_DIR}/_deps/nvcomp_proprietary_binary-src/${CMAKE_INSTALL_LIBDIR}/cmake/nvcomp/${filename}" nvcomp_targets_release_contents)
foreach(line IN LISTS nvcomp_targets_release_contents)
string(FIND "${line}" "_IMPORT_PREFIX" _IMPORT_PREFIX_INDEX)
if(_IMPORT_PREFIX_INDEX EQUAL -1)
continue()
endif()
cmake_path(GET CMAKE_INSTALL_LIBDIR FILENAME lib_dir_name)
string(FIND "${line}" "${lib_dir_name}" _LIBDIR_INDEX)
if(_LIBDIR_INDEX EQUAL -1)
message(FATAL_ERROR "nvcomp-targets-release.cmake file does not contain ${lib_dir_name}")
endif()
endforeach()
endforeach()

# Install and check the install directory.
Expand Down