diff --git a/README.md b/README.md index 6d9de4c8b7..8519ebcae1 100755 --- a/README.md +++ b/README.md @@ -195,8 +195,7 @@ RAFT itself can be installed through conda, [CMake Package Manager (CPM)](https: The easiest way to install RAFT is through conda and several packages are provided. - `libraft-headers` RAFT headers -- `libraft-nn` (optional) contains shared libraries for the nearest neighbors primitives. -- `libraft-distance` (optional) contains shared libraries for distance primitives. +- `libraft` (optional) shared library of pre-compiled template specializations and runtime APIs. - `pylibraft` (optional) Python wrappers around RAFT algorithms and primitives. - `raft-dask` (optional) enables deployment of multi-node multi-GPU algorithms that use RAFT `raft::comms` in Dask clusters. @@ -205,9 +204,9 @@ Use the following command to install all of the RAFT packages with conda (replac mamba install -c rapidsai -c conda-forge -c nvidia raft-dask pylibraft ``` -You can also install the `libraft-*` conda packages individually using the `mamba` command above. +You can also install the conda packages individually using the `mamba` command above. -After installing RAFT, `find_package(raft COMPONENTS nn distance)` can be used in your CUDA/C++ cmake build to compile and/or link against needed dependencies in your raft target. `COMPONENTS` are optional and will depend on the packages installed. +After installing RAFT, `find_package(raft COMPONENTS compiled distributed)` can be used in your CUDA/C++ cmake build to compile and/or link against needed dependencies in your raft target. `COMPONENTS` are optional and will depend on the packages installed. ### Pip @@ -266,12 +265,11 @@ find_and_configure_raft(VERSION ${RAFT_VERSION}.00 Several CMake targets can be made available by adding components in the table below to the `RAFT_COMPONENTS` list above, separated by spaces. The `raft::raft` target will always be available. RAFT headers require, at a minimum, the CUDA toolkit libraries and RMM dependencies. -| Component | Target | Description | Base Dependencies | -| --- | --- | --- |------------------------------------------------------------------| -| n/a | `raft::raft` | Full RAFT header library | CUDA toolkit library, RMM, Thrust (optional), NVTools (optional) | -| distance | `raft::distance` | Pre-compiled template specializations for raft::distance | raft::raft, cuCollections (optional) | -| nn | `raft::nn` | Pre-compiled template specializations for raft::neighbors | raft::raft | -| distributed | `raft::distributed` | No specializations | raft::raft, UCX, NCCL | +| Component | Target | Description | Base Dependencies | +|-------------|---------------------|-----------------------------------------------------------|---------------------------------------| +| n/a | `raft::raft` | Full RAFT header library | CUDA toolkit, RMM, NVTX, CCCL, CUTLASS | +| compiled | `raft::compiled` | Pre-compiled template specializations and runtime library | raft::raft | +| distributed | `raft::distributed` | Dependencies for `raft::comms` APIs | raft::raft, UCX, NCCL | ### Source @@ -282,7 +280,7 @@ mamba env create --name raft_dev_env -f conda/environments/all_cuda-118_arch-x86 mamba activate raft_dev_env ``` ``` -./build.sh raft-dask pylibraft libraft tests bench --compile-libs +./build.sh raft-dask pylibraft libraft tests bench --compile-lib ``` The [build](docs/source/build.md) instructions contain more details on building RAFT from source and including it in downstream projects. You can also find a more comprehensive version of the above CPM code snippet the [Building RAFT C++ from source](docs/source/build.md#building-raft-c-from-source-in-cmake) section of the build instructions. diff --git a/build.sh b/build.sh index 7215b8199a..b5a72f4205 100755 --- a/build.sh +++ b/build.sh @@ -18,7 +18,7 @@ ARGS=$* # script, and that this script resides in the repo dir! REPODIR=$(cd $(dirname $0); pwd) -VALIDARGS="clean libraft pylibraft raft-dask docs tests bench clean --uninstall -v -g -n --compile-libs --compile-nn --compile-dist --allgpuarch --no-nvtx --show_depr_warn -h --minimal-deps" +VALIDARGS="clean libraft pylibraft raft-dask docs tests bench clean --uninstall -v -g -n --compile-lib --allgpuarch --no-nvtx --show_depr_warn -h" HELP="$0 [ ...] [ ...] [--cmake-args=\"\"] [--cache-tool=] [--limit-tests=] [--limit-bench=] where is: clean - remove all existing build artifacts and configuration (start over) @@ -35,12 +35,7 @@ HELP="$0 [ ...] [ ...] [--cmake-args=\"\"] [--cache-tool==11.7.1,<12.0 - cudatoolkit ={{ cuda_version }} - cython >=0.29,<0.30 - - libraft-distance {{ version }} + - libraft {{ version }} - libraft-headers {{ version }} - python x.x - rmm ={{ minor_version }} @@ -43,7 +43,7 @@ requirements: run: - {{ pin_compatible('cudatoolkit', max_pin='x', min_pin='x') }} - cuda-python >=11.7.1,<12.0 - - libraft-distance {{ version }} + - libraft {{ version }} - libraft-headers {{ version }} - python x.x diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt index 3889c39e6e..bdaacb4a85 100644 --- a/cpp/CMakeLists.txt +++ b/cpp/CMakeLists.txt @@ -57,22 +57,13 @@ option(DISABLE_DEPRECATION_WARNINGS "Disable deprecaction warnings " ON) option(DISABLE_OPENMP "Disable OpenMP" OFF) option(RAFT_NVTX "Enable nvtx markers" OFF) -set(RAFT_COMPILE_LIBRARIES_DEFAULT OFF) +set(RAFT_COMPILE_LIBRARY_DEFAULT OFF) if(BUILD_TESTS OR BUILD_BENCH) - set(RAFT_COMPILE_LIBRARIES_DEFAULT ON) + set(RAFT_COMPILE_LIBRARY_DEFAULT ON) endif() -option(RAFT_COMPILE_LIBRARIES "Enable building raft shared library instantiations" - ${RAFT_COMPILE_LIBRARIES_DEFAULT} +option(RAFT_COMPILE_LIBRARY "Enable building raft shared library instantiations" + ${RAFT_COMPILE_LIBRARY_DEFAULT} ) -option( - RAFT_COMPILE_NN_LIBRARY "Enable building raft nearest neighbors shared library instantiations" - ${RAFT_COMPILE_LIBRARIES} -) -option(RAFT_COMPILE_DIST_LIBRARY "Enable building raft distant shared library instantiations" - ${RAFT_COMPILE_LIBRARIES} -) - -option(RAFT_ENABLE_thrust_DEPENDENCY "Enable Thrust dependency" ON) if(BUILD_TESTS OR BUILD_BENCH) # Needed because GoogleBenchmark changes the state of FindThreads.cmake, causing subsequent runs @@ -81,10 +72,9 @@ if(BUILD_TESTS OR BUILD_BENCH) set(THREADS_PREFER_PTHREAD_FLAG ON) endif() -if(BUILD_TESTS AND NOT RAFT_ENABLE_thrust_DEPENDENCY) - message(VERBOSE "RAFT: BUILD_TESTS is enabled, overriding RAFT_ENABLE_thrust_DEPENDENCY") - set(RAFT_ENABLE_thrust_DEPENDENCY ON) -endif() +include(CMakeDependentOption) +# cmake_dependent_option( RAFT_USE_FAISS_STATIC "Build and statically link the FAISS library for +# nearest neighbors search on GPU" ON RAFT_COMPILE_LIBRARY OFF ) message(VERBOSE "RAFT: Building optional components: ${raft_FIND_COMPONENTS}") message(VERBOSE "RAFT: Build RAFT unit-tests: ${BUILD_TESTS}") @@ -154,15 +144,6 @@ include(cmake/modules/ConfigureCUDA.cmake) # ################################################################################################## # * Requirements ------------------------------------------------------------- -if(RAFT_COMPILE_LIBRARIES) - set(RAFT_COMPILE_DIST_LIBRARY ON) - set(RAFT_COMPILE_NN_LIBRARY ON) -endif() - -if(RAFT_COMPILE_DIST_LIBRARY OR distance IN_LIST raft_FIND_COMPONENTS) - set(RAFT_ENABLE_cuco_DEPENDENCY ON) -endif() - # add third party dependencies using CPM rapids_cpm_init() @@ -171,12 +152,8 @@ include(cmake/thirdparty/get_thrust.cmake) include(cmake/thirdparty/get_rmm.cmake) include(cmake/thirdparty/get_cutlass.cmake) -if(RAFT_ENABLE_cuco_DEPENDENCY) - include(${rapids-cmake-dir}/cpm/cuco.cmake) - rapids_cpm_cuco( - BUILD_EXPORT_SET raft-distance-lib-exports INSTALL_EXPORT_SET raft-distance-lib-exports - ) -endif() +include(${rapids-cmake-dir}/cpm/cuco.cmake) +rapids_cpm_cuco(BUILD_EXPORT_SET raft-exports INSTALL_EXPORT_SET raft-exports) if(BUILD_TESTS) include(cmake/thirdparty/get_gtest.cmake) @@ -200,11 +177,13 @@ target_include_directories( 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> + raft::Thrust ) target_compile_features(raft INTERFACE cxx_std_17 $) @@ -222,7 +201,7 @@ else() target_compile_definitions(raft INTERFACE RAFT_SYSTEM_LITTLE_ENDIAN=1) endif() -if(RAFT_COMPILE_DIST_LIBRARY OR RAFT_COMPILE_NN_LIBRARY) +if(RAFT_COMPILE_LIBRARY) file( WRITE "${CMAKE_CURRENT_BINARY_DIR}/fatbin.ld" [=[ @@ -266,148 +245,203 @@ target_compile_definitions(raft::raft INTERFACE $<$:NVTX_ENAB endif() # ################################################################################################## -# * raft_distance ------------------------------------------------------------ TODO: Currently, this +# * raft_compiled ------------------------------------------------------------ TODO: Currently, this # package also contains the 'random' namespace (for rmat logic) We couldn't get this to work # properly due to strange CI failures as noticed in the PR#778. In the long term, we should rename # this package to `raft_compiled` in order to have a single pre-compiled raft package for those # who need it. -add_library(raft_distance INTERFACE) +add_library(raft_compiled INTERFACE) -if(TARGET raft_distance AND (NOT TARGET raft::distance)) - add_library(raft::distance ALIAS raft_distance) +if(TARGET raft_compiled AND (NOT TARGET raft::compiled)) + add_library(raft::compiled ALIAS raft_compiled) endif() -set_target_properties(raft_distance PROPERTIES EXPORT_NAME distance) +set_target_properties(raft_compiled PROPERTIES EXPORT_NAME compiled) -if(RAFT_COMPILE_DIST_LIBRARY) +if(RAFT_COMPILE_LIBRARY) add_library( - raft_distance_lib - src/distance/distance/pairwise_distance.cu - src/distance/distance/fused_l2_min_arg.cu - src/distance/cluster/update_centroids_float.cu - src/distance/cluster/update_centroids_double.cu - src/distance/cluster/cluster_cost_float.cu - src/distance/cluster/cluster_cost_double.cu - src/distance/neighbors/refine_d_int64_t_float.cu - src/distance/neighbors/refine_d_int64_t_int8_t.cu - src/distance/neighbors/refine_d_int64_t_uint8_t.cu - src/distance/neighbors/refine_h_int64_t_float.cu - src/distance/neighbors/refine_h_int64_t_int8_t.cu - src/distance/neighbors/refine_h_int64_t_uint8_t.cu - src/distance/neighbors/specializations/refine_d_int64_t_float.cu - src/distance/neighbors/specializations/refine_d_int64_t_int8_t.cu - src/distance/neighbors/specializations/refine_d_int64_t_uint8_t.cu - src/distance/neighbors/specializations/refine_h_int64_t_float.cu - src/distance/neighbors/specializations/refine_h_int64_t_int8_t.cu - src/distance/neighbors/specializations/refine_h_int64_t_uint8_t.cu - src/distance/cluster/kmeans_fit_float.cu - src/distance/cluster/kmeans_fit_double.cu - src/distance/cluster/kmeans_init_plus_plus_double.cu - src/distance/cluster/kmeans_init_plus_plus_float.cu - src/distance/distance/specializations/detail/canberra_double_double_double_int.cu - src/distance/distance/specializations/detail/canberra_float_float_float_int.cu - src/distance/distance/specializations/detail/correlation_double_double_double_int.cu - src/distance/distance/specializations/detail/correlation_float_float_float_int.cu - src/distance/distance/specializations/detail/cosine_double_double_double_int.cu - src/distance/distance/specializations/detail/cosine_float_float_float_int.cu - src/distance/distance/specializations/detail/hamming_unexpanded_double_double_double_int.cu - src/distance/distance/specializations/detail/hamming_unexpanded_float_float_float_int.cu - src/distance/distance/specializations/detail/hellinger_expanded_float_float_float_int.cu - src/distance/distance/specializations/detail/hellinger_expanded_double_double_double_int.cu - src/distance/distance/specializations/detail/inner_product_float_float_float_int.cu - src/distance/distance/specializations/detail/inner_product_double_double_double_int.cu - src/distance/distance/specializations/detail/jensen_shannon_float_float_float_int.cu - src/distance/distance/specializations/detail/jensen_shannon_double_double_double_int.cu - src/distance/distance/specializations/detail/kernels/gram_matrix_base_double.cu - src/distance/distance/specializations/detail/kernels/gram_matrix_base_float.cu - src/distance/distance/specializations/detail/kernels/polynomial_kernel_double_int.cu - src/distance/distance/specializations/detail/kernels/polynomial_kernel_float_int.cu + raft_lib + src/distance/pairwise_distance.cu + src/distance/fused_l2_min_arg.cu + src/cluster/update_centroids_float.cu + src/cluster/update_centroids_double.cu + src/cluster/cluster_cost_float.cu + src/cluster/cluster_cost_double.cu + src/neighbors/refine_d_int64_t_float.cu + src/neighbors/refine_d_int64_t_int8_t.cu + src/neighbors/refine_d_int64_t_uint8_t.cu + src/neighbors/refine_h_int64_t_float.cu + src/neighbors/refine_h_int64_t_int8_t.cu + src/neighbors/refine_h_int64_t_uint8_t.cu + src/neighbors/specializations/refine_d_int64_t_float.cu + src/neighbors/specializations/refine_d_int64_t_int8_t.cu + src/neighbors/specializations/refine_d_int64_t_uint8_t.cu + src/neighbors/specializations/refine_h_int64_t_float.cu + src/neighbors/specializations/refine_h_int64_t_int8_t.cu + src/neighbors/specializations/refine_h_int64_t_uint8_t.cu + src/cluster/kmeans_fit_float.cu + src/cluster/kmeans_fit_double.cu + src/cluster/kmeans_init_plus_plus_double.cu + src/cluster/kmeans_init_plus_plus_float.cu + src/distance/specializations/detail/canberra_double_double_double_int.cu + src/distance/specializations/detail/canberra_float_float_float_int.cu + src/distance/specializations/detail/correlation_double_double_double_int.cu + src/distance/specializations/detail/correlation_float_float_float_int.cu + src/distance/specializations/detail/cosine_double_double_double_int.cu + src/distance/specializations/detail/cosine_float_float_float_int.cu + src/distance/specializations/detail/hamming_unexpanded_double_double_double_int.cu + src/distance/specializations/detail/hamming_unexpanded_float_float_float_int.cu + src/distance/specializations/detail/hellinger_expanded_float_float_float_int.cu + src/distance/specializations/detail/hellinger_expanded_double_double_double_int.cu + src/distance/specializations/detail/inner_product_float_float_float_int.cu + src/distance/specializations/detail/inner_product_double_double_double_int.cu + src/distance/specializations/detail/jensen_shannon_float_float_float_int.cu + src/distance/specializations/detail/jensen_shannon_double_double_double_int.cu + src/distance/specializations/detail/kernels/gram_matrix_base_double.cu + src/distance/specializations/detail/kernels/gram_matrix_base_float.cu + src/distance/specializations/detail/kernels/polynomial_kernel_double_int.cu + src/distance/specializations/detail/kernels/polynomial_kernel_float_int.cu # These are somehow missing a kernel definition which is causing a compile error. # src/distance/specializations/detail/kernels/rbf_kernel_double.cu # src/distance/specializations/detail/kernels/rbf_kernel_float.cu - src/distance/distance/specializations/detail/kernels/tanh_kernel_double.cu - src/distance/distance/specializations/detail/kernels/tanh_kernel_float.cu - src/distance/distance/specializations/detail/kl_divergence_float_float_float_int.cu - src/distance/distance/specializations/detail/kl_divergence_double_double_double_int.cu - src/distance/distance/specializations/detail/l1_float_float_float_int.cu - src/distance/distance/specializations/detail/l1_double_double_double_int.cu - src/distance/distance/specializations/detail/l2_expanded_float_float_float_int.cu - src/distance/distance/specializations/detail/l2_expanded_double_double_double_int.cu - src/distance/distance/specializations/detail/l2_sqrt_expanded_float_float_float_int.cu - src/distance/distance/specializations/detail/l2_sqrt_expanded_double_double_double_int.cu - src/distance/distance/specializations/detail/l2_sqrt_unexpanded_float_float_float_int.cu - src/distance/distance/specializations/detail/l2_sqrt_unexpanded_double_double_double_int.cu - src/distance/distance/specializations/detail/l2_unexpanded_double_double_double_int.cu - src/distance/distance/specializations/detail/l2_unexpanded_float_float_float_int.cu - src/distance/distance/specializations/detail/l_inf_double_double_double_int.cu - src/distance/distance/specializations/detail/l_inf_float_float_float_int.cu - src/distance/distance/specializations/detail/lp_unexpanded_double_double_double_int.cu - src/distance/distance/specializations/detail/lp_unexpanded_float_float_float_int.cu - src/distance/distance/specializations/detail/russel_rao_double_double_double_int.cu - src/distance/distance/specializations/detail/russel_rao_float_float_float_int.cu - src/distance/distance/specializations/fused_l2_nn_double_int.cu - src/distance/distance/specializations/fused_l2_nn_double_int64.cu - src/distance/distance/specializations/fused_l2_nn_float_int.cu - src/distance/distance/specializations/fused_l2_nn_float_int64.cu - src/distance/matrix/specializations/detail/select_k_float_uint32_t.cu - src/distance/matrix/specializations/detail/select_k_float_int64_t.cu - src/distance/matrix/specializations/detail/select_k_half_uint32_t.cu - src/distance/matrix/specializations/detail/select_k_half_int64_t.cu - src/distance/neighbors/ivf_flat_search.cu - src/distance/neighbors/ivf_flat_build.cu - src/distance/neighbors/specializations/ivfflat_build_float_int64_t.cu - src/distance/neighbors/specializations/ivfflat_build_int8_t_int64_t.cu - src/distance/neighbors/specializations/ivfflat_build_uint8_t_int64_t.cu - src/distance/neighbors/specializations/ivfflat_extend_float_int64_t.cu - src/distance/neighbors/specializations/ivfflat_extend_int8_t_int64_t.cu - src/distance/neighbors/specializations/ivfflat_extend_uint8_t_int64_t.cu - src/distance/neighbors/specializations/ivfflat_search_float_int64_t.cu - src/distance/neighbors/specializations/ivfflat_search_int8_t_int64_t.cu - src/distance/neighbors/specializations/ivfflat_search_uint8_t_int64_t.cu - src/distance/neighbors/ivfpq_build.cu - src/distance/neighbors/ivfpq_deserialize.cu - src/distance/neighbors/ivfpq_serialize.cu - src/distance/neighbors/ivfpq_search_float_int64_t.cu - src/distance/neighbors/ivfpq_search_int8_t_int64_t.cu - src/distance/neighbors/ivfpq_search_uint8_t_int64_t.cu - src/distance/neighbors/specializations/ivfpq_build_float_int64_t.cu - src/distance/neighbors/specializations/ivfpq_build_int8_t_int64_t.cu - src/distance/neighbors/specializations/ivfpq_build_uint8_t_int64_t.cu - src/distance/neighbors/specializations/ivfpq_extend_float_int64_t.cu - src/distance/neighbors/specializations/ivfpq_extend_int8_t_int64_t.cu - src/distance/neighbors/specializations/ivfpq_extend_uint8_t_int64_t.cu - src/distance/neighbors/specializations/ivfpq_search_float_int64_t.cu - src/distance/neighbors/specializations/ivfpq_search_int8_t_int64_t.cu - src/distance/neighbors/specializations/ivfpq_search_uint8_t_int64_t.cu - src/distance/neighbors/specializations/detail/compute_similarity_float_float_fast.cu - src/distance/neighbors/specializations/detail/compute_similarity_float_float_no_basediff.cu - src/distance/neighbors/specializations/detail/compute_similarity_float_float_no_smem_lut.cu - src/distance/neighbors/specializations/detail/compute_similarity_float_fp8s_fast.cu - src/distance/neighbors/specializations/detail/compute_similarity_float_fp8s_no_basediff.cu - src/distance/neighbors/specializations/detail/compute_similarity_float_fp8s_no_smem_lut.cu - src/distance/neighbors/specializations/detail/compute_similarity_float_fp8u_fast.cu - src/distance/neighbors/specializations/detail/compute_similarity_float_fp8u_no_basediff.cu - src/distance/neighbors/specializations/detail/compute_similarity_float_fp8u_no_smem_lut.cu - src/distance/neighbors/specializations/detail/compute_similarity_float_half_fast.cu - src/distance/neighbors/specializations/detail/compute_similarity_float_half_no_basediff.cu - src/distance/neighbors/specializations/detail/compute_similarity_float_half_no_smem_lut.cu - src/distance/neighbors/specializations/detail/compute_similarity_half_fp8s_fast.cu - src/distance/neighbors/specializations/detail/compute_similarity_half_fp8s_no_basediff.cu - src/distance/neighbors/specializations/detail/compute_similarity_half_fp8s_no_smem_lut.cu - src/distance/neighbors/specializations/detail/compute_similarity_half_fp8u_fast.cu - src/distance/neighbors/specializations/detail/compute_similarity_half_fp8u_no_basediff.cu - src/distance/neighbors/specializations/detail/compute_similarity_half_fp8u_no_smem_lut.cu - src/distance/neighbors/specializations/detail/compute_similarity_half_half_fast.cu - src/distance/neighbors/specializations/detail/compute_similarity_half_half_no_basediff.cu - src/distance/neighbors/specializations/detail/compute_similarity_half_half_no_smem_lut.cu - src/distance/random/rmat_rectangular_generator_int_double.cu - src/distance/random/rmat_rectangular_generator_int64_double.cu - src/distance/random/rmat_rectangular_generator_int_float.cu - src/distance/random/rmat_rectangular_generator_int64_float.cu + src/distance/specializations/detail/kernels/tanh_kernel_double.cu + src/distance/specializations/detail/kernels/tanh_kernel_float.cu + src/distance/specializations/detail/kl_divergence_float_float_float_int.cu + src/distance/specializations/detail/kl_divergence_double_double_double_int.cu + src/distance/specializations/detail/l1_float_float_float_int.cu + src/distance/specializations/detail/l1_double_double_double_int.cu + src/distance/specializations/detail/l2_expanded_float_float_float_int.cu + src/distance/specializations/detail/l2_expanded_double_double_double_int.cu + src/distance/specializations/detail/l2_sqrt_expanded_float_float_float_int.cu + src/distance/specializations/detail/l2_sqrt_expanded_double_double_double_int.cu + src/distance/specializations/detail/l2_sqrt_unexpanded_float_float_float_int.cu + src/distance/specializations/detail/l2_sqrt_unexpanded_double_double_double_int.cu + src/distance/specializations/detail/l2_unexpanded_double_double_double_int.cu + src/distance/specializations/detail/l2_unexpanded_float_float_float_int.cu + src/distance/specializations/detail/l_inf_double_double_double_int.cu + src/distance/specializations/detail/l_inf_float_float_float_int.cu + src/distance/specializations/detail/lp_unexpanded_double_double_double_int.cu + src/distance/specializations/detail/lp_unexpanded_float_float_float_int.cu + src/distance/specializations/detail/russel_rao_double_double_double_int.cu + src/distance/specializations/detail/russel_rao_float_float_float_int.cu + src/distance/specializations/fused_l2_nn_double_int.cu + src/distance/specializations/fused_l2_nn_double_int64.cu + src/distance/specializations/fused_l2_nn_float_int.cu + src/distance/specializations/fused_l2_nn_float_int64.cu + src/matrix/specializations/detail/select_k_float_uint32_t.cu + src/matrix/specializations/detail/select_k_float_int64_t.cu + src/matrix/specializations/detail/select_k_half_uint32_t.cu + src/matrix/specializations/detail/select_k_half_int64_t.cu + src/neighbors/ivfpq_build.cu + src/neighbors/ivfpq_deserialize.cu + src/neighbors/ivfpq_serialize.cu + src/neighbors/ivfpq_search_float_int64_t.cu + src/neighbors/ivfpq_search_int8_t_int64_t.cu + src/neighbors/ivfpq_search_uint8_t_int64_t.cu + src/neighbors/specializations/ivfpq_build_float_int64_t.cu + src/neighbors/specializations/ivfpq_build_int8_t_int64_t.cu + src/neighbors/specializations/ivfpq_build_uint8_t_int64_t.cu + src/neighbors/specializations/ivfpq_extend_float_int64_t.cu + src/neighbors/specializations/ivfpq_extend_int8_t_int64_t.cu + src/neighbors/specializations/ivfpq_extend_uint8_t_int64_t.cu + src/neighbors/specializations/ivfpq_search_float_int64_t.cu + src/neighbors/specializations/ivfpq_search_int8_t_int64_t.cu + src/neighbors/specializations/ivfpq_search_uint8_t_int64_t.cu + src/neighbors/specializations/detail/brute_force_knn_impl_long_float_int.cu + src/neighbors/specializations/detail/brute_force_knn_impl_long_float_uint.cu + src/neighbors/specializations/detail/brute_force_knn_impl_uint_float_int.cu + src/neighbors/specializations/detail/brute_force_knn_impl_uint_float_uint.cu + src/neighbors/specializations/detail/compute_similarity_float_float_fast.cu + src/neighbors/specializations/detail/compute_similarity_float_float_no_basediff.cu + src/neighbors/specializations/detail/compute_similarity_float_float_no_smem_lut.cu + src/neighbors/specializations/detail/compute_similarity_float_fp8s_fast.cu + src/neighbors/specializations/detail/compute_similarity_float_fp8s_no_basediff.cu + src/neighbors/specializations/detail/compute_similarity_float_fp8s_no_smem_lut.cu + src/neighbors/specializations/detail/compute_similarity_float_fp8u_fast.cu + src/neighbors/specializations/detail/compute_similarity_float_fp8u_no_basediff.cu + src/neighbors/specializations/detail/compute_similarity_float_fp8u_no_smem_lut.cu + src/neighbors/specializations/detail/compute_similarity_float_half_fast.cu + src/neighbors/specializations/detail/compute_similarity_float_half_no_basediff.cu + src/neighbors/specializations/detail/compute_similarity_float_half_no_smem_lut.cu + src/neighbors/specializations/detail/compute_similarity_half_fp8s_fast.cu + src/neighbors/specializations/detail/compute_similarity_half_fp8s_no_basediff.cu + src/neighbors/specializations/detail/compute_similarity_half_fp8s_no_smem_lut.cu + src/neighbors/specializations/detail/compute_similarity_half_fp8u_fast.cu + src/neighbors/specializations/detail/compute_similarity_half_fp8u_no_basediff.cu + src/neighbors/specializations/detail/compute_similarity_half_fp8u_no_smem_lut.cu + src/neighbors/specializations/detail/compute_similarity_half_half_fast.cu + src/neighbors/specializations/detail/compute_similarity_half_half_no_basediff.cu + src/neighbors/specializations/detail/compute_similarity_half_half_no_smem_lut.cu + src/random/rmat_rectangular_generator_int_double.cu + src/random/rmat_rectangular_generator_int64_double.cu + src/random/rmat_rectangular_generator_int_float.cu + src/random/rmat_rectangular_generator_int64_float.cu + src/neighbors/specializations/detail/ball_cover_lowdim_pass_one_2d.cu + src/neighbors/specializations/detail/ball_cover_lowdim_pass_two_2d.cu + src/neighbors/specializations/detail/ball_cover_lowdim_pass_one_3d.cu + src/neighbors/specializations/detail/ball_cover_lowdim_pass_two_3d.cu + src/neighbors/specializations/ball_cover_all_knn_query.cu + src/neighbors/specializations/ball_cover_build_index.cu + src/neighbors/specializations/ball_cover_knn_query.cu + src/neighbors/specializations/fused_l2_knn_long_float_true.cu + src/neighbors/specializations/fused_l2_knn_long_float_false.cu + src/neighbors/specializations/fused_l2_knn_int_float_true.cu + src/neighbors/specializations/fused_l2_knn_int_float_false.cu + src/neighbors/ivf_flat_search.cu + src/neighbors/ivf_flat_build.cu + src/neighbors/specializations/ivfflat_build_float_int64_t.cu + src/neighbors/specializations/ivfflat_build_int8_t_int64_t.cu + src/neighbors/specializations/ivfflat_build_uint8_t_int64_t.cu + src/neighbors/specializations/ivfflat_extend_float_int64_t.cu + src/neighbors/specializations/ivfflat_extend_int8_t_int64_t.cu + src/neighbors/specializations/ivfflat_extend_uint8_t_int64_t.cu + src/neighbors/specializations/ivfflat_search_float_int64_t.cu + src/neighbors/specializations/ivfflat_search_int8_t_int64_t.cu + src/neighbors/specializations/ivfflat_search_uint8_t_int64_t.cu + src/neighbors/ivfpq_build.cu + src/neighbors/ivfpq_deserialize.cu + src/neighbors/ivfpq_serialize.cu + src/neighbors/ivfpq_search_float_int64_t.cu + src/neighbors/ivfpq_search_int8_t_int64_t.cu + src/neighbors/ivfpq_search_uint8_t_int64_t.cu + src/neighbors/specializations/ivfpq_build_float_int64_t.cu + src/neighbors/specializations/ivfpq_build_int8_t_int64_t.cu + src/neighbors/specializations/ivfpq_build_uint8_t_int64_t.cu + src/neighbors/specializations/ivfpq_extend_float_int64_t.cu + src/neighbors/specializations/ivfpq_extend_int8_t_int64_t.cu + src/neighbors/specializations/ivfpq_extend_uint8_t_int64_t.cu + src/neighbors/specializations/ivfpq_search_float_int64_t.cu + src/neighbors/specializations/ivfpq_search_int8_t_int64_t.cu + src/neighbors/specializations/ivfpq_search_uint8_t_int64_t.cu + src/neighbors/specializations/detail/compute_similarity_float_float_fast.cu + src/neighbors/specializations/detail/compute_similarity_float_float_no_basediff.cu + src/neighbors/specializations/detail/compute_similarity_float_float_no_smem_lut.cu + src/neighbors/specializations/detail/compute_similarity_float_fp8s_fast.cu + src/neighbors/specializations/detail/compute_similarity_float_fp8s_no_basediff.cu + src/neighbors/specializations/detail/compute_similarity_float_fp8s_no_smem_lut.cu + src/neighbors/specializations/detail/compute_similarity_float_fp8u_fast.cu + src/neighbors/specializations/detail/compute_similarity_float_fp8u_no_basediff.cu + src/neighbors/specializations/detail/compute_similarity_float_fp8u_no_smem_lut.cu + src/neighbors/specializations/detail/compute_similarity_float_half_fast.cu + src/neighbors/specializations/detail/compute_similarity_float_half_no_basediff.cu + src/neighbors/specializations/detail/compute_similarity_float_half_no_smem_lut.cu + src/neighbors/specializations/detail/compute_similarity_half_fp8s_fast.cu + src/neighbors/specializations/detail/compute_similarity_half_fp8s_no_basediff.cu + src/neighbors/specializations/detail/compute_similarity_half_fp8s_no_smem_lut.cu + src/neighbors/specializations/detail/compute_similarity_half_fp8u_fast.cu + src/neighbors/specializations/detail/compute_similarity_half_fp8u_no_basediff.cu + src/neighbors/specializations/detail/compute_similarity_half_fp8u_no_smem_lut.cu + src/neighbors/specializations/detail/compute_similarity_half_half_fast.cu + src/neighbors/specializations/detail/compute_similarity_half_half_no_basediff.cu + src/neighbors/specializations/detail/compute_similarity_half_half_no_smem_lut.cu + src/random/rmat_rectangular_generator_int_double.cu + src/random/rmat_rectangular_generator_int64_double.cu + src/random/rmat_rectangular_generator_int_float.cu + src/random/rmat_rectangular_generator_int64_float.cu ) set_target_properties( - raft_distance_lib - PROPERTIES OUTPUT_NAME raft_distance + raft_lib + PROPERTIES OUTPUT_NAME raft BUILD_RPATH "\$ORIGIN" INSTALL_RPATH "\$ORIGIN" CXX_STANDARD 17 @@ -418,95 +452,23 @@ if(RAFT_COMPILE_DIST_LIBRARY) INTERFACE_POSITION_INDEPENDENT_CODE ON ) - target_link_libraries( - raft_distance_lib - PUBLIC raft::raft cuco::cuco - PRIVATE nvidia::cutlass::cutlass $ - ) + target_link_libraries(raft_lib PUBLIC raft::raft $) target_compile_options( - raft_distance_lib PRIVATE "$<$:${RAFT_CXX_FLAGS}>" - "$<$:${RAFT_CUDA_FLAGS}>" - ) - target_compile_definitions(raft_distance_lib INTERFACE "RAFT_DISTANCE_COMPILED") - - # ensure CUDA symbols aren't relocated to the middle of the debug build binaries - target_link_options(raft_distance_lib PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/fatbin.ld") - -endif() - -if(TARGET raft_distance_lib AND (NOT TARGET raft::raft_distance_lib)) - add_library(raft::raft_distance_lib ALIAS raft_distance_lib) -endif() - -target_link_libraries( - raft_distance INTERFACE raft::raft $ - nvidia::cutlass::cutlass -) - -# ################################################################################################## -# * raft_nn ------------------------------------------------------------------ -add_library(raft_nn INTERFACE) - -if(TARGET raft_nn AND (NOT TARGET raft::nn)) - add_library(raft::nn ALIAS raft_nn) -endif() - -set_target_properties(raft_nn PROPERTIES EXPORT_NAME nn) - -if(RAFT_COMPILE_NN_LIBRARY) - add_library( - raft_nn_lib - src/nn/specializations/detail/ball_cover_lowdim_pass_one_2d.cu - src/nn/specializations/detail/ball_cover_lowdim_pass_two_2d.cu - src/nn/specializations/detail/ball_cover_lowdim_pass_one_3d.cu - src/nn/specializations/detail/ball_cover_lowdim_pass_two_3d.cu - src/nn/specializations/ball_cover_all_knn_query.cu - src/nn/specializations/ball_cover_build_index.cu - src/nn/specializations/ball_cover_knn_query.cu - src/nn/specializations/fused_l2_knn_long_float_true.cu - src/nn/specializations/fused_l2_knn_long_float_false.cu - src/nn/specializations/fused_l2_knn_int_float_true.cu - src/nn/specializations/fused_l2_knn_int_float_false.cu - src/nn/specializations/brute_force_knn_long_float_int.cu - src/nn/specializations/brute_force_knn_long_float_uint.cu - src/nn/specializations/brute_force_knn_uint32_t_float_int.cu - src/nn/specializations/brute_force_knn_uint32_t_float_uint.cu - ) - 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 + raft_lib PRIVATE "$<$:${RAFT_CXX_FLAGS}>" + "$<$:${RAFT_CUDA_FLAGS}>" ) + target_compile_definitions(raft_lib INTERFACE "RAFT_COMPILED") - target_link_libraries( - raft_nn_lib - PUBLIC raft::raft - PRIVATE nvidia::cutlass::cutlass - ) - target_compile_options( - raft_nn_lib PRIVATE "$<$:${RAFT_CXX_FLAGS}>" - "$<$:${RAFT_CUDA_FLAGS}>" - ) # ensure CUDA symbols aren't relocated to the middle of the debug build binaries - target_link_options(raft_nn_lib PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/fatbin.ld") + target_link_options(raft_lib PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/fatbin.ld") - target_compile_definitions(raft_nn_lib INTERFACE "RAFT_NN_COMPILED") endif() -if(TARGET raft_nn_lib AND (NOT TARGET raft::raft_nn_lib)) - add_library(raft::raft_nn_lib ALIAS raft_nn_lib) +if(TARGET raft_lib AND (NOT TARGET raft::raft_lib)) + add_library(raft::raft_lib ALIAS raft_lib) endif() -target_link_libraries( - raft_nn INTERFACE raft::raft $ nvidia::cutlass::cutlass -) +target_link_libraries(raft_compiled INTERFACE raft::raft $) # ################################################################################################## # * raft_distributed ------------------------------------------------------------------------------- @@ -547,39 +509,23 @@ install( ) install( - TARGETS raft_distance + TARGETS raft_compiled DESTINATION ${lib_dir} COMPONENT raft - EXPORT raft-distance-exports + EXPORT raft-compiled-exports ) -install( - TARGETS raft_nn - DESTINATION ${lib_dir} - COMPONENT raft - EXPORT raft-nn-exports -) - -if(TARGET raft_distance_lib) +if(TARGET raft_lib) install( - TARGETS raft_distance_lib + TARGETS raft_lib DESTINATION ${lib_dir} - COMPONENT distance - EXPORT raft-distance-lib-exports + COMPONENT compiled + EXPORT raft-compiled-lib-exports ) install( DIRECTORY include/raft_runtime DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} - COMPONENT distance - ) -endif() - -if(TARGET raft_nn_lib) - install( - TARGETS raft_nn_lib - DESTINATION ${lib_dir} - COMPONENT nn - EXPORT raft-nn-lib-exports + COMPONENT compiled ) endif() @@ -614,15 +560,11 @@ install( include("${rapids-cmake-dir}/export/write_dependencies.cmake") -set(raft_components distance nn distributed) -set(raft_install_comp raft raft raft) -if(TARGET raft_distance_lib) - list(APPEND raft_components distance-lib) - list(APPEND raft_install_comp distance) -endif() -if(TARGET raft_nn_lib) - list(APPEND raft_components nn-lib) - list(APPEND raft_install_comp nn) +set(raft_components compiled distributed) +set(raft_install_comp raft raft) +if(TARGET raft_lib) + list(APPEND raft_components compiled-lib) + list(APPEND raft_install_comp compiled) endif() foreach(comp install_comp IN ZIP_LISTS raft_components raft_install_comp) @@ -658,14 +600,12 @@ RAFT contains fundamental widely-used algorithms and primitives for data science and machine learning. Optional Components: - - nn - - distance + - compiled - distributed Imported Targets: - raft::raft - - raft::nn brought in by the `nn` optional component - - raft::distance brought in by the `distance` optional component + - raft::compiled brought in by the `compiled` optional component - raft::distributed brought in by the `distributed` optional component ]=] @@ -673,27 +613,21 @@ Imported Targets: set(code_string ${nvtx_export_string}) -if(RAFT_ENABLE_thrust_DEPENDENCY) - string( - APPEND - code_string - [=[ - if(NOT TARGET raft::Thrust) - thrust_create_target(raft::Thrust FROM_OPTIONS) - endif() - ]=] - ) -endif() - string( APPEND code_string [=[ -if(distance IN_LIST raft_FIND_COMPONENTS) - enable_language(CUDA) +if(NOT TARGET raft::Thrust) + thrust_create_target(raft::Thrust FROM_OPTIONS) endif() +]=] +) -if(nn IN_LIST raft_FIND_COMPONENTS) +string( + APPEND + code_string + [=[ +if(compiled IN_LIST raft_FIND_COMPONENTS) enable_language(CUDA) endif() ]=] @@ -702,15 +636,15 @@ endif() # Use `rapids_export` for 22.04 as it will have COMPONENT support include(cmake/modules/raft_export.cmake) raft_export( - INSTALL raft COMPONENTS nn distance distributed EXPORT_SET raft-exports GLOBAL_TARGETS raft nn - distance distributed NAMESPACE raft:: DOCUMENTATION doc_string FINAL_CODE_BLOCK code_string + INSTALL raft COMPONENTS compiled distributed EXPORT_SET raft-exports GLOBAL_TARGETS raft compiled + distributed NAMESPACE raft:: DOCUMENTATION doc_string FINAL_CODE_BLOCK code_string ) # ################################################################################################## # * build export ------------------------------------------------------------- raft_export( - BUILD raft EXPORT_SET raft-exports COMPONENTS nn distance distributed GLOBAL_TARGETS raft - distance distributed nn DOCUMENTATION doc_string NAMESPACE raft:: FINAL_CODE_BLOCK code_string + BUILD raft EXPORT_SET raft-exports COMPONENTS compiled distributed GLOBAL_TARGETS raft compiled + distributed DOCUMENTATION doc_string NAMESPACE raft:: FINAL_CODE_BLOCK code_string ) # ################################################################################################## diff --git a/cpp/bench/CMakeLists.txt b/cpp/bench/CMakeLists.txt index e2324de654..8049074c09 100644 --- a/cpp/bench/CMakeLists.txt +++ b/cpp/bench/CMakeLists.txt @@ -17,7 +17,7 @@ function(ConfigureBench) - set(options OPTIONAL DIST NN) + set(options OPTIONAL LIB) set(oneValueArgs NAME) set(multiValueArgs PATH TARGETS CONFIGURATIONS) @@ -31,8 +31,7 @@ function(ConfigureBench) ${BENCH_NAME} PRIVATE raft::raft raft_internal - $<$:raft::distance> - $<$:raft::nn> + $<$:raft::compiled> benchmark::benchmark Threads::Threads $ @@ -70,7 +69,7 @@ endfunction() if(BUILD_BENCH) ConfigureBench( NAME CLUSTER_BENCH PATH bench/cluster/kmeans_balanced.cu bench/cluster/kmeans.cu bench/main.cpp - OPTIONAL DIST NN + OPTIONAL LIB ) ConfigureBench( @@ -86,7 +85,7 @@ if(BUILD_BENCH) bench/distance/kernels.cu bench/main.cpp OPTIONAL - DIST + LIB ) ConfigureBench( @@ -106,7 +105,7 @@ if(BUILD_BENCH) ConfigureBench( NAME MATRIX_BENCH PATH bench/matrix/argmin.cu bench/matrix/gather.cu bench/matrix/select_k.cu - bench/main.cpp OPTIONAL DIST + bench/main.cpp OPTIONAL LIB ) ConfigureBench( @@ -132,7 +131,6 @@ if(BUILD_BENCH) bench/neighbors/refine_uint8_t_int64_t.cu bench/main.cpp OPTIONAL - DIST - NN + LIB ) endif() diff --git a/cpp/bench/cluster/kmeans.cu b/cpp/bench/cluster/kmeans.cu index f593ec090d..af7afb8037 100644 --- a/cpp/bench/cluster/kmeans.cu +++ b/cpp/bench/cluster/kmeans.cu @@ -18,7 +18,7 @@ #include #include -#if defined RAFT_DISTANCE_COMPILED +#if defined RAFT_COMPILED #include #endif diff --git a/cpp/bench/cluster/kmeans_balanced.cu b/cpp/bench/cluster/kmeans_balanced.cu index 8dda155a59..6bda43bdb2 100644 --- a/cpp/bench/cluster/kmeans_balanced.cu +++ b/cpp/bench/cluster/kmeans_balanced.cu @@ -18,7 +18,7 @@ #include #include -#if defined RAFT_DISTANCE_COMPILED +#if defined RAFT_COMPILED #include #endif diff --git a/cpp/bench/distance/distance_common.cuh b/cpp/bench/distance/distance_common.cuh index 906271bf5a..9b5d67a46f 100644 --- a/cpp/bench/distance/distance_common.cuh +++ b/cpp/bench/distance/distance_common.cuh @@ -17,7 +17,7 @@ #include #include #include -#if defined RAFT_DISTANCE_COMPILED +#if defined RAFT_COMPILED #include #endif #include diff --git a/cpp/bench/distance/fused_l2_nn.cu b/cpp/bench/distance/fused_l2_nn.cu index 7531784707..1c45572782 100644 --- a/cpp/bench/distance/fused_l2_nn.cu +++ b/cpp/bench/distance/fused_l2_nn.cu @@ -17,7 +17,7 @@ #include #include #include -#if defined RAFT_DISTANCE_COMPILED +#if defined RAFT_COMPILED #include #endif #include diff --git a/cpp/bench/distance/kernels.cu b/cpp/bench/distance/kernels.cu index 027f93171e..4407bdcf83 100644 --- a/cpp/bench/distance/kernels.cu +++ b/cpp/bench/distance/kernels.cu @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#if defined RAFT_DISTANCE_COMPILED +#if defined RAFT_COMPILED #include #endif diff --git a/cpp/bench/distance/masked_nn.cu b/cpp/bench/distance/masked_nn.cu index 1fecb455c3..f9f234187d 100644 --- a/cpp/bench/distance/masked_nn.cu +++ b/cpp/bench/distance/masked_nn.cu @@ -30,7 +30,7 @@ #include #include -#ifdef RAFT_DISTANCE_COMPILED +#ifdef RAFT_COMPILED #include #endif diff --git a/cpp/bench/matrix/select_k.cu b/cpp/bench/matrix/select_k.cu index 3b6f031c77..d4873e2640 100644 --- a/cpp/bench/matrix/select_k.cu +++ b/cpp/bench/matrix/select_k.cu @@ -23,7 +23,7 @@ #include #include -#if defined RAFT_DISTANCE_COMPILED +#if defined RAFT_COMPILED #include #endif diff --git a/cpp/bench/neighbors/knn.cuh b/cpp/bench/neighbors/knn.cuh index fe8c2c10d8..6caf355034 100644 --- a/cpp/bench/neighbors/knn.cuh +++ b/cpp/bench/neighbors/knn.cuh @@ -24,15 +24,10 @@ #include #include -#if defined RAFT_DISTANCE_COMPILED +#if defined RAFT_COMPILED #include #endif -#if defined RAFT_NN_COMPILED -// TODO: Legacy. Remove when FAISS is removed -#include -#endif - #include #include diff --git a/cpp/bench/neighbors/refine_float_int64_t.cu b/cpp/bench/neighbors/refine_float_int64_t.cu index 40ab2bc0ca..43be330e9b 100644 --- a/cpp/bench/neighbors/refine_float_int64_t.cu +++ b/cpp/bench/neighbors/refine_float_int64_t.cu @@ -17,11 +17,8 @@ #include "refine.cuh" #include -#if defined RAFT_DISTANCE_COMPILED +#if defined RAFT_COMPILED #include -#endif - -#if defined RAFT_NN_COMPILED #include #endif diff --git a/cpp/bench/neighbors/refine_uint8_t_int64_t.cu b/cpp/bench/neighbors/refine_uint8_t_int64_t.cu index 92806f84a7..1d7cb8c8aa 100644 --- a/cpp/bench/neighbors/refine_uint8_t_int64_t.cu +++ b/cpp/bench/neighbors/refine_uint8_t_int64_t.cu @@ -17,13 +17,8 @@ #include "refine.cuh" #include -#if defined RAFT_DISTANCE_COMPILED -#include -#include -#endif - -#if defined RAFT_NN_COMPILED -#include +#if defined RAFT_COMPILED +#include #endif using namespace raft::neighbors; diff --git a/cpp/cmake/modules/raft_export.cmake b/cpp/cmake/modules/raft_export.cmake index bcc3578bf8..0a43f9451c 100644 --- a/cpp/cmake/modules/raft_export.cmake +++ b/cpp/cmake/modules/raft_export.cmake @@ -1,5 +1,5 @@ # ============================================================================= -# Copyright (c) 2021-2022, NVIDIA CORPORATION. +# Copyright (c) 2021-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. You may obtain a copy of the License at @@ -213,7 +213,7 @@ function(raft_export type project_name) DESTINATION "${install_location}" COMPONENT raft ) - foreach(comp nn distance) + foreach(comp compiled) set(scratch_dir "${PROJECT_BINARY_DIR}/rapids-cmake/${project_name}/export/${comp}/") file(MAKE_DIRECTORY "${scratch_dir}") install( diff --git a/cpp/cmake/thirdparty/get_cutlass.cmake b/cpp/cmake/thirdparty/get_cutlass.cmake index 3e02ce064e..cb809de445 100644 --- a/cpp/cmake/thirdparty/get_cutlass.cmake +++ b/cpp/cmake/thirdparty/get_cutlass.cmake @@ -1,5 +1,5 @@ # ============================================================================= -# Copyright (c) 2021-2022, NVIDIA CORPORATION. +# Copyright (c) 2021-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. You may obtain a copy of the License at @@ -61,32 +61,19 @@ function(find_and_configure_cutlass) # We generate the cutlass-config files when we built cutlass locally, so always do # `find_dependency` rapids_export_package( - BUILD NvidiaCutlass raft-distance-exports GLOBAL_TARGETS nvidia::cutlass::cutlass + BUILD NvidiaCutlass raft-exports GLOBAL_TARGETS nvidia::cutlass::cutlass ) rapids_export_package( - INSTALL NvidiaCutlass raft-distance-exports GLOBAL_TARGETS nvidia::cutlass::cutlass - ) - rapids_export_package( - BUILD NvidiaCutlass raft-nn-exports GLOBAL_TARGETS nvidia::cutlass::cutlass - ) - rapids_export_package( - INSTALL NvidiaCutlass raft-nn-exports GLOBAL_TARGETS nvidia::cutlass::cutlass + INSTALL NvidiaCutlass raft-exports GLOBAL_TARGETS nvidia::cutlass::cutlass ) # Tell cmake where it can find the generated NvidiaCutlass-config.cmake we wrote. include("${rapids-cmake-dir}/export/find_package_root.cmake") rapids_export_find_package_root( - INSTALL NvidiaCutlass [=[${CMAKE_CURRENT_LIST_DIR}/../]=] raft-distance-exports - ) - rapids_export_find_package_root( - BUILD NvidiaCutlass [=[${CMAKE_CURRENT_LIST_DIR}]=] raft-distance-exports - ) - include("${rapids-cmake-dir}/export/find_package_root.cmake") - rapids_export_find_package_root( - INSTALL NvidiaCutlass [=[${CMAKE_CURRENT_LIST_DIR}/../]=] raft-nn-exports + INSTALL NvidiaCutlass [=[${CMAKE_CURRENT_LIST_DIR}/../]=] raft-exports ) rapids_export_find_package_root( - BUILD NvidiaCutlass [=[${CMAKE_CURRENT_LIST_DIR}]=] raft-nn-exports + BUILD NvidiaCutlass [=[${CMAKE_CURRENT_LIST_DIR}]=] raft-exports ) endfunction() diff --git a/cpp/cmake/thirdparty/get_thrust.cmake b/cpp/cmake/thirdparty/get_thrust.cmake index 12360b9482..6e37aab40d 100644 --- a/cpp/cmake/thirdparty/get_thrust.cmake +++ b/cpp/cmake/thirdparty/get_thrust.cmake @@ -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. You may obtain a copy of the License at @@ -21,6 +21,4 @@ function(find_and_configure_thrust) INSTALL_EXPORT_SET raft-exports) endfunction() -if(RAFT_ENABLE_thrust_DEPENDENCY) - find_and_configure_thrust() -endif() +find_and_configure_thrust() diff --git a/cpp/include/raft/neighbors/specializations.cuh b/cpp/include/raft/neighbors/specializations.cuh index 27105b6eab..9da5649ef8 100644 --- a/cpp/include/raft/neighbors/specializations.cuh +++ b/cpp/include/raft/neighbors/specializations.cuh @@ -16,10 +16,14 @@ #pragma once +#include +#include +#include + #include #include #include #include #include -#include \ No newline at end of file +#include diff --git a/cpp/include/raft/neighbors/specializations/knn.cuh b/cpp/include/raft/neighbors/specializations/brute_force.cuh similarity index 61% rename from cpp/include/raft/neighbors/specializations/knn.cuh rename to cpp/include/raft/neighbors/specializations/brute_force.cuh index e0b64415fe..d418d40185 100644 --- a/cpp/include/raft/neighbors/specializations/knn.cuh +++ b/cpp/include/raft/neighbors/specializations/brute_force.cuh @@ -17,31 +17,6 @@ #pragma once #include -#include - -namespace raft::spatial::knn { -#define RAFT_INST(IdxT, T, IntT) \ - extern template void brute_force_knn(raft::device_resources const& handle, \ - std::vector& input, \ - std::vector& sizes, \ - IntT D, \ - T* search_items, \ - IntT n, \ - IdxT* res_I, \ - T* res_D, \ - IntT k, \ - bool rowMajorIndex, \ - bool rowMajorQuery, \ - std::vector* translations, \ - distance::DistanceType metric, \ - float metric_arg); - -RAFT_INST(long, float, int); -RAFT_INST(long, float, unsigned int); -RAFT_INST(uint32_t, float, int); -RAFT_INST(uint32_t, float, unsigned int); -#undef RAFT_INST -}; // namespace raft::spatial::knn // also define the detail api, which is used by raft::neighbors::brute_force // (not doing the public api, since has extra template params on index_layout, matrix_index, diff --git a/cpp/include/raft/spatial/knn/specializations.cuh b/cpp/include/raft/spatial/knn/specializations.cuh index 34b7b742e9..5f0a39a61b 100644 --- a/cpp/include/raft/spatial/knn/specializations.cuh +++ b/cpp/include/raft/spatial/knn/specializations.cuh @@ -14,13 +14,8 @@ * limitations under the License. */ -#ifndef __KNN_SPECIALIZATIONS_H -#define __KNN_SPECIALIZATIONS_H - #pragma once #include +#include #include -#include - -#endif diff --git a/cpp/include/raft/spatial/knn/specializations/knn.cuh b/cpp/include/raft/spatial/knn/specializations/knn.cuh new file mode 100644 index 0000000000..e045487597 --- /dev/null +++ b/cpp/include/raft/spatial/knn/specializations/knn.cuh @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2021-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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +#include + +namespace raft::spatial::knn { +#define RAFT_INST(IdxT, T, IntT) \ + extern template void brute_force_knn(raft::device_resources const& handle, \ + std::vector& input, \ + std::vector& sizes, \ + IntT D, \ + T* search_items, \ + IntT n, \ + IdxT* res_I, \ + T* res_D, \ + IntT k, \ + bool rowMajorIndex, \ + bool rowMajorQuery, \ + std::vector* translations, \ + distance::DistanceType metric, \ + float metric_arg); + +RAFT_INST(long, float, int); +RAFT_INST(long, float, unsigned int); +RAFT_INST(uint32_t, float, int); +RAFT_INST(uint32_t, float, unsigned int); +#undef RAFT_INST +}; // namespace raft::spatial::knn diff --git a/cpp/include/raft/spectral/specializations.cuh b/cpp/include/raft/spectral/specializations.cuh index 2303b426fd..0ce5f0c653 100644 --- a/cpp/include/raft/spectral/specializations.cuh +++ b/cpp/include/raft/spectral/specializations.cuh @@ -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. @@ -19,6 +19,6 @@ #pragma once #include -#include +#include #endif \ No newline at end of file diff --git a/cpp/include/raft/stats/specializations.cuh b/cpp/include/raft/stats/specializations.cuh index 660eee783f..e6622469d3 100644 --- a/cpp/include/raft/stats/specializations.cuh +++ b/cpp/include/raft/stats/specializations.cuh @@ -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. @@ -19,6 +19,6 @@ #pragma once #include -#include +#include #endif \ No newline at end of file diff --git a/cpp/include/raft_runtime/neighbors/brute_force.hpp b/cpp/include/raft_runtime/neighbors/brute_force.hpp new file mode 100644 index 0000000000..19904f4f78 --- /dev/null +++ b/cpp/include/raft_runtime/neighbors/brute_force.hpp @@ -0,0 +1,39 @@ +/* + * Copyright (c) 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +#include +#include + +namespace raft::runtime::neighbors::brute_force { + +#define RAFT_INST_BFKNN(IDX_T, DATA_T, MATRIX_IDX_T, INDEX_LAYOUT, SEARCH_LAYOUT) \ + void knn(raft::device_resources const& handle, \ + std::vector> index, \ + raft::device_matrix_view search, \ + raft::device_matrix_view indices, \ + raft::device_matrix_view distances, \ + int k, \ + distance::DistanceType metric = distance::DistanceType::L2Unexpanded, \ + std::optional metric_arg = std::make_optional(2.0f), \ + std::optional global_id_offset = std::nullopt); + +RAFT_INST_BFKNN(int64_t, float, uint32_t, raft::row_major, raft::row_major); + +#undef RAFT_INST_BFKNN + +} // namespace raft::runtime::neighbors::brute_force diff --git a/cpp/internal/raft_internal/matrix/select_k.cuh b/cpp/internal/raft_internal/matrix/select_k.cuh index 59cbff9dfb..ede6382c33 100644 --- a/cpp/internal/raft_internal/matrix/select_k.cuh +++ b/cpp/internal/raft_internal/matrix/select_k.cuh @@ -20,7 +20,7 @@ #include #include -#ifdef RAFT_DISTANCE_COMPILED +#ifdef RAFT_COMPILED #include #endif diff --git a/cpp/internal/raft_internal/neighbors/naive_knn.cuh b/cpp/internal/raft_internal/neighbors/naive_knn.cuh index 942c096e58..47d6f068e3 100644 --- a/cpp/internal/raft_internal/neighbors/naive_knn.cuh +++ b/cpp/internal/raft_internal/neighbors/naive_knn.cuh @@ -21,7 +21,7 @@ #include #include -#if defined RAFT_DISTANCE_COMPILED +#if defined RAFT_COMPILED #include #endif diff --git a/cpp/src/distance/cluster/cluster_cost.cuh b/cpp/src/cluster/cluster_cost.cuh similarity index 100% rename from cpp/src/distance/cluster/cluster_cost.cuh rename to cpp/src/cluster/cluster_cost.cuh diff --git a/cpp/src/distance/cluster/cluster_cost_double.cu b/cpp/src/cluster/cluster_cost_double.cu similarity index 100% rename from cpp/src/distance/cluster/cluster_cost_double.cu rename to cpp/src/cluster/cluster_cost_double.cu diff --git a/cpp/src/distance/cluster/cluster_cost_float.cu b/cpp/src/cluster/cluster_cost_float.cu similarity index 100% rename from cpp/src/distance/cluster/cluster_cost_float.cu rename to cpp/src/cluster/cluster_cost_float.cu diff --git a/cpp/src/distance/cluster/kmeans_fit_double.cu b/cpp/src/cluster/kmeans_fit_double.cu similarity index 100% rename from cpp/src/distance/cluster/kmeans_fit_double.cu rename to cpp/src/cluster/kmeans_fit_double.cu diff --git a/cpp/src/distance/cluster/kmeans_fit_float.cu b/cpp/src/cluster/kmeans_fit_float.cu similarity index 100% rename from cpp/src/distance/cluster/kmeans_fit_float.cu rename to cpp/src/cluster/kmeans_fit_float.cu diff --git a/cpp/src/distance/cluster/kmeans_init_plus_plus_double.cu b/cpp/src/cluster/kmeans_init_plus_plus_double.cu similarity index 100% rename from cpp/src/distance/cluster/kmeans_init_plus_plus_double.cu rename to cpp/src/cluster/kmeans_init_plus_plus_double.cu diff --git a/cpp/src/distance/cluster/kmeans_init_plus_plus_float.cu b/cpp/src/cluster/kmeans_init_plus_plus_float.cu similarity index 100% rename from cpp/src/distance/cluster/kmeans_init_plus_plus_float.cu rename to cpp/src/cluster/kmeans_init_plus_plus_float.cu diff --git a/cpp/src/distance/cluster/update_centroids.cuh b/cpp/src/cluster/update_centroids.cuh similarity index 100% rename from cpp/src/distance/cluster/update_centroids.cuh rename to cpp/src/cluster/update_centroids.cuh diff --git a/cpp/src/distance/cluster/update_centroids_double.cu b/cpp/src/cluster/update_centroids_double.cu similarity index 100% rename from cpp/src/distance/cluster/update_centroids_double.cu rename to cpp/src/cluster/update_centroids_double.cu diff --git a/cpp/src/distance/cluster/update_centroids_float.cu b/cpp/src/cluster/update_centroids_float.cu similarity index 100% rename from cpp/src/distance/cluster/update_centroids_float.cu rename to cpp/src/cluster/update_centroids_float.cu diff --git a/cpp/src/distance/distance/fused_l2_min_arg.cu b/cpp/src/distance/fused_l2_min_arg.cu similarity index 100% rename from cpp/src/distance/distance/fused_l2_min_arg.cu rename to cpp/src/distance/fused_l2_min_arg.cu diff --git a/cpp/src/distance/distance/pairwise_distance.cu b/cpp/src/distance/pairwise_distance.cu similarity index 100% rename from cpp/src/distance/distance/pairwise_distance.cu rename to cpp/src/distance/pairwise_distance.cu diff --git a/cpp/src/distance/distance/specializations/detail/canberra_double_double_double_int.cu b/cpp/src/distance/specializations/detail/canberra_double_double_double_int.cu similarity index 100% rename from cpp/src/distance/distance/specializations/detail/canberra_double_double_double_int.cu rename to cpp/src/distance/specializations/detail/canberra_double_double_double_int.cu diff --git a/cpp/src/distance/distance/specializations/detail/canberra_float_float_float_int.cu b/cpp/src/distance/specializations/detail/canberra_float_float_float_int.cu similarity index 100% rename from cpp/src/distance/distance/specializations/detail/canberra_float_float_float_int.cu rename to cpp/src/distance/specializations/detail/canberra_float_float_float_int.cu diff --git a/cpp/src/distance/distance/specializations/detail/correlation_double_double_double_int.cu b/cpp/src/distance/specializations/detail/correlation_double_double_double_int.cu similarity index 100% rename from cpp/src/distance/distance/specializations/detail/correlation_double_double_double_int.cu rename to cpp/src/distance/specializations/detail/correlation_double_double_double_int.cu diff --git a/cpp/src/distance/distance/specializations/detail/correlation_float_float_float_int.cu b/cpp/src/distance/specializations/detail/correlation_float_float_float_int.cu similarity index 100% rename from cpp/src/distance/distance/specializations/detail/correlation_float_float_float_int.cu rename to cpp/src/distance/specializations/detail/correlation_float_float_float_int.cu diff --git a/cpp/src/distance/distance/specializations/detail/cosine_double_double_double_int.cu b/cpp/src/distance/specializations/detail/cosine_double_double_double_int.cu similarity index 100% rename from cpp/src/distance/distance/specializations/detail/cosine_double_double_double_int.cu rename to cpp/src/distance/specializations/detail/cosine_double_double_double_int.cu diff --git a/cpp/src/distance/distance/specializations/detail/cosine_float_float_float_int.cu b/cpp/src/distance/specializations/detail/cosine_float_float_float_int.cu similarity index 100% rename from cpp/src/distance/distance/specializations/detail/cosine_float_float_float_int.cu rename to cpp/src/distance/specializations/detail/cosine_float_float_float_int.cu diff --git a/cpp/src/distance/distance/specializations/detail/hamming_unexpanded_double_double_double_int.cu b/cpp/src/distance/specializations/detail/hamming_unexpanded_double_double_double_int.cu similarity index 100% rename from cpp/src/distance/distance/specializations/detail/hamming_unexpanded_double_double_double_int.cu rename to cpp/src/distance/specializations/detail/hamming_unexpanded_double_double_double_int.cu diff --git a/cpp/src/distance/distance/specializations/detail/hamming_unexpanded_float_float_float_int.cu b/cpp/src/distance/specializations/detail/hamming_unexpanded_float_float_float_int.cu similarity index 100% rename from cpp/src/distance/distance/specializations/detail/hamming_unexpanded_float_float_float_int.cu rename to cpp/src/distance/specializations/detail/hamming_unexpanded_float_float_float_int.cu diff --git a/cpp/src/distance/distance/specializations/detail/hellinger_expanded_double_double_double_int.cu b/cpp/src/distance/specializations/detail/hellinger_expanded_double_double_double_int.cu similarity index 100% rename from cpp/src/distance/distance/specializations/detail/hellinger_expanded_double_double_double_int.cu rename to cpp/src/distance/specializations/detail/hellinger_expanded_double_double_double_int.cu diff --git a/cpp/src/distance/distance/specializations/detail/hellinger_expanded_float_float_float_int.cu b/cpp/src/distance/specializations/detail/hellinger_expanded_float_float_float_int.cu similarity index 100% rename from cpp/src/distance/distance/specializations/detail/hellinger_expanded_float_float_float_int.cu rename to cpp/src/distance/specializations/detail/hellinger_expanded_float_float_float_int.cu diff --git a/cpp/src/distance/distance/specializations/detail/inner_product_double_double_double_int.cu b/cpp/src/distance/specializations/detail/inner_product_double_double_double_int.cu similarity index 100% rename from cpp/src/distance/distance/specializations/detail/inner_product_double_double_double_int.cu rename to cpp/src/distance/specializations/detail/inner_product_double_double_double_int.cu diff --git a/cpp/src/distance/distance/specializations/detail/inner_product_float_float_float_int.cu b/cpp/src/distance/specializations/detail/inner_product_float_float_float_int.cu similarity index 100% rename from cpp/src/distance/distance/specializations/detail/inner_product_float_float_float_int.cu rename to cpp/src/distance/specializations/detail/inner_product_float_float_float_int.cu diff --git a/cpp/src/distance/distance/specializations/detail/jensen_shannon_double_double_double_int.cu b/cpp/src/distance/specializations/detail/jensen_shannon_double_double_double_int.cu similarity index 100% rename from cpp/src/distance/distance/specializations/detail/jensen_shannon_double_double_double_int.cu rename to cpp/src/distance/specializations/detail/jensen_shannon_double_double_double_int.cu diff --git a/cpp/src/distance/distance/specializations/detail/jensen_shannon_float_float_float_int.cu b/cpp/src/distance/specializations/detail/jensen_shannon_float_float_float_int.cu similarity index 100% rename from cpp/src/distance/distance/specializations/detail/jensen_shannon_float_float_float_int.cu rename to cpp/src/distance/specializations/detail/jensen_shannon_float_float_float_int.cu diff --git a/cpp/src/distance/distance/specializations/detail/kernels/gram_matrix_base_double.cu b/cpp/src/distance/specializations/detail/kernels/gram_matrix_base_double.cu similarity index 100% rename from cpp/src/distance/distance/specializations/detail/kernels/gram_matrix_base_double.cu rename to cpp/src/distance/specializations/detail/kernels/gram_matrix_base_double.cu diff --git a/cpp/src/distance/distance/specializations/detail/kernels/gram_matrix_base_float.cu b/cpp/src/distance/specializations/detail/kernels/gram_matrix_base_float.cu similarity index 100% rename from cpp/src/distance/distance/specializations/detail/kernels/gram_matrix_base_float.cu rename to cpp/src/distance/specializations/detail/kernels/gram_matrix_base_float.cu diff --git a/cpp/src/distance/distance/specializations/detail/kernels/polynomial_kernel_double_int.cu b/cpp/src/distance/specializations/detail/kernels/polynomial_kernel_double_int.cu similarity index 100% rename from cpp/src/distance/distance/specializations/detail/kernels/polynomial_kernel_double_int.cu rename to cpp/src/distance/specializations/detail/kernels/polynomial_kernel_double_int.cu diff --git a/cpp/src/distance/distance/specializations/detail/kernels/polynomial_kernel_float_int.cu b/cpp/src/distance/specializations/detail/kernels/polynomial_kernel_float_int.cu similarity index 100% rename from cpp/src/distance/distance/specializations/detail/kernels/polynomial_kernel_float_int.cu rename to cpp/src/distance/specializations/detail/kernels/polynomial_kernel_float_int.cu diff --git a/cpp/src/distance/distance/specializations/detail/kernels/rbf_kernel_double.cu b/cpp/src/distance/specializations/detail/kernels/rbf_kernel_double.cu similarity index 100% rename from cpp/src/distance/distance/specializations/detail/kernels/rbf_kernel_double.cu rename to cpp/src/distance/specializations/detail/kernels/rbf_kernel_double.cu diff --git a/cpp/src/distance/distance/specializations/detail/kernels/rbf_kernel_float.cu b/cpp/src/distance/specializations/detail/kernels/rbf_kernel_float.cu similarity index 100% rename from cpp/src/distance/distance/specializations/detail/kernels/rbf_kernel_float.cu rename to cpp/src/distance/specializations/detail/kernels/rbf_kernel_float.cu diff --git a/cpp/src/distance/distance/specializations/detail/kernels/tanh_kernel_double.cu b/cpp/src/distance/specializations/detail/kernels/tanh_kernel_double.cu similarity index 100% rename from cpp/src/distance/distance/specializations/detail/kernels/tanh_kernel_double.cu rename to cpp/src/distance/specializations/detail/kernels/tanh_kernel_double.cu diff --git a/cpp/src/distance/distance/specializations/detail/kernels/tanh_kernel_float.cu b/cpp/src/distance/specializations/detail/kernels/tanh_kernel_float.cu similarity index 100% rename from cpp/src/distance/distance/specializations/detail/kernels/tanh_kernel_float.cu rename to cpp/src/distance/specializations/detail/kernels/tanh_kernel_float.cu diff --git a/cpp/src/distance/distance/specializations/detail/kl_divergence_double_double_double_int.cu b/cpp/src/distance/specializations/detail/kl_divergence_double_double_double_int.cu similarity index 100% rename from cpp/src/distance/distance/specializations/detail/kl_divergence_double_double_double_int.cu rename to cpp/src/distance/specializations/detail/kl_divergence_double_double_double_int.cu diff --git a/cpp/src/distance/distance/specializations/detail/kl_divergence_float_float_float_int.cu b/cpp/src/distance/specializations/detail/kl_divergence_float_float_float_int.cu similarity index 100% rename from cpp/src/distance/distance/specializations/detail/kl_divergence_float_float_float_int.cu rename to cpp/src/distance/specializations/detail/kl_divergence_float_float_float_int.cu diff --git a/cpp/src/distance/distance/specializations/detail/l1_double_double_double_int.cu b/cpp/src/distance/specializations/detail/l1_double_double_double_int.cu similarity index 100% rename from cpp/src/distance/distance/specializations/detail/l1_double_double_double_int.cu rename to cpp/src/distance/specializations/detail/l1_double_double_double_int.cu diff --git a/cpp/src/distance/distance/specializations/detail/l1_float_float_float_int.cu b/cpp/src/distance/specializations/detail/l1_float_float_float_int.cu similarity index 100% rename from cpp/src/distance/distance/specializations/detail/l1_float_float_float_int.cu rename to cpp/src/distance/specializations/detail/l1_float_float_float_int.cu diff --git a/cpp/src/distance/distance/specializations/detail/l2_expanded_double_double_double_int.cu b/cpp/src/distance/specializations/detail/l2_expanded_double_double_double_int.cu similarity index 100% rename from cpp/src/distance/distance/specializations/detail/l2_expanded_double_double_double_int.cu rename to cpp/src/distance/specializations/detail/l2_expanded_double_double_double_int.cu diff --git a/cpp/src/distance/distance/specializations/detail/l2_expanded_float_float_float_int.cu b/cpp/src/distance/specializations/detail/l2_expanded_float_float_float_int.cu similarity index 100% rename from cpp/src/distance/distance/specializations/detail/l2_expanded_float_float_float_int.cu rename to cpp/src/distance/specializations/detail/l2_expanded_float_float_float_int.cu diff --git a/cpp/src/distance/distance/specializations/detail/l2_sqrt_expanded_double_double_double_int.cu b/cpp/src/distance/specializations/detail/l2_sqrt_expanded_double_double_double_int.cu similarity index 100% rename from cpp/src/distance/distance/specializations/detail/l2_sqrt_expanded_double_double_double_int.cu rename to cpp/src/distance/specializations/detail/l2_sqrt_expanded_double_double_double_int.cu diff --git a/cpp/src/distance/distance/specializations/detail/l2_sqrt_expanded_float_float_float_int.cu b/cpp/src/distance/specializations/detail/l2_sqrt_expanded_float_float_float_int.cu similarity index 100% rename from cpp/src/distance/distance/specializations/detail/l2_sqrt_expanded_float_float_float_int.cu rename to cpp/src/distance/specializations/detail/l2_sqrt_expanded_float_float_float_int.cu diff --git a/cpp/src/distance/distance/specializations/detail/l2_sqrt_unexpanded_double_double_double_int.cu b/cpp/src/distance/specializations/detail/l2_sqrt_unexpanded_double_double_double_int.cu similarity index 100% rename from cpp/src/distance/distance/specializations/detail/l2_sqrt_unexpanded_double_double_double_int.cu rename to cpp/src/distance/specializations/detail/l2_sqrt_unexpanded_double_double_double_int.cu diff --git a/cpp/src/distance/distance/specializations/detail/l2_sqrt_unexpanded_float_float_float_int.cu b/cpp/src/distance/specializations/detail/l2_sqrt_unexpanded_float_float_float_int.cu similarity index 100% rename from cpp/src/distance/distance/specializations/detail/l2_sqrt_unexpanded_float_float_float_int.cu rename to cpp/src/distance/specializations/detail/l2_sqrt_unexpanded_float_float_float_int.cu diff --git a/cpp/src/distance/distance/specializations/detail/l2_unexpanded_double_double_double_int.cu b/cpp/src/distance/specializations/detail/l2_unexpanded_double_double_double_int.cu similarity index 100% rename from cpp/src/distance/distance/specializations/detail/l2_unexpanded_double_double_double_int.cu rename to cpp/src/distance/specializations/detail/l2_unexpanded_double_double_double_int.cu diff --git a/cpp/src/distance/distance/specializations/detail/l2_unexpanded_float_float_float_int.cu b/cpp/src/distance/specializations/detail/l2_unexpanded_float_float_float_int.cu similarity index 100% rename from cpp/src/distance/distance/specializations/detail/l2_unexpanded_float_float_float_int.cu rename to cpp/src/distance/specializations/detail/l2_unexpanded_float_float_float_int.cu diff --git a/cpp/src/distance/distance/specializations/detail/l_inf_double_double_double_int.cu b/cpp/src/distance/specializations/detail/l_inf_double_double_double_int.cu similarity index 100% rename from cpp/src/distance/distance/specializations/detail/l_inf_double_double_double_int.cu rename to cpp/src/distance/specializations/detail/l_inf_double_double_double_int.cu diff --git a/cpp/src/distance/distance/specializations/detail/l_inf_float_float_float_int.cu b/cpp/src/distance/specializations/detail/l_inf_float_float_float_int.cu similarity index 100% rename from cpp/src/distance/distance/specializations/detail/l_inf_float_float_float_int.cu rename to cpp/src/distance/specializations/detail/l_inf_float_float_float_int.cu diff --git a/cpp/src/distance/distance/specializations/detail/lp_unexpanded_double_double_double_int.cu b/cpp/src/distance/specializations/detail/lp_unexpanded_double_double_double_int.cu similarity index 100% rename from cpp/src/distance/distance/specializations/detail/lp_unexpanded_double_double_double_int.cu rename to cpp/src/distance/specializations/detail/lp_unexpanded_double_double_double_int.cu diff --git a/cpp/src/distance/distance/specializations/detail/lp_unexpanded_float_float_float_int.cu b/cpp/src/distance/specializations/detail/lp_unexpanded_float_float_float_int.cu similarity index 100% rename from cpp/src/distance/distance/specializations/detail/lp_unexpanded_float_float_float_int.cu rename to cpp/src/distance/specializations/detail/lp_unexpanded_float_float_float_int.cu diff --git a/cpp/src/distance/distance/specializations/detail/russel_rao_double_double_double_int.cu b/cpp/src/distance/specializations/detail/russel_rao_double_double_double_int.cu similarity index 100% rename from cpp/src/distance/distance/specializations/detail/russel_rao_double_double_double_int.cu rename to cpp/src/distance/specializations/detail/russel_rao_double_double_double_int.cu diff --git a/cpp/src/distance/distance/specializations/detail/russel_rao_float_float_float_int.cu b/cpp/src/distance/specializations/detail/russel_rao_float_float_float_int.cu similarity index 100% rename from cpp/src/distance/distance/specializations/detail/russel_rao_float_float_float_int.cu rename to cpp/src/distance/specializations/detail/russel_rao_float_float_float_int.cu diff --git a/cpp/src/distance/distance/specializations/fused_l2_nn_double_int.cu b/cpp/src/distance/specializations/fused_l2_nn_double_int.cu similarity index 100% rename from cpp/src/distance/distance/specializations/fused_l2_nn_double_int.cu rename to cpp/src/distance/specializations/fused_l2_nn_double_int.cu diff --git a/cpp/src/distance/distance/specializations/fused_l2_nn_double_int64.cu b/cpp/src/distance/specializations/fused_l2_nn_double_int64.cu similarity index 100% rename from cpp/src/distance/distance/specializations/fused_l2_nn_double_int64.cu rename to cpp/src/distance/specializations/fused_l2_nn_double_int64.cu diff --git a/cpp/src/distance/distance/specializations/fused_l2_nn_float_int.cu b/cpp/src/distance/specializations/fused_l2_nn_float_int.cu similarity index 100% rename from cpp/src/distance/distance/specializations/fused_l2_nn_float_int.cu rename to cpp/src/distance/specializations/fused_l2_nn_float_int.cu diff --git a/cpp/src/distance/distance/specializations/fused_l2_nn_float_int64.cu b/cpp/src/distance/specializations/fused_l2_nn_float_int64.cu similarity index 100% rename from cpp/src/distance/distance/specializations/fused_l2_nn_float_int64.cu rename to cpp/src/distance/specializations/fused_l2_nn_float_int64.cu diff --git a/cpp/src/distance/matrix/specializations/detail/select_k_float_int64_t.cu b/cpp/src/matrix/specializations/detail/select_k_float_int64_t.cu similarity index 100% rename from cpp/src/distance/matrix/specializations/detail/select_k_float_int64_t.cu rename to cpp/src/matrix/specializations/detail/select_k_float_int64_t.cu diff --git a/cpp/src/distance/matrix/specializations/detail/select_k_float_uint32_t.cu b/cpp/src/matrix/specializations/detail/select_k_float_uint32_t.cu similarity index 100% rename from cpp/src/distance/matrix/specializations/detail/select_k_float_uint32_t.cu rename to cpp/src/matrix/specializations/detail/select_k_float_uint32_t.cu diff --git a/cpp/src/distance/matrix/specializations/detail/select_k_half_int64_t.cu b/cpp/src/matrix/specializations/detail/select_k_half_int64_t.cu similarity index 100% rename from cpp/src/distance/matrix/specializations/detail/select_k_half_int64_t.cu rename to cpp/src/matrix/specializations/detail/select_k_half_int64_t.cu diff --git a/cpp/src/distance/matrix/specializations/detail/select_k_half_uint32_t.cu b/cpp/src/matrix/specializations/detail/select_k_half_uint32_t.cu similarity index 100% rename from cpp/src/distance/matrix/specializations/detail/select_k_half_uint32_t.cu rename to cpp/src/matrix/specializations/detail/select_k_half_uint32_t.cu diff --git a/cpp/src/neighbors/brute_force_knn_int64_t_float.cu b/cpp/src/neighbors/brute_force_knn_int64_t_float.cu new file mode 100644 index 0000000000..b0411a59ce --- /dev/null +++ b/cpp/src/neighbors/brute_force_knn_int64_t_float.cu @@ -0,0 +1,54 @@ +/* + * Copyright (c) 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +#include +#include +#include + +#include + +#include + +namespace raft::runtime::neighbors::brute_force { + +#define RAFT_INST_BFKNN(IDX_T, DATA_T, MATRIX_IDX_T, INDEX_LAYOUT, SEARCH_LAYOUT) \ + void knn(raft::device_resources const& handle, \ + std::vector> index, \ + raft::device_matrix_view search, \ + raft::device_matrix_view indices, \ + raft::device_matrix_view distances, \ + distance::DistanceType metric = distance::DistanceType::L2Unexpanded, \ + std::optional metric_arg = std::make_optional(2.0f), \ + std::optional global_id_offset = std::nullopt) \ + { \ + raft::neighbors::brute_force::knn(handle, \ + index, \ + search, \ + indices, \ + distances, \ + static_cast(indices.extent(1)), \ + metric, \ + metric_arg, \ + global_id_offset); \ + } + +RAFT_INST_BFKNN(int64_t, float, uint32_t, raft::row_major, raft::row_major); + +#undef RAFT_INST_BFKNN + +} // namespace raft::runtime::neighbors::brute_force diff --git a/cpp/src/distance/neighbors/ivf_flat_build.cu b/cpp/src/neighbors/ivf_flat_build.cu similarity index 100% rename from cpp/src/distance/neighbors/ivf_flat_build.cu rename to cpp/src/neighbors/ivf_flat_build.cu diff --git a/cpp/src/distance/neighbors/ivf_flat_search.cu b/cpp/src/neighbors/ivf_flat_search.cu similarity index 100% rename from cpp/src/distance/neighbors/ivf_flat_search.cu rename to cpp/src/neighbors/ivf_flat_search.cu diff --git a/cpp/src/distance/neighbors/ivfpq_build.cu b/cpp/src/neighbors/ivfpq_build.cu similarity index 100% rename from cpp/src/distance/neighbors/ivfpq_build.cu rename to cpp/src/neighbors/ivfpq_build.cu diff --git a/cpp/src/distance/neighbors/ivfpq_deserialize.cu b/cpp/src/neighbors/ivfpq_deserialize.cu similarity index 100% rename from cpp/src/distance/neighbors/ivfpq_deserialize.cu rename to cpp/src/neighbors/ivfpq_deserialize.cu diff --git a/cpp/src/distance/neighbors/ivfpq_search_float_int64_t.cu b/cpp/src/neighbors/ivfpq_search_float_int64_t.cu similarity index 100% rename from cpp/src/distance/neighbors/ivfpq_search_float_int64_t.cu rename to cpp/src/neighbors/ivfpq_search_float_int64_t.cu diff --git a/cpp/src/distance/neighbors/ivfpq_search_int8_t_int64_t.cu b/cpp/src/neighbors/ivfpq_search_int8_t_int64_t.cu similarity index 100% rename from cpp/src/distance/neighbors/ivfpq_search_int8_t_int64_t.cu rename to cpp/src/neighbors/ivfpq_search_int8_t_int64_t.cu diff --git a/cpp/src/distance/neighbors/ivfpq_search_uint8_t_int64_t.cu b/cpp/src/neighbors/ivfpq_search_uint8_t_int64_t.cu similarity index 100% rename from cpp/src/distance/neighbors/ivfpq_search_uint8_t_int64_t.cu rename to cpp/src/neighbors/ivfpq_search_uint8_t_int64_t.cu diff --git a/cpp/src/distance/neighbors/ivfpq_serialize.cu b/cpp/src/neighbors/ivfpq_serialize.cu similarity index 100% rename from cpp/src/distance/neighbors/ivfpq_serialize.cu rename to cpp/src/neighbors/ivfpq_serialize.cu diff --git a/cpp/src/distance/neighbors/refine_d_int64_t_float.cu b/cpp/src/neighbors/refine_d_int64_t_float.cu similarity index 100% rename from cpp/src/distance/neighbors/refine_d_int64_t_float.cu rename to cpp/src/neighbors/refine_d_int64_t_float.cu diff --git a/cpp/src/distance/neighbors/refine_d_int64_t_int8_t.cu b/cpp/src/neighbors/refine_d_int64_t_int8_t.cu similarity index 100% rename from cpp/src/distance/neighbors/refine_d_int64_t_int8_t.cu rename to cpp/src/neighbors/refine_d_int64_t_int8_t.cu diff --git a/cpp/src/distance/neighbors/refine_d_int64_t_uint8_t.cu b/cpp/src/neighbors/refine_d_int64_t_uint8_t.cu similarity index 100% rename from cpp/src/distance/neighbors/refine_d_int64_t_uint8_t.cu rename to cpp/src/neighbors/refine_d_int64_t_uint8_t.cu diff --git a/cpp/src/distance/neighbors/refine_h_int64_t_float.cu b/cpp/src/neighbors/refine_h_int64_t_float.cu similarity index 100% rename from cpp/src/distance/neighbors/refine_h_int64_t_float.cu rename to cpp/src/neighbors/refine_h_int64_t_float.cu diff --git a/cpp/src/distance/neighbors/refine_h_int64_t_int8_t.cu b/cpp/src/neighbors/refine_h_int64_t_int8_t.cu similarity index 100% rename from cpp/src/distance/neighbors/refine_h_int64_t_int8_t.cu rename to cpp/src/neighbors/refine_h_int64_t_int8_t.cu diff --git a/cpp/src/distance/neighbors/refine_h_int64_t_uint8_t.cu b/cpp/src/neighbors/refine_h_int64_t_uint8_t.cu similarity index 100% rename from cpp/src/distance/neighbors/refine_h_int64_t_uint8_t.cu rename to cpp/src/neighbors/refine_h_int64_t_uint8_t.cu diff --git a/cpp/src/nn/specializations/ball_cover_all_knn_query.cu b/cpp/src/neighbors/specializations/ball_cover_all_knn_query.cu similarity index 80% rename from cpp/src/nn/specializations/ball_cover_all_knn_query.cu rename to cpp/src/neighbors/specializations/ball_cover_all_knn_query.cu index d9cb836bfc..305dd6796e 100644 --- a/cpp/src/nn/specializations/ball_cover_all_knn_query.cu +++ b/cpp/src/neighbors/specializations/ball_cover_all_knn_query.cu @@ -16,14 +16,7 @@ #include #include - -// Ignore upstream specializations to avoid unnecessary recompiling -#ifdef RAFT_DISTANCE_COMPILED -#include -#endif - -// TODO: Change this to proper specializations after FAISS is removed -#include +#include #include diff --git a/cpp/src/nn/specializations/ball_cover_build_index.cu b/cpp/src/neighbors/specializations/ball_cover_build_index.cu similarity index 81% rename from cpp/src/nn/specializations/ball_cover_build_index.cu rename to cpp/src/neighbors/specializations/ball_cover_build_index.cu index 76c5a2bd5b..ec7f4bcf52 100644 --- a/cpp/src/nn/specializations/ball_cover_build_index.cu +++ b/cpp/src/neighbors/specializations/ball_cover_build_index.cu @@ -16,14 +16,7 @@ #include #include - -// Ignore upstream specializations to avoid unnecessary recompiling -#ifdef RAFT_DISTANCE_COMPILED -#include -#endif - -// TODO: Change this to proper specializations after FAISS is removed -#include +#include #include diff --git a/cpp/src/nn/specializations/ball_cover_knn_query.cu b/cpp/src/neighbors/specializations/ball_cover_knn_query.cu similarity index 80% rename from cpp/src/nn/specializations/ball_cover_knn_query.cu rename to cpp/src/neighbors/specializations/ball_cover_knn_query.cu index c01da452b2..634427200e 100644 --- a/cpp/src/nn/specializations/ball_cover_knn_query.cu +++ b/cpp/src/neighbors/specializations/ball_cover_knn_query.cu @@ -14,18 +14,10 @@ * limitations under the License. */ +#include #include #include - -// Ignore upstream specializations to avoid unnecessary recompiling -#ifdef RAFT_DISTANCE_COMPILED -#include -#endif - -// TODO: Change this to proper specializations after FAISS is removed -#include - -#include +#include namespace raft::neighbors::ball_cover { template void knn_query( diff --git a/cpp/src/nn/specializations/detail/ball_cover_lowdim_pass_one_2d.cu b/cpp/src/neighbors/specializations/detail/ball_cover_lowdim_pass_one_2d.cu similarity index 91% rename from cpp/src/nn/specializations/detail/ball_cover_lowdim_pass_one_2d.cu rename to cpp/src/neighbors/specializations/detail/ball_cover_lowdim_pass_one_2d.cu index 9a71ce4f9a..b69751a62a 100644 --- a/cpp/src/nn/specializations/detail/ball_cover_lowdim_pass_one_2d.cu +++ b/cpp/src/neighbors/specializations/detail/ball_cover_lowdim_pass_one_2d.cu @@ -15,11 +15,9 @@ */ #include +#include #include -// TODO: Change this to proper specializations after FAISS is removed -#include - namespace raft { namespace spatial { namespace knn { diff --git a/cpp/src/nn/specializations/detail/ball_cover_lowdim_pass_one_3d.cu b/cpp/src/neighbors/specializations/detail/ball_cover_lowdim_pass_one_3d.cu similarity index 91% rename from cpp/src/nn/specializations/detail/ball_cover_lowdim_pass_one_3d.cu rename to cpp/src/neighbors/specializations/detail/ball_cover_lowdim_pass_one_3d.cu index b1b3439e8f..ca44ad3165 100644 --- a/cpp/src/nn/specializations/detail/ball_cover_lowdim_pass_one_3d.cu +++ b/cpp/src/neighbors/specializations/detail/ball_cover_lowdim_pass_one_3d.cu @@ -15,11 +15,9 @@ */ #include +#include #include -// TODO: Change this to proper specializations after FAISS is removed -#include - namespace raft { namespace spatial { namespace knn { diff --git a/cpp/src/nn/specializations/detail/ball_cover_lowdim_pass_two_2d.cu b/cpp/src/neighbors/specializations/detail/ball_cover_lowdim_pass_two_2d.cu similarity index 91% rename from cpp/src/nn/specializations/detail/ball_cover_lowdim_pass_two_2d.cu rename to cpp/src/neighbors/specializations/detail/ball_cover_lowdim_pass_two_2d.cu index 9f512dcda1..ba44327653 100644 --- a/cpp/src/nn/specializations/detail/ball_cover_lowdim_pass_two_2d.cu +++ b/cpp/src/neighbors/specializations/detail/ball_cover_lowdim_pass_two_2d.cu @@ -15,11 +15,8 @@ */ #include +#include #include - -// TODO: Change this to proper specializations after FAISS is removed -#include - namespace raft { namespace spatial { namespace knn { diff --git a/cpp/src/nn/specializations/detail/ball_cover_lowdim_pass_two_3d.cu b/cpp/src/neighbors/specializations/detail/ball_cover_lowdim_pass_two_3d.cu similarity index 91% rename from cpp/src/nn/specializations/detail/ball_cover_lowdim_pass_two_3d.cu rename to cpp/src/neighbors/specializations/detail/ball_cover_lowdim_pass_two_3d.cu index 0eeb448d1e..59132c1f99 100644 --- a/cpp/src/nn/specializations/detail/ball_cover_lowdim_pass_two_3d.cu +++ b/cpp/src/neighbors/specializations/detail/ball_cover_lowdim_pass_two_3d.cu @@ -15,11 +15,9 @@ */ #include +#include #include -// TODO: Change this to proper specializations after FAISS is removed -#include - namespace raft { namespace spatial { namespace knn { diff --git a/cpp/src/neighbors/specializations/detail/brute_force_knn_impl_long_float_int.cu b/cpp/src/neighbors/specializations/detail/brute_force_knn_impl_long_float_int.cu new file mode 100644 index 0000000000..07810aa576 --- /dev/null +++ b/cpp/src/neighbors/specializations/detail/brute_force_knn_impl_long_float_int.cu @@ -0,0 +1,38 @@ +/* + * Copyright (c) 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include + +namespace raft::neighbors::detail { +#define RAFT_INST(IdxT, T, IntT) \ + template void brute_force_knn_impl(raft::device_resources const& handle, \ + std::vector& input, \ + std::vector& sizes, \ + IntT D, \ + T* search_items, \ + IntT n, \ + IdxT* res_I, \ + T* res_D, \ + IntT k, \ + bool rowMajorIndex, \ + bool rowMajorQuery, \ + std::vector* translations, \ + raft::distance::DistanceType metric, \ + float metricArg); +RAFT_INST(long, float, int); +#undef RAFT_INST +} // namespace raft::neighbors::detail diff --git a/cpp/src/neighbors/specializations/detail/brute_force_knn_impl_long_float_uint.cu b/cpp/src/neighbors/specializations/detail/brute_force_knn_impl_long_float_uint.cu new file mode 100644 index 0000000000..0cb873b40a --- /dev/null +++ b/cpp/src/neighbors/specializations/detail/brute_force_knn_impl_long_float_uint.cu @@ -0,0 +1,38 @@ +/* + * Copyright (c) 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include + +namespace raft::neighbors::detail { +#define RAFT_INST(IdxT, T, IntT) \ + template void brute_force_knn_impl(raft::device_resources const& handle, \ + std::vector& input, \ + std::vector& sizes, \ + IntT D, \ + T* search_items, \ + IntT n, \ + IdxT* res_I, \ + T* res_D, \ + IntT k, \ + bool rowMajorIndex, \ + bool rowMajorQuery, \ + std::vector* translations, \ + raft::distance::DistanceType metric, \ + float metricArg); +RAFT_INST(long, float, unsigned int); +#undef RAFT_INST +} // namespace raft::neighbors::detail diff --git a/cpp/src/neighbors/specializations/detail/brute_force_knn_impl_uint_float_int.cu b/cpp/src/neighbors/specializations/detail/brute_force_knn_impl_uint_float_int.cu new file mode 100644 index 0000000000..f8a69b896f --- /dev/null +++ b/cpp/src/neighbors/specializations/detail/brute_force_knn_impl_uint_float_int.cu @@ -0,0 +1,38 @@ +/* + * Copyright (c) 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include + +namespace raft::neighbors::detail { +#define RAFT_INST(IdxT, T, IntT) \ + template void brute_force_knn_impl(raft::device_resources const& handle, \ + std::vector& input, \ + std::vector& sizes, \ + IntT D, \ + T* search_items, \ + IntT n, \ + IdxT* res_I, \ + T* res_D, \ + IntT k, \ + bool rowMajorIndex, \ + bool rowMajorQuery, \ + std::vector* translations, \ + raft::distance::DistanceType metric, \ + float metricArg); +RAFT_INST(uint32_t, float, int); +#undef RAFT_INST +} // namespace raft::neighbors::detail diff --git a/cpp/src/neighbors/specializations/detail/brute_force_knn_impl_uint_float_uint.cu b/cpp/src/neighbors/specializations/detail/brute_force_knn_impl_uint_float_uint.cu new file mode 100644 index 0000000000..3c23d1f3e0 --- /dev/null +++ b/cpp/src/neighbors/specializations/detail/brute_force_knn_impl_uint_float_uint.cu @@ -0,0 +1,38 @@ +/* + * Copyright (c) 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include + +namespace raft::neighbors::detail { +#define RAFT_INST(IdxT, T, IntT) \ + template void brute_force_knn_impl(raft::device_resources const& handle, \ + std::vector& input, \ + std::vector& sizes, \ + IntT D, \ + T* search_items, \ + IntT n, \ + IdxT* res_I, \ + T* res_D, \ + IntT k, \ + bool rowMajorIndex, \ + bool rowMajorQuery, \ + std::vector* translations, \ + raft::distance::DistanceType metric, \ + float metricArg); +RAFT_INST(uint32_t, float, unsigned int); +#undef RAFT_INST +} // namespace raft::neighbors::detail diff --git a/cpp/src/distance/neighbors/specializations/detail/compute_similarity_float_float_fast.cu b/cpp/src/neighbors/specializations/detail/compute_similarity_float_float_fast.cu similarity index 100% rename from cpp/src/distance/neighbors/specializations/detail/compute_similarity_float_float_fast.cu rename to cpp/src/neighbors/specializations/detail/compute_similarity_float_float_fast.cu diff --git a/cpp/src/distance/neighbors/specializations/detail/compute_similarity_float_float_no_basediff.cu b/cpp/src/neighbors/specializations/detail/compute_similarity_float_float_no_basediff.cu similarity index 100% rename from cpp/src/distance/neighbors/specializations/detail/compute_similarity_float_float_no_basediff.cu rename to cpp/src/neighbors/specializations/detail/compute_similarity_float_float_no_basediff.cu diff --git a/cpp/src/distance/neighbors/specializations/detail/compute_similarity_float_float_no_smem_lut.cu b/cpp/src/neighbors/specializations/detail/compute_similarity_float_float_no_smem_lut.cu similarity index 100% rename from cpp/src/distance/neighbors/specializations/detail/compute_similarity_float_float_no_smem_lut.cu rename to cpp/src/neighbors/specializations/detail/compute_similarity_float_float_no_smem_lut.cu diff --git a/cpp/src/distance/neighbors/specializations/detail/compute_similarity_float_fp8s_fast.cu b/cpp/src/neighbors/specializations/detail/compute_similarity_float_fp8s_fast.cu similarity index 100% rename from cpp/src/distance/neighbors/specializations/detail/compute_similarity_float_fp8s_fast.cu rename to cpp/src/neighbors/specializations/detail/compute_similarity_float_fp8s_fast.cu diff --git a/cpp/src/distance/neighbors/specializations/detail/compute_similarity_float_fp8s_no_basediff.cu b/cpp/src/neighbors/specializations/detail/compute_similarity_float_fp8s_no_basediff.cu similarity index 100% rename from cpp/src/distance/neighbors/specializations/detail/compute_similarity_float_fp8s_no_basediff.cu rename to cpp/src/neighbors/specializations/detail/compute_similarity_float_fp8s_no_basediff.cu diff --git a/cpp/src/distance/neighbors/specializations/detail/compute_similarity_float_fp8s_no_smem_lut.cu b/cpp/src/neighbors/specializations/detail/compute_similarity_float_fp8s_no_smem_lut.cu similarity index 100% rename from cpp/src/distance/neighbors/specializations/detail/compute_similarity_float_fp8s_no_smem_lut.cu rename to cpp/src/neighbors/specializations/detail/compute_similarity_float_fp8s_no_smem_lut.cu diff --git a/cpp/src/distance/neighbors/specializations/detail/compute_similarity_float_fp8u_fast.cu b/cpp/src/neighbors/specializations/detail/compute_similarity_float_fp8u_fast.cu similarity index 100% rename from cpp/src/distance/neighbors/specializations/detail/compute_similarity_float_fp8u_fast.cu rename to cpp/src/neighbors/specializations/detail/compute_similarity_float_fp8u_fast.cu diff --git a/cpp/src/distance/neighbors/specializations/detail/compute_similarity_float_fp8u_no_basediff.cu b/cpp/src/neighbors/specializations/detail/compute_similarity_float_fp8u_no_basediff.cu similarity index 100% rename from cpp/src/distance/neighbors/specializations/detail/compute_similarity_float_fp8u_no_basediff.cu rename to cpp/src/neighbors/specializations/detail/compute_similarity_float_fp8u_no_basediff.cu diff --git a/cpp/src/distance/neighbors/specializations/detail/compute_similarity_float_fp8u_no_smem_lut.cu b/cpp/src/neighbors/specializations/detail/compute_similarity_float_fp8u_no_smem_lut.cu similarity index 100% rename from cpp/src/distance/neighbors/specializations/detail/compute_similarity_float_fp8u_no_smem_lut.cu rename to cpp/src/neighbors/specializations/detail/compute_similarity_float_fp8u_no_smem_lut.cu diff --git a/cpp/src/distance/neighbors/specializations/detail/compute_similarity_float_half_fast.cu b/cpp/src/neighbors/specializations/detail/compute_similarity_float_half_fast.cu similarity index 100% rename from cpp/src/distance/neighbors/specializations/detail/compute_similarity_float_half_fast.cu rename to cpp/src/neighbors/specializations/detail/compute_similarity_float_half_fast.cu diff --git a/cpp/src/distance/neighbors/specializations/detail/compute_similarity_float_half_no_basediff.cu b/cpp/src/neighbors/specializations/detail/compute_similarity_float_half_no_basediff.cu similarity index 100% rename from cpp/src/distance/neighbors/specializations/detail/compute_similarity_float_half_no_basediff.cu rename to cpp/src/neighbors/specializations/detail/compute_similarity_float_half_no_basediff.cu diff --git a/cpp/src/distance/neighbors/specializations/detail/compute_similarity_float_half_no_smem_lut.cu b/cpp/src/neighbors/specializations/detail/compute_similarity_float_half_no_smem_lut.cu similarity index 100% rename from cpp/src/distance/neighbors/specializations/detail/compute_similarity_float_half_no_smem_lut.cu rename to cpp/src/neighbors/specializations/detail/compute_similarity_float_half_no_smem_lut.cu diff --git a/cpp/src/distance/neighbors/specializations/detail/compute_similarity_half_fp8s_fast.cu b/cpp/src/neighbors/specializations/detail/compute_similarity_half_fp8s_fast.cu similarity index 100% rename from cpp/src/distance/neighbors/specializations/detail/compute_similarity_half_fp8s_fast.cu rename to cpp/src/neighbors/specializations/detail/compute_similarity_half_fp8s_fast.cu diff --git a/cpp/src/distance/neighbors/specializations/detail/compute_similarity_half_fp8s_no_basediff.cu b/cpp/src/neighbors/specializations/detail/compute_similarity_half_fp8s_no_basediff.cu similarity index 100% rename from cpp/src/distance/neighbors/specializations/detail/compute_similarity_half_fp8s_no_basediff.cu rename to cpp/src/neighbors/specializations/detail/compute_similarity_half_fp8s_no_basediff.cu diff --git a/cpp/src/distance/neighbors/specializations/detail/compute_similarity_half_fp8s_no_smem_lut.cu b/cpp/src/neighbors/specializations/detail/compute_similarity_half_fp8s_no_smem_lut.cu similarity index 100% rename from cpp/src/distance/neighbors/specializations/detail/compute_similarity_half_fp8s_no_smem_lut.cu rename to cpp/src/neighbors/specializations/detail/compute_similarity_half_fp8s_no_smem_lut.cu diff --git a/cpp/src/distance/neighbors/specializations/detail/compute_similarity_half_fp8u_fast.cu b/cpp/src/neighbors/specializations/detail/compute_similarity_half_fp8u_fast.cu similarity index 100% rename from cpp/src/distance/neighbors/specializations/detail/compute_similarity_half_fp8u_fast.cu rename to cpp/src/neighbors/specializations/detail/compute_similarity_half_fp8u_fast.cu diff --git a/cpp/src/distance/neighbors/specializations/detail/compute_similarity_half_fp8u_no_basediff.cu b/cpp/src/neighbors/specializations/detail/compute_similarity_half_fp8u_no_basediff.cu similarity index 100% rename from cpp/src/distance/neighbors/specializations/detail/compute_similarity_half_fp8u_no_basediff.cu rename to cpp/src/neighbors/specializations/detail/compute_similarity_half_fp8u_no_basediff.cu diff --git a/cpp/src/distance/neighbors/specializations/detail/compute_similarity_half_fp8u_no_smem_lut.cu b/cpp/src/neighbors/specializations/detail/compute_similarity_half_fp8u_no_smem_lut.cu similarity index 100% rename from cpp/src/distance/neighbors/specializations/detail/compute_similarity_half_fp8u_no_smem_lut.cu rename to cpp/src/neighbors/specializations/detail/compute_similarity_half_fp8u_no_smem_lut.cu diff --git a/cpp/src/distance/neighbors/specializations/detail/compute_similarity_half_half_fast.cu b/cpp/src/neighbors/specializations/detail/compute_similarity_half_half_fast.cu similarity index 100% rename from cpp/src/distance/neighbors/specializations/detail/compute_similarity_half_half_fast.cu rename to cpp/src/neighbors/specializations/detail/compute_similarity_half_half_fast.cu diff --git a/cpp/src/distance/neighbors/specializations/detail/compute_similarity_half_half_no_basediff.cu b/cpp/src/neighbors/specializations/detail/compute_similarity_half_half_no_basediff.cu similarity index 100% rename from cpp/src/distance/neighbors/specializations/detail/compute_similarity_half_half_no_basediff.cu rename to cpp/src/neighbors/specializations/detail/compute_similarity_half_half_no_basediff.cu diff --git a/cpp/src/distance/neighbors/specializations/detail/compute_similarity_half_half_no_smem_lut.cu b/cpp/src/neighbors/specializations/detail/compute_similarity_half_half_no_smem_lut.cu similarity index 100% rename from cpp/src/distance/neighbors/specializations/detail/compute_similarity_half_half_no_smem_lut.cu rename to cpp/src/neighbors/specializations/detail/compute_similarity_half_half_no_smem_lut.cu diff --git a/cpp/src/distance/neighbors/specializations/detail/ivfpq_compute_similarity_float_half_no_smem_lut.cu b/cpp/src/neighbors/specializations/detail/ivfpq_compute_similarity_float_half_no_smem_lut.cu similarity index 100% rename from cpp/src/distance/neighbors/specializations/detail/ivfpq_compute_similarity_float_half_no_smem_lut.cu rename to cpp/src/neighbors/specializations/detail/ivfpq_compute_similarity_float_half_no_smem_lut.cu diff --git a/cpp/src/nn/specializations/fused_l2_knn_int_float_false.cu b/cpp/src/neighbors/specializations/fused_l2_knn_int_float_false.cu similarity index 93% rename from cpp/src/nn/specializations/fused_l2_knn_int_float_false.cu rename to cpp/src/neighbors/specializations/fused_l2_knn_int_float_false.cu index 41cf409416..72fdac9526 100644 --- a/cpp/src/nn/specializations/fused_l2_knn_int_float_false.cu +++ b/cpp/src/neighbors/specializations/fused_l2_knn_int_float_false.cu @@ -15,11 +15,9 @@ */ #include +#include #include -// TODO: Change this to proper specializations after FAISS is removed -#include - namespace raft { namespace spatial { namespace knn { diff --git a/cpp/src/nn/specializations/fused_l2_knn_int_float_true.cu b/cpp/src/neighbors/specializations/fused_l2_knn_int_float_true.cu similarity index 93% rename from cpp/src/nn/specializations/fused_l2_knn_int_float_true.cu rename to cpp/src/neighbors/specializations/fused_l2_knn_int_float_true.cu index 7d183d7220..c7616462fe 100644 --- a/cpp/src/nn/specializations/fused_l2_knn_int_float_true.cu +++ b/cpp/src/neighbors/specializations/fused_l2_knn_int_float_true.cu @@ -15,11 +15,9 @@ */ #include +#include #include -// TODO: Change this to proper specializations after FAISS is removed -#include - namespace raft { namespace spatial { namespace knn { diff --git a/cpp/src/nn/specializations/fused_l2_knn_long_float_false.cu b/cpp/src/neighbors/specializations/fused_l2_knn_long_float_false.cu similarity index 93% rename from cpp/src/nn/specializations/fused_l2_knn_long_float_false.cu rename to cpp/src/neighbors/specializations/fused_l2_knn_long_float_false.cu index fa273986dc..16bf058238 100644 --- a/cpp/src/nn/specializations/fused_l2_knn_long_float_false.cu +++ b/cpp/src/neighbors/specializations/fused_l2_knn_long_float_false.cu @@ -15,11 +15,9 @@ */ #include +#include #include -// TODO: Change this to proper specializations after FAISS is removed -#include - namespace raft { namespace spatial { namespace knn { diff --git a/cpp/src/nn/specializations/fused_l2_knn_long_float_true.cu b/cpp/src/neighbors/specializations/fused_l2_knn_long_float_true.cu similarity index 93% rename from cpp/src/nn/specializations/fused_l2_knn_long_float_true.cu rename to cpp/src/neighbors/specializations/fused_l2_knn_long_float_true.cu index 5313a87786..06cf55eae3 100644 --- a/cpp/src/nn/specializations/fused_l2_knn_long_float_true.cu +++ b/cpp/src/neighbors/specializations/fused_l2_knn_long_float_true.cu @@ -15,11 +15,9 @@ */ #include +#include #include -// TODO: Change this to proper specializations after FAISS is removed -#include - namespace raft { namespace spatial { namespace knn { diff --git a/cpp/src/distance/neighbors/specializations/ivfflat_build_float_int64_t.cu b/cpp/src/neighbors/specializations/ivfflat_build_float_int64_t.cu similarity index 100% rename from cpp/src/distance/neighbors/specializations/ivfflat_build_float_int64_t.cu rename to cpp/src/neighbors/specializations/ivfflat_build_float_int64_t.cu diff --git a/cpp/src/distance/neighbors/specializations/ivfflat_build_int8_t_int64_t.cu b/cpp/src/neighbors/specializations/ivfflat_build_int8_t_int64_t.cu similarity index 100% rename from cpp/src/distance/neighbors/specializations/ivfflat_build_int8_t_int64_t.cu rename to cpp/src/neighbors/specializations/ivfflat_build_int8_t_int64_t.cu diff --git a/cpp/src/distance/neighbors/specializations/ivfflat_build_uint8_t_int64_t.cu b/cpp/src/neighbors/specializations/ivfflat_build_uint8_t_int64_t.cu similarity index 100% rename from cpp/src/distance/neighbors/specializations/ivfflat_build_uint8_t_int64_t.cu rename to cpp/src/neighbors/specializations/ivfflat_build_uint8_t_int64_t.cu diff --git a/cpp/src/distance/neighbors/specializations/ivfflat_extend_float_int64_t.cu b/cpp/src/neighbors/specializations/ivfflat_extend_float_int64_t.cu similarity index 100% rename from cpp/src/distance/neighbors/specializations/ivfflat_extend_float_int64_t.cu rename to cpp/src/neighbors/specializations/ivfflat_extend_float_int64_t.cu diff --git a/cpp/src/distance/neighbors/specializations/ivfflat_extend_int8_t_int64_t.cu b/cpp/src/neighbors/specializations/ivfflat_extend_int8_t_int64_t.cu similarity index 100% rename from cpp/src/distance/neighbors/specializations/ivfflat_extend_int8_t_int64_t.cu rename to cpp/src/neighbors/specializations/ivfflat_extend_int8_t_int64_t.cu diff --git a/cpp/src/distance/neighbors/specializations/ivfflat_extend_uint8_t_int64_t.cu b/cpp/src/neighbors/specializations/ivfflat_extend_uint8_t_int64_t.cu similarity index 100% rename from cpp/src/distance/neighbors/specializations/ivfflat_extend_uint8_t_int64_t.cu rename to cpp/src/neighbors/specializations/ivfflat_extend_uint8_t_int64_t.cu diff --git a/cpp/src/distance/neighbors/specializations/ivfflat_search_float_int64_t.cu b/cpp/src/neighbors/specializations/ivfflat_search_float_int64_t.cu similarity index 100% rename from cpp/src/distance/neighbors/specializations/ivfflat_search_float_int64_t.cu rename to cpp/src/neighbors/specializations/ivfflat_search_float_int64_t.cu diff --git a/cpp/src/distance/neighbors/specializations/ivfflat_search_int8_t_int64_t.cu b/cpp/src/neighbors/specializations/ivfflat_search_int8_t_int64_t.cu similarity index 100% rename from cpp/src/distance/neighbors/specializations/ivfflat_search_int8_t_int64_t.cu rename to cpp/src/neighbors/specializations/ivfflat_search_int8_t_int64_t.cu diff --git a/cpp/src/distance/neighbors/specializations/ivfflat_search_uint8_t_int64_t.cu b/cpp/src/neighbors/specializations/ivfflat_search_uint8_t_int64_t.cu similarity index 100% rename from cpp/src/distance/neighbors/specializations/ivfflat_search_uint8_t_int64_t.cu rename to cpp/src/neighbors/specializations/ivfflat_search_uint8_t_int64_t.cu diff --git a/cpp/src/distance/neighbors/specializations/ivfpq_build_float_int64_t.cu b/cpp/src/neighbors/specializations/ivfpq_build_float_int64_t.cu similarity index 100% rename from cpp/src/distance/neighbors/specializations/ivfpq_build_float_int64_t.cu rename to cpp/src/neighbors/specializations/ivfpq_build_float_int64_t.cu diff --git a/cpp/src/distance/neighbors/specializations/ivfpq_build_int8_t_int64_t.cu b/cpp/src/neighbors/specializations/ivfpq_build_int8_t_int64_t.cu similarity index 100% rename from cpp/src/distance/neighbors/specializations/ivfpq_build_int8_t_int64_t.cu rename to cpp/src/neighbors/specializations/ivfpq_build_int8_t_int64_t.cu diff --git a/cpp/src/distance/neighbors/specializations/ivfpq_build_uint8_t_int64_t.cu b/cpp/src/neighbors/specializations/ivfpq_build_uint8_t_int64_t.cu similarity index 100% rename from cpp/src/distance/neighbors/specializations/ivfpq_build_uint8_t_int64_t.cu rename to cpp/src/neighbors/specializations/ivfpq_build_uint8_t_int64_t.cu diff --git a/cpp/src/distance/neighbors/specializations/ivfpq_extend_float_int64_t.cu b/cpp/src/neighbors/specializations/ivfpq_extend_float_int64_t.cu similarity index 100% rename from cpp/src/distance/neighbors/specializations/ivfpq_extend_float_int64_t.cu rename to cpp/src/neighbors/specializations/ivfpq_extend_float_int64_t.cu diff --git a/cpp/src/distance/neighbors/specializations/ivfpq_extend_int8_t_int64_t.cu b/cpp/src/neighbors/specializations/ivfpq_extend_int8_t_int64_t.cu similarity index 100% rename from cpp/src/distance/neighbors/specializations/ivfpq_extend_int8_t_int64_t.cu rename to cpp/src/neighbors/specializations/ivfpq_extend_int8_t_int64_t.cu diff --git a/cpp/src/distance/neighbors/specializations/ivfpq_extend_uint8_t_int64_t.cu b/cpp/src/neighbors/specializations/ivfpq_extend_uint8_t_int64_t.cu similarity index 100% rename from cpp/src/distance/neighbors/specializations/ivfpq_extend_uint8_t_int64_t.cu rename to cpp/src/neighbors/specializations/ivfpq_extend_uint8_t_int64_t.cu diff --git a/cpp/src/distance/neighbors/specializations/ivfpq_search_float_int64_t.cu b/cpp/src/neighbors/specializations/ivfpq_search_float_int64_t.cu similarity index 100% rename from cpp/src/distance/neighbors/specializations/ivfpq_search_float_int64_t.cu rename to cpp/src/neighbors/specializations/ivfpq_search_float_int64_t.cu diff --git a/cpp/src/distance/neighbors/specializations/ivfpq_search_int8_t_int64_t.cu b/cpp/src/neighbors/specializations/ivfpq_search_int8_t_int64_t.cu similarity index 100% rename from cpp/src/distance/neighbors/specializations/ivfpq_search_int8_t_int64_t.cu rename to cpp/src/neighbors/specializations/ivfpq_search_int8_t_int64_t.cu diff --git a/cpp/src/distance/neighbors/specializations/ivfpq_search_uint8_t_int64_t.cu b/cpp/src/neighbors/specializations/ivfpq_search_uint8_t_int64_t.cu similarity index 100% rename from cpp/src/distance/neighbors/specializations/ivfpq_search_uint8_t_int64_t.cu rename to cpp/src/neighbors/specializations/ivfpq_search_uint8_t_int64_t.cu diff --git a/cpp/src/distance/neighbors/specializations/refine_d_int64_t_float.cu b/cpp/src/neighbors/specializations/refine_d_int64_t_float.cu similarity index 100% rename from cpp/src/distance/neighbors/specializations/refine_d_int64_t_float.cu rename to cpp/src/neighbors/specializations/refine_d_int64_t_float.cu diff --git a/cpp/src/distance/neighbors/specializations/refine_d_int64_t_int8_t.cu b/cpp/src/neighbors/specializations/refine_d_int64_t_int8_t.cu similarity index 100% rename from cpp/src/distance/neighbors/specializations/refine_d_int64_t_int8_t.cu rename to cpp/src/neighbors/specializations/refine_d_int64_t_int8_t.cu diff --git a/cpp/src/distance/neighbors/specializations/refine_d_int64_t_uint8_t.cu b/cpp/src/neighbors/specializations/refine_d_int64_t_uint8_t.cu similarity index 100% rename from cpp/src/distance/neighbors/specializations/refine_d_int64_t_uint8_t.cu rename to cpp/src/neighbors/specializations/refine_d_int64_t_uint8_t.cu diff --git a/cpp/src/distance/neighbors/specializations/refine_h_int64_t_float.cu b/cpp/src/neighbors/specializations/refine_h_int64_t_float.cu similarity index 100% rename from cpp/src/distance/neighbors/specializations/refine_h_int64_t_float.cu rename to cpp/src/neighbors/specializations/refine_h_int64_t_float.cu diff --git a/cpp/src/distance/neighbors/specializations/refine_h_int64_t_int8_t.cu b/cpp/src/neighbors/specializations/refine_h_int64_t_int8_t.cu similarity index 100% rename from cpp/src/distance/neighbors/specializations/refine_h_int64_t_int8_t.cu rename to cpp/src/neighbors/specializations/refine_h_int64_t_int8_t.cu diff --git a/cpp/src/distance/neighbors/specializations/refine_h_int64_t_uint8_t.cu b/cpp/src/neighbors/specializations/refine_h_int64_t_uint8_t.cu similarity index 100% rename from cpp/src/distance/neighbors/specializations/refine_h_int64_t_uint8_t.cu rename to cpp/src/neighbors/specializations/refine_h_int64_t_uint8_t.cu diff --git a/cpp/src/distance/random/common.cuh b/cpp/src/random/common.cuh similarity index 100% rename from cpp/src/distance/random/common.cuh rename to cpp/src/random/common.cuh diff --git a/cpp/src/distance/random/rmat_rectangular_generator_int64_double.cu b/cpp/src/random/rmat_rectangular_generator_int64_double.cu similarity index 93% rename from cpp/src/distance/random/rmat_rectangular_generator_int64_double.cu rename to cpp/src/random/rmat_rectangular_generator_int64_double.cu index 1b8fb8bd6d..657aa0533c 100644 --- a/cpp/src/distance/random/rmat_rectangular_generator_int64_double.cu +++ b/cpp/src/random/rmat_rectangular_generator_int64_double.cu @@ -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. diff --git a/cpp/src/distance/random/rmat_rectangular_generator_int64_float.cu b/cpp/src/random/rmat_rectangular_generator_int64_float.cu similarity index 93% rename from cpp/src/distance/random/rmat_rectangular_generator_int64_float.cu rename to cpp/src/random/rmat_rectangular_generator_int64_float.cu index 249e8c2ffb..9cd748da89 100644 --- a/cpp/src/distance/random/rmat_rectangular_generator_int64_float.cu +++ b/cpp/src/random/rmat_rectangular_generator_int64_float.cu @@ -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. diff --git a/cpp/src/distance/random/rmat_rectangular_generator_int_double.cu b/cpp/src/random/rmat_rectangular_generator_int_double.cu similarity index 93% rename from cpp/src/distance/random/rmat_rectangular_generator_int_double.cu rename to cpp/src/random/rmat_rectangular_generator_int_double.cu index 3333b87983..1f10dbc03c 100644 --- a/cpp/src/distance/random/rmat_rectangular_generator_int_double.cu +++ b/cpp/src/random/rmat_rectangular_generator_int_double.cu @@ -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. diff --git a/cpp/src/distance/random/rmat_rectangular_generator_int_float.cu b/cpp/src/random/rmat_rectangular_generator_int_float.cu similarity index 93% rename from cpp/src/distance/random/rmat_rectangular_generator_int_float.cu rename to cpp/src/random/rmat_rectangular_generator_int_float.cu index db8d024c04..fecc134326 100644 --- a/cpp/src/distance/random/rmat_rectangular_generator_int_float.cu +++ b/cpp/src/random/rmat_rectangular_generator_int_float.cu @@ -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. diff --git a/cpp/test/CMakeLists.txt b/cpp/test/CMakeLists.txt index 696a271c65..a778b0d195 100644 --- a/cpp/test/CMakeLists.txt +++ b/cpp/test/CMakeLists.txt @@ -17,7 +17,7 @@ function(ConfigureTest) - set(options OPTIONAL DIST NN) + set(options OPTIONAL LIB) set(oneValueArgs NAME) set(multiValueArgs PATH TARGETS CONFIGURATIONS) @@ -33,8 +33,7 @@ function(ConfigureTest) ${TEST_NAME} PRIVATE raft::raft raft_internal - $<$:raft::distance> - $<$:raft::nn> + $<$:raft::compiled> GTest::gtest GTest::gtest_main Threads::Threads @@ -87,8 +86,7 @@ if(BUILD_TESTS) test/cluster/linkage.cu test/cluster/kmeans_find_k.cu OPTIONAL - DIST - NN + LIB ) ConfigureTest( @@ -140,7 +138,7 @@ if(BUILD_TESTS) test/distance/fused_l2_nn.cu test/distance/gram.cu OPTIONAL - DIST + LIB ) ConfigureTest(NAME LABEL_TEST PATH test/label/label.cu test/label/merge_labels.cu) @@ -201,7 +199,7 @@ if(BUILD_TESTS) test/matrix/triangular.cu test/sparse/spectral_matrix.cu OPTIONAL - DIST + LIB ) ConfigureTest( @@ -221,7 +219,7 @@ if(BUILD_TESTS) ConfigureTest( NAME SOLVERS_TEST PATH test/cluster/cluster_solvers_deprecated.cu test/linalg/eigen_solvers.cu - test/lap/lap.cu test/sparse/mst.cu OPTIONAL DIST + test/lap/lap.cu test/sparse/mst.cu OPTIONAL LIB ) ConfigureTest( @@ -245,13 +243,12 @@ if(BUILD_TESTS) ) ConfigureTest( - NAME SPARSE_DIST_TEST PATH test/sparse/dist_coo_spmv.cu test/sparse/distance.cu OPTIONAL DIST - NN + NAME SPARSE_DIST_TEST PATH test/sparse/dist_coo_spmv.cu test/sparse/distance.cu OPTIONAL LIB ) ConfigureTest( NAME SPARSE_NEIGHBORS_TEST PATH test/sparse/neighbors/connect_components.cu - test/sparse/neighbors/brute_force.cu test/sparse/neighbors/knn_graph.cu OPTIONAL DIST NN + test/sparse/neighbors/brute_force.cu test/sparse/neighbors/knn_graph.cu OPTIONAL LIB ) ConfigureTest( @@ -275,8 +272,7 @@ if(BUILD_TESTS) test/neighbors/refine.cu test/neighbors/selection.cu OPTIONAL - DIST - NN + LIB ) ConfigureTest( @@ -309,8 +305,7 @@ if(BUILD_TESTS) test/stats/weighted_mean.cu test/stats/v_measure.cu OPTIONAL - DIST - NN + LIB ) ConfigureTest( diff --git a/cpp/test/cluster/cluster_solvers.cu b/cpp/test/cluster/cluster_solvers.cu index 5121cdf139..f26c598a2b 100644 --- a/cpp/test/cluster/cluster_solvers.cu +++ b/cpp/test/cluster/cluster_solvers.cu @@ -19,7 +19,7 @@ #include #include -#if defined RAFT_DISTANCE_COMPILED && defined RAFT_NN_COMPILED +#if defined RAFT_COMPILED #include #endif diff --git a/cpp/test/cluster/kmeans.cu b/cpp/test/cluster/kmeans.cu index 3e2153dcde..cfec84256b 100644 --- a/cpp/test/cluster/kmeans.cu +++ b/cpp/test/cluster/kmeans.cu @@ -29,7 +29,7 @@ #include #include -#if defined RAFT_DISTANCE_COMPILED +#if defined RAFT_COMPILED #include #endif diff --git a/cpp/test/cluster/kmeans_balanced.cu b/cpp/test/cluster/kmeans_balanced.cu index ae06572061..220eba4186 100644 --- a/cpp/test/cluster/kmeans_balanced.cu +++ b/cpp/test/cluster/kmeans_balanced.cu @@ -30,7 +30,7 @@ #include #include -#if defined RAFT_DISTANCE_COMPILED +#if defined RAFT_COMPILED #include #endif diff --git a/cpp/test/cluster/kmeans_find_k.cu b/cpp/test/cluster/kmeans_find_k.cu index e80cbaa93b..a865651f56 100644 --- a/cpp/test/cluster/kmeans_find_k.cu +++ b/cpp/test/cluster/kmeans_find_k.cu @@ -25,7 +25,7 @@ #include #include -#if defined RAFT_DISTANCE_COMPILED +#if defined RAFT_COMPILED #include #endif diff --git a/cpp/test/cluster/linkage.cu b/cpp/test/cluster/linkage.cu index 20f2952e7d..4946d52f26 100644 --- a/cpp/test/cluster/linkage.cu +++ b/cpp/test/cluster/linkage.cu @@ -20,8 +20,8 @@ #include #include -#if defined RAFT_NN_COMPILED -#include +#if defined RAFT_COMPILED +#include #endif #include diff --git a/cpp/test/distance/distance_base.cuh b/cpp/test/distance/distance_base.cuh index 5fcaf07539..0e084f2ad8 100644 --- a/cpp/test/distance/distance_base.cuh +++ b/cpp/test/distance/distance_base.cuh @@ -22,7 +22,7 @@ #include #include #include -#if defined RAFT_DISTANCE_COMPILED +#if defined RAFT_COMPILED #include #endif #include diff --git a/cpp/test/distance/fused_l2_nn.cu b/cpp/test/distance/fused_l2_nn.cu index af67214193..4a74d7f16a 100644 --- a/cpp/test/distance/fused_l2_nn.cu +++ b/cpp/test/distance/fused_l2_nn.cu @@ -24,7 +24,7 @@ #include #include -#if defined RAFT_DISTANCE_COMPILED +#if defined RAFT_COMPILED #include #endif diff --git a/cpp/test/distance/gram.cu b/cpp/test/distance/gram.cu index a2f0e2385c..f99d02dc7f 100644 --- a/cpp/test/distance/gram.cu +++ b/cpp/test/distance/gram.cu @@ -14,7 +14,7 @@ * limitations under the License. */ -#if defined RAFT_DISTANCE_COMPILED +#if defined RAFT_COMPILED #include #endif diff --git a/cpp/test/distance/masked_nn.cu b/cpp/test/distance/masked_nn.cu index 6f7d8bf44a..d01911206b 100644 --- a/cpp/test/distance/masked_nn.cu +++ b/cpp/test/distance/masked_nn.cu @@ -28,7 +28,7 @@ #include #include -#ifdef RAFT_DISTANCE_COMPILED +#ifdef RAFT_COMPILED #include #endif diff --git a/cpp/test/matrix/select_k.cu b/cpp/test/matrix/select_k.cu index a9fc4c8f40..392464eb27 100644 --- a/cpp/test/matrix/select_k.cu +++ b/cpp/test/matrix/select_k.cu @@ -18,7 +18,7 @@ #include -#ifdef RAFT_DISTANCE_COMPILED +#ifdef RAFT_COMPILED #include #endif diff --git a/cpp/test/neighbors/ann_ivf_flat.cuh b/cpp/test/neighbors/ann_ivf_flat.cuh index 486ff61724..fe6f9163a0 100644 --- a/cpp/test/neighbors/ann_ivf_flat.cuh +++ b/cpp/test/neighbors/ann_ivf_flat.cuh @@ -36,7 +36,7 @@ #include -#if defined RAFT_DISTANCE_COMPILED +#if defined RAFT_COMPILED #include #endif diff --git a/cpp/test/neighbors/ann_ivf_flat/test_float_int64_t.cu b/cpp/test/neighbors/ann_ivf_flat/test_float_int64_t.cu index cee0d03c99..e430af89df 100644 --- a/cpp/test/neighbors/ann_ivf_flat/test_float_int64_t.cu +++ b/cpp/test/neighbors/ann_ivf_flat/test_float_int64_t.cu @@ -18,7 +18,7 @@ #include "../ann_ivf_flat.cuh" -#if defined RAFT_DISTANCE_COMPILED +#if defined RAFT_COMPILED #include #endif diff --git a/cpp/test/neighbors/ann_ivf_flat/test_int8_t_int64_t.cu b/cpp/test/neighbors/ann_ivf_flat/test_int8_t_int64_t.cu index 95876f9165..e4e7a207fb 100644 --- a/cpp/test/neighbors/ann_ivf_flat/test_int8_t_int64_t.cu +++ b/cpp/test/neighbors/ann_ivf_flat/test_int8_t_int64_t.cu @@ -18,7 +18,7 @@ #include "../ann_ivf_flat.cuh" -#if defined RAFT_DISTANCE_COMPILED +#if defined RAFT_COMPILED #include #endif diff --git a/cpp/test/neighbors/ann_ivf_flat/test_uint8_t_int64_t.cu b/cpp/test/neighbors/ann_ivf_flat/test_uint8_t_int64_t.cu index ebee20c2b6..ef7980401a 100644 --- a/cpp/test/neighbors/ann_ivf_flat/test_uint8_t_int64_t.cu +++ b/cpp/test/neighbors/ann_ivf_flat/test_uint8_t_int64_t.cu @@ -18,7 +18,7 @@ #include "../ann_ivf_flat.cuh" -#if defined RAFT_DISTANCE_COMPILED +#if defined RAFT_COMPILED #include #endif diff --git a/cpp/test/neighbors/ann_ivf_pq.cuh b/cpp/test/neighbors/ann_ivf_pq.cuh index c368192b03..c331081314 100644 --- a/cpp/test/neighbors/ann_ivf_pq.cuh +++ b/cpp/test/neighbors/ann_ivf_pq.cuh @@ -24,7 +24,7 @@ #include #include #include -#ifdef RAFT_DISTANCE_COMPILED +#ifdef RAFT_COMPILED #include #else #pragma message("NN specializations are not enabled; expect very long building times.") diff --git a/cpp/test/neighbors/ball_cover.cu b/cpp/test/neighbors/ball_cover.cu index 6dcae8e34d..9b51d585de 100644 --- a/cpp/test/neighbors/ball_cover.cu +++ b/cpp/test/neighbors/ball_cover.cu @@ -22,8 +22,9 @@ #include #include #include -#if defined RAFT_NN_COMPILED -#include + +#ifdef RAFT_COMPILED +#include #endif #include diff --git a/cpp/test/neighbors/epsilon_neighborhood.cu b/cpp/test/neighbors/epsilon_neighborhood.cu index 977e8f3ce8..769cb7ec2d 100644 --- a/cpp/test/neighbors/epsilon_neighborhood.cu +++ b/cpp/test/neighbors/epsilon_neighborhood.cu @@ -23,7 +23,7 @@ #include #include -#ifdef RAFT_DISTANCE_COMPILED +#ifdef RAFT_COMPILED #include #endif diff --git a/cpp/test/neighbors/fused_l2_knn.cu b/cpp/test/neighbors/fused_l2_knn.cu index a5fead8093..ab05b41cc9 100644 --- a/cpp/test/neighbors/fused_l2_knn.cu +++ b/cpp/test/neighbors/fused_l2_knn.cu @@ -23,12 +23,8 @@ #include #include -#if defined RAFT_NN_COMPILED -#include -#endif - -#ifdef RAFT_DISTANCE_COMPILED -#include +#ifdef RAFT_COMPILED +#include #endif #include diff --git a/cpp/test/neighbors/knn.cu b/cpp/test/neighbors/knn.cu index 7976725c65..4bb977432c 100644 --- a/cpp/test/neighbors/knn.cu +++ b/cpp/test/neighbors/knn.cu @@ -21,14 +21,10 @@ #include #include -#if defined RAFT_DISTANCE_COMPILED +#ifdef RAFT_COMPILED #include #endif -#if defined RAFT_NN_COMPILED -#include -#endif - #include #include diff --git a/cpp/test/neighbors/refine.cu b/cpp/test/neighbors/refine.cu index 8866c404a9..dd3491673e 100644 --- a/cpp/test/neighbors/refine.cu +++ b/cpp/test/neighbors/refine.cu @@ -31,7 +31,7 @@ #include -#if defined RAFT_DISTANCE_COMPILED +#if defined RAFT_COMPILED #include #endif diff --git a/cpp/test/neighbors/selection.cu b/cpp/test/neighbors/selection.cu index 25939f65c3..9f13de357c 100644 --- a/cpp/test/neighbors/selection.cu +++ b/cpp/test/neighbors/selection.cu @@ -24,7 +24,7 @@ #include #include -#if defined RAFT_DISTANCE_COMPILED +#if defined RAFT_COMPILED #include #endif diff --git a/cpp/test/neighbors/tiled_knn.cu b/cpp/test/neighbors/tiled_knn.cu index 4784f915f3..ccc3a64edd 100644 --- a/cpp/test/neighbors/tiled_knn.cu +++ b/cpp/test/neighbors/tiled_knn.cu @@ -25,8 +25,7 @@ #include #include -#if defined RAFT_NN_COMPILED -#include +#if defined RAFT_COMPILED #include #endif diff --git a/cpp/test/sparse/neighbors/knn_graph.cu b/cpp/test/sparse/neighbors/knn_graph.cu index 3b025fc082..8873445c37 100644 --- a/cpp/test/sparse/neighbors/knn_graph.cu +++ b/cpp/test/sparse/neighbors/knn_graph.cu @@ -22,8 +22,8 @@ #include #include -#if defined RAFT_NN_COMPILED -#include +#if defined RAFT_COMPILED +#include #endif #include diff --git a/cpp/test/stats/silhouette_score.cu b/cpp/test/stats/silhouette_score.cu index 80e60a4884..40b7e59d81 100644 --- a/cpp/test/stats/silhouette_score.cu +++ b/cpp/test/stats/silhouette_score.cu @@ -20,7 +20,7 @@ #include #include -#if defined RAFT_DISTANCE_COMPILED && defined RAFT_NN_COMPILED +#if defined RAFT_COMPILED #include #endif diff --git a/cpp/test/stats/trustworthiness.cu b/cpp/test/stats/trustworthiness.cu index a2f72516eb..2fde6b29c1 100644 --- a/cpp/test/stats/trustworthiness.cu +++ b/cpp/test/stats/trustworthiness.cu @@ -20,7 +20,7 @@ #include #include -#if defined RAFT_DISTANCE_COMPILED && defined RAFT_NN_COMPILED +#if defined RAFT_COMPILED #include #endif diff --git a/docs/source/build.md b/docs/source/build.md index 5ba1e75fad..bbb454736a 100644 --- a/docs/source/build.md +++ b/docs/source/build.md @@ -4,8 +4,7 @@ The easiest way to install RAFT is through conda and several packages are provided. - `libraft-headers` RAFT headers -- `libraft-nn` (optional) contains shared libraries for the nearest neighbors primitives. -- `libraft-distance` (optional) contains shared libraries for distance primitives. +- `libraft` (optional) shared library containing pre-compiled template specializations and runtime API. - `pylibraft` (optional) Python wrappers around RAFT algorithms and primitives. - `raft-dask` (optional) enables deployment of multi-node multi-GPU algorithms that use RAFT `raft::comms` in Dask clusters. @@ -14,7 +13,7 @@ Use the following command to install all of the RAFT packages with conda (replac mamba install -c rapidsai -c conda-forge -c nvidia raft-dask pylibraft ``` -You can also install the `libraft-*` conda packages individually using the `mamba` command above. +You can also install the conda packages individually using the `mamba` command above. After installing RAFT, `find_package(raft COMPONENTS nn distance)` can be used in your CUDA/C++ cmake build to compile and/or link against needed dependencies in your raft target. `COMPONENTS` are optional and will depend on the packages installed. @@ -42,11 +41,10 @@ In addition to the libraries included with cudatoolkit 11.0+, there are some oth #### Required - [RMM](https://github.com/rapidsai/rmm) corresponding to RAFT version. - [Thrust](https://github.com/NVIDIA/thrust) v1.17 / [CUB](https://github.com/NVIDIA/cub) - -#### Optional - [cuCollections](https://github.com/NVIDIA/cuCollections) - Used in `raft::sparse::distance` API. -- [Libcu++](https://github.com/NVIDIA/libcudacxx) v1.7.0 - Used by cuCollections - [CUTLASS](https://github.com/NVIDIA/cutlass) v2.9.1 - Used in `raft::distance` API. + +#### Optional - [NCCL](https://github.com/NVIDIA/nccl) - Used in `raft::comms` API and needed to build `raft-dask`. - [UCX](https://github.com/openucx/ucx) - Used in `raft::comms` API and needed to build `raft-dask`. - [Googletest](https://github.com/google/googletest) - Needed to build tests @@ -79,19 +77,14 @@ Once installed, `libraft` headers (and dependencies which were downloaded and in ### C++ Shared Libraries (optional) -For larger projects which make heavy use of the pairwise distances or nearest neighbors APIs, shared libraries can be built to speed up compile times. These shared libraries can also significantly improve re-compile times both while developing RAFT and developing against the APIs. Build all of the available shared libraries by passing `--compile-libs` flag to `build.sh`: +A shared library can be built for speeding up compile times. The shared library also contains a runtime API that allows you to invoke RAFT APIs directly from C++ source files (without `nvcc`). The shared library can also significantly improve re-compile times both while developing RAFT and using its APIs to develop applications. Pass the `--compile-lib` flag to `build.sh` to build the library: ```bash -./build.sh libraft --compile-libs +./build.sh libraft --compile-lib ``` -Individual shared libraries have their own flags and multiple can be used (though currently only the `nn` and `distance` packages contain shared libraries): -```bash -./build.sh libraft --compile-nn --compile-dist -``` +In above example the shared library is installed by default into `$INSTALL_PREFIX/lib`. To disable this, pass `-n` flag. -In above example the shared libraries are installed by default into `$INSTALL_PREFIX/lib`. To disable this, pass `-n` flag. - -Once installed, the shared libraries, headers (and any dependencies downloaded and installed via `rapids-cmake`) can be uninstalled using `build.sh`: +Once installed, the shared library, headers (and any dependencies downloaded and installed via `rapids-cmake`) can be uninstalled using `build.sh`: ```bash ./build.sh libraft --uninstall ``` @@ -152,7 +145,7 @@ Use `CMAKE_INSTALL_PREFIX` to install RAFT into a specific location. The snippet cd cpp mkdir build cd build -cmake -D BUILD_TESTS=ON -DRAFT_COMPILE_LIBRARIES=ON -DRAFT_ENABLE_NN_DEPENDENCIES=ON -DCMAKE_INSTALL_PREFIX=$CONDA_PREFIX ../ +cmake -D BUILD_TESTS=ON -DRAFT_COMPILE_LIBRARY=ON -DCMAKE_INSTALL_PREFIX=$CONDA_PREFIX ../ make -j install ``` @@ -187,9 +180,9 @@ The Python APIs can be built and installed using the `build.sh` script: ```bash # to build pylibraft -./build.sh libraft pylibraft --compile-libs +./build.sh libraft pylibraft --compile-lib # to build raft-dask -./build.sh libraft raft-dask --compile-libs +./build.sh libraft pylibraft raft-dask --compile-lib ``` `setup.py` can also be used to build the Python APIs manually: @@ -225,7 +218,7 @@ The documentation requires that the C++ headers and python packages have been bu The following will build the docs along with the C++ and Python packages: ``` -./build.sh libraft pylibraft raft-dask docs --compile-libs +./build.sh libraft pylibraft raft-dask docs --compile-lib ``` @@ -274,11 +267,11 @@ If RAFT has already been installed, such as by using the `build.sh` script, use ### Using C++ pre-compiled shared libraries -Use `find_package(raft COMPONENTS nn distance)` to enable the shared libraries and transitively pass dependencies through separate targets for each component. In this example, the `raft::distance` and `raft::nn` targets will be available for configuring linking paths in addition to `raft::raft`. These targets will also pass through any transitive dependencies (such as CUTLASS for the `distance` package). +Use `find_package(raft COMPONENTS compiled distributed)` to enable the shared library and transitively pass dependencies through separate targets for each component. In this example, the `raft::compiled` and `raft::distributed` targets will be available for configuring linking paths in addition to `raft::raft`. These targets will also pass through any transitive dependencies (such as NCCL for the `distributed` component). The pre-compiled libraries contain template specializations for commonly used types, such as single- and double-precision floating-point. In order to use the symbols in the pre-compiled libraries, the compiler needs to be told not to instantiate templates that are already contained in the shared libraries. By convention, these header files are named `specializations.cuh` and located in the base directory for the packages that contain specializations. -The following example tells the compiler to ignore the pre-compiled templates for the `libraft-distance` API so any symbols already compiled into pre-compiled shared library will be used instead: +The following example tells the compiler to ignore the pre-compiled templates for the `raft::distance` API so any symbols already compiled into the `libraft` shared library will be used instead: ```c++ #include #include @@ -299,10 +292,7 @@ set(RAFT_FORK "rapidsai") set(RAFT_PINNED_TAG "branch-${RAFT_VERSION}") function(find_and_configure_raft) - set(oneValueArgs VERSION FORK PINNED_TAG - COMPILE_LIBRARIES CLONE_ON_PIN - USE_NN_LIBRARY USE_DISTANCE_LIBRARY - ENABLE_thrust_DEPENDENCY) + set(oneValueArgs VERSION FORK PINNED_TAG COMPILE_LIBRARY CLONE_ON_PIN) cmake_parse_arguments(PKG "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN} ) @@ -315,18 +305,6 @@ function(find_and_configure_raft) set(CMAKE_IGNORE_PATH "${CMAKE_INSTALL_PREFIX}/include/raft;${CMAKE_IGNORE_PATH}) endif() - #----------------------------------------------------- - # Add components - #----------------------------------------------------- - - if(PKG_USE_NN_LIBRARY) - string(APPEND RAFT_COMPONENTS " nn") - endif() - - if(PKG_USE_DISTANCE_LIBRARY) - string(APPEND RAFT_COMPONENTS " distance") - endif() - #----------------------------------------------------- # Invoke CPM find_package() #----------------------------------------------------- @@ -339,12 +317,11 @@ function(find_and_configure_raft) GIT_REPOSITORY https://github.com/${PKG_FORK}/raft.git GIT_TAG ${PKG_PINNED_TAG} SOURCE_SUBDIR cpp - FIND_PACKAGE_ARGUMENTS "COMPONENTS ${RAFT_COMPONENTS}" + FIND_PACKAGE_ARGUMENTS "COMPONENTS compiled distributed" OPTIONS "BUILD_TESTS OFF" "BUILD_BENCH OFF" - "RAFT_COMPILE_LIBRARIES ${PKG_COMPILE_LIBRARIES}" - "RAFT_ENABLE_thrust_DEPENDENCY ${PKG_ENABLE_thrust_DEPENDENCY}" + "RAFT_COMPILE_LIBRARY ${PKG_COMPILE_LIBRARY}" ) endfunction() @@ -360,16 +337,10 @@ find_and_configure_raft(VERSION ${RAFT_VERSION}.00 # force local raft clone in build directory # even if it's already installed. CLONE_ON_PIN ON - - COMPILE_LIBRARIES NO - USE_NN_LIBRARY NO - USE_DISTANCE_LIBRARY NO - ENABLE_thrust_DEPENDENCY YES + COMPILE_LIBRARY NO ) ``` -If using the nearest neighbors APIs without the shared libraries, set `ENABLE_NN_DEPENDENCIES=ON` and keep `USE_NN_LIBRARY=OFF` - ## Uninstall Once built and installed, RAFT can be safely uninstalled using `build.sh` by specifying any or all of the installed components. Please note that since `pylibraft` depends on `libraft`, uninstalling `pylibraft` will also uninstall `libraft`: diff --git a/python/pylibraft/CMakeLists.txt b/python/pylibraft/CMakeLists.txt index b12d0a63ea..a87b798eae 100644 --- a/python/pylibraft/CMakeLists.txt +++ b/python/pylibraft/CMakeLists.txt @@ -36,11 +36,11 @@ option(RAFT_BUILD_WHEELS "Whether this build is generating a Python wheel." OFF) # If the user requested it we attempt to find RAFT. if(FIND_RAFT_CPP) - find_package(raft ${pylibraft_version} REQUIRED COMPONENTS distance) - if(NOT TARGET raft::raft_distance_lib) + find_package(raft ${pylibraft_version} REQUIRED COMPONENTS compiled) + if(NOT TARGET raft::raft_lib) message( FATAL_ERROR - "Building against a preexisting libraft library requires the distance components of that library to have been built!" + "Building against a preexisting libraft library requires the compiled libraft to have been built!" ) endif() @@ -62,8 +62,7 @@ if(NOT raft_FOUND) set(BUILD_TESTS OFF) set(BUILD_BENCH OFF) - set(RAFT_COMPILE_LIBRARIES OFF) - set(RAFT_COMPILE_DIST_LIBRARY ON) + set(RAFT_COMPILE_LIBRARY ON) set(_exclude_from_all "") if(RAFT_BUILD_WHEELS) @@ -75,11 +74,11 @@ if(NOT raft_FOUND) add_subdirectory(../../cpp raft-cpp ${_exclude_from_all}) - # When building the C++ libraries from source we must copy libraft_distance.so alongside the + # When building the C++ libraries from source we must copy libraft.so alongside the # pairwise_distance and random Cython libraries TODO: when we have a single 'compiled' raft # library, we shouldn't need this set(cython_lib_dir pylibraft) - install(TARGETS raft_distance_lib DESTINATION ${cython_lib_dir}) + install(TARGETS raft_lib DESTINATION ${cython_lib_dir}) endif() rapids_cython_init() diff --git a/python/pylibraft/pylibraft/cluster/CMakeLists.txt b/python/pylibraft/pylibraft/cluster/CMakeLists.txt index ba77403a5d..7d6e05d918 100644 --- a/python/pylibraft/pylibraft/cluster/CMakeLists.txt +++ b/python/pylibraft/pylibraft/cluster/CMakeLists.txt @@ -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. You may obtain a copy of the License at @@ -14,7 +14,7 @@ # Set the list of Cython files to build set(cython_sources kmeans.pyx) -set(linked_libraries raft::distance) +set(linked_libraries raft::compiled) # Build all of the Cython targets rapids_cython_create_modules( diff --git a/python/pylibraft/pylibraft/distance/CMakeLists.txt b/python/pylibraft/pylibraft/distance/CMakeLists.txt index cae00007d6..14f0cc441a 100644 --- a/python/pylibraft/pylibraft/distance/CMakeLists.txt +++ b/python/pylibraft/pylibraft/distance/CMakeLists.txt @@ -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. You may obtain a copy of the License at @@ -14,7 +14,7 @@ # Set the list of Cython files to build set(cython_sources pairwise_distance.pyx fused_l2_nn.pyx) -set(linked_libraries raft::raft raft::distance) +set(linked_libraries raft::raft raft::compiled) # Build all of the Cython targets rapids_cython_create_modules( diff --git a/python/pylibraft/pylibraft/neighbors/CMakeLists.txt b/python/pylibraft/pylibraft/neighbors/CMakeLists.txt index 572ea47f4e..98f0d7f67a 100644 --- a/python/pylibraft/pylibraft/neighbors/CMakeLists.txt +++ b/python/pylibraft/pylibraft/neighbors/CMakeLists.txt @@ -14,7 +14,7 @@ # Set the list of Cython files to build set(cython_sources common.pyx refine.pyx) -set(linked_libraries raft::raft raft::distance) +set(linked_libraries raft::raft raft::compiled) # Build all of the Cython targets rapids_cython_create_modules( diff --git a/python/pylibraft/pylibraft/neighbors/ivf_flat/CMakeLists.txt b/python/pylibraft/pylibraft/neighbors/ivf_flat/CMakeLists.txt index f183e17157..8f395faec9 100644 --- a/python/pylibraft/pylibraft/neighbors/ivf_flat/CMakeLists.txt +++ b/python/pylibraft/pylibraft/neighbors/ivf_flat/CMakeLists.txt @@ -14,7 +14,7 @@ # Set the list of Cython files to build set(cython_sources ivf_flat.pyx) -set(linked_libraries raft::raft raft::distance) +set(linked_libraries raft::raft raft::compiled) # Build all of the Cython targets rapids_cython_create_modules( diff --git a/python/pylibraft/pylibraft/neighbors/ivf_pq/CMakeLists.txt b/python/pylibraft/pylibraft/neighbors/ivf_pq/CMakeLists.txt index cfce37b560..e3d721a6ea 100644 --- a/python/pylibraft/pylibraft/neighbors/ivf_pq/CMakeLists.txt +++ b/python/pylibraft/pylibraft/neighbors/ivf_pq/CMakeLists.txt @@ -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. You may obtain a copy of the License at @@ -14,7 +14,7 @@ # Set the list of Cython files to build set(cython_sources ivf_pq.pyx) -set(linked_libraries raft::raft raft::distance) +set(linked_libraries raft::raft raft::compiled) # Build all of the Cython targets rapids_cython_create_modules( diff --git a/python/pylibraft/pylibraft/random/CMakeLists.txt b/python/pylibraft/pylibraft/random/CMakeLists.txt index 49ca8627cc..fcc5ee6311 100644 --- a/python/pylibraft/pylibraft/random/CMakeLists.txt +++ b/python/pylibraft/pylibraft/random/CMakeLists.txt @@ -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. You may obtain a copy of the License at @@ -17,7 +17,7 @@ set(cython_sources rmat_rectangular_generator.pyx) # TODO: should finally be replaced with 'compiled' library to be more generic, when that is # available -set(linked_libraries raft::raft raft::distance) +set(linked_libraries raft::raft raft::compiled) # Build all of the Cython targets rapids_cython_create_modules(