Skip to content

Commit

Permalink
Adding base header-only conda package without cuda math libs (#1386)
Browse files Browse the repository at this point in the history
cc @MatthiasKohl  @bdice 

Making sure CI agrees w/ this change. @MatthiasKohl, if CI succeeds here let's try to plug the resulting conda packages into a cugraph-ops PR to make sure cugraph-ops CI is happy as well.

Authors:
  - Corey J. Nolet (https://github.com/cjnolet)
  - Robert Maynard (https://github.com/robertmaynard)

Approvers:
  - AJ Schmidt (https://github.com/ajschmidt8)
  - Divye Gala (https://github.com/divyegala)

URL: #1386
  • Loading branch information
cjnolet authored Apr 13, 2023
1 parent 7c5b638 commit c950854
Show file tree
Hide file tree
Showing 8 changed files with 89 additions and 81 deletions.
2 changes: 1 addition & 1 deletion build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,7 @@ fi
# Initiate build for example RAFT application template (if needed)

if hasArg template; then
pushd cpp/template
pushd ${REPODIR}/cpp/template
./build.sh
popd
fi
51 changes: 18 additions & 33 deletions conda/recipes/libraft/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ source:
git_url: ../../..

outputs:
- name: libraft-headers
- name: libraft-headers-only
version: {{ version }}
script: build_libraft_headers.sh
build:
Expand Down Expand Up @@ -50,20 +50,26 @@ outputs:
- ninja
- sysroot_{{ target_platform }} {{ sysroot_version }}
host:
- cuda-profiler-api {{ cuda_profiler_api_host_version }}
- cudatoolkit ={{ cuda_version }}
- libcublas {{ libcublas_host_version }}
- libcublas-dev {{ libcublas_host_version }}
- libcurand {{ libcurand_host_version }}
- libcurand-dev {{ libcurand_host_version }}
- libcusolver {{ libcusolver_host_version }}
- libcusolver-dev {{ libcusolver_host_version }}
- libcusparse {{ libcusparse_host_version }}
- libcusparse-dev {{ libcusparse_host_version }}
- librmm ={{ minor_version }}
- cudatoolkit {{ cuda_version }}
about:
home: https://rapids.ai/
license: Apache-2.0
summary: libraft-headers-only library
- name: libraft-headers
version: {{ version }}
build:
number: {{ GIT_DESCRIBE_NUMBER }}
string: cuda{{ cuda_major }}_{{ date_string }}_{{ GIT_DESCRIBE_HASH }}_{{ GIT_DESCRIBE_NUMBER }}
ignore_run_exports_from:
- {{ compiler('cuda') }}
- librmm
requirements:
run:
- {{ pin_compatible('cudatoolkit', max_pin='x', min_pin='x') }}
- {{ pin_subpackage('libraft-headers-only', exact=True) }}
- cuda-profiler-api {{ cuda_profiler_api_run_version }}
- cudatoolkit {{ cuda_version }}
- librmm ={{ minor_version }}
- libcublas {{ libcublas_run_version }}
- libcublas-dev {{ libcublas_run_version }}
- libcurand {{ libcurand_run_version }}
Expand All @@ -72,7 +78,6 @@ outputs:
- libcusolver-dev {{ libcusolver_run_version }}
- libcusparse {{ libcusparse_run_version }}
- libcusparse-dev {{ libcusparse_run_version }}
- librmm ={{ minor_version }}
about:
home: https://rapids.ai/
license: Apache-2.0
Expand Down Expand Up @@ -130,7 +135,6 @@ outputs:
- sysroot_{{ target_platform }} {{ sysroot_version }}
host:
- {{ pin_subpackage('libraft', exact=True) }}
- {{ pin_subpackage('libraft-headers', exact=True) }}
- cuda-profiler-api {{ cuda_profiler_api_host_version }}
- gmock {{ gtest_version }}
- gtest {{ gtest_version }}
Expand All @@ -144,7 +148,6 @@ outputs:
- libcusparse-dev {{ libcusparse_host_version }}
run:
- {{ pin_subpackage('libraft', exact=True) }}
- {{ pin_subpackage('libraft-headers', exact=True) }}
- gmock {{ gtest_version }}
- gtest {{ gtest_version }}
about:
Expand All @@ -170,19 +173,10 @@ outputs:
- sysroot_{{ target_platform }} {{ sysroot_version }}
host:
- {{ pin_subpackage('libraft', exact=True) }}
- {{ pin_subpackage('libraft-headers', exact=True) }}
- cuda-profiler-api {{ cuda_profiler_api_host_version }}
- libcublas {{ libcublas_host_version }}
- libcublas-dev {{ libcublas_host_version }}
- libcurand {{ libcurand_host_version }}
- libcurand-dev {{ libcurand_host_version }}
- libcusolver {{ libcusolver_host_version }}
- libcusolver-dev {{ libcusolver_host_version }}
- libcusparse {{ libcusparse_host_version }}
- libcusparse-dev {{ libcusparse_host_version }}
run:
- {{ pin_subpackage('libraft', exact=True) }}
- {{ pin_subpackage('libraft-headers', exact=True) }}
about:
home: https://rapids.ai/
license: Apache-2.0
Expand All @@ -206,23 +200,14 @@ outputs:
- sysroot_{{ target_platform }} {{ sysroot_version }}
host:
- {{ pin_subpackage('libraft', exact=True) }}
- {{ pin_subpackage('libraft-headers', exact=True) }}
- cuda-profiler-api {{ cuda_profiler_api_host_version }}
- libcublas {{ libcublas_host_version }}
- libcublas-dev {{ libcublas_host_version }}
- libcurand {{ libcurand_host_version }}
- libcurand-dev {{ libcurand_host_version }}
- libcusolver {{ libcusolver_host_version }}
- libcusolver-dev {{ libcusolver_host_version }}
- libcusparse {{ libcusparse_host_version }}
- libcusparse-dev {{ libcusparse_host_version }}
- glog {{ glog_version }}
- nlohmann_json {{ nlohmann_json_version }}
- libfaiss>=1.7.1
- faiss-proc=*=cuda
run:
- {{ pin_subpackage('libraft', exact=True) }}
- {{ pin_subpackage('libraft-headers', exact=True) }}
- glog {{ glog_version }}
- faiss-proc=*=cuda
- libfaiss {{ faiss_version }}
Expand Down
63 changes: 48 additions & 15 deletions cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -179,24 +179,23 @@ target_include_directories(
)

# Keep RAFT as lightweight as possible. Only CUDA libs and rmm should be used in global target.
target_link_libraries(
raft
INTERFACE rmm::rmm
cuco::cuco
nvidia::cutlass::cutlass
CUDA::cublas${_ctk_static_suffix}
CUDA::curand${_ctk_static_suffix}
CUDA::cusolver${_ctk_static_suffix}
CUDA::cusparse${_ctk_static_suffix}
raft::Thrust
)
target_link_libraries(raft INTERFACE rmm::rmm cuco::cuco nvidia::cutlass::cutlass raft::Thrust)

target_compile_features(raft INTERFACE cxx_std_17 $<BUILD_INTERFACE:cuda_std_17>)
target_compile_options(
raft INTERFACE $<$<COMPILE_LANG_AND_ID:CUDA,NVIDIA>:--expt-extended-lambda
--expt-relaxed-constexpr>
)

set(RAFT_CUSOLVER_DEPENDENCY CUDA::cusolver${_ctk_static_suffix})
set(RAFT_CUBLAS_DEPENDENCY CUDA::cublas${_ctk_static_suffix})
set(RAFT_CURAND_DEPENDENCY CUDA::curand${_ctk_static_suffix})
set(RAFT_CUSPARSE_DEPENDENCY CUDA::cusparse${_ctk_static_suffix})

set(RAFT_CTK_MATH_DEPENDENCIES ${RAFT_CUBLAS_DEPENDENCY} ${RAFT_CUSOLVER_DEPENDENCY}
${RAFT_CUSPARSE_DEPENDENCY} ${RAFT_CURAND_DEPENDENCY}
)

# Endian detection
include(TestBigEndian)
test_big_endian(BIG_ENDIAN)
Expand Down Expand Up @@ -454,7 +453,13 @@ if(RAFT_COMPILE_LIBRARY)
INTERFACE_POSITION_INDEPENDENT_CODE ON
)

target_link_libraries(raft_lib PUBLIC raft::raft $<TARGET_NAME_IF_EXISTS:OpenMP::OpenMP_CXX>)
target_link_libraries(
raft_lib
PUBLIC raft::raft
${RAFT_CTK_MATH_DEPENDENCIES} # TODO: Once `raft::resources` is used everywhere, this
# will just be cublas
$<TARGET_NAME_IF_EXISTS:OpenMP::OpenMP_CXX>
)
target_compile_options(
raft_lib PRIVATE "$<$<COMPILE_LANGUAGE:CXX>:${RAFT_CXX_FLAGS}>"
"$<$<COMPILE_LANGUAGE:CUDA>:${RAFT_CUDA_FLAGS}>"
Expand Down Expand Up @@ -606,13 +611,39 @@ if(TARGET raft_lib)
list(APPEND raft_export_sets raft-compiled-lib-exports)
endif()

string(
APPEND
code_string
[=[
option(RAFT_ENABLE_CUSOLVER_DEPENDENCY "Enable cusolver dependency" ON)
option(RAFT_ENABLE_CUBLAS_DEPENDENCY "Enable cublas dependency" ON)
option(RAFT_ENABLE_CURAND_DEPENDENCY "Enable curand dependency" ON)
option(RAFT_ENABLE_CUSPARSE_DEPENDENCY "Enable cusparse dependency" ON)

mark_as_advanced(RAFT_ENABLE_CUSOLVER_DEPENDENCY)
mark_as_advanced(RAFT_ENABLE_CUBLAS_DEPENDENCY)
mark_as_advanced(RAFT_ENABLE_CURAND_DEPENDENCY)
mark_as_advanced(RAFT_ENABLE_CUSPARSE_DEPENDENCY)

target_link_libraries(raft::raft INTERFACE
$<$<BOOL:${RAFT_ENABLE_CUSOLVER_DEPENDENCY}>:${RAFT_CUSOLVER_DEPENDENCY}>
$<$<BOOL:${RAFT_ENABLE_CUBLAS_DEPENDENCY}>:${RAFT_CUBLAS_DEPENDENCY}>
$<$<BOOL:${RAFT_ENABLE_CUSPARSE_DEPENDENCY}>:${RAFT_CUSPARSE_DEPENDENCY}>
$<$<BOOL:${RAFT_ENABLE_CURAND_DEPENDENCY}>:${RAFT_CURAND_DEPENDENCY}>
)
]=]
)

# Use `rapids_export` for 22.04 as it will have COMPONENT support
rapids_export(
INSTALL raft
EXPORT_SET raft-exports
COMPONENTS ${raft_components}
COMPONENTS_EXPORT_SET ${raft_export_sets}
GLOBAL_TARGETS raft compiled distributed
NAMESPACE raft:: DOCUMENTATION doc_string FINAL_CODE_BLOCK code_string
NAMESPACE raft::
DOCUMENTATION doc_string
FINAL_CODE_BLOCK code_string
)

# ##################################################################################################
Expand All @@ -622,8 +653,10 @@ rapids_export(
EXPORT_SET raft-exports
COMPONENTS ${raft_components}
COMPONENTS_EXPORT_SET ${raft_export_sets}
GLOBAL_TARGETS raft
compiled distributed DOCUMENTATION doc_string NAMESPACE raft:: FINAL_CODE_BLOCK code_string
GLOBAL_TARGETS raft compiled distributed
DOCUMENTATION doc_string
NAMESPACE raft::
FINAL_CODE_BLOCK code_string
)

# ##################################################################################################
Expand Down
1 change: 1 addition & 0 deletions cpp/bench/ann/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ function(ConfigureAnnBench)
$<$<BOOL:${RAFT_ANN_BENCH_USE_MULTIGPU}>:NCCL::NCCL>
${ConfigureAnnBench_LINKS}
Threads::Threads
${RAFT_CTK_MATH_DEPENDENCIES}
$<TARGET_NAME_IF_EXISTS:OpenMP::OpenMP_CXX>
$<TARGET_NAME_IF_EXISTS:conda_env>
)
Expand Down
8 changes: 5 additions & 3 deletions cpp/include/raft/linalg/detail/cublas_wrappers.hpp
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -965,7 +965,8 @@ inline cublasStatus_t cublasdot(cublasHandle_t handle,
cudaStream_t stream)
{
RAFT_CUBLAS_TRY(cublasSetStream(handle, stream));
return cublasSdot(handle, n, x, incx, y, incy, result);
return cublasDotEx(
handle, n, x, CUDA_R_32F, incx, y, CUDA_R_32F, incy, result, CUDA_R_32F, CUDA_R_32F);
}

template <>
Expand All @@ -979,7 +980,8 @@ inline cublasStatus_t cublasdot(cublasHandle_t handle,
cudaStream_t stream)
{
RAFT_CUBLAS_TRY(cublasSetStream(handle, stream));
return cublasDdot(handle, n, x, incx, y, incy, result);
return cublasDotEx(
handle, n, x, CUDA_R_64F, incx, y, CUDA_R_64F, incy, result, CUDA_R_64F, CUDA_R_64F);
}
/** @} */

Expand Down
18 changes: 0 additions & 18 deletions cpp/include/raft/spectral/detail/modularity_maximization.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,24 +32,6 @@
#include <raft/spectral/eigen_solvers.cuh>
#include <raft/spectral/matrix_wrappers.hpp>

#ifdef COLLECT_TIME_STATISTICS
#include <cuda_profiler_api.h>
#include <stddef.h>
#include <sys/resource.h>
#include <sys/sysinfo.h>
#include <sys/time.h>
#endif

#ifdef COLLECT_TIME_STATISTICS
static double timer(void)
{
struct timeval tv;
cudaDeviceSynchronize();
gettimeofday(&tv, NULL);
return (double)tv.tv_sec + (double)tv.tv_usec / 1000000.0;
}
#endif

namespace raft {
namespace spectral {
namespace detail {
Expand Down
3 changes: 2 additions & 1 deletion cpp/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,13 @@ function(ConfigureTest)

target_link_libraries(
${TEST_NAME}
PRIVATE raft::raft
PRIVATE raft
raft_internal
$<$<BOOL:${ConfigureTest_LIB}>:raft::compiled>
GTest::gtest
GTest::gtest_main
Threads::Threads
${RAFT_CTK_MATH_DEPENDENCIES}
$<TARGET_NAME_IF_EXISTS:OpenMP::OpenMP_CXX>
$<TARGET_NAME_IF_EXISTS:conda_env>
)
Expand Down
24 changes: 14 additions & 10 deletions docs/source/build.md
Original file line number Diff line number Diff line change
Expand Up @@ -151,18 +151,22 @@ make -j<parallel_level> install

RAFT's cmake has the following configurable flags available:.

| Flag | Possible Values | Default Value | Behavior |
|---------------------------|----------------------| --- | --- |
| BUILD_TESTS | ON, OFF | ON | Compile Googletests |
| BUILD_PRIMS_BENCH | ON, OFF | OFF | Compile benchmarks |
| Flag | Possible Values | Default Value | Behavior |
|---------------------------------|----------------------| --- |------------------------------------------------------------------------------|
| BUILD_TESTS | ON, OFF | ON | Compile Googletests |
| BUILD_PRIMS_BENCH | ON, OFF | OFF | Compile benchmarks |
| BUILD_ANN_BENCH | ON, OFF | OFF | Compile end-to-end ANN benchmarks |
| raft_FIND_COMPONENTS | compiled distributed | | Configures the optional components as a space-separated list |
| RAFT_COMPILE_LIBRARY | ON, OFF | ON if either BUILD_TESTS or BUILD_PRIMS_BENCH is ON; otherwise OFF | Compiles all `libraft` shared libraries (these are required for Googletests) |
| DETECT_CONDA_ENV | ON, OFF | ON | Enable detection of conda environment for dependencies |
| RAFT_NVTX | ON, OFF | OFF | Enable NVTX Markers |
| CUDA_ENABLE_KERNELINFO | ON, OFF | OFF | Enables `kernelinfo` in nvcc. This is useful for `compute-sanitizer` |
| CUDA_ENABLE_LINEINFO | ON, OFF | OFF | Enable the -lineinfo option for nvcc |
| CUDA_STATIC_RUNTIME | ON, OFF | OFF | Statically link the CUDA runtime |
| raft_FIND_COMPONENTS | compiled distributed | | Configures the optional components as a space-separated list |
| RAFT_ENABLE_CUBLAS_DEPENDENCY | ON, OFF | ON | Link against cublas library in `raft::raft` |
| RAFT_ENABLE_CUSOLVER_DEPENDENCY | ON, OFF | ON | Link against cusolver library in `raft::raft` |
| RAFT_ENABLE_CUSPARSE_DEPENDENCY | ON, OFF | ON | Link against cusparse library in `raft::raft` |
| RAFT_ENABLE_CUSOLVER_DEPENDENCY | ON, OFF | ON | Link against curand library in `raft::raft` |
| DETECT_CONDA_ENV | ON, OFF | ON | Enable detection of conda environment for dependencies |
| RAFT_NVTX | ON, OFF | OFF | Enable NVTX Markers |
| CUDA_ENABLE_KERNELINFO | ON, OFF | OFF | Enables `kernelinfo` in nvcc. This is useful for `compute-sanitizer` |
| CUDA_ENABLE_LINEINFO | ON, OFF | OFF | Enable the -lineinfo option for nvcc |
| CUDA_STATIC_RUNTIME | ON, OFF | OFF | Statically link the CUDA runtime |

Currently, shared libraries are provided for the `libraft-nn` and `libraft-distance` components.

Expand Down

0 comments on commit c950854

Please sign in to comment.