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

[FEA] Enable building static libs #4673

Merged
merged 14 commits into from
May 10, 2022
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
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
11 changes: 9 additions & 2 deletions cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
##############################################################################
# - User Options ------------------------------------------------------------

option(BUILD_SHARED_LIBS "Build cuML shared libraries" ON)
option(BUILD_CUML_C_LIBRARY "Build libcuml_c shared library. Contains the cuML C API" ON)
option(BUILD_CUML_CPP_LIBRARY "Build libcuml shared library" ON)
option(BUILD_CUML_TESTS "Build cuML algorithm tests" ON)
Expand Down Expand Up @@ -205,6 +206,11 @@ endif()

if(all_algo OR treeshap_algo)
include(cmake/thirdparty/get_gputreeshap.cmake)
# Workaround until https://github.com/rapidsai/rapids-cmake/issues/176 is resolved
if(NOT BUILD_SHARED_LIBS)
rapids_export_package(BUILD GPUTreeShap cuml-exports)
rapids_export_package(INSTALL GPUTreeShap cuml-exports)
endif()
endif()

if(NOT SINGLEGPU)
Expand Down Expand Up @@ -242,7 +248,7 @@ if(BUILD_CUML_CPP_LIBRARY)

# single GPU components
# common components
add_library(${CUML_CPP_TARGET} SHARED
add_library(${CUML_CPP_TARGET}
src/common/logger.cpp)

if(all_algo OR arima_algo)
Expand Down Expand Up @@ -480,6 +486,7 @@ if(BUILD_CUML_CPP_LIBRARY)
CXX_STANDARD_REQUIRED ON
CUDA_STANDARD 17
CUDA_STANDARD_REQUIRED ON
POSITION_INDEPENDENT_CODE ON
INTERFACE_POSITION_INDEPENDENT_CODE ON
)

Expand Down Expand Up @@ -537,7 +544,7 @@ endif()
# - build libcuml C shared library -------------------------------------------

if(BUILD_CUML_C_LIBRARY)
add_library(${CUML_C_TARGET} SHARED
add_library(${CUML_C_TARGET}
src/common/cumlHandle.cpp
src/common/cuml_api.cpp
src/dbscan/dbscan_api.cpp
Expand Down
35 changes: 35 additions & 0 deletions cpp/cmake/thirdparty/get_gputreeshap.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,41 @@ function(find_and_configure_gputreeshap)
GIT_TAG ${PKG_PINNED_TAG}
)

if (GPUTreeShap_ADDED)
install(TARGETS GPUTreeShap
EXPORT gputreeshap-exports)

# generate gputreeshap-targets.cmake for install dir
rapids_export(INSTALL GPUTreeShap
EXPORT_SET gputreeshap-exports
GLOBAL_TARGETS GPUTreeShap
NAMESPACE GPUTreeShap::)

# generate gputreeshap-targets.cmake for binary dir
rapids_export(BUILD GPUTreeShap
EXPORT_SET gputreeshap-exports
GLOBAL_TARGETS GPUTreeShap
NAMESPACE GPUTreeShap::)

# clear out incorrect INTERFACE_SOURCES
set_target_properties(GPUTreeShap PROPERTIES INTERFACE_SOURCES "")
trxcllnt marked this conversation as resolved.
Show resolved Hide resolved
get_target_property(all_includes GPUTreeShap INTERFACE_INCLUDE_DIRECTORIES)
# clear out incorrect INTERFACE_INCLUDE_DIRECTORIES
set_target_properties(GPUTreeShap PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "")
# set INTERFACE_INCLUDE_DIRECTORIES appropriately
target_include_directories(GPUTreeShap INTERFACE
$<BUILD_INTERFACE:${all_includes}>
$<INSTALL_INTERFACE:include>)
trxcllnt marked this conversation as resolved.
Show resolved Hide resolved
endif()

# do `find_dependency(GPUTreeShap) in build and install`
rapids_export_package(BUILD GPUTreeShap cuml-exports)
rapids_export_package(INSTALL GPUTreeShap cuml-exports)

# Tell cmake where it can find the generated gputreeshap-config.cmake we wrote.
include("${rapids-cmake-dir}/export/find_package_root.cmake")
rapids_export_find_package_root(BUILD GPUTreeShap [=[${CMAKE_CURRENT_LIST_DIR}]=] cuml-exports)

set(GPUTreeShap_ADDED ${GPUTreeShap_ADDED} PARENT_SCOPE)

endfunction()
Expand Down
7 changes: 5 additions & 2 deletions cpp/include/cuml/manifold/common.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020-2021, NVIDIA CORPORATION.
* Copyright (c) 2020-2022, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -30,7 +30,10 @@ typedef int knn_indices_sparse_t;
*/
template <typename value_idx, typename value_t>
struct knn_graph {
knn_graph(value_idx n_rows_, int n_neighbors_) : n_rows(n_rows_), n_neighbors(n_neighbors_) {}
knn_graph(value_idx n_rows_, int n_neighbors_)
: n_rows(n_rows_), n_neighbors(n_neighbors_), knn_indices{nullptr}, knn_dists{nullptr}
{
}

knn_graph(value_idx n_rows_, int n_neighbors_, value_idx* knn_indices_, value_t* knn_dists_)
: n_rows(n_rows_), n_neighbors(n_neighbors_), knn_indices(knn_indices_), knn_dists(knn_dists_)
Expand Down