Rate This Document
Findability
Accuracy
Completeness
Readability

Compiling hnswlib

Obtain the hnswlib open source code and hnswlib patch from GitHub and GitCode, apply the patch, and then compile hnswlib.

  1. Obtain the open source code. Assume that the installation path is /path/to.
    cd /path/to
    git clone -b v0.8.0 https://github.com/nmslib/hnswlib.git
  2. Download the hnswlib patch file. Assume that the installation path is /path/to.
    git clone -b v1.0.0 https://gitcode.com/boostkit/hnswlib.git k_hnswlib
  3. Apply the patch.
    cd hnswlib
    patch -p1 < ../k_hnswlib/0001-boostsra-hnswlib.patch
  4. Install GCC 12.3.1 and GCC-C++ 12.3.1.
    yum install gcc-toolset-12-gcc gcc-toolset-12-gcc-c++
    export PATH=/opt/openEuler/gcc-toolset-12/root/usr/bin/:$PATH
    export LD_LIBRARY_PATH=/opt/openEuler/gcc-toolset-12/root/usr/lib64/:$LD_LIBRARY_PATH
  5. Install OpenMP, CMake, and Make.
    yum install cmake libgomp make
  6. Install the HDF5 library.
    yum install hdf5-devel
  7. Compile the hnswlib source code.
    make hnswlib_neon_test
    make hnswlib_sve_test
    make hnswlib_fp16_neon_test
    make hnswlib_fp16_sve_test

    Compilation option description:

    • hnswlib_neon_test: FP32 operations using NEON vectorization
    • hnswlib_sve_test: FP32 operations using SVE vectorization.
    • hnswlib_fp16_neon_test: FP16 operations using NEON vectorization.
    • hnswlib_fp16_sve_test: FP16 operations using SVE vectorization.