Skip to content

Commit

Permalink
Renaming remaining namespaces and files
Browse files Browse the repository at this point in the history
  • Loading branch information
cjnolet committed Nov 21, 2023
1 parent 1f03abe commit 4c04a0e
Show file tree
Hide file tree
Showing 482 changed files with 3,631 additions and 3,702 deletions.
21 changes: 10 additions & 11 deletions cpp/bench/ann/src/common/ann_types.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#include <string>
#include <vector>

namespace raft::bench::ann {
namespace cuvs::bench {

enum Objective {
THROUGHPUT, // See how many vectors we can push through
Expand All @@ -43,9 +43,9 @@ enum class Metric {
inline auto parse_metric(const std::string& metric_str) -> Metric
{
if (metric_str == "inner_product") {
return raft::bench::ann::Metric::kInnerProduct;
return cuvs::bench::Metric::kInnerProduct;
} else if (metric_str == "euclidean") {
return raft::bench::ann::Metric::kEuclidean;
return cuvs::bench::Metric::kEuclidean;
} else {
throw std::runtime_error("invalid metric: '" + metric_str + "'");
}
Expand Down Expand Up @@ -127,12 +127,11 @@ class ANN : public AnnBase {
virtual void set_search_dataset(const T* /*dataset*/, size_t /*nrow*/){};
};

} // namespace raft::bench::ann
} // namespace cuvs::bench

#define REGISTER_ALGO_INSTANCE(DataT) \
template auto raft::bench::ann::create_algo<DataT>( \
const std::string&, const std::string&, int, const nlohmann::json&, const std::vector<int>&) \
->std::unique_ptr<raft::bench::ann::ANN<DataT>>; \
template auto raft::bench::ann::create_search_param<DataT>(const std::string&, \
const nlohmann::json&) \
->std::unique_ptr<typename raft::bench::ann::ANN<DataT>::AnnSearchParam>;
#define REGISTER_ALGO_INSTANCE(DataT) \
template auto cuvs::bench::create_algo<DataT>( \
const std::string&, const std::string&, int, const nlohmann::json&, const std::vector<int>&) \
->std::unique_ptr<cuvs::bench::ANN<DataT>>; \
template auto cuvs::bench::create_search_param<DataT>(const std::string&, const nlohmann::json&) \
->std::unique_ptr<typename cuvs::bench::ANN<DataT>::AnnSearchParam>;
10 changes: 5 additions & 5 deletions cpp/bench/ann/src/common/benchmark.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
#include <dlfcn.h>
#include <filesystem>

namespace raft::bench::ann {
namespace cuvs::bench {

struct lib_handle {
void* handle{nullptr};
Expand Down Expand Up @@ -72,7 +72,7 @@ auto create_algo(const std::string& algo,
const std::string& distance,
int dim,
const nlohmann::json& conf,
const std::vector<int>& dev_list) -> std::unique_ptr<raft::bench::ann::ANN<T>>
const std::vector<int>& dev_list) -> std::unique_ptr<cuvs::bench::ANN<T>>
{
static auto fname = get_fun_name(reinterpret_cast<void*>(&create_algo<T>));
auto handle = load_lib(algo);
Expand All @@ -85,7 +85,7 @@ auto create_algo(const std::string& algo,
}

template <typename T>
std::unique_ptr<typename raft::bench::ann::ANN<T>::AnnSearchParam> create_search_param(
std::unique_ptr<typename cuvs::bench::ANN<T>::AnnSearchParam> create_search_param(
const std::string& algo, const nlohmann::json& conf)
{
static auto fname = get_fun_name(reinterpret_cast<void*>(&create_search_param<T>));
Expand All @@ -98,12 +98,12 @@ std::unique_ptr<typename raft::bench::ann::ANN<T>::AnnSearchParam> create_search
return fun(algo, conf);
}

}; // namespace raft::bench::ann
}; // namespace cuvs::bench

REGISTER_ALGO_INSTANCE(float);
REGISTER_ALGO_INSTANCE(std::int8_t);
REGISTER_ALGO_INSTANCE(std::uint8_t);

#include "benchmark.hpp"

int main(int argc, char** argv) { return raft::bench::ann::run_main(argc, argv); }
int main(int argc, char** argv) { return cuvs::bench::run_main(argc, argv); }
4 changes: 2 additions & 2 deletions cpp/bench/ann/src/common/benchmark.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
#include <string>
#include <unistd.h>
#include <vector>
namespace raft::bench::ann {
namespace cuvs::bench {

std::mutex init_mutex;
std::condition_variable cond_var;
Expand Down Expand Up @@ -711,4 +711,4 @@ inline auto run_main(int argc, char** argv) -> int
current_algo.reset();
return 0;
}
}; // namespace raft::bench::ann
}; // namespace cuvs::bench
4 changes: 2 additions & 2 deletions cpp/bench/ann/src/common/conf.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
#define JSON_DIAGNOSTICS 1
#include <nlohmann/json.hpp>

namespace raft::bench::ann {
namespace cuvs::bench {

class Configuration {
public:
Expand Down Expand Up @@ -153,4 +153,4 @@ class Configuration {
std::vector<Index> indices_;
};

} // namespace raft::bench::ann
} // namespace cuvs::bench
4 changes: 2 additions & 2 deletions cpp/bench/ann/src/common/cuda_stub.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ typedef void* cudaStream_t;
typedef void* cudaEvent_t;
#endif

namespace raft::bench::ann {
namespace cuvs::bench {

struct cuda_lib_handle {
void* handle{nullptr};
Expand Down Expand Up @@ -231,4 +231,4 @@ RAFT_DECLARE_CUDART(cudaGetDeviceProperties);
#undef RAFT_DECLARE_CUDART
#endif

}; // namespace raft::bench::ann
}; // namespace cuvs::bench
4 changes: 2 additions & 2 deletions cpp/bench/ann/src/common/dataset.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ typedef uint16_t half;
#include <type_traits>
#include <vector>

namespace raft::bench::ann {
namespace cuvs::bench {

// http://big-ann-benchmarks.com/index.html:
// binary format that starts with 8 bytes of data consisting of num_points(uint32_t)
Expand Down Expand Up @@ -498,4 +498,4 @@ void BinDataset<T>::map_base_set_() const
this->mapped_base_set_ = base_file_.map();
}

} // namespace raft::bench::ann
} // namespace cuvs::bench
4 changes: 2 additions & 2 deletions cpp/bench/ann/src/common/util.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
#include <filesystem>
#include <functional>

namespace raft::bench::ann {
namespace cuvs::bench {

template <typename T>
struct buf {
Expand Down Expand Up @@ -345,4 +345,4 @@ void log_error(Ts&&... vs)
log_("error", std::forward<Ts>(vs)...);
}

} // namespace raft::bench::ann
} // namespace cuvs::bench
58 changes: 29 additions & 29 deletions cpp/bench/ann/src/faiss/faiss_cpu_benchmark.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,26 +27,26 @@
#define JSON_DIAGNOSTICS 1
#include <nlohmann/json.hpp>

namespace raft::bench::ann {
namespace cuvs::bench {

template <typename T>
void parse_base_build_param(const nlohmann::json& conf,
typename raft::bench::ann::FaissCpu<T>::BuildParam& param)
typename cuvs::bench::FaissCpu<T>::BuildParam& param)
{
param.nlist = conf.at("nlist");
if (conf.contains("ratio")) { param.ratio = conf.at("ratio"); }
}

template <typename T>
void parse_build_param(const nlohmann::json& conf,
typename raft::bench::ann::FaissCpuIVFFlat<T>::BuildParam& param)
typename cuvs::bench::FaissCpuIVFFlat<T>::BuildParam& param)
{
parse_base_build_param<T>(conf, param);
}

template <typename T>
void parse_build_param(const nlohmann::json& conf,
typename raft::bench::ann::FaissCpuIVFPQ<T>::BuildParam& param)
typename cuvs::bench::FaissCpuIVFPQ<T>::BuildParam& param)
{
parse_base_build_param<T>(conf, param);
param.M = conf.at("M");
Expand All @@ -64,36 +64,36 @@ void parse_build_param(const nlohmann::json& conf,

template <typename T>
void parse_build_param(const nlohmann::json& conf,
typename raft::bench::ann::FaissCpuIVFSQ<T>::BuildParam& param)
typename cuvs::bench::FaissCpuIVFSQ<T>::BuildParam& param)
{
parse_base_build_param<T>(conf, param);
param.quantizer_type = conf.at("quantizer_type");
}

template <typename T>
void parse_search_param(const nlohmann::json& conf,
typename raft::bench::ann::FaissCpu<T>::SearchParam& param)
typename cuvs::bench::FaissCpu<T>::SearchParam& param)
{
param.nprobe = conf.at("nprobe");
if (conf.contains("refine_ratio")) { param.refine_ratio = conf.at("refine_ratio"); }
if (conf.contains("numThreads")) { param.num_threads = conf.at("numThreads"); }
}

template <typename T, template <typename> class Algo>
std::unique_ptr<raft::bench::ann::ANN<T>> make_algo(raft::bench::ann::Metric metric,
int dim,
const nlohmann::json& conf)
std::unique_ptr<cuvs::bench::ANN<T>> make_algo(cuvs::bench::Metric metric,
int dim,
const nlohmann::json& conf)
{
typename Algo<T>::BuildParam param;
parse_build_param<T>(conf, param);
return std::make_unique<Algo<T>>(metric, dim, param);
}

template <typename T, template <typename> class Algo>
std::unique_ptr<raft::bench::ann::ANN<T>> make_algo(raft::bench::ann::Metric metric,
int dim,
const nlohmann::json& conf,
const std::vector<int>& dev_list)
std::unique_ptr<cuvs::bench::ANN<T>> make_algo(cuvs::bench::Metric metric,
int dim,
const nlohmann::json& conf,
const std::vector<int>& dev_list)
{
typename Algo<T>::BuildParam param;
parse_build_param<T>(conf, param);
Expand All @@ -103,27 +103,27 @@ std::unique_ptr<raft::bench::ann::ANN<T>> make_algo(raft::bench::ann::Metric met
}

template <typename T>
std::unique_ptr<raft::bench::ann::ANN<T>> create_algo(const std::string& algo,
const std::string& distance,
int dim,
const nlohmann::json& conf,
const std::vector<int>& dev_list)
std::unique_ptr<cuvs::bench::ANN<T>> create_algo(const std::string& algo,
const std::string& distance,
int dim,
const nlohmann::json& conf,
const std::vector<int>& dev_list)
{
// stop compiler warning; not all algorithms support multi-GPU so it may not be used
(void)dev_list;

std::unique_ptr<raft::bench::ann::ANN<T>> ann;
std::unique_ptr<cuvs::bench::ANN<T>> ann;

if constexpr (std::is_same_v<T, float>) {
raft::bench::ann::Metric metric = parse_metric(distance);
cuvs::bench::Metric metric = parse_metric(distance);
if (algo == "faiss_cpu_ivf_flat") {
ann = make_algo<T, raft::bench::ann::FaissCpuIVFFlat>(metric, dim, conf, dev_list);
ann = make_algo<T, cuvs::bench::FaissCpuIVFFlat>(metric, dim, conf, dev_list);
} else if (algo == "faiss_cpu_ivf_pq") {
ann = make_algo<T, raft::bench::ann::FaissCpuIVFPQ>(metric, dim, conf);
ann = make_algo<T, cuvs::bench::FaissCpuIVFPQ>(metric, dim, conf);
} else if (algo == "faiss_cpu_ivf_sq") {
ann = make_algo<T, raft::bench::ann::FaissCpuIVFSQ>(metric, dim, conf);
ann = make_algo<T, cuvs::bench::FaissCpuIVFSQ>(metric, dim, conf);
} else if (algo == "faiss_cpu_flat") {
ann = std::make_unique<raft::bench::ann::FaissCpuFlat<T>>(metric, dim);
ann = std::make_unique<cuvs::bench::FaissCpuFlat<T>>(metric, dim);
}
}

Expand All @@ -135,28 +135,28 @@ std::unique_ptr<raft::bench::ann::ANN<T>> create_algo(const std::string& algo,
}

template <typename T>
std::unique_ptr<typename raft::bench::ann::ANN<T>::AnnSearchParam> create_search_param(
std::unique_ptr<typename cuvs::bench::ANN<T>::AnnSearchParam> create_search_param(
const std::string& algo, const nlohmann::json& conf)
{
if (algo == "faiss_cpu_ivf_flat" || algo == "faiss_cpu_ivf_pq" || algo == "faiss_cpu_ivf_sq") {
auto param = std::make_unique<typename raft::bench::ann::FaissCpu<T>::SearchParam>();
auto param = std::make_unique<typename cuvs::bench::FaissCpu<T>::SearchParam>();
parse_search_param<T>(conf, *param);
return param;
} else if (algo == "faiss_cpu_flat") {
auto param = std::make_unique<typename raft::bench::ann::ANN<T>::AnnSearchParam>();
auto param = std::make_unique<typename cuvs::bench::ANN<T>::AnnSearchParam>();
return param;
}
// else
throw std::runtime_error("invalid algo: '" + algo + "'");
}

} // namespace raft::bench::ann
} // namespace cuvs::bench

REGISTER_ALGO_INSTANCE(float);
REGISTER_ALGO_INSTANCE(std::int8_t);
REGISTER_ALGO_INSTANCE(std::uint8_t);

#ifdef CUVS_BENCH_BUILD_MAIN
#include "../common/benchmark.hpp"
int main(int argc, char** argv) { return raft::bench::ann::run_main(argc, argv); }
int main(int argc, char** argv) { return cuvs::bench::run_main(argc, argv); }
#endif
10 changes: 5 additions & 5 deletions cpp/bench/ann/src/faiss/faiss_cpu_wrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,19 +35,19 @@

namespace {

faiss::MetricType parse_metric_type(raft::bench::ann::Metric metric)
faiss::MetricType parse_metric_type(cuvs::bench::Metric metric)
{
if (metric == raft::bench::ann::Metric::kInnerProduct) {
if (metric == cuvs::bench::Metric::kInnerProduct) {
return faiss::METRIC_INNER_PRODUCT;
} else if (metric == raft::bench::ann::Metric::kEuclidean) {
} else if (metric == cuvs::bench::Metric::kEuclidean) {
return faiss::METRIC_L2;
} else {
throw std::runtime_error("faiss supports only metric type of inner product and L2");
}
}
} // namespace

namespace raft::bench::ann {
namespace cuvs::bench {

template <typename T>
class FaissCpu : public ANN<T> {
Expand Down Expand Up @@ -310,4 +310,4 @@ class FaissCpuFlat : public FaissCpu<T> {
void load(const std::string& file) override { this->template load_<faiss::IndexFlat>(file); }
};

} // namespace raft::bench::ann
} // namespace cuvs::bench
Loading

0 comments on commit 4c04a0e

Please sign in to comment.