From 03d97fd50cd35969c32bf24b9025a8012ed8399e Mon Sep 17 00:00:00 2001 From: Mickael Ide Date: Thu, 11 Jan 2024 14:23:27 +0100 Subject: [PATCH 01/13] Add `compile-library` dependency on pylibraft build --- build.sh | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/build.sh b/build.sh index e5df0af826..3b5f2cd41b 100755 --- a/build.sh +++ b/build.sh @@ -1,6 +1,6 @@ #!/bin/bash -# Copyright (c) 2020-2023, NVIDIA CORPORATION. +# Copyright (c) 2020-2024, NVIDIA CORPORATION. # raft build scripts @@ -377,6 +377,10 @@ fi if hasArg --incl-cache-stats; then BUILD_REPORT_INCL_CACHE_STATS=ON fi +if hasArg pylibraft; then + COMPILE_LIBRARY=ON + CMAKE_TARGET="${CMAKE_TARGET};raft_lib" +fi if [[ ${CMAKE_TARGET} == "" ]]; then CMAKE_TARGET="all" fi @@ -405,7 +409,7 @@ fi ################################################################################ # Configure for building all C++ targets -if (( ${NUMARGS} == 0 )) || hasArg libraft || hasArg docs || hasArg tests || hasArg bench-prims || hasArg bench-ann; then +if (( ${NUMARGS} == 0 )) || hasArg libraft || hasArg docs || hasArg tests || hasArg bench-prims || hasArg bench-ann || ((${COMPILE_LIBRARY} == ON )); then if (( ${BUILD_ALL_GPU_ARCH} == 0 )); then RAFT_CMAKE_CUDA_ARCHITECTURES="NATIVE" echo "Building for the architecture of the GPU in the system..." From 4abca2fe85bfcf4a907a6b3c6fb948894031bd72 Mon Sep 17 00:00:00 2001 From: Mickael Ide Date: Thu, 11 Jan 2024 16:40:47 +0100 Subject: [PATCH 02/13] Merge `--compile-lib` and `pylibraft` options in build.sh --- build.sh | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/build.sh b/build.sh index 3b5f2cd41b..f6f9240531 100755 --- a/build.sh +++ b/build.sh @@ -305,7 +305,7 @@ if hasArg --allgpuarch; then BUILD_ALL_GPU_ARCH=1 fi -if hasArg --compile-lib || (( ${NUMARGS} == 0 )); then +if hasArg --compile-lib || hasArg pylibraft || (( ${NUMARGS} == 0 )); then COMPILE_LIBRARY=ON CMAKE_TARGET="${CMAKE_TARGET};raft_lib" fi @@ -377,10 +377,6 @@ fi if hasArg --incl-cache-stats; then BUILD_REPORT_INCL_CACHE_STATS=ON fi -if hasArg pylibraft; then - COMPILE_LIBRARY=ON - CMAKE_TARGET="${CMAKE_TARGET};raft_lib" -fi if [[ ${CMAKE_TARGET} == "" ]]; then CMAKE_TARGET="all" fi From 337c569f5f2086e8ce9bc5d80e9ece2d0cad79a4 Mon Sep 17 00:00:00 2001 From: Mickael Ide Date: Tue, 23 Jan 2024 18:02:13 +0100 Subject: [PATCH 03/13] Use nvtx3 --- cpp/CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt index dbce46abfe..f4b66bd600 100644 --- a/cpp/CMakeLists.txt +++ b/cpp/CMakeLists.txt @@ -251,7 +251,7 @@ endif() if(RAFT_NVTX) # This enables NVTX within the project with no option to disable it downstream. - target_link_libraries(raft INTERFACE CUDA::nvToolsExt) + target_link_libraries(raft INTERFACE CUDA::nvtx3) target_compile_definitions(raft INTERFACE NVTX_ENABLED) else() # Allow enable NVTX downstream if not set here. This creates a new option at build/install time, @@ -269,7 +269,7 @@ else() "\" OFF)" [=[ -target_link_libraries(raft::raft INTERFACE $<$:CUDA::nvToolsExt>) +target_link_libraries(raft::raft INTERFACE $<$:CUDA::nvtx3>) target_compile_definitions(raft::raft INTERFACE $<$:NVTX_ENABLED>) ]=] From dcad17ceae2774e6216c169fc523617c6043348d Mon Sep 17 00:00:00 2001 From: Mickael Ide Date: Tue, 23 Jan 2024 18:05:00 +0100 Subject: [PATCH 04/13] Update copyright --- cpp/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt index f4b66bd600..145b8d88c9 100644 --- a/cpp/CMakeLists.txt +++ b/cpp/CMakeLists.txt @@ -1,5 +1,5 @@ # ============================================================================= -# Copyright (c) 2020-2023, NVIDIA CORPORATION. +# Copyright (c) 2020-2024, 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 From fbfee095a74b17846b4bf9bfbfa2bab71bd4e4aa Mon Sep 17 00:00:00 2001 From: Mickael Ide Date: Wed, 24 Jan 2024 15:44:47 +0100 Subject: [PATCH 05/13] Update template cmake --- cpp/template/build.sh | 1 - cpp/template/cmake/thirdparty/get_raft.cmake | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/cpp/template/build.sh b/cpp/template/build.sh index 3ac00fc9af..6b1ea36ecc 100755 --- a/cpp/template/build.sh +++ b/cpp/template/build.sh @@ -32,7 +32,6 @@ cd $BUILD_DIR cmake \ -DCMAKE_BUILD_TYPE=${BUILD_TYPE} \ - -DRAFT_NVTX=OFF \ -DCMAKE_CUDA_ARCHITECTURES="NATIVE" \ -DCMAKE_EXPORT_COMPILE_COMMANDS=ON \ ${EXTRA_CMAKE_ARGS} \ diff --git a/cpp/template/cmake/thirdparty/get_raft.cmake b/cpp/template/cmake/thirdparty/get_raft.cmake index 6128b5c43c..e9f8518508 100644 --- a/cpp/template/cmake/thirdparty/get_raft.cmake +++ b/cpp/template/cmake/thirdparty/get_raft.cmake @@ -46,7 +46,7 @@ function(find_and_configure_raft) "BUILD_TESTS OFF" "BUILD_PRIMS_BENCH OFF" "BUILD_ANN_BENCH OFF" - "RAFT_NVTX ${ENABLE_NVTX}" + "RAFT_NVTX ${PKG_ENABLE_NVTX}" "RAFT_COMPILE_LIBRARY ${PKG_COMPILE_LIBRARY}" ) endfunction() From 90c3b006859cf21df15a06be0b8251e15c7c3130 Mon Sep 17 00:00:00 2001 From: Mickael Ide Date: Wed, 24 Jan 2024 18:37:04 +0100 Subject: [PATCH 06/13] Copyrights --- cpp/template/build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cpp/template/build.sh b/cpp/template/build.sh index 6b1ea36ecc..15f49015d2 100755 --- a/cpp/template/build.sh +++ b/cpp/template/build.sh @@ -1,6 +1,6 @@ #!/bin/bash -# Copyright (c) 2023, NVIDIA CORPORATION. +# Copyright (c) 2023-2024, NVIDIA CORPORATION. # raft empty project template build script From 9c6f6288a1a9038aee08ce0e10c11ced4fb7b9c7 Mon Sep 17 00:00:00 2001 From: Mickael Ide Date: Wed, 24 Jan 2024 18:46:47 +0100 Subject: [PATCH 07/13] Copyright template --- cpp/template/cmake/thirdparty/get_raft.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cpp/template/cmake/thirdparty/get_raft.cmake b/cpp/template/cmake/thirdparty/get_raft.cmake index e9f8518508..8a3b089dc9 100644 --- a/cpp/template/cmake/thirdparty/get_raft.cmake +++ b/cpp/template/cmake/thirdparty/get_raft.cmake @@ -1,5 +1,5 @@ # ============================================================================= -# Copyright (c) 2023, NVIDIA CORPORATION. +# Copyright (c) 2023-2024, 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 From 86a535861ad291ef74277c6f8ff4554acd788e85 Mon Sep 17 00:00:00 2001 From: Mickael Ide Date: Mon, 11 Mar 2024 11:18:21 +0100 Subject: [PATCH 08/13] NVTX issue build.sh Signed-off-by: Mickael Ide --- cpp/template/README.md | 2 +- cpp/template/build.sh | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/cpp/template/README.md b/cpp/template/README.md index 348dff270a..05ec48964f 100644 --- a/cpp/template/README.md +++ b/cpp/template/README.md @@ -8,7 +8,7 @@ Once the minimum requirements are satisfied, this example template application c This directory (`RAFT_SOURCE/cpp/template`) can be copied directly in order to build a new application with RAFT. -RAFT can be integrated into an existing CMake project by copying the contents in the `configure rapids-cmake` and `configure raft` sections of the provided `CMakeLists.txt` into your project, along with `cmake/thirdparty/get_raft.cmake`. +RAFT can be integrated into an existing CMake project by copying the contents in the `configure rapids-cmake` and `configure raft` sections of the provided `CMakeLists.txt` into your project, along with `cmake/thirdparty/get_raft.cmake`. Make sure to link against the appropriate Cmake targets. Use `raft::raft`to add make the headers available and `raft::compiled` when utilizing the shared library. diff --git a/cpp/template/build.sh b/cpp/template/build.sh index 15f49015d2..49c17f7499 100755 --- a/cpp/template/build.sh +++ b/cpp/template/build.sh @@ -32,6 +32,7 @@ cd $BUILD_DIR cmake \ -DCMAKE_BUILD_TYPE=${BUILD_TYPE} \ + -DRAFT_NVTX=OFF \ -DCMAKE_CUDA_ARCHITECTURES="NATIVE" \ -DCMAKE_EXPORT_COMPILE_COMMANDS=ON \ ${EXTRA_CMAKE_ARGS} \ From 3d0d2cb2b88c006aa17b2a5a0dc477e6787b9e1e Mon Sep 17 00:00:00 2001 From: Mickael Ide Date: Wed, 13 Mar 2024 17:38:58 +0100 Subject: [PATCH 09/13] Revert nvtx Signed-off-by: Mickael Ide --- cpp/CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt index 324a6e03cb..650bc1a059 100644 --- a/cpp/CMakeLists.txt +++ b/cpp/CMakeLists.txt @@ -259,7 +259,7 @@ endif() if(RAFT_NVTX) # This enables NVTX within the project with no option to disable it downstream. - target_link_libraries(raft INTERFACE CUDA::nvtx3) + target_link_libraries(raft INTERFACE CUDA::nvToolsExt) target_compile_definitions(raft INTERFACE NVTX_ENABLED) else() # Allow enable NVTX downstream if not set here. This creates a new option at build/install time, @@ -277,7 +277,7 @@ else() "\" OFF)" [=[ -target_link_libraries(raft::raft INTERFACE $<$:CUDA::nvtx3>) +target_link_libraries(raft::raft INTERFACE $<$:CUDA::nvToolsExt>) target_compile_definitions(raft::raft INTERFACE $<$:NVTX_ENABLED>) ]=] From 67715d41f4b684f66ddbee4288a68e0367bbf846 Mon Sep 17 00:00:00 2001 From: Mickael Ide Date: Wed, 13 Mar 2024 18:36:55 +0100 Subject: [PATCH 10/13] Test enable_nvtx --- cpp/template/cmake/thirdparty/get_raft.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cpp/template/cmake/thirdparty/get_raft.cmake b/cpp/template/cmake/thirdparty/get_raft.cmake index 8a3b089dc9..2cccc9e7d4 100644 --- a/cpp/template/cmake/thirdparty/get_raft.cmake +++ b/cpp/template/cmake/thirdparty/get_raft.cmake @@ -46,7 +46,7 @@ function(find_and_configure_raft) "BUILD_TESTS OFF" "BUILD_PRIMS_BENCH OFF" "BUILD_ANN_BENCH OFF" - "RAFT_NVTX ${PKG_ENABLE_NVTX}" + "RAFT_NVTX ${ENABLE_NVTX}" "RAFT_COMPILE_LIBRARY ${PKG_COMPILE_LIBRARY}" ) endfunction() From 1a743ce510de12f0f086187ffb3d3d244f7b109a Mon Sep 17 00:00:00 2001 From: Mickael Ide Date: Wed, 13 Mar 2024 23:03:03 +0100 Subject: [PATCH 11/13] Set RAFT_NVTX in template cmake --- cpp/template/cmake/thirdparty/get_raft.cmake | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/cpp/template/cmake/thirdparty/get_raft.cmake b/cpp/template/cmake/thirdparty/get_raft.cmake index 2cccc9e7d4..07b0897be0 100644 --- a/cpp/template/cmake/thirdparty/get_raft.cmake +++ b/cpp/template/cmake/thirdparty/get_raft.cmake @@ -33,6 +33,12 @@ function(find_and_configure_raft) #----------------------------------------------------- # Invoke CPM find_package() #----------------------------------------------------- + # Since the RAFT_NVTX option is used by targets generated by + # find_package(RAFT_NVTX) and when building from source we want to + # make `RAFT_NVTX` a cache variable so we get consistent + # behavior + # + set(RAFT_NVTX ${PKG_ENABLE_NVTX} CACHE BOOL "Enable raft nvtx logging" FORCE) rapids_cpm_find(raft ${PKG_VERSION} GLOBAL_TARGETS raft::raft BUILD_EXPORT_SET raft-template-exports @@ -46,7 +52,6 @@ function(find_and_configure_raft) "BUILD_TESTS OFF" "BUILD_PRIMS_BENCH OFF" "BUILD_ANN_BENCH OFF" - "RAFT_NVTX ${ENABLE_NVTX}" "RAFT_COMPILE_LIBRARY ${PKG_COMPILE_LIBRARY}" ) endfunction() From 3263ada2d52d9453d552fb52bdca3645c3176cdd Mon Sep 17 00:00:00 2001 From: Mickael Ide Date: Thu, 14 Mar 2024 20:46:35 +0100 Subject: [PATCH 12/13] `--no-nvtx` in conda build --- conda/recipes/libraft/build_libraft_template.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conda/recipes/libraft/build_libraft_template.sh b/conda/recipes/libraft/build_libraft_template.sh index bd7719af76..18198c619b 100644 --- a/conda/recipes/libraft/build_libraft_template.sh +++ b/conda/recipes/libraft/build_libraft_template.sh @@ -2,4 +2,4 @@ # Copyright (c) 2022-2023, NVIDIA CORPORATION. # Just building template so we verify it uses libraft.so and fail if it doesn't build -./build.sh template +./build.sh template --no-nvtx From b669135241a492040acd92742ff2766269236145 Mon Sep 17 00:00:00 2001 From: Mickael Ide Date: Thu, 14 Mar 2024 21:08:06 +0100 Subject: [PATCH 13/13] Update copyright --- conda/recipes/libraft/build_libraft_template.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conda/recipes/libraft/build_libraft_template.sh b/conda/recipes/libraft/build_libraft_template.sh index 18198c619b..86c0fa11b6 100644 --- a/conda/recipes/libraft/build_libraft_template.sh +++ b/conda/recipes/libraft/build_libraft_template.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -# Copyright (c) 2022-2023, NVIDIA CORPORATION. +# Copyright (c) 2022-2024, NVIDIA CORPORATION. # Just building template so we verify it uses libraft.so and fail if it doesn't build ./build.sh template --no-nvtx