Skip to content

Commit 9b24f05

Browse files
committed
no embedding headers
1 parent 2994c62 commit 9b24f05

6 files changed

Lines changed: 15 additions & 90 deletions

File tree

cpp/CMakeLists.txt

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -452,32 +452,7 @@ if(NOT BUILD_CPU_ONLY)
452452
)
453453
endblock()
454454

455-
find_file(
456-
CUVS_BUILD_TIME_CUDA_FP16_H cuda_fp16.h
457-
PATHS ${CUDAToolkit_INCLUDE_DIRS}
458-
NO_DEFAULT_PATH REQUIRED
459-
DOC "cuda_fp16.h from the CUDA toolkit (embedded for NVRTC UDF JIT)"
460-
)
461-
462-
set(CUVS_EMBEDDED_CUDA_FP16_CPP
463-
"${CMAKE_CURRENT_BINARY_DIR}/generated_jit_lto/embedded_cuda_fp16.cpp"
464-
)
465-
file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/generated_jit_lto")
466-
add_custom_command(
467-
OUTPUT ${CUVS_EMBEDDED_CUDA_FP16_CPP}
468-
COMMAND
469-
${CMAKE_COMMAND} "-DINPUT=${CUVS_BUILD_TIME_CUDA_FP16_H}"
470-
"-DOUTPUT=${CUVS_EMBEDDED_CUDA_FP16_CPP}" -P
471-
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/embed_cuda_fp16.cmake"
472-
DEPENDS "${CUVS_BUILD_TIME_CUDA_FP16_H}"
473-
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/embed_cuda_fp16.cmake"
474-
COMMENT
475-
"Embedding cuda_fp16.h from CUDA toolkit for NVRTC (rebuilt when toolkit header changes)"
476-
VERBATIM
477-
)
478-
479455
set(jit_lto_files
480-
${CUVS_EMBEDDED_CUDA_FP16_CPP}
481456
${interleaved_scan_files}
482457
${metric_files}
483458
${filter_files}
@@ -767,10 +742,6 @@ if(NOT BUILD_CPU_ONLY)
767742
${jit_lto_files}
768743
)
769744

770-
set_source_files_properties("${CUVS_EMBEDDED_CUDA_FP16_CPP}" PROPERTIES GENERATED TRUE)
771-
add_custom_target(cuvs_embed_cuda_fp16_header DEPENDS "${CUVS_EMBEDDED_CUDA_FP16_CPP}")
772-
add_dependencies(cuvs_objs cuvs_embed_cuda_fp16_header)
773-
774745
set_target_properties(
775746
cuvs_objs
776747
PROPERTIES CXX_STANDARD 20

cpp/cmake/embed_cuda_fp16.cmake

Lines changed: 0 additions & 33 deletions
This file was deleted.

cpp/include/cuvs/detail/jit_lto/embedded_cuda_fp16.hpp

Lines changed: 0 additions & 13 deletions
This file was deleted.

cpp/include/cuvs/neighbors/ivf_flat.hpp

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3062,10 +3062,11 @@ namespace experimental::udf {
30623062
/**
30633063
* @brief Wrapper for vector elements that provides both packed and unpacked access.
30643064
*
3065-
* For float/half: trivial wrapper around scalar values
3065+
* For float: trivial wrapper around scalar values
30663066
* For int8/uint8 with Veclen > 1: wraps packed bytes in a 32-bit word
30673067
*
3068-
* @tparam T Data type (float, __half, int8_t, uint8_t)
3068+
* @tparam T Data type (float, int8_t, uint8_t). Fp16 vector elements are not supported for UDFs
3069+
* at this time (see `metric_interface` static_assert when `cuda_fp16.h` is available).
30693070
* @tparam AccT Storage/accumulator type (float, __half, int32_t, uint32_t)
30703071
* @tparam Veclen Vector length (1, 2, 4, 8, 16)
30713072
*/
@@ -3130,6 +3131,13 @@ template <typename T, typename AccT, int Veclen = 1>
31303131
struct metric_interface {
31313132
using point_type = point<T, AccT, Veclen>;
31323133

3134+
#if CUVS_IVF_FLAT_UDF_HAS_CUDA_FP16
3135+
static_assert(
3136+
!(std::is_same_v<std::remove_cv_t<T>, __half> || std::is_same_v<std::remove_cv_t<T>, half>),
3137+
"IVF-Flat custom metric UDF does not support fp16 (__half / half) at this time; do not set "
3138+
"search_params.metric_udf for fp16 indices.");
3139+
#endif
3140+
31333141
virtual __device__ void operator()(AccT& acc, point_type x, point_type y) = 0;
31343142
virtual ~metric_interface() = default;
31353143
};
@@ -3380,8 +3388,6 @@ __device__ __forceinline__ AccT max_elem(point<T, AccT, V> x, point<T, AccT, V>
33803388
* the necessary types and utilities inline.
33813389
*/
33823390
constexpr std::string_view jit_preamble_code = R"(
3383-
#include <cuda_fp16.h>
3384-
33853391
/* Fixed-width integer types for nvrtc */
33863392
using int8_t = signed char;
33873393
using uint8_t = unsigned char;

cpp/src/detail/jit_lto/NVRTCLTOFragmentCompiler.cpp

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
*/
55

66
#include <cuvs/detail/jit_lto/NVRTCLTOFragmentCompiler.hpp>
7-
#include <cuvs/detail/jit_lto/embedded_cuda_fp16.hpp>
87

98
#include <mutex>
109

@@ -37,8 +36,6 @@ NVRTCLTOFragmentCompiler::NVRTCLTOFragmentCompiler()
3736
std::string{"-rdc=true"},
3837
std::string{"--std=c++20"},
3938
std::string{"-default-device"},
40-
// cuda_fp16.h skips stdlib / vector includes when compiling for NVRTC
41-
std::string{"-D__CUDACC_RTC__"},
4239
};
4340
}
4441

@@ -62,12 +59,9 @@ std::unique_ptr<UDFFatbinFragment> NVRTCLTOFragmentCompiler::compile(std::string
6259
return std::make_unique<UDFFatbinFragment>(key, it->second);
6360
}
6461

65-
char const* const udf_headers[] = {cuvs::detail::jit_lto::k_nvrtc_embedded_cuda_fp16_h};
66-
char const* const udf_include_names[] = {"cuda_fp16.h"};
67-
6862
nvrtcProgram prog;
69-
NVRTC_SAFE_CALL(nvrtcCreateProgram(
70-
&prog, code.c_str(), "nvrtc_lto_fragment", 1, udf_headers, udf_include_names));
63+
NVRTC_SAFE_CALL(
64+
nvrtcCreateProgram(&prog, code.c_str(), "nvrtc_lto_fragment", 0, nullptr, nullptr));
7165

7266
// Convert std::vector<std::string> to std::vector<const char*> for nvrtc API
7367
std::vector<const char*> opts;

cpp/tests/neighbors/ann_ivf_flat/test_udf.cu

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ CUVS_METRIC(custom_l2, { acc += squared_diff(x, y); })
3131
// ============================================================================
3232

3333
template <typename T>
34-
concept udf_test_fp_element = std::same_as<T, float> || std::same_as<T, __half>;
34+
concept udf_test_fp_element = std::same_as<T, float>;
3535

3636
template <typename T>
3737
concept udf_test_int_byte_element = std::same_as<T, int8_t> || std::same_as<T, uint8_t>;
@@ -46,7 +46,7 @@ struct TestDataTraits<T> {
4646

4747
static std::vector<T> database()
4848
{
49-
// 4-dimensional float/__half dataset
49+
// 4-dimensional float dataset
5050
// Vectors arranged for easy distance verification:
5151
// db[0] = [0, 0, 0, 0] - origin
5252
// db[1] = [1, 0, 0, 0] - unit along x
@@ -292,7 +292,7 @@ class IvfFlatUdfTest : public ::testing::Test {
292292
uint32_t n_probes_;
293293
};
294294

295-
using TestTypes = ::testing::Types<float, __half, int8_t, uint8_t>;
295+
using TestTypes = ::testing::Types<float, int8_t, uint8_t>;
296296
TYPED_TEST_SUITE(IvfFlatUdfTest, TestTypes);
297297

298298
// ============================================================================

0 commit comments

Comments
 (0)