diff --git a/build.sh b/build.sh index 039f0ed6a5..ab904abdad 100755 --- a/build.sh +++ b/build.sh @@ -522,7 +522,7 @@ fi # Initiate build for example RAFT application template (if needed) if hasArg template; then - pushd cpp/template + pushd ${REPODIR}/cpp/template ./build.sh popd fi diff --git a/conda/recipes/libraft/meta.yaml b/conda/recipes/libraft/meta.yaml index ccd7314484..8ec9cc10c6 100644 --- a/conda/recipes/libraft/meta.yaml +++ b/conda/recipes/libraft/meta.yaml @@ -16,7 +16,7 @@ source: git_url: ../../.. outputs: - - name: libraft-headers + - name: libraft-headers-only version: {{ version }} script: build_libraft_headers.sh build: @@ -50,20 +50,26 @@ outputs: - ninja - sysroot_{{ target_platform }} {{ sysroot_version }} host: - - cuda-profiler-api {{ cuda_profiler_api_host_version }} - - cudatoolkit ={{ cuda_version }} - - libcublas {{ libcublas_host_version }} - - libcublas-dev {{ libcublas_host_version }} - - libcurand {{ libcurand_host_version }} - - libcurand-dev {{ libcurand_host_version }} - - libcusolver {{ libcusolver_host_version }} - - libcusolver-dev {{ libcusolver_host_version }} - - libcusparse {{ libcusparse_host_version }} - - libcusparse-dev {{ libcusparse_host_version }} - librmm ={{ minor_version }} + - cudatoolkit {{ cuda_version }} + about: + home: https://rapids.ai/ + license: Apache-2.0 + summary: libraft-headers-only library + - name: libraft-headers + version: {{ version }} + build: + number: {{ GIT_DESCRIBE_NUMBER }} + string: cuda{{ cuda_major }}_{{ date_string }}_{{ GIT_DESCRIBE_HASH }}_{{ GIT_DESCRIBE_NUMBER }} + ignore_run_exports_from: + - {{ compiler('cuda') }} + - librmm + requirements: run: - - {{ pin_compatible('cudatoolkit', max_pin='x', min_pin='x') }} + - {{ pin_subpackage('libraft-headers-only', exact=True) }} - cuda-profiler-api {{ cuda_profiler_api_run_version }} + - cudatoolkit {{ cuda_version }} + - librmm ={{ minor_version }} - libcublas {{ libcublas_run_version }} - libcublas-dev {{ libcublas_run_version }} - libcurand {{ libcurand_run_version }} @@ -72,7 +78,6 @@ outputs: - libcusolver-dev {{ libcusolver_run_version }} - libcusparse {{ libcusparse_run_version }} - libcusparse-dev {{ libcusparse_run_version }} - - librmm ={{ minor_version }} about: home: https://rapids.ai/ license: Apache-2.0 @@ -130,7 +135,6 @@ outputs: - sysroot_{{ target_platform }} {{ sysroot_version }} host: - {{ pin_subpackage('libraft', exact=True) }} - - {{ pin_subpackage('libraft-headers', exact=True) }} - cuda-profiler-api {{ cuda_profiler_api_host_version }} - gmock {{ gtest_version }} - gtest {{ gtest_version }} @@ -144,7 +148,6 @@ outputs: - libcusparse-dev {{ libcusparse_host_version }} run: - {{ pin_subpackage('libraft', exact=True) }} - - {{ pin_subpackage('libraft-headers', exact=True) }} - gmock {{ gtest_version }} - gtest {{ gtest_version }} about: @@ -170,19 +173,10 @@ outputs: - sysroot_{{ target_platform }} {{ sysroot_version }} host: - {{ pin_subpackage('libraft', exact=True) }} - - {{ pin_subpackage('libraft-headers', exact=True) }} - - cuda-profiler-api {{ cuda_profiler_api_host_version }} - libcublas {{ libcublas_host_version }} - libcublas-dev {{ libcublas_host_version }} - - libcurand {{ libcurand_host_version }} - - libcurand-dev {{ libcurand_host_version }} - - libcusolver {{ libcusolver_host_version }} - - libcusolver-dev {{ libcusolver_host_version }} - - libcusparse {{ libcusparse_host_version }} - - libcusparse-dev {{ libcusparse_host_version }} run: - {{ pin_subpackage('libraft', exact=True) }} - - {{ pin_subpackage('libraft-headers', exact=True) }} about: home: https://rapids.ai/ license: Apache-2.0 @@ -206,23 +200,14 @@ outputs: - sysroot_{{ target_platform }} {{ sysroot_version }} host: - {{ pin_subpackage('libraft', exact=True) }} - - {{ pin_subpackage('libraft-headers', exact=True) }} - - cuda-profiler-api {{ cuda_profiler_api_host_version }} - libcublas {{ libcublas_host_version }} - libcublas-dev {{ libcublas_host_version }} - - libcurand {{ libcurand_host_version }} - - libcurand-dev {{ libcurand_host_version }} - - libcusolver {{ libcusolver_host_version }} - - libcusolver-dev {{ libcusolver_host_version }} - - libcusparse {{ libcusparse_host_version }} - - libcusparse-dev {{ libcusparse_host_version }} - glog {{ glog_version }} - nlohmann_json {{ nlohmann_json_version }} - libfaiss>=1.7.1 - faiss-proc=*=cuda run: - {{ pin_subpackage('libraft', exact=True) }} - - {{ pin_subpackage('libraft-headers', exact=True) }} - glog {{ glog_version }} - faiss-proc=*=cuda - libfaiss {{ faiss_version }} diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt index 144f58c4d6..6461492169 100644 --- a/cpp/CMakeLists.txt +++ b/cpp/CMakeLists.txt @@ -179,17 +179,7 @@ target_include_directories( ) # Keep RAFT as lightweight as possible. Only CUDA libs and rmm should be used in global target. -target_link_libraries( - raft - INTERFACE rmm::rmm - cuco::cuco - nvidia::cutlass::cutlass - CUDA::cublas${_ctk_static_suffix} - CUDA::curand${_ctk_static_suffix} - CUDA::cusolver${_ctk_static_suffix} - CUDA::cusparse${_ctk_static_suffix} - raft::Thrust -) +target_link_libraries(raft INTERFACE rmm::rmm cuco::cuco nvidia::cutlass::cutlass raft::Thrust) target_compile_features(raft INTERFACE cxx_std_17 $) target_compile_options( @@ -197,6 +187,15 @@ target_compile_options( --expt-relaxed-constexpr> ) +set(RAFT_CUSOLVER_DEPENDENCY CUDA::cusolver${_ctk_static_suffix}) +set(RAFT_CUBLAS_DEPENDENCY CUDA::cublas${_ctk_static_suffix}) +set(RAFT_CURAND_DEPENDENCY CUDA::curand${_ctk_static_suffix}) +set(RAFT_CUSPARSE_DEPENDENCY CUDA::cusparse${_ctk_static_suffix}) + +set(RAFT_CTK_MATH_DEPENDENCIES ${RAFT_CUBLAS_DEPENDENCY} ${RAFT_CUSOLVER_DEPENDENCY} + ${RAFT_CUSPARSE_DEPENDENCY} ${RAFT_CURAND_DEPENDENCY} +) + # Endian detection include(TestBigEndian) test_big_endian(BIG_ENDIAN) @@ -454,7 +453,13 @@ if(RAFT_COMPILE_LIBRARY) INTERFACE_POSITION_INDEPENDENT_CODE ON ) - target_link_libraries(raft_lib PUBLIC raft::raft $) + target_link_libraries( + raft_lib + PUBLIC raft::raft + ${RAFT_CTK_MATH_DEPENDENCIES} # TODO: Once `raft::resources` is used everywhere, this + # will just be cublas + $ + ) target_compile_options( raft_lib PRIVATE "$<$:${RAFT_CXX_FLAGS}>" "$<$:${RAFT_CUDA_FLAGS}>" @@ -606,13 +611,39 @@ if(TARGET raft_lib) list(APPEND raft_export_sets raft-compiled-lib-exports) endif() +string( + APPEND + code_string + [=[ + option(RAFT_ENABLE_CUSOLVER_DEPENDENCY "Enable cusolver dependency" ON) + option(RAFT_ENABLE_CUBLAS_DEPENDENCY "Enable cublas dependency" ON) + option(RAFT_ENABLE_CURAND_DEPENDENCY "Enable curand dependency" ON) + option(RAFT_ENABLE_CUSPARSE_DEPENDENCY "Enable cusparse dependency" ON) + +mark_as_advanced(RAFT_ENABLE_CUSOLVER_DEPENDENCY) +mark_as_advanced(RAFT_ENABLE_CUBLAS_DEPENDENCY) +mark_as_advanced(RAFT_ENABLE_CURAND_DEPENDENCY) +mark_as_advanced(RAFT_ENABLE_CUSPARSE_DEPENDENCY) + +target_link_libraries(raft::raft INTERFACE + $<$:${RAFT_CUSOLVER_DEPENDENCY}> + $<$:${RAFT_CUBLAS_DEPENDENCY}> + $<$:${RAFT_CUSPARSE_DEPENDENCY}> + $<$:${RAFT_CURAND_DEPENDENCY}> +) +]=] +) + +# Use `rapids_export` for 22.04 as it will have COMPONENT support rapids_export( INSTALL raft EXPORT_SET raft-exports COMPONENTS ${raft_components} COMPONENTS_EXPORT_SET ${raft_export_sets} GLOBAL_TARGETS raft compiled distributed - NAMESPACE raft:: DOCUMENTATION doc_string FINAL_CODE_BLOCK code_string + NAMESPACE raft:: + DOCUMENTATION doc_string + FINAL_CODE_BLOCK code_string ) # ################################################################################################## @@ -622,8 +653,10 @@ rapids_export( EXPORT_SET raft-exports COMPONENTS ${raft_components} COMPONENTS_EXPORT_SET ${raft_export_sets} - GLOBAL_TARGETS raft - compiled distributed DOCUMENTATION doc_string NAMESPACE raft:: FINAL_CODE_BLOCK code_string + GLOBAL_TARGETS raft compiled distributed + DOCUMENTATION doc_string + NAMESPACE raft:: + FINAL_CODE_BLOCK code_string ) # ################################################################################################## diff --git a/cpp/bench/ann/CMakeLists.txt b/cpp/bench/ann/CMakeLists.txt index 6267be518e..a14018a15d 100644 --- a/cpp/bench/ann/CMakeLists.txt +++ b/cpp/bench/ann/CMakeLists.txt @@ -80,6 +80,7 @@ function(ConfigureAnnBench) $<$:NCCL::NCCL> ${ConfigureAnnBench_LINKS} Threads::Threads + ${RAFT_CTK_MATH_DEPENDENCIES} $ $ ) diff --git a/cpp/include/raft/linalg/detail/cublas_wrappers.hpp b/cpp/include/raft/linalg/detail/cublas_wrappers.hpp index 03975b1b7d..87a195757c 100644 --- a/cpp/include/raft/linalg/detail/cublas_wrappers.hpp +++ b/cpp/include/raft/linalg/detail/cublas_wrappers.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, NVIDIA CORPORATION. + * Copyright (c) 2022-2023, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -965,7 +965,8 @@ inline cublasStatus_t cublasdot(cublasHandle_t handle, cudaStream_t stream) { RAFT_CUBLAS_TRY(cublasSetStream(handle, stream)); - return cublasSdot(handle, n, x, incx, y, incy, result); + return cublasDotEx( + handle, n, x, CUDA_R_32F, incx, y, CUDA_R_32F, incy, result, CUDA_R_32F, CUDA_R_32F); } template <> @@ -979,7 +980,8 @@ inline cublasStatus_t cublasdot(cublasHandle_t handle, cudaStream_t stream) { RAFT_CUBLAS_TRY(cublasSetStream(handle, stream)); - return cublasDdot(handle, n, x, incx, y, incy, result); + return cublasDotEx( + handle, n, x, CUDA_R_64F, incx, y, CUDA_R_64F, incy, result, CUDA_R_64F, CUDA_R_64F); } /** @} */ diff --git a/cpp/include/raft/spectral/detail/modularity_maximization.hpp b/cpp/include/raft/spectral/detail/modularity_maximization.hpp index 160664bae8..d81c64b257 100644 --- a/cpp/include/raft/spectral/detail/modularity_maximization.hpp +++ b/cpp/include/raft/spectral/detail/modularity_maximization.hpp @@ -32,24 +32,6 @@ #include #include -#ifdef COLLECT_TIME_STATISTICS -#include -#include -#include -#include -#include -#endif - -#ifdef COLLECT_TIME_STATISTICS -static double timer(void) -{ - struct timeval tv; - cudaDeviceSynchronize(); - gettimeofday(&tv, NULL); - return (double)tv.tv_sec + (double)tv.tv_usec / 1000000.0; -} -#endif - namespace raft { namespace spectral { namespace detail { diff --git a/cpp/test/CMakeLists.txt b/cpp/test/CMakeLists.txt index 9109d84fe4..22e8a9d73c 100644 --- a/cpp/test/CMakeLists.txt +++ b/cpp/test/CMakeLists.txt @@ -31,12 +31,13 @@ function(ConfigureTest) target_link_libraries( ${TEST_NAME} - PRIVATE raft::raft + PRIVATE raft raft_internal $<$:raft::compiled> GTest::gtest GTest::gtest_main Threads::Threads + ${RAFT_CTK_MATH_DEPENDENCIES} $ $ ) diff --git a/docs/source/build.md b/docs/source/build.md index d7550eb631..262c5703bc 100644 --- a/docs/source/build.md +++ b/docs/source/build.md @@ -151,18 +151,22 @@ make -j install RAFT's cmake has the following configurable flags available:. -| Flag | Possible Values | Default Value | Behavior | -|---------------------------|----------------------| --- | --- | -| BUILD_TESTS | ON, OFF | ON | Compile Googletests | -| BUILD_PRIMS_BENCH | ON, OFF | OFF | Compile benchmarks | +| Flag | Possible Values | Default Value | Behavior | +|---------------------------------|----------------------| --- |------------------------------------------------------------------------------| +| BUILD_TESTS | ON, OFF | ON | Compile Googletests | +| BUILD_PRIMS_BENCH | ON, OFF | OFF | Compile benchmarks | | BUILD_ANN_BENCH | ON, OFF | OFF | Compile end-to-end ANN benchmarks | -| raft_FIND_COMPONENTS | compiled distributed | | Configures the optional components as a space-separated list | | RAFT_COMPILE_LIBRARY | ON, OFF | ON if either BUILD_TESTS or BUILD_PRIMS_BENCH is ON; otherwise OFF | Compiles all `libraft` shared libraries (these are required for Googletests) | -| DETECT_CONDA_ENV | ON, OFF | ON | Enable detection of conda environment for dependencies | -| RAFT_NVTX | ON, OFF | OFF | Enable NVTX Markers | -| CUDA_ENABLE_KERNELINFO | ON, OFF | OFF | Enables `kernelinfo` in nvcc. This is useful for `compute-sanitizer` | -| CUDA_ENABLE_LINEINFO | ON, OFF | OFF | Enable the -lineinfo option for nvcc | -| CUDA_STATIC_RUNTIME | ON, OFF | OFF | Statically link the CUDA runtime | +| raft_FIND_COMPONENTS | compiled distributed | | Configures the optional components as a space-separated list | +| RAFT_ENABLE_CUBLAS_DEPENDENCY | ON, OFF | ON | Link against cublas library in `raft::raft` | +| RAFT_ENABLE_CUSOLVER_DEPENDENCY | ON, OFF | ON | Link against cusolver library in `raft::raft` | +| RAFT_ENABLE_CUSPARSE_DEPENDENCY | ON, OFF | ON | Link against cusparse library in `raft::raft` | +| RAFT_ENABLE_CUSOLVER_DEPENDENCY | ON, OFF | ON | Link against curand library in `raft::raft` | +| DETECT_CONDA_ENV | ON, OFF | ON | Enable detection of conda environment for dependencies | +| RAFT_NVTX | ON, OFF | OFF | Enable NVTX Markers | +| CUDA_ENABLE_KERNELINFO | ON, OFF | OFF | Enables `kernelinfo` in nvcc. This is useful for `compute-sanitizer` | +| CUDA_ENABLE_LINEINFO | ON, OFF | OFF | Enable the -lineinfo option for nvcc | +| CUDA_STATIC_RUNTIME | ON, OFF | OFF | Statically link the CUDA runtime | Currently, shared libraries are provided for the `libraft-nn` and `libraft-distance` components.