Skip to content

Commit

Permalink
ConfigureCUDA.cmake now sets CUVS_ prefixed variables (#66)
Browse files Browse the repository at this point in the history
This makes sure that CUVS uses the compile flags that are required for RAPIDS C++ projects.

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

Approvers:
  - Bradley Dice (https://github.com/bdice)
  - Corey J. Nolet (https://github.com/cjnolet)

URL: rapidsai/cuvs#66
  • Loading branch information
difyrrwrzd authored May 17, 2024
1 parent 5c7bad3 commit 41c2cf9
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 21 deletions.
32 changes: 16 additions & 16 deletions cpp/cmake/modules/ConfigureCUDA.cmake
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# =============================================================================
# Copyright (c) 2018-2023, NVIDIA CORPORATION.
# Copyright (c) 2018-2024, 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
Expand All @@ -13,45 +13,45 @@
# =============================================================================

if(DISABLE_DEPRECATION_WARNINGS)
list(APPEND RAFT_CXX_FLAGS -Wno-deprecated-declarations)
list(APPEND RAFT_CUDA_FLAGS -Xcompiler=-Wno-deprecated-declarations)
list(APPEND CUVS_CXX_FLAGS -Wno-deprecated-declarations)
list(APPEND CUVS_CUDA_FLAGS -Xcompiler=-Wno-deprecated-declarations)
endif()

# Be very strict when compiling with GCC as host compiler (and thus more lenient when compiling with
# clang)
if(CMAKE_COMPILER_IS_GNUCXX)
list(APPEND RAFT_CXX_FLAGS -Wall -Werror -Wno-unknown-pragmas -Wno-error=deprecated-declarations)
list(APPEND RAFT_CUDA_FLAGS -Xcompiler=-Wall,-Werror,-Wno-error=deprecated-declarations)
list(APPEND CUVS_CXX_FLAGS -Wall -Werror -Wno-unknown-pragmas -Wno-error=deprecated-declarations)
list(APPEND CUVS_CUDA_FLAGS -Xcompiler=-Wall,-Werror,-Wno-error=deprecated-declarations)

# set warnings as errors
if(CMAKE_CUDA_COMPILER_VERSION VERSION_GREATER_EQUAL 11.2.0)
list(APPEND RAFT_CUDA_FLAGS -Werror=all-warnings)
list(APPEND CUVS_CUDA_FLAGS -Werror=all-warnings)
endif()
endif()

if(CUDA_LOG_COMPILE_TIME)
list(APPEND RAFT_CUDA_FLAGS "--time=nvcc_compile_log.csv")
list(APPEND CUVS_CUDA_FLAGS "--time=nvcc_compile_log.csv")
endif()

list(APPEND RAFT_CUDA_FLAGS --expt-extended-lambda --expt-relaxed-constexpr)
list(APPEND RAFT_CXX_FLAGS "-DCUDA_API_PER_THREAD_DEFAULT_STREAM")
list(APPEND RAFT_CUDA_FLAGS "-DCUDA_API_PER_THREAD_DEFAULT_STREAM")
list(APPEND CUVS_CUDA_FLAGS --expt-extended-lambda --expt-relaxed-constexpr)
list(APPEND CUVS_CXX_FLAGS "-DCUDA_API_PER_THREAD_DEFAULT_STREAM")
list(APPEND CUVS_CUDA_FLAGS "-DCUDA_API_PER_THREAD_DEFAULT_STREAM")
# make sure we produce smallest binary size
list(APPEND RAFT_CUDA_FLAGS -Xfatbin=-compress-all)
list(APPEND CUVS_CUDA_FLAGS -Xfatbin=-compress-all)

# Option to enable line info in CUDA device compilation to allow introspection when profiling /
# memchecking
if(CUDA_ENABLE_LINEINFO)
list(APPEND RAFT_CUDA_FLAGS -lineinfo)
list(APPEND CUVS_CUDA_FLAGS -lineinfo)
endif()

if(OpenMP_FOUND)
list(APPEND RAFT_CUDA_FLAGS -Xcompiler=${OpenMP_CXX_FLAGS})
list(APPEND CUVS_CUDA_FLAGS -Xcompiler=${OpenMP_CXX_FLAGS})
endif()

# Debug options
if(CMAKE_BUILD_TYPE MATCHES Debug)
message(VERBOSE "RAFT: Building with debugging flags")
list(APPEND RAFT_CUDA_FLAGS -G -Xcompiler=-rdynamic)
list(APPEND RAFT_CUDA_FLAGS -Xptxas --suppress-stack-size-warning)
message(VERBOSE "cuVS: Building with debugging flags")
list(APPEND CUVS_CUDA_FLAGS -G -Xcompiler=-rdynamic)
list(APPEND CUVS_CUDA_FLAGS -Xptxas --suppress-stack-size-warning)
endif()
6 changes: 3 additions & 3 deletions cpp/src/neighbors/ivf_pq_index.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,13 @@ index<IdxT>::index(raft::resources const& handle,
pq_bits_(pq_bits),
pq_dim_(pq_dim == 0 ? calculate_pq_dim(dim) : pq_dim),
conservative_memory_allocation_(conservative_memory_allocation),
pq_centers_{raft::make_device_mdarray<float>(handle, make_pq_centers_extents())},
lists_{n_lists},
rotation_matrix_{
raft::make_device_matrix<float, uint32_t>(handle, this->rot_dim(), this->dim())},
list_sizes_{raft::make_device_vector<uint32_t, uint32_t>(handle, n_lists)},
pq_centers_{raft::make_device_mdarray<float>(handle, make_pq_centers_extents())},
centers_{raft::make_device_matrix<float, uint32_t>(handle, n_lists, this->dim_ext())},
centers_rot_{raft::make_device_matrix<float, uint32_t>(handle, n_lists, this->rot_dim())},
rotation_matrix_{
raft::make_device_matrix<float, uint32_t>(handle, this->rot_dim(), this->dim())},
data_ptrs_{raft::make_device_vector<uint8_t*, uint32_t>(handle, n_lists)},
inds_ptrs_{raft::make_device_vector<IdxT*, uint32_t>(handle, n_lists)},
accum_sorted_sizes_{raft::make_host_vector<IdxT, uint32_t>(n_lists + 1)}
Expand Down
4 changes: 2 additions & 2 deletions cpp/test/neighbors/ann_ivf_pq.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -354,8 +354,8 @@ class ivf_pq_test : public ::testing::TestWithParam<ivf_pq_inputs> {
cuvs::Compare<uint8_t>{}));

// Another test with the API that take list_data directly
auto list_data = index->lists()[label]->data.view();
uint32_t n_take = 4;
[[maybe_unused]] auto list_data = index->lists()[label]->data.view();
uint32_t n_take = 4;
ASSERT_TRUE(row_offset + n_take < n_rows);
auto codes2 = raft::make_device_matrix<uint8_t>(handle_, n_take, index->pq_dim());
ivf_pq::helpers::codepacker::unpack_list_data(
Expand Down

0 comments on commit 41c2cf9

Please sign in to comment.