From 5708fbd184bad505c4b723da16e0fe9af9a27073 Mon Sep 17 00:00:00 2001 From: Ben Frederickson Date: Wed, 31 Jan 2024 16:34:17 -0800 Subject: [PATCH] prefix new public api functions w/ cuvs --- cpp/include/cuvs/neighbors/cagra_c.h | 36 ++++++++++++++-------------- cpp/src/neighbors/cagra_c.cpp | 12 +++++----- cpp/test/neighbors/ann_cagra_c.cu | 12 +++++----- 3 files changed, 30 insertions(+), 30 deletions(-) diff --git a/cpp/include/cuvs/neighbors/cagra_c.h b/cpp/include/cuvs/neighbors/cagra_c.h index b7374acbb..59861b502 100644 --- a/cpp/include/cuvs/neighbors/cagra_c.h +++ b/cpp/include/cuvs/neighbors/cagra_c.h @@ -55,15 +55,15 @@ struct cagraIndexParams { size_t nn_descent_niter; }; -typedef struct cagraIndexParams* cagraIndexParams_t; +typedef struct cagraIndexParams* cuvsCagraIndexParams_t; /** * @brief Allocate CAGRA Index params, and populate with default values * - * @param[in] params cagraIndexParams_t to allocate + * @param[in] params cuvsCagraIndexParams_t to allocate * @return cuvsError_t */ -cuvsError_t cagraIndexParamsCreate(cagraIndexParams_t* params); +cuvsError_t cuvsCagraIndexParamsCreate(cuvsCagraIndexParams_t* params); /** * @brief De-allocate CAGRA Index params @@ -71,7 +71,7 @@ cuvsError_t cagraIndexParamsCreate(cagraIndexParams_t* params); * @param[in] params * @return cuvsError_t */ -cuvsError_t cagraIndexParamsDestroy(cagraIndexParams_t index); +cuvsError_t cuvsCagraIndexParamsDestroy(cuvsCagraIndexParams_t index); /** * @brief Enum to denote algorithm used to search CAGRA Index @@ -140,15 +140,15 @@ struct cagraSearchParams { uint64_t rand_xor_mask; }; -typedef struct cagraSearchParams* cagraSearchParams_t; +typedef struct cagraSearchParams* cuvsCagraSearchParams_t; /** * @brief Allocate CAGRA search params, and populate with default values * - * @param[in] params cagraSearchParams_t to allocate + * @param[in] params cuvsCagraSearchParams_t to allocate * @return cuvsError_t */ -cuvsError_t cagraSearchParamsCreate(cagraSearchParams_t* params); +cuvsError_t cuvsCagraSearchParamsCreate(cuvsCagraSearchParams_t* params); /** * @brief De-allocate CAGRA search params @@ -156,7 +156,7 @@ cuvsError_t cagraSearchParamsCreate(cagraSearchParams_t* params); * @param[in] params * @return cuvsError_t */ -cuvsError_t cagraSearchParamsDestroy(cagraSearchParams_t params); +cuvsError_t cuvsCagraSearchParamsDestroy(cuvsCagraSearchParams_t params); /** * @brief Struct to hold address of cuvs::neighbors::cagra::index and its active trained dtype @@ -205,8 +205,8 @@ cuvsError_t cagraIndexDestroy(cagraIndex_t index); * DLManagedTensor dataset; * * // Create default index params - * cagraIndexParams_t params; - * cuvsError_t params_create_status = cagraIndexParamsCreate(¶ms); + * cuvsCagraIndexParams_t params; + * cuvsError_t params_create_status = cuvsCagraIndexParamsCreate(¶ms); * * // Create CAGRA index * cagraIndex_t index; @@ -216,19 +216,19 @@ cuvsError_t cagraIndexDestroy(cagraIndex_t index); * cuvsError_t build_status = cagraBuild(res, params, &dataset, index); * * // de-allocate `params`, `index` and `res` - * cuvsError_t params_destroy_status = cagraIndexParamsDestroy(params); + * cuvsError_t params_destroy_status = cuvsCagraIndexParamsDestroy(params); * cuvsError_t index_destroy_status = cagraIndexDestroy(index); * cuvsError_t res_destroy_status = cuvsResourcesDestroy(res); * @endcode * * @param[in] res cuvsResources_t opaque C handle - * @param[in] params cagraIndexParams_t used to build CAGRA index + * @param[in] params cuvsCagraIndexParams_t used to build CAGRA index * @param[in] dataset DLManagedTensor* training dataset * @param[out] index cagraIndex_t Newly built CAGRA index * @return cuvsError_t */ cuvsError_t cagraBuild(cuvsResources_t res, - cagraIndexParams_t params, + cuvsCagraIndexParams_t params, DLManagedTensor* dataset, cagraIndex_t index); @@ -256,26 +256,26 @@ cuvsError_t cagraBuild(cuvsResources_t res, * DLManagedTensor neighbors; * * // Create default search params - * cagraSearchParams_t params; - * cuvsError_t params_create_status = cagraSearchParamsCreate(¶ms); + * cuvsCagraSearchParams_t params; + * cuvsError_t params_create_status = cuvsCagraSearchParamsCreate(¶ms); * * // Search the `index` built using `cagraBuild` * cuvsError_t search_status = cagraSearch(res, params, index, queries, neighbors, distances); * * // de-allocate `params` and `res` - * cuvsError_t params_destroy_status = cagraSearchParamsDestroy(params); + * cuvsError_t params_destroy_status = cuvsCagraSearchParamsDestroy(params); * cuvsError_t res_destroy_status = cuvsResourcesDestroy(res); * @endcode * * @param[in] res cuvsResources_t opaque C handle - * @param[in] params cagraSearchParams_t used to search CAGRA index + * @param[in] params cuvsCagraSearchParams_t used to search CAGRA index * @param[in] index cagraIndex which has been returned by `cagraBuild` * @param[in] queries DLManagedTensor* queries dataset to search * @param[out] neighbors DLManagedTensor* output `k` neighbors for queries * @param[out] distances DLManagedTensor* output `k` distances for queries */ cuvsError_t cagraSearch(cuvsResources_t res, - cagraSearchParams_t params, + cuvsCagraSearchParams_t params, cagraIndex_t index, DLManagedTensor* queries, DLManagedTensor* neighbors, diff --git a/cpp/src/neighbors/cagra_c.cpp b/cpp/src/neighbors/cagra_c.cpp index e9b9860fb..638c9a23d 100644 --- a/cpp/src/neighbors/cagra_c.cpp +++ b/cpp/src/neighbors/cagra_c.cpp @@ -131,7 +131,7 @@ extern "C" cuvsError_t cagraIndexDestroy(cagraIndex_t index_c_ptr) } extern "C" cuvsError_t cagraBuild(cuvsResources_t res, - cagraIndexParams_t params, + cuvsCagraIndexParams_t params, DLManagedTensor* dataset_tensor, cagraIndex_t index) { @@ -159,7 +159,7 @@ extern "C" cuvsError_t cagraBuild(cuvsResources_t res, } extern "C" cuvsError_t cagraSearch(cuvsResources_t res, - cagraSearchParams_t params, + cuvsCagraSearchParams_t params, cagraIndex_t index_c_ptr, DLManagedTensor* queries_tensor, DLManagedTensor* neighbors_tensor, @@ -202,7 +202,7 @@ extern "C" cuvsError_t cagraSearch(cuvsResources_t res, } } -extern "C" cuvsError_t cagraIndexParamsCreate(cagraIndexParams_t* params) +extern "C" cuvsError_t cuvsCagraIndexParamsCreate(cuvsCagraIndexParams_t* params) { try { *params = new cagraIndexParams{.intermediate_graph_degree = 128, @@ -215,7 +215,7 @@ extern "C" cuvsError_t cagraIndexParamsCreate(cagraIndexParams_t* params) } } -extern "C" cuvsError_t cagraIndexParamsDestroy(cagraIndexParams_t params) +extern "C" cuvsError_t cuvsCagraIndexParamsDestroy(cuvsCagraIndexParams_t params) { try { delete params; @@ -225,7 +225,7 @@ extern "C" cuvsError_t cagraIndexParamsDestroy(cagraIndexParams_t params) } } -extern "C" cuvsError_t cagraSearchParamsCreate(cagraSearchParams_t* params) +extern "C" cuvsError_t cuvsCagraSearchParamsCreate(cuvsCagraSearchParams_t* params) { try { *params = new cagraSearchParams{.itopk_size = 64, @@ -239,7 +239,7 @@ extern "C" cuvsError_t cagraSearchParamsCreate(cagraSearchParams_t* params) } } -extern "C" cuvsError_t cagraSearchParamsDestroy(cagraSearchParams_t params) +extern "C" cuvsError_t cuvsCagraSearchParamsDestroy(cuvsCagraSearchParams_t params) { try { delete params; diff --git a/cpp/test/neighbors/ann_cagra_c.cu b/cpp/test/neighbors/ann_cagra_c.cu index a41498490..4870ac3b8 100644 --- a/cpp/test/neighbors/ann_cagra_c.cu +++ b/cpp/test/neighbors/ann_cagra_c.cu @@ -60,8 +60,8 @@ TEST(CagraC, BuildSearch) cagraIndexCreate(&index); // build index - cagraIndexParams_t build_params; - cagraIndexParamsCreate(&build_params); + cuvsCagraIndexParams_t build_params; + cuvsCagraIndexParamsCreate(&build_params); cagraBuild(res, build_params, &dataset_tensor, index); // create queries DLTensor @@ -111,8 +111,8 @@ TEST(CagraC, BuildSearch) distances_tensor.dl_tensor.strides = nullptr; // search index - cagraSearchParams_t search_params; - cagraSearchParamsCreate(&search_params); + cuvsCagraSearchParams_t search_params; + cuvsCagraSearchParamsCreate(&search_params); cagraSearch(res, search_params, index, &queries_tensor, &neighbors_tensor, &distances_tensor); // verify output @@ -126,8 +126,8 @@ TEST(CagraC, BuildSearch) cudaFree(distances_d); // de-allocate index and res - cagraSearchParamsDestroy(search_params); - cagraIndexParamsDestroy(build_params); + cuvsCagraSearchParamsDestroy(search_params); + cuvsCagraIndexParamsDestroy(build_params); cagraIndexDestroy(index); cuvsResourcesDestroy(res); }