Skip to content

Commit

Permalink
correct compliation of cuml c library (rapidsai#3908)
Browse files Browse the repository at this point in the history
Resolves two issues found when trying to build `cuml` locally. 

The first was that the `CUML_C_TARGET` had `FAISS` in the public link requirements, which doesn't look needed. This caused CMake configuration errors when trying to generate the `cuml-config.cmake` file. Solution was to move `FAISS` to be a private dependency ( brought in via `CUML_CPP_TARGET` )

The second was that the `CUML_C_TARGET`  tests need to make sure the `C` library is enabled. CUML doesn't enable this language by default as the `CUML_C_TARGET` builds using the `C++` compiler and exposes a `C` API via `extern C` blocks. 
I didn't go with a blanket enable `C` language as each language enabled, as that would increase the default requirements to build CUML when testing is disabled.

Authors:
  - Robert Maynard (https://github.com/robertmaynard)

Approvers:
  - Dante Gama Dessavre (https://github.com/dantegd)

URL: rapidsai#3908
  • Loading branch information
robertmaynard authored Jun 2, 2021
1 parent 1b5b238 commit bafbc3b
Show file tree
Hide file tree
Showing 14 changed files with 25 additions and 14 deletions.
8 changes: 8 additions & 0 deletions cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,7 @@ if(BUILD_CUML_C_LIBRARY)
target_link_libraries(${CUML_C_TARGET}
PUBLIC
${CUML_CPP_TARGET}
PRIVATE
FAISS::FAISS
)

Expand Down Expand Up @@ -448,6 +449,13 @@ rapids_export(BUILD cuml
FINAL_CODE_BLOCK code_string
)

##############################################################################
# - build benchmark executable -----------------------------------------------

if(BUILD_CUML_BENCH OR BUILD_CUML_PRIMS_BENCH)
add_subdirectory(bench)
endif(BUILD_CUML_BENCH)

##############################################################################
# - doxygen targets ----------------------------------------------------------

Expand Down
2 changes: 2 additions & 0 deletions cpp/bench/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ if(BUILD_CUML_PRIMS_BENCH)

target_link_libraries(${PRIMS_BENCH_TARGET}
PUBLIC
cuml
CUDA::cublas
benchmark::benchmark
raft::raft
Expand All @@ -89,5 +90,6 @@ if(BUILD_CUML_PRIMS_BENCH)
target_include_directories(${PRIMS_BENCH_TARGET}
PRIVATE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../src_prims>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
)
endif(BUILD_CUML_PRIMS_BENCH)
2 changes: 1 addition & 1 deletion cpp/bench/prims/add.cu
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
* limitations under the License.
*/

#include <common/ml_benchmark.hpp>
#include <raft/linalg/add.cuh>
#include <raft/mr/device/allocator.hpp>
#include "../common/ml_benchmark.hpp"

namespace MLCommon {
namespace Bench {
Expand Down
2 changes: 1 addition & 1 deletion cpp/bench/prims/distance_common.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
*/

#include <raft/cudart_utils.h>
#include <common/ml_benchmark.hpp>
#include <raft/distance/distance.cuh>
#include <raft/mr/device/allocator.hpp>
#include "../common/ml_benchmark.hpp"

namespace MLCommon {
namespace Bench {
Expand Down
2 changes: 1 addition & 1 deletion cpp/bench/prims/fused_l2_nn.cu
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@
*/

#include <raft/cudart_utils.h>
#include <common/ml_benchmark.hpp>
#include <limits>
#include <raft/distance/fused_l2_nn.cuh>
#include <raft/linalg/norm.cuh>
#include <raft/mr/device/allocator.hpp>
#include <raft/random/rng.cuh>
#include "../common/ml_benchmark.hpp"

namespace MLCommon {
namespace Bench {
Expand Down
2 changes: 1 addition & 1 deletion cpp/bench/prims/gram_matrix.cu
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/

#include <cuml/matrix/kernelparams.h>
#include <common/ml_benchmark.hpp>
#include <matrix/grammatrix.cuh>
#include <matrix/kernelfactory.cuh>
#include <memory>
Expand All @@ -23,7 +24,6 @@
#include <sstream>
#include <string>
#include <vector>
#include "../common/ml_benchmark.hpp"

namespace MLCommon {
namespace Bench {
Expand Down
2 changes: 1 addition & 1 deletion cpp/bench/prims/make_blobs.cu
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
* limitations under the License.
*/

#include <common/ml_benchmark.hpp>
#include <raft/mr/device/allocator.hpp>
#include <random/make_blobs.cuh>
#include "../common/ml_benchmark.hpp"

namespace MLCommon {
namespace Bench {
Expand Down
2 changes: 1 addition & 1 deletion cpp/bench/prims/map_then_reduce.cu
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
* limitations under the License.
*/

#include <common/ml_benchmark.hpp>
#include <raft/linalg/map_then_reduce.cuh>
#include <raft/mr/device/allocator.hpp>
#include "../common/ml_benchmark.hpp"

namespace MLCommon {
namespace Bench {
Expand Down
2 changes: 1 addition & 1 deletion cpp/bench/prims/matrix_vector_op.cu
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
* limitations under the License.
*/

#include <common/ml_benchmark.hpp>
#include <raft/linalg/matrix_vector_op.cuh>
#include <raft/mr/device/allocator.hpp>
#include "../common/ml_benchmark.hpp"

namespace MLCommon {
namespace Bench {
Expand Down
2 changes: 1 addition & 1 deletion cpp/bench/prims/permute.cu
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
*/

#include <raft/cudart_utils.h>
#include <common/ml_benchmark.hpp>
#include <raft/mr/device/allocator.hpp>
#include <raft/random/rng.cuh>
#include <random/permute.cuh>
#include "../common/ml_benchmark.hpp"

namespace MLCommon {
namespace Bench {
Expand Down
2 changes: 1 addition & 1 deletion cpp/bench/prims/reduce.cu
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
* limitations under the License.
*/

#include <common/ml_benchmark.hpp>
#include <raft/linalg/reduce.cuh>
#include <raft/mr/device/allocator.hpp>
#include "../common/ml_benchmark.hpp"

namespace MLCommon {
namespace Bench {
Expand Down
2 changes: 1 addition & 1 deletion cpp/bench/prims/rng.cu
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
*/

#include <raft/cudart_utils.h>
#include <common/ml_benchmark.hpp>
#include <raft/mr/device/allocator.hpp>
#include <raft/random/rng.cuh>
#include "../common/ml_benchmark.hpp"

namespace MLCommon {
namespace Bench {
Expand Down
2 changes: 1 addition & 1 deletion cpp/cmake/thirdparty/get_faiss.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ function(find_and_configure_faiss)
)

if(FAISS_ADDED)
set(FAISS_GPU_HEADERS ${FAISS_SOURCE_DIR} PARENT_SCOPE)
target_include_directories(faiss INTERFACE $<BUILD_INTERFACE:${FAISS_SOURCE_DIR}>)
add_library(FAISS::FAISS ALIAS faiss)
endif()

Expand Down
7 changes: 4 additions & 3 deletions cpp/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,9 @@ endif()
# - build C-API test library -------------------------------------------------

if(BUILD_CUML_C_LIBRARY)

enable_language(C)

add_library(${CUML_C_TEST_TARGET} SHARED
c_api/dbscan_api_test.c
c_api/glm_api_test.c
Expand All @@ -236,8 +239,6 @@ if(BUILD_CUML_C_LIBRARY)
c_api/svm_api_test.c
)

set_target_properties(${CUML_C_TEST_TARGET} PROPERTIES LINKER_LANGUAGE C)

target_link_libraries(${CUML_C_TEST_TARGET} PUBLIC cuml_c)
target_link_libraries(${CUML_C_TEST_TARGET} PUBLIC ${CUML_C_TARGET})

endif(BUILD_CUML_C_LIBRARY)

0 comments on commit bafbc3b

Please sign in to comment.