Skip to content

Commit f379229

Browse files
committed
Test rtcx refactoring
1 parent 4e307af commit f379229

25 files changed

Lines changed: 130 additions & 125 deletions

cpp/cmake/thirdparty/get_rtcx.cmake

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,15 @@ function(find_and_configure_rtcx VERSION)
2222
BUILD_EXPORT_SET cuvs-static-exports
2323
INSTALL_EXPORT_SET cuvs-static-exports
2424
CPM_ARGS
25-
GIT_REPOSITORY https://github.com/rapidsai/librtcx
26-
GIT_TAG b5e753e9427e331c02f8c370143cb0d5f40da0fd
25+
GIT_REPOSITORY https://github.com/arhag23/librtcx
26+
GIT_TAG 67b5e05f5282fca9ad04d44b7dc93d75d89f1ad1
2727
GIT_SHALLOW FALSE
2828
)
2929

3030
# When CPM fetches from source (add_subdirectory), generate_jit_lto_kernels.cmake is not
3131
# auto-included. Include it explicitly so necessary functions are available.
3232
if(rtcx_ADDED OR DEFINED CPM_rtcx_SOURCE)
33-
include("${rtcx_SOURCE_DIR}/generate_jit_lto_kernels.cmake")
33+
include("${rtcx_SOURCE_DIR}/cmake/modules/generate_jit_lto_kernels.cmake")
3434
endif()
3535
endfunction()
3636

cpp/src/distance/detail/pairwise_matrix/jit_lto_kernels/pairwise_matrix_planner.hpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55

66
#pragma once
77

8-
#include <AlgorithmPlanner.hpp>
98
#include <cuvs/detail/jit_lto/pairwise_matrix/pairwise_matrix_fragments.hpp>
9+
#include <rtcx/algorithm_planner.hpp>
1010

1111
namespace cuvs::distance::detail {
1212

@@ -20,7 +20,7 @@ template <typename DistanceTag_,
2020
typename FinOpTag_,
2121
typename LayoutTag_,
2222
int Veclen_>
23-
struct PairwiseMatrixPlanner : AlgorithmPlanner {
23+
struct PairwiseMatrixPlanner : rtcx::algorithm_planner {
2424
using DistanceTag = DistanceTag_;
2525
using DataTag = DataTag_;
2626
using AccTag = AccTag_;
@@ -31,9 +31,12 @@ struct PairwiseMatrixPlanner : AlgorithmPlanner {
3131

3232
static constexpr int Veclen = Veclen_;
3333

34-
inline static LauncherJitCache launcher_jit_cache{};
34+
inline static rtcx::launcher_jit_cache launcher_jit_cache{};
3535

36-
PairwiseMatrixPlanner() : AlgorithmPlanner(kPairwiseMatrixJitEntrypoint, launcher_jit_cache) {}
36+
PairwiseMatrixPlanner()
37+
: rtcx::algorithm_planner(kPairwiseMatrixJitEntrypoint, launcher_jit_cache)
38+
{
39+
}
3740

3841
void add_entrypoint()
3942
{

cpp/src/neighbors/detail/cagra/jit_lto_kernels/cagra_jit_launcher_factory.hpp

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@
1212
#include "search_multi_kernel_planner.hpp"
1313
#include "search_single_cta_planner.hpp"
1414

15-
#include <AlgorithmLauncher.hpp>
1615
#include <cuvs/detail/jit_lto/cagra/cagra_fragments.hpp>
1716
#include <cuvs/distance/distance.hpp>
17+
#include <rtcx/algorithm_launcher.hpp>
1818

1919
#include <memory>
2020
#include <type_traits>
@@ -34,12 +34,12 @@ template <typename DataTag,
3434
typename IndexT,
3535
typename DistanceT,
3636
typename SourceIndexT>
37-
std::shared_ptr<AlgorithmLauncher> build_single_cta_launcher(
37+
std::shared_ptr<rtcx::algorithm_launcher> build_single_cta_launcher(
3838
const dataset_descriptor_host<DataT, IndexT, DistanceT>& dataset_desc,
3939
bool topk_by_bitonic_sort,
4040
bool bitonic_sort_and_merge_multi_warps,
4141
bool persistent,
42-
std::unique_ptr<UDFFatbinFragment> sample_filter_udf_fragment)
42+
std::unique_ptr<rtcx::udf_fatbin_fragment> sample_filter_udf_fragment)
4343
{
4444
single_cta_search::CagraSingleCtaSearchPlanner<DataTag,
4545
IndexTag,
@@ -90,9 +90,9 @@ template <typename DataTag,
9090
typename IndexT,
9191
typename DistanceT,
9292
typename SourceIndexT>
93-
std::shared_ptr<AlgorithmLauncher> build_multi_cta_launcher(
93+
std::shared_ptr<rtcx::algorithm_launcher> build_multi_cta_launcher(
9494
const dataset_descriptor_host<DataT, IndexT, DistanceT>& dataset_desc,
95-
std::unique_ptr<UDFFatbinFragment> sample_filter_udf_fragment)
95+
std::unique_ptr<rtcx::udf_fatbin_fragment> sample_filter_udf_fragment)
9696
{
9797
multi_cta_search::CagraMultiCtaSearchPlanner<DataTag,
9898
IndexTag,
@@ -139,7 +139,7 @@ template <typename DataTag,
139139
typename IndexT,
140140
typename DistanceT,
141141
typename SourceIndexT>
142-
std::shared_ptr<AlgorithmLauncher> build_single_cta_mp_launcher(
142+
std::shared_ptr<rtcx::algorithm_launcher> build_single_cta_mp_launcher(
143143
const dataset_descriptor_host<DataT, IndexT, DistanceT>& dataset_desc,
144144
bool topk_by_bitonic_sort,
145145
bool bitonic_sort_and_merge_multi_warps)
@@ -191,7 +191,7 @@ template <typename DataTag,
191191
typename IndexT,
192192
typename DistanceT,
193193
typename SourceIndexT>
194-
std::shared_ptr<AlgorithmLauncher> build_multi_cta_mp_launcher(
194+
std::shared_ptr<rtcx::algorithm_launcher> build_multi_cta_mp_launcher(
195195
const dataset_descriptor_host<DataT, IndexT, DistanceT>& dataset_desc)
196196
{
197197
multi_cta_search::CagraMultiCtaMpSearchPlanner<DataTag,
@@ -239,10 +239,10 @@ template <typename DataTag,
239239
typename IndexT,
240240
typename DistanceT,
241241
typename SourceIndexT>
242-
std::shared_ptr<AlgorithmLauncher> build_multi_kernel_launcher(
242+
std::shared_ptr<rtcx::algorithm_launcher> build_multi_kernel_launcher(
243243
const dataset_descriptor_host<DataT, IndexT, DistanceT>& dataset_desc,
244244
const char* linked_kernel_name,
245-
std::unique_ptr<UDFFatbinFragment> sample_filter_udf_fragment)
245+
std::unique_ptr<rtcx::udf_fatbin_fragment> sample_filter_udf_fragment)
246246
{
247247
multi_kernel_search::CagraMultiKernelSearchPlanner<DataTag,
248248
IndexTag,
@@ -291,8 +291,8 @@ template <typename DataTag,
291291
typename IndexT,
292292
typename DistanceT,
293293
typename SourceIndexT>
294-
std::shared_ptr<AlgorithmLauncher> build_apply_filter_only_launcher(
295-
std::unique_ptr<UDFFatbinFragment> sample_filter_udf_fragment)
294+
std::shared_ptr<rtcx::algorithm_launcher> build_apply_filter_only_launcher(
295+
std::unique_ptr<rtcx::udf_fatbin_fragment> sample_filter_udf_fragment)
296296
{
297297
multi_kernel_search::CagraMultiKernelSearchPlanner<DataTag,
298298
IndexTag,
@@ -309,20 +309,20 @@ std::shared_ptr<AlgorithmLauncher> build_apply_filter_only_launcher(
309309

310310
} // namespace cagra_jit_launcher_factory_detail
311311

312-
/// Build a JIT AlgorithmLauncher for single-CTA CAGRA search (runtime VPQ / metric → tag
312+
/// Build a JIT rtcx::algorithm_launcher for single-CTA CAGRA search (runtime VPQ / metric → tag
313313
/// dispatch). `SampleFilterJitTag` is `cuvs::neighbors::detail::tag_filter_none`,
314314
/// `tag_filter_bitset`, or use `sample_filter_jit_tag_t<SAMPLE_FILTER_T>`.
315315
template <typename DataT,
316316
typename IndexT,
317317
typename DistanceT,
318318
typename SourceIndexT,
319319
typename SampleFilterJitTag>
320-
std::shared_ptr<AlgorithmLauncher> make_cagra_single_cta_jit_launcher(
320+
std::shared_ptr<rtcx::algorithm_launcher> make_cagra_single_cta_jit_launcher(
321321
const dataset_descriptor_host<DataT, IndexT, DistanceT>& dataset_desc,
322322
bool topk_by_bitonic_sort,
323323
bool bitonic_sort_and_merge_multi_warps,
324324
bool persistent,
325-
std::unique_ptr<UDFFatbinFragment> sample_filter_udf_fragment = nullptr)
325+
std::unique_ptr<rtcx::udf_fatbin_fragment> sample_filter_udf_fragment = nullptr)
326326
{
327327
using DataTag = decltype(get_data_type_tag<DataT>());
328328
using IndexTag = decltype(get_index_type_tag<IndexT>());
@@ -389,15 +389,15 @@ std::shared_ptr<AlgorithmLauncher> make_cagra_single_cta_jit_launcher(
389389
std::move(sample_filter_udf_fragment));
390390
}
391391

392-
/// Build a JIT AlgorithmLauncher for multi-CTA CAGRA search.
392+
/// Build a JIT rtcx::algorithm_launcher for multi-CTA CAGRA search.
393393
template <typename DataT,
394394
typename IndexT,
395395
typename DistanceT,
396396
typename SourceIndexT,
397397
typename SampleFilterJitTag>
398-
std::shared_ptr<AlgorithmLauncher> make_cagra_multi_cta_jit_launcher(
398+
std::shared_ptr<rtcx::algorithm_launcher> make_cagra_multi_cta_jit_launcher(
399399
const dataset_descriptor_host<DataT, IndexT, DistanceT>& dataset_desc,
400-
std::unique_ptr<UDFFatbinFragment> sample_filter_udf_fragment = nullptr)
400+
std::unique_ptr<rtcx::udf_fatbin_fragment> sample_filter_udf_fragment = nullptr)
401401
{
402402
using DataTag = decltype(get_data_type_tag<DataT>());
403403
using IndexTag = decltype(get_index_type_tag<IndexT>());
@@ -452,13 +452,13 @@ std::shared_ptr<AlgorithmLauncher> make_cagra_multi_cta_jit_launcher(
452452
dataset_desc, std::move(sample_filter_udf_fragment));
453453
}
454454

455-
/// Build a JIT AlgorithmLauncher for the multi-partition single-CTA CAGRA search.
455+
/// Build a JIT rtcx::algorithm_launcher for the multi-partition single-CTA CAGRA search.
456456
template <typename DataT,
457457
typename IndexT,
458458
typename DistanceT,
459459
typename SourceIndexT,
460460
typename SampleFilterJitTag>
461-
std::shared_ptr<AlgorithmLauncher> make_cagra_single_cta_mp_jit_launcher(
461+
std::shared_ptr<rtcx::algorithm_launcher> make_cagra_single_cta_mp_jit_launcher(
462462
const dataset_descriptor_host<DataT, IndexT, DistanceT>& dataset_desc,
463463
bool topk_by_bitonic_sort,
464464
bool bitonic_sort_and_merge_multi_warps)
@@ -516,13 +516,13 @@ std::shared_ptr<AlgorithmLauncher> make_cagra_single_cta_mp_jit_launcher(
516516
dataset_desc, topk_by_bitonic_sort, bitonic_sort_and_merge_multi_warps);
517517
}
518518

519-
/// Build a JIT AlgorithmLauncher for the multi-partition multi-CTA CAGRA search.
519+
/// Build a JIT rtcx::algorithm_launcher for the multi-partition multi-CTA CAGRA search.
520520
template <typename DataT,
521521
typename IndexT,
522522
typename DistanceT,
523523
typename SourceIndexT,
524524
typename SampleFilterJitTag>
525-
std::shared_ptr<AlgorithmLauncher> make_cagra_multi_cta_mp_jit_launcher(
525+
std::shared_ptr<rtcx::algorithm_launcher> make_cagra_multi_cta_mp_jit_launcher(
526526
const dataset_descriptor_host<DataT, IndexT, DistanceT>& dataset_desc)
527527
{
528528
using DataTag = decltype(get_data_type_tag<DataT>());
@@ -577,8 +577,8 @@ std::shared_ptr<AlgorithmLauncher> make_cagra_multi_cta_mp_jit_launcher(
577577
SourceIndexT>(dataset_desc);
578578
}
579579

580-
/// Build a JIT AlgorithmLauncher for multi-kernel CAGRA helpers that need `setup_workspace` and
581-
/// `compute_distance` linked (e.g. `random_pickup`, `compute_distance_to_child_nodes`). For
580+
/// Build a JIT rtcx::algorithm_launcher for multi-kernel CAGRA helpers that need `setup_workspace`
581+
/// and `compute_distance` linked (e.g. `random_pickup`, `compute_distance_to_child_nodes`). For
582582
/// `apply_filter_kernel` only, use `make_cagra_apply_filter_jit_launcher` instead. Use
583583
/// `SampleFilterJitTag = tag_cagra_jit_sample_filter_link_absent` (default) when the kernel does
584584
/// not link `sample_filter`; otherwise `sample_filter_jit_tag_t<SAMPLE_FILTER_T>` or a
@@ -588,10 +588,10 @@ template <typename DataT,
588588
typename DistanceT,
589589
typename SourceIndexT,
590590
typename SampleFilterJitTag = tag_cagra_jit_sample_filter_link_absent>
591-
std::shared_ptr<AlgorithmLauncher> make_cagra_multi_kernel_jit_launcher(
591+
std::shared_ptr<rtcx::algorithm_launcher> make_cagra_multi_kernel_jit_launcher(
592592
const dataset_descriptor_host<DataT, IndexT, DistanceT>& dataset_desc,
593593
const char* linked_kernel_name,
594-
std::unique_ptr<UDFFatbinFragment> sample_filter_udf_fragment = nullptr)
594+
std::unique_ptr<rtcx::udf_fatbin_fragment> sample_filter_udf_fragment = nullptr)
595595
{
596596
using DataTag = decltype(get_data_type_tag<DataT>());
597597
using IndexTag = decltype(get_index_type_tag<IndexT>());
@@ -655,9 +655,9 @@ template <typename DataT,
655655
typename DistanceT,
656656
typename SourceIndexT,
657657
typename SampleFilterJitTag>
658-
std::shared_ptr<AlgorithmLauncher> make_cagra_apply_filter_jit_launcher(
658+
std::shared_ptr<rtcx::algorithm_launcher> make_cagra_apply_filter_jit_launcher(
659659
const dataset_descriptor_host<DataT, IndexT, DistanceT>& dataset_desc,
660-
std::unique_ptr<UDFFatbinFragment> sample_filter_udf_fragment = nullptr)
660+
std::unique_ptr<rtcx::udf_fatbin_fragment> sample_filter_udf_fragment = nullptr)
661661
{
662662
using DataTag = decltype(get_data_type_tag<DataT>());
663663
using IndexTag = decltype(get_index_type_tag<IndexT>());

cpp/src/neighbors/detail/cagra/jit_lto_kernels/cagra_planner_base.hpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@
55

66
#pragma once
77

8-
#include <AlgorithmPlanner.hpp>
98
#include <cuvs/detail/jit_lto/cagra/cagra_fragments.hpp>
109
#include <cuvs/detail/jit_lto/common_fragments.hpp>
1110
#include <cuvs/distance/distance.hpp>
1211
#include <raft/core/error.hpp>
1312
#include <raft/core/logger.hpp>
13+
#include <rtcx/algorithm_planner.hpp>
1414

1515
#include <cstdint>
1616
#include <memory>
@@ -25,16 +25,16 @@ template <typename DataTag_,
2525
typename QueryTag_,
2626
typename CodebookTag_,
2727
typename SampleFilterJitTag_ = tag_cagra_jit_sample_filter_link_absent>
28-
struct CagraPlannerBase : AlgorithmPlanner {
28+
struct CagraPlannerBase : rtcx::algorithm_planner {
2929
using DataTag = DataTag_;
3030
using IndexTag = IndexTag_;
3131
using DistanceTag = DistanceTag_;
3232
using QueryTag = QueryTag_;
3333
using CodebookTag = CodebookTag_;
3434
using SampleFilterJitTag = SampleFilterJitTag_;
3535

36-
explicit CagraPlannerBase(std::string entrypoint, LauncherJitCache& jit_cache)
37-
: AlgorithmPlanner(std::move(entrypoint), jit_cache)
36+
explicit CagraPlannerBase(std::string entrypoint, rtcx::launcher_jit_cache& jit_cache)
37+
: rtcx::algorithm_planner(std::move(entrypoint), jit_cache)
3838
{
3939
}
4040

@@ -385,7 +385,8 @@ struct CagraPlannerBase : AlgorithmPlanner {
385385
static_cast<unsigned>(dataset_block_dim));
386386
}
387387

388-
void add_sample_filter_device_function(std::unique_ptr<UDFFatbinFragment> udf_fragment = nullptr)
388+
void add_sample_filter_device_function(
389+
std::unique_ptr<rtcx::udf_fatbin_fragment> udf_fragment = nullptr)
389390
{
390391
if constexpr (std::is_same_v<SampleFilterJitTag_, tag_cagra_jit_sample_filter_link_absent>) {
391392
RAFT_EXPECTS(udf_fragment == nullptr, "Unexpected CAGRA sample-filter UDF fragment");

cpp/src/neighbors/detail/cagra/jit_lto_kernels/kernel_def.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
namespace cuvs::neighbors::cagra::detail {
2121

2222
// Function types for extern "C" __global__ JIT entry points — must match cudaLibraryGetKernel /
23-
// AlgorithmLauncher::dispatch signatures exactly (see static_assert in each *_kernel.cu).
23+
// rtcx::algorithm_launcher::dispatch signatures exactly (see static_assert in each *_kernel.cu).
2424

2525
template <typename DataT, typename IndexT, typename DistanceT, typename SourceIndexT>
2626
using search_single_cta_kernel_func_t =

cpp/src/neighbors/detail/cagra/jit_lto_kernels/sample_filter_udf.cuh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77

88
#include "../cagra_filter_payload.hpp"
99

10-
#include <NVRTCLTOFragmentCompiler.hpp>
1110
#include <raft/core/error.hpp>
11+
#include <rtcx/nvrtc_lto_fragment_compiler.hpp>
1212

1313
#include <cstdint>
1414
#include <memory>
@@ -66,7 +66,7 @@ __device__ bool sample_filter<source_index_t>(uint32_t query_id,
6666
}
6767

6868
template <typename SourceIndexT, typename SampleFilterT>
69-
std::unique_ptr<UDFFatbinFragment> make_cagra_sample_filter_udf_fragment(
69+
std::unique_ptr<rtcx::udf_fatbin_fragment> make_cagra_sample_filter_udf_fragment(
7070
const SampleFilterT& sample_filter)
7171
{
7272
const auto* udf = get_cagra_udf_filter(sample_filter);
@@ -83,7 +83,7 @@ std::unique_ptr<UDFFatbinFragment> make_cagra_sample_filter_udf_fragment(
8383
key += udf->function_name;
8484
key += ":";
8585
key += code;
86-
return nvrtc_compiler().compile(key, code);
86+
return rtcx::nvrtc_compiler().compile(key, code);
8787
}
8888

8989
} // namespace cuvs::neighbors::cagra::detail

cpp/src/neighbors/detail/cagra/jit_lto_kernels/search_multi_cta_planner.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ template <typename DataTag,
2020
typename SampleFilterJitTag>
2121
struct CagraMultiCtaSearchPlanner
2222
: CagraPlannerBase<DataTag, IndexTag, DistanceTag, QueryTag, CodebookTag, SampleFilterJitTag> {
23-
static inline LauncherJitCache launcher_jit_cache{};
23+
static inline rtcx::launcher_jit_cache launcher_jit_cache{};
2424

2525
CagraMultiCtaSearchPlanner(cuvs::distance::DistanceType /*metric*/,
2626
uint32_t /*team_size*/,
@@ -49,7 +49,7 @@ template <typename DataTag,
4949
typename SampleFilterJitTag>
5050
struct CagraMultiCtaMpSearchPlanner
5151
: CagraPlannerBase<DataTag, IndexTag, DistanceTag, QueryTag, CodebookTag, SampleFilterJitTag> {
52-
static inline LauncherJitCache launcher_jit_cache{};
52+
static inline rtcx::launcher_jit_cache launcher_jit_cache{};
5353

5454
CagraMultiCtaMpSearchPlanner(cuvs::distance::DistanceType /*metric*/,
5555
uint32_t /*team_size*/,

cpp/src/neighbors/detail/cagra/jit_lto_kernels/search_multi_kernel_planner.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* SPDX-FileCopyrightText: Copyright (c) 2026, NVIDIA CORPORATION.
2+
* SPDX-FileCopyrightText: Copyright (c) 2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
33
* SPDX-License-Identifier: Apache-2.0
44
*/
55

@@ -21,7 +21,7 @@ template <typename DataTag,
2121
typename SampleFilterJitTag = tag_cagra_jit_sample_filter_link_absent>
2222
struct CagraMultiKernelSearchPlanner
2323
: CagraPlannerBase<DataTag, IndexTag, DistanceTag, QueryTag, CodebookTag, SampleFilterJitTag> {
24-
static inline LauncherJitCache launcher_jit_cache{};
24+
static inline rtcx::launcher_jit_cache launcher_jit_cache{};
2525

2626
/// Kernels that only need `sample_filter` + one linked TU (e.g. `apply_filter_kernel`): no
2727
/// `setup_workspace` / `compute_distance` fragments. Metric / team / VPQ are unused.

cpp/src/neighbors/detail/cagra/jit_lto_kernels/search_single_cta_planner.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ template <typename DataTag,
2121
typename SampleFilterJitTag>
2222
struct CagraSingleCtaSearchPlanner
2323
: CagraPlannerBase<DataTag, IndexTag, DistanceTag, QueryTag, CodebookTag, SampleFilterJitTag> {
24-
static inline LauncherJitCache launcher_jit_cache{};
24+
static inline rtcx::launcher_jit_cache launcher_jit_cache{};
2525

2626
CagraSingleCtaSearchPlanner(cuvs::distance::DistanceType /*metric*/,
2727
bool /*topk_by_bitonic_sort*/,
@@ -114,7 +114,7 @@ template <typename DataTag,
114114
typename SampleFilterJitTag>
115115
struct CagraSingleCtaMpSearchPlanner
116116
: CagraPlannerBase<DataTag, IndexTag, DistanceTag, QueryTag, CodebookTag, SampleFilterJitTag> {
117-
static inline LauncherJitCache launcher_jit_cache{};
117+
static inline rtcx::launcher_jit_cache launcher_jit_cache{};
118118

119119
CagraSingleCtaMpSearchPlanner(cuvs::distance::DistanceType /*metric*/,
120120
bool /*topk_by_bitonic_sort*/,

0 commit comments

Comments
 (0)