Examples
Obtain the test framework code from the source code obtained in 1. Assume that the source code is stored in /path/to/scann/sra_scann_adapter and the test framework code is stored in /path/to/scann/sra_scann_adapter/ann-benchmarks. The following uses the sift-128-euclidean.hdf5 dataset as an example.
Obtain a dataset.
1 2 3 | cd /path/to/scann/sra_scann_adapter/ann-benchmarks mkdir data && cd data wget http://ann-benchmarks.com/sift-128-euclidean.hdf5 --no-check-certificate |
The directory structure of the main files is as follows:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | ├── ann-benchmarks ├── data // Dataset └── sift-128-euclidean.hdf5 ├── ann_benchmarks └── algorithms └── scann └── cpp_test └── config-sift-128-euclidean.config // Dataset configuration file └── test_cpp.sh // Test script ├── scann ├── CMakeLists.txt // Compilation configuration file ├── eval.cpp // Test code └── cmdline.h // Header file of the command line argument parsing library project.sh // Compilation script |
Procedure:
- Check that libscann_cc.so has been compiled in 8.
- Install CMake.
yum install cmake
- Install the dependencies.
yum install numactl numactl-devel hdf5 hdf5-devel gtest-devel gcc-toolset-12-libstdc++-static
- Install the Python dependencies.
1 2 3
cd /path/to/scann/sra_scann_adapter/ann-benchmarks pip install -r requirements.txt pip install treelite==4.2.1 tl2cgen
- Install protobuf.
wget https://github.com/protocolbuffers/protobuf/archive/refs/tags/v3.21.9.tar.gz --no-check-certificate tar -xzf v3.21.9.tar.gz cd protobuf-3.21.9 mkdir build && cd build cmake .. -Dprotobuf_BUILD_TESTS=OFF -DCMAKE_INSTALL_PREFIX=/usr/local/protobuf-3.21.9 make install export PATH=/usr/local/protobuf-3.21.9/bin:$PATH export LD_LIBRARY_PATH=/usr/local/protobuf-3.21.9/lib:$LD_LIBRARY_PATH
- Install Abseil.
wget https://storage.googleapis.com/mirror.tensorflow.org/github.com/abseil/abseil-cpp/archive/fb3621f4f897824c0dbe0615fa94543df6192f30.tar.gz --no-check-certificate tar -xvzf fb3621f4f897824c0dbe0615fa94543df6192f30.tar.gz cd abseil-cpp-fb3621f4f897824c0dbe0615fa94543df6192f30 mkdir build && cd build cmake .. && make -j make install
- Install Eigen.
git clone https://gitlab.com/libeigen/eigen.git cd eigen git checkout 33d0937c6bdf5ec999939fb17f2a553183d14a74 mkdir build && cd build cmake .. -DCMAKE_INSTALL_PREFIX=/usr/local/eigen-3.3.7 make -j && make install
- Build the executable file.
cd /path/to/scann/sra_scann_adapter sh project.sh --build_eval_cmake_sve
project.sh contains the following compilation options. You can select them as required:
- --prepare: Installs Python dependencies.
- --build_eval_cmake_sve: Builds the executable file of the SVE instruction version using libscann_cc.so through cmake.
- --build_eval_cmake_neon: Builds the executable file of the NEON instruction version using libscann_cc.so through cmake.
- --build_eval_bazel_sve: Builds the executable file of the SVE instruction version using the source code through bazel.
- --build_eval_bazel_neon: Builds the executable file of the NEON instruction version using the source code through bazel.
- Run the test script.
1sh test_cpp.sh
The execution result is as follows:

Parent topic: C++ APIs