From e7009d4cad8e04b8344b20fca2891d8df891f7d8 Mon Sep 17 00:00:00 2001 From: ptaylor Date: Tue, 1 Feb 2022 10:29:06 -0800 Subject: [PATCH 1/7] use define for PTDS to support sccache --- cpp/cmake/modules/ConfigureCUDA.cmake | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cpp/cmake/modules/ConfigureCUDA.cmake b/cpp/cmake/modules/ConfigureCUDA.cmake index 02bd15c407..a9163a474f 100644 --- a/cpp/cmake/modules/ConfigureCUDA.cmake +++ b/cpp/cmake/modules/ConfigureCUDA.cmake @@ -23,7 +23,9 @@ if(CMAKE_COMPILER_IS_GNUCXX) list(APPEND RAFT_CXX_FLAGS -Wall -Werror -Wno-unknown-pragmas -Wno-error=deprecated-declarations) endif() -list(APPEND RAFT_CUDA_FLAGS --expt-extended-lambda --expt-relaxed-constexpr --default-stream per-thread) +list(APPEND RAFT_CUDA_FLAGS --expt-extended-lambda --expt-relaxed-constexpr) +list(APPEND RAFT_CXX_FLAGS "-DCUDA_API_PER_THREAD_DEFAULT_STREAM") +list(APPEND RAFT_CUDA_FLAGS "-DCUDA_API_PER_THREAD_DEFAULT_STREAM") # set warnings as errors if(CMAKE_CUDA_COMPILER_VERSION VERSION_GREATER_EQUAL 11.2.0) From 3b3aef0f93d37b5addda2862fcd9c803f436aef5 Mon Sep 17 00:00:00 2001 From: ptaylor Date: Thu, 24 Mar 2022 09:40:25 -0700 Subject: [PATCH 2/7] set cuco version to 0.0.1 --- cpp/cmake/thirdparty/get_cuco.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cpp/cmake/thirdparty/get_cuco.cmake b/cpp/cmake/thirdparty/get_cuco.cmake index 381addb03c..be43674776 100644 --- a/cpp/cmake/thirdparty/get_cuco.cmake +++ b/cpp/cmake/thirdparty/get_cuco.cmake @@ -31,4 +31,4 @@ function(find_and_configure_cuco VERSION) endfunction() # cuCollections doesn't have a version yet -find_and_configure_cuco(0.0) +find_and_configure_cuco(0.0.1) From 17eb5f988efc7a38fb4e7f42486cd190a0b2ab97 Mon Sep 17 00:00:00 2001 From: ptaylor Date: Thu, 24 Mar 2022 10:12:43 -0700 Subject: [PATCH 3/7] use rapids-cmake v22.04 --- cpp/CMakeLists.txt | 2 +- cpp/cmake/thirdparty/get_cuco.cmake | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt index f1c71e7a3f..1f40b939a5 100644 --- a/cpp/CMakeLists.txt +++ b/cpp/CMakeLists.txt @@ -15,7 +15,7 @@ #============================================================================= cmake_minimum_required(VERSION 3.20.1 FATAL_ERROR) -file(DOWNLOAD https://raw.githubusercontent.com/rapidsai/rapids-cmake/branch-22.02/RAPIDS.cmake +file(DOWNLOAD https://raw.githubusercontent.com/rapidsai/rapids-cmake/branch-22.04/RAPIDS.cmake ${CMAKE_BINARY_DIR}/RAPIDS.cmake) include(${CMAKE_BINARY_DIR}/RAPIDS.cmake) include(rapids-cmake) diff --git a/cpp/cmake/thirdparty/get_cuco.cmake b/cpp/cmake/thirdparty/get_cuco.cmake index be43674776..1c366fc72d 100644 --- a/cpp/cmake/thirdparty/get_cuco.cmake +++ b/cpp/cmake/thirdparty/get_cuco.cmake @@ -21,8 +21,8 @@ function(find_and_configure_cuco VERSION) BUILD_EXPORT_SET raft-exports INSTALL_EXPORT_SET raft-exports CPM_ARGS - GIT_REPOSITORY https://github.com/NVIDIA/cuCollections.git - GIT_TAG 0ca860b824f5dc22cf8a41f09912e62e11f07d82 + GIT_REPOSITORY https://github.com/robertmaynard/cuCollections.git + GIT_TAG move_to_latest_rapids_cmake OPTIONS "BUILD_TESTS OFF" "BUILD_BENCHMARKS OFF" "BUILD_EXAMPLES OFF" From 2d26d79e9cd65c66a85e9bb3c51441b104220557 Mon Sep 17 00:00:00 2001 From: ptaylor Date: Thu, 24 Mar 2022 14:06:23 -0700 Subject: [PATCH 4/7] allow building shared or static libs via -DBUILD_SHARED_LIBS=YES|NO --- cpp/CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt index 1f40b939a5..7d3ccc9bcf 100644 --- a/cpp/CMakeLists.txt +++ b/cpp/CMakeLists.txt @@ -153,7 +153,7 @@ endif() set_target_properties(raft_distance PROPERTIES EXPORT_NAME distance) if(RAFT_COMPILE_LIBRARIES) - add_library(raft_distance_lib SHARED + add_library(raft_distance_lib src/distance/specializations/detail src/distance/specializations/detail/canberra.cu src/distance/specializations/detail/chebyshev.cu @@ -197,7 +197,7 @@ endif() set_target_properties(raft_nn PROPERTIES EXPORT_NAME nn) if(RAFT_COMPILE_LIBRARIES) - add_library(raft_nn_lib SHARED + add_library(raft_nn_lib src/nn/specializations/ball_cover.cu src/nn/specializations/detail/ball_cover_lowdim.cu src/nn/specializations/fused_l2_knn_long_float_true.cu From 5aa5ba604eab83fd61e270a480501a97c68f48be Mon Sep 17 00:00:00 2001 From: ptaylor Date: Thu, 24 Mar 2022 19:28:33 -0700 Subject: [PATCH 5/7] add option to build shared libs (default=on) --- cpp/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt index 7d3ccc9bcf..040c7d7a2b 100644 --- a/cpp/CMakeLists.txt +++ b/cpp/CMakeLists.txt @@ -40,6 +40,7 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS ON) ############################################################################## # - User Options ------------------------------------------------------------ +option(BUILD_SHARED_LIBS "Build raft shared libraries" ON) option(BUILD_TESTS "Build raft unit-tests" ON) option(CUDA_ENABLE_KERNELINFO "Enable kernel resource usage info" OFF) option(CUDA_ENABLE_LINEINFO "Enable the -lineinfo option for nvcc (useful for cuda-memcheck / profiler)" OFF) From 84de126abe289bff6abf0187b1b484c39b8acae3 Mon Sep 17 00:00:00 2001 From: ptaylor Date: Wed, 30 Mar 2022 08:53:11 -0700 Subject: [PATCH 6/7] compress fatbins --- cpp/cmake/modules/ConfigureCUDA.cmake | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cpp/cmake/modules/ConfigureCUDA.cmake b/cpp/cmake/modules/ConfigureCUDA.cmake index 5984c424e7..440c8c4f3a 100644 --- a/cpp/cmake/modules/ConfigureCUDA.cmake +++ b/cpp/cmake/modules/ConfigureCUDA.cmake @@ -26,6 +26,8 @@ endif() list(APPEND RAFT_CUDA_FLAGS --expt-extended-lambda --expt-relaxed-constexpr) list(APPEND RAFT_CXX_FLAGS "-DCUDA_API_PER_THREAD_DEFAULT_STREAM") list(APPEND RAFT_CUDA_FLAGS "-DCUDA_API_PER_THREAD_DEFAULT_STREAM") +# make sure we produce smallest binary size +list(APPEND RAFT_CUDA_FLAGS -Xfatbin=-compress-all) # set warnings as errors if(CMAKE_CUDA_COMPILER_VERSION VERSION_GREATER_EQUAL 11.2.0) From 9d81edc05e6053f7f82fc1b02fbfc7a3c410b9ca Mon Sep 17 00:00:00 2001 From: ptaylor Date: Wed, 30 Mar 2022 09:05:54 -0700 Subject: [PATCH 7/7] enable -fPIC for raft libs, align with CMake standard BUILD_SHARED_LIBS option --- cpp/CMakeLists.txt | 34 ++++++++++++++++++++++++---------- 1 file changed, 24 insertions(+), 10 deletions(-) diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt index 66d43b72e6..35b066abc9 100644 --- a/cpp/CMakeLists.txt +++ b/cpp/CMakeLists.txt @@ -58,7 +58,6 @@ option(DETECT_CONDA_ENV "Enable detection of conda environment for dependencies" option(DISABLE_DEPRECATION_WARNINGS "Disable depreaction warnings " ON) option(DISABLE_OPENMP "Disable OpenMP" OFF) option(NVTX "Enable nvtx markers" OFF) -option(RAFT_STATIC_LINK_LIBRARIES "Statically link compiled libraft libraries") option(RAFT_COMPILE_LIBRARIES "Enable building raft shared library instantiations" ON) option(RAFT_COMPILE_NN_LIBRARY "Enable building raft nearest neighbors shared library instantiations" OFF) @@ -178,11 +177,6 @@ SECTIONS ]=]) endif() -set(RAFT_LIB_TYPE SHARED) -if(${RAFT_STATIC_LINK_LIBRARIES}) - set(RAFT_LIB_TYPE STATIC) -endif() - ############################################################################## # - raft_distance ------------------------------------------------------------ add_library(raft_distance INTERFACE) @@ -194,7 +188,7 @@ endif() set_target_properties(raft_distance PROPERTIES EXPORT_NAME distance) if(RAFT_COMPILE_LIBRARIES OR RAFT_COMPILE_DIST_LIBRARY) - add_library(raft_distance_lib ${RAFT_LIB_TYPE} + add_library(raft_distance_lib src/distance/pairwise_distance.cu src/distance/specializations/detail/canberra.cu src/distance/specializations/detail/chebyshev.cu @@ -227,7 +221,17 @@ if(RAFT_COMPILE_LIBRARIES OR RAFT_COMPILE_DIST_LIBRARY) src/distance/specializations/detail/lp_unexpanded_float_float_float_uint32.cu src/distance/specializations/detail/lp_unexpanded_float_float_float_int.cu ) - set_target_properties(raft_distance_lib PROPERTIES OUTPUT_NAME raft_distance) + set_target_properties( + raft_distance_lib + PROPERTIES OUTPUT_NAME raft_distance + BUILD_RPATH "\$ORIGIN" + INSTALL_RPATH "\$ORIGIN" + CXX_STANDARD 17 + CXX_STANDARD_REQUIRED ON + CUDA_STANDARD 17 + CUDA_STANDARD_REQUIRED ON + POSITION_INDEPENDENT_CODE ON + INTERFACE_POSITION_INDEPENDENT_CODE ON) target_link_libraries(raft_distance_lib PRIVATE raft::raft) target_compile_options(raft_distance_lib @@ -259,7 +263,7 @@ endif() set_target_properties(raft_nn PROPERTIES EXPORT_NAME nn) if(RAFT_COMPILE_LIBRARIES OR RAFT_COMPILE_NN_LIBRARY) - add_library(raft_nn_lib ${RAFT_LIB_TYPE} + add_library(raft_nn_lib src/nn/specializations/ball_cover.cu src/nn/specializations/detail/ball_cover_lowdim_pass_one_2d.cu src/nn/specializations/detail/ball_cover_lowdim_pass_two_2d.cu @@ -271,7 +275,17 @@ if(RAFT_COMPILE_LIBRARIES OR RAFT_COMPILE_NN_LIBRARY) src/nn/specializations/fused_l2_knn_int_float_false.cu src/nn/specializations/knn.cu ) - set_target_properties(raft_nn_lib PROPERTIES OUTPUT_NAME raft_nn) + set_target_properties( + raft_nn_lib + PROPERTIES OUTPUT_NAME raft_nn + BUILD_RPATH "\$ORIGIN" + INSTALL_RPATH "\$ORIGIN" + CXX_STANDARD 17 + CXX_STANDARD_REQUIRED ON + CUDA_STANDARD 17 + CUDA_STANDARD_REQUIRED ON + POSITION_INDEPENDENT_CODE ON + INTERFACE_POSITION_INDEPENDENT_CODE ON) target_link_libraries(raft_nn_lib PUBLIC faiss::faiss PRIVATE raft::raft) target_compile_options(raft_nn_lib