Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding distance specializations #376

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
06cb94d
Adding specializations
cjnolet Nov 15, 2021
bdf43f9
Merge branch 'branch-22.02' into fea-2202-distance_knn_specializations
cjnolet Nov 15, 2021
96677a3
Merge branch 'branch-21.12' into fea-2202-distance_knn_specializations
cjnolet Nov 16, 2021
efe8a7c
Merge branch 'branch-21.12' into fea-2202-distance_knn_specializations
cjnolet Nov 17, 2021
6afc3f5
Merge branch 'branch-22.02' into fea-2202-distance_knn_specializations
cjnolet Nov 17, 2021
9b2002a
Merge branch 'branch-22.02' into fea-2202-distance_knn_specializations
cjnolet Dec 6, 2021
e5568d6
Fixes after clang-format changes
cjnolet Dec 6, 2021
0880cf7
Style on cpp/src
cjnolet Dec 6, 2021
e27306b
Merge branch 'branch-22.02' into fea-2202-distance_knn_specializations
cjnolet Dec 6, 2021
644cfd5
Merge branch 'branch-22.02' into fea-2202-distance_knn_specializations
cjnolet Dec 7, 2021
28b9b42
Review corrections
cjnolet Dec 7, 2021
42a76c8
Fixing style
cjnolet Dec 7, 2021
abee64e
Adding rbc properly
cjnolet Dec 8, 2021
908daa1
Fixing tests
cjnolet Dec 8, 2021
f17b200
Using proper distance specializations
cjnolet Dec 8, 2021
67e7f40
Missed a few files
cjnolet Dec 8, 2021
5173407
Fixing style
cjnolet Dec 8, 2021
627e35c
Fix test file
cjnolet Dec 8, 2021
3298f64
Merge branch 'branch-22.02' into fea-2202-distance_knn_specializations
cjnolet Dec 10, 2021
4186667
Removing distfunc
cjnolet Dec 10, 2021
d36c880
Ignoring low dim ball cover functions in ball_cover.cu instantiations
cjnolet Dec 10, 2021
a5adf36
Merge branch 'branch-22.02' into fea-2202-distance_knn_specializations
cjnolet Dec 10, 2021
a0b30f9
Merge branch 'branch-22.02' into fea-2202-distance_knn_specializations
cjnolet Dec 13, 2021
925678c
Merge branch 'branch-22.02' into fea-2202-distance_knn_specializations
cjnolet Dec 14, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 57 additions & 20 deletions cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -119,28 +119,66 @@ rapids_cmake_install_lib_dir( lib_dir )

include(CPack)

file(GLOB_RECURSE RAFT_DISTANCE_SOURCES "src/distance/specializations/*.cu")
file(GLOB_RECURSE RAFT_NN_SOURCES "src/nn/specializations/*.cu" )

add_library(raft_distance SHARED ${RAFT_DISTANCE_SOURCES})
add_library(raft::raft_distance ALIAS raft_distance)

add_library(raft_nn SHARED ${RAFT_NN_SOURCES})
add_library(raft::raft_nn ALIAS raft_nn)

add_library(raft INTERFACE)
add_library(raft::raft ALIAS raft)
target_include_directories(raft INTERFACE "$<BUILD_INTERFACE:${RAFT_SOURCE_DIR}/include>"
"$<INSTALL_INTERFACE:include>")

target_link_libraries(raft
INTERFACE
CUDA::cublas
CUDA::curand
CUDA::cusolver
CUDA::cudart
CUDA::cusparse
rmm::rmm
cuco::cuco
)
target_include_directories(raft_distance PUBLIC "$<BUILD_INTERFACE:${RAFT_SOURCE_DIR}/include>"
"$<INSTALL_INTERFACE:include>")

target_include_directories(raft_nn PUBLIC "$<BUILD_INTERFACE:${RAFT_SOURCE_DIR}/include>"
"$<INSTALL_INTERFACE:include>")

set(RAFT_LINK_LIBRARIES
CUDA::cublas
CUDA::curand
CUDA::cusolver
CUDA::cudart
CUDA::cusparse
rmm::rmm
cuco::cuco
)

target_link_libraries(raft INTERFACE ${RAFT_LINK_LIBRARIES})
target_link_libraries(raft_distance PUBLIC ${RAFT_LINK_LIBRARIES})
target_link_libraries(raft_nn PUBLIC ${RAFT_LINK_LIBRARIES} FAISS::FAISS)

target_compile_options(raft_distance
PRIVATE "$<$<COMPILE_LANGUAGE:CXX>:${RAFT_CXX_FLAGS}>"
"$<$<COMPILE_LANGUAGE:CUDA>:${RAFT_CUDA_FLAGS}>"
)


target_compile_options(raft_nn
PRIVATE "$<$<COMPILE_LANGUAGE:CXX>:${RAFT_CXX_FLAGS}>"
"$<$<COMPILE_LANGUAGE:CUDA>:${RAFT_CUDA_FLAGS}>"
)

target_compile_features(raft_distance PUBLIC cxx_std_17 $<BUILD_INTERFACE:cuda_std_17>)
target_compile_features(raft_nn PUBLIC cxx_std_17 $<BUILD_INTERFACE:cuda_std_17>)
target_compile_features(raft INTERFACE cxx_std_17 $<BUILD_INTERFACE:cuda_std_17>)

install(TARGETS raft_distance
DESTINATION ${lib_dir}
EXPORT raft-exports)

install(TARGETS raft_nn
DESTINATION ${lib_dir}
EXPORT raft-exports)

install(TARGETS raft
DESTINATION ${lib_dir}
EXPORT raft-exports
)
EXPORT raft-exports)

include(GNUInstallDirs)
install(DIRECTORY include/raft/
Expand All @@ -149,23 +187,22 @@ install(DIRECTORY include/raft/

# Temporary install of raft.hpp while the file is removed
install(FILES include/raft.hpp
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/raft
)
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/raft)

##############################################################################
# - install export -----------------------------------------------------------
set(doc_string
[=[
Provide targets for the RAFT: RAPIDS Analytics Frameworks Toolset.

RAFT is a repository containining shared utilities, mathematical operations
and common functions for the analytics components of RAPIDS.
Provide targets for the RAFT: RAPIDS Analytics Framework Toolkit.

RAPIDS Analytics Framework Toolkit contains shared representations,
mathematical computational primitives, and utilities that accelerate
building analytics and data science algorithms in the RAPIDS ecosystem.
]=])

rapids_export(INSTALL raft
EXPORT_SET raft-exports
GLOBAL_TARGETS raft # since we can't hook into EXPORT SETS
GLOBAL_TARGETS raft raft_distance# since we can't hook into EXPORT SETS
NAMESPACE raft::
DOCUMENTATION doc_string
)
Expand All @@ -175,7 +212,7 @@ and common functions for the analytics components of RAPIDS.

rapids_export(BUILD raft
EXPORT_SET raft-exports
GLOBAL_TARGETS raft # since we can't hook into EXPORT SETS
GLOBAL_TARGETS raft raft_distance raft_nn# since we can't hook into EXPORT SETS
LANGUAGES CUDA
DOCUMENTATION doc_string
NAMESPACE raft::
Expand Down
19 changes: 19 additions & 0 deletions cpp/include/raft/distance/specializations.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/*
* Copyright (c) 2021, 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 <raft/distance/specializations/distance.hpp>
67 changes: 67 additions & 0 deletions cpp/include/raft/distance/specializations/detail/canberra.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
/*
* Copyright (c) 2021, 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 <cstdint>
#include <raft/distance/detail/distance.cuh>

namespace raft {
namespace distance {
namespace detail {
extern template void distance<raft::distance::DistanceType::Canberra, float, float, float, int>(
const float* x,
const float* y,
float* dist,
int m,
int n,
int k,
void* workspace,
size_t worksize,
cudaStream_t stream,
bool isRowMajor,
float metric_arg);

extern template void distance<raft::distance::DistanceType::Canberra, double, double, double, int>(
const double* x,
const double* y,
double* dist,
int m,
int n,
int k,
void* workspace,
size_t worksize,
cudaStream_t stream,
bool isRowMajor,
double metric_arg);

extern template void
distance<raft::distance::DistanceType::Canberra, float, float, float, std::uint32_t>(
const float* x,
const float* y,
float* dist,
std::uint32_t m,
std::uint32_t n,
std::uint32_t k,
void* workspace,
size_t worksize,
cudaStream_t stream,
bool isRowMajor,
float metric_arg);

} // namespace detail
} // namespace distance
} // namespace raft
66 changes: 66 additions & 0 deletions cpp/include/raft/distance/specializations/detail/chebyshev.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
/*
* Copyright (c) 2021, 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 <raft/distance/detail/distance.cuh>

namespace raft {
namespace distance {
namespace detail {
extern template void distance<raft::distance::DistanceType::Linf, float, float, float, int>(
const float* x,
const float* y,
float* dist,
int m,
int n,
int k,
void* workspace,
size_t worksize,
cudaStream_t stream,
bool isRowMajor,
float metric_arg);

extern template void distance<raft::distance::DistanceType::Linf, double, double, double, int>(
const double* x,
const double* y,
double* dist,
int m,
int n,
int k,
void* workspace,
size_t worksize,
cudaStream_t stream,
bool isRowMajor,
double metric_arg);

extern template void
distance<raft::distance::DistanceType::Linf, float, float, float, std::uint32_t>(
const float* x,
const float* y,
float* dist,
std::uint32_t m,
std::uint32_t n,
std::uint32_t k,
void* workspace,
size_t worksize,
cudaStream_t stream,
bool isRowMajor,
float metric_arg);

} // namespace detail
} // namespace distance
} // namespace raft
68 changes: 68 additions & 0 deletions cpp/include/raft/distance/specializations/detail/correlation.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
/*
* Copyright (c) 2021, 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 <raft/distance/detail/distance.cuh>

namespace raft {
namespace distance {
namespace detail {
extern template void
distance<raft::distance::DistanceType::CorrelationExpanded, float, float, float, int>(
const float* x,
const float* y,
float* dist,
int m,
int n,
int k,
void* workspace,
size_t worksize,
cudaStream_t stream,
bool isRowMajor,
float metric_arg);

extern template void
distance<raft::distance::DistanceType::CorrelationExpanded, double, double, double, int>(
const double* x,
const double* y,
double* dist,
int m,
int n,
int k,
void* workspace,
size_t worksize,
cudaStream_t stream,
bool isRowMajor,
double metric_arg);

extern template void
distance<raft::distance::DistanceType::CorrelationExpanded, float, float, float, std::uint32_t>(
const float* x,
const float* y,
float* dist,
std::uint32_t m,
std::uint32_t n,
std::uint32_t k,
void* workspace,
size_t worksize,
cudaStream_t stream,
bool isRowMajor,
float metric_arg);

} // namespace detail
} // namespace distance
} // namespace raft
Loading