Skip to content

Commit

Permalink
Updated range_search_disk_index to use the new required/optional form…
Browse files Browse the repository at this point in the history
…at. #370
  • Loading branch information
Jon McLean committed Jul 10, 2023
1 parent ed8ce3e commit 38644e1
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 21 deletions.
52 changes: 33 additions & 19 deletions apps/range_search_disk_index.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include "pq_flash_index.h"
#include "partition.h"
#include "timer.h"
#include "../src/program_options_utils.hpp"

#ifndef _WINDOWS
#include <sys/mman.h>
Expand Down Expand Up @@ -273,29 +274,42 @@ int main(int argc, char **argv)
std::vector<uint32_t> Lvec;
float range;

po::options_description desc{"Arguments"};
po::options_description desc{
program_options_utils::make_program_description("range_search_disk_index", "Searches disk DiskANN indexes using ranges")};
try
{
desc.add_options()("help,h", "Print information on arguments");
desc.add_options()("data_type", po::value<std::string>(&data_type)->required(), "data type <int8/uint8/float>");
desc.add_options()("dist_fn", po::value<std::string>(&dist_fn)->required(),
"distance function <l2/mips/fast_l2>");
desc.add_options()("index_path_prefix", po::value<std::string>(&index_path_prefix)->required(),
"Path prefix to the index");
desc.add_options()("query_file", po::value<std::string>(&query_file)->required(),
"Query file in binary format");
desc.add_options()("gt_file", po::value<std::string>(&gt_file)->default_value(std::string("null")),
"ground truth file for the queryset");
desc.add_options()("range_threshold,K", po::value<float>(&range)->required(),

// Required parameters
po::options_description required_configs("Required");
required_configs.add_options()("data_type", po::value<std::string>(&data_type)->required(),
program_options_utils::DATA_TYPE_DESCRIPTION);
required_configs.add_options()("dist_fn", po::value<std::string>(&dist_fn)->required(),
program_options_utils::DISTANCE_FUNCTION_DESCRIPTION);
required_configs.add_options()("index_path_prefix", po::value<std::string>(&index_path_prefix)->required(),
program_options_utils::INDEX_PATH_PREFIX_DESCRIPTION);
required_configs.add_options()("query_file", po::value<std::string>(&query_file)->required(),
program_options_utils::QUERY_FILE_DESCRIPTION);
required_configs.add_options()("search_list,L",
po::value<std::vector<uint32_t>>(&Lvec)->multitoken()->required(),
program_options_utils::SEARCH_LIST_DESCRIPTION);
required_configs.add_options()("range_threshold,K", po::value<float>(&range)->required(),
"Number of neighbors to be returned");
desc.add_options()("search_list,L", po::value<std::vector<uint32_t>>(&Lvec)->multitoken(),
"List of L values of search");
desc.add_options()("beamwidth,W", po::value<uint32_t>(&W)->default_value(2), "Beamwidth for search");
desc.add_options()("num_nodes_to_cache", po::value<uint32_t>(&num_nodes_to_cache)->default_value(100000),
"Beamwidth for search");
desc.add_options()("num_threads,T", po::value<uint32_t>(&num_threads)->default_value(omp_get_num_procs()),
"Number of threads used for building index (defaults to "
"omp_get_num_procs())");

// Optional parameters
po::options_description optional_configs("Optional");
optional_configs.add_options()("num_threads,T",
po::value<uint32_t>(&num_threads)->default_value(omp_get_num_procs()),
program_options_utils::NUMBER_THREADS_DESCRIPTION);
optional_configs.add_options()("gt_file", po::value<std::string>(&gt_file)->default_value(std::string("null")),
program_options_utils::GROUND_TRUTH_FILE_DESCRIPTION);
optional_configs.add_options()("num_nodes_to_cache", po::value<uint32_t>(&num_nodes_to_cache)->default_value(0),
program_options_utils::NUMBER_OF_NODES_TO_CACHE);
optional_configs.add_options()("beamwidth,W", po::value<uint32_t>(&W)->default_value(2),
program_options_utils::BEAMWIDTH);

// Merge required and optional parameters
desc.add(required_configs).add(optional_configs);

po::variables_map vm;
po::store(po::parse_command_line(argc, argv, desc), vm);
Expand Down
4 changes: 2 additions & 2 deletions apps/search_disk_index.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -348,9 +348,9 @@ int main(int argc, char **argv)
optional_configs.add_options()("gt_file", po::value<std::string>(&gt_file)->default_value(std::string("null")),
program_options_utils::GROUND_TRUTH_FILE_DESCRIPTION);
optional_configs.add_options()("beamwidth,W", po::value<uint32_t>(&W)->default_value(2),
"Beamwidth for search. Set 0 to optimize internally. Default value: 2");
program_options_utils::BEAMWIDTH);
optional_configs.add_options()("num_nodes_to_cache", po::value<uint32_t>(&num_nodes_to_cache)->default_value(0),
"Number of BFS nodes around medoid(s) to cache. Default value: 0");
program_options_utils::NUMBER_OF_NODES_TO_CACHE);
optional_configs.add_options()("search_io_limit",
po::value<uint32_t>(&search_io_limit)->default_value(std::numeric_limits<uint32_t>::max()),
"Max #IOs for search. Default value: uint32::max()");
Expand Down
2 changes: 2 additions & 0 deletions src/program_options_utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ const char* LABEL_TYPE_DESCRIPTION ="Storage type of Labels <uint/ushort>, defau
const char* GROUND_TRUTH_FILE_DESCRIPTION ="ground truth file for the queryset"; // what's the format, what's the requirements? does it need to include an entry for every item or just a small subset? I have so many questions about this file
const char* NUMBER_THREADS_DESCRIPTION="Number of threads used for building index. Defaults to number of logical processor cores on your this machine returned by omp_get_num_procs()";
const char* FAIl_IF_RECALL_BELOW="If set to a value >0 and <100%, program returns -1 if best recall found is below this threshold. "; // does it continue running or die immediately? Will I still get my results even if the return code is -1?
const char* NUMBER_OF_NODES_TO_CACHE="Number of BFS nodes around medoid(s) to cache. Default value: 0";
const char* BEAMWIDTH="Beamwidth for search. Set 0 to optimize internally. Default value: 2";

} // namespace program_options_utils

Expand Down

0 comments on commit 38644e1

Please sign in to comment.