2929#include " common.cuh"
3030
3131template <typename T>
32- void vamana_build_and_write (raft::device_resources const & dev_resources,
32+ void vamana_build_and_write (raft::device_resources const & dev_resources,
3333 raft::device_matrix_view<const T, int64_t > dataset,
34- std::string out_fname, int degree, int visited_size,
35- float max_fraction, int iters) {
34+ std::string out_fname,
35+ int degree,
36+ int visited_size,
37+ float max_fraction,
38+ int iters)
39+ {
3640 using namespace cuvs ::neighbors;
3741
3842 // use default index parameters
@@ -46,23 +50,24 @@ void vamana_build_and_write(raft::device_resources const &dev_resources,
4650
4751 auto start = std::chrono::system_clock::now ();
4852 auto index = vamana::build (dev_resources, index_params, dataset);
49- auto end = std::chrono::system_clock::now ();
53+ auto end = std::chrono::system_clock::now ();
5054 std::chrono::duration<double > elapsed_seconds = end - start;
5155
5256 std::cout << " Vamana index has " << index.size () << " vectors" << std::endl;
53- std::cout << " Vamana graph has degree " << index.graph_degree ()
54- << " , graph size [" << index.graph ().extent (0 ) << " , "
55- << index.graph ().extent (1 ) << " ]" << std::endl;
57+ std::cout << " Vamana graph has degree " << index.graph_degree () << " , graph size ["
58+ << index.graph ().extent (0 ) << " , " << index.graph ().extent (1 ) << " ]" << std::endl;
5659
5760 std::cout << " Time to build index: " << elapsed_seconds.count () << " s\n " ;
5861
5962 // Output index to file
6063 serialize (dev_resources, out_fname, index);
6164}
6265
63- void usage () {
64- printf (" Usage: ./vamana_example <data filename> <output filename> <graph "
65- " degree> <visited_size> <max_fraction> <iterations> \n " );
66+ void usage ()
67+ {
68+ printf (
69+ " Usage: ./vamana_example <data filename> <output filename> <graph "
70+ " degree> <visited_size> <max_fraction> <iterations> \n " );
6671 printf (" Input file expected to be binary file of fp32 vectors.\n " );
6772 printf (" Graph degree sizes supported: 32, 64, 128, 256\n " );
6873 printf (" Visited_size must be > degree and a power of 2.\n " );
@@ -71,13 +76,14 @@ void usage() {
7176 exit (1 );
7277}
7378
74- int main (int argc, char *argv[]) {
79+ int main (int argc, char * argv[])
80+ {
7581 raft::device_resources dev_resources;
7682
7783 // Set pool memory resource with 1 GiB initial pool size. All allocations use
7884 // the same pool.
7985 rmm::mr::pool_memory_resource<rmm::mr::device_memory_resource> pool_mr (
80- rmm::mr::get_current_device_resource (), 1024 * 1024 * 1024ull );
86+ rmm::mr::get_current_device_resource (), 1024 * 1024 * 1024ull );
8187 rmm::mr::set_current_device_resource (&pool_mr);
8288
8389 // Alternatively, one could define a pool allocator for temporary arrays (used
@@ -87,22 +93,24 @@ int main(int argc, char *argv[]) {
8793 // limit. raft::resource::set_workspace_to_pool_resource(dev_resources, 2 *
8894 // 1024 * 1024 * 1024ull);
8995
90- if (argc != 7 )
91- usage ();
96+ if (argc != 7 ) usage ();
9297
93- std::string data_fname = (std::string)(argv[1 ]); // Input filename
94- std::string out_fname = (std::string)argv[2 ]; // Output index filename
95- int degree = atoi (argv[3 ]);
96- int max_visited = atoi (argv[4 ]);
97- float max_fraction = atof (argv[5 ]);
98- int iters = atoi (argv[6 ]);
98+ std::string data_fname = (std::string)(argv[1 ]); // Input filename
99+ std::string out_fname = (std::string)argv[2 ]; // Output index filename
100+ int degree = atoi (argv[3 ]);
101+ int max_visited = atoi (argv[4 ]);
102+ float max_fraction = atof (argv[5 ]);
103+ int iters = atoi (argv[6 ]);
99104
100105 // Read in binary dataset file
101- auto dataset =
102- read_bin_dataset<uint8_t , int64_t >(dev_resources, data_fname, INT_MAX);
106+ auto dataset = read_bin_dataset<uint8_t , int64_t >(dev_resources, data_fname, INT_MAX);
103107
104108 // Simple build example to create graph and write to a file
105- vamana_build_and_write<uint8_t >(
106- dev_resources, raft::make_const_mdspan (dataset.view ()), out_fname, degree,
107- max_visited, max_fraction, iters);
109+ vamana_build_and_write<uint8_t >(dev_resources,
110+ raft::make_const_mdspan (dataset.view ()),
111+ out_fname,
112+ degree,
113+ max_visited,
114+ max_fraction,
115+ iters);
108116}
0 commit comments