Add package NMSLiB (#2875)

* [nmslib] Init port

* [nmslib] Trying extra building
This commit is contained in:
Jacob Zhong 2018-02-27 23:05:18 +08:00 committed by Robert Schumacher
parent 25b8f25dad
commit 9db298e34a
4 changed files with 183 additions and 0 deletions

8
ports/nmslib/CONTROL Normal file
View File

@ -0,0 +1,8 @@
Source: nmslib
Version: 1.7.2
Description: Non-Metric Space Library (NMSLIB) is an efficient similarity search library and a toolkit for evaluation of k-NN methods for generic non-metric spaces.
#
# ## Extras are currently unsupported for Windows, waiting for fixes.
# Feature: extra
# Description: Build extra algorithms and tools for nmslib. Note that this feature requires a large bunch of dependencies.
# Build-Depends: gsl, eigen3, boost-system, boost-filesystem, boost-timer, boost-foreach, boost-format, boost-math, boost-random, boost-dynamic-bitset, boost-program-options

View File

@ -0,0 +1,23 @@
diff --git a/similarity_search/CMakeLists.txt b/similarity_search/CMakeLists.txt
index 1451b30..a9f1616 100644
--- a/similarity_search/CMakeLists.txt
+++ b/similarity_search/CMakeLists.txt
@@ -109,9 +109,6 @@ if (WITH_EXTRAS)
message (FATAL_ERROR "Could not locate GSL.")
endif (GSL_FOUND)
- include_directories (${PROJECT_SOURCE_DIR}/lshkit/include)
- add_subdirectory (lshkit)
-
find_package(Eigen3 3 REQUIRED)
if (EIGEN3_FOUND)
message (STATUS "Found Eigen3.")
@@ -139,6 +136,8 @@ if (WITH_EXTRAS)
else ()
message (FATAL_ERROR "Could not locate BOOST.")
endif ()
+
+ add_subdirectory (lshkit)
endif()
add_subdirectory (src)

View File

@ -0,0 +1,92 @@
diff --git a/similarity_search/src/method/hnsw.cc b/similarity_search/src/method/hnsw.cc
index 30a7c8a..5ca07c5 100644
--- a/similarity_search/src/method/hnsw.cc
+++ b/similarity_search/src/method/hnsw.cc
@@ -27,7 +27,7 @@
#include <iostream>
#include <memory>
// This is only for _mm_prefetch
-#include <mmintrin.h>
+#include <xmmintrin.h>
#include "portable_simd.h"
#include "knnquery.h"
diff --git a/similarity_search/src/method/hnsw_distfunc_opt.cc b/similarity_search/src/method/hnsw_distfunc_opt.cc
index 168ee81..408d95d 100644
--- a/similarity_search/src/method/hnsw_distfunc_opt.cc
+++ b/similarity_search/src/method/hnsw_distfunc_opt.cc
@@ -30,7 +30,7 @@
#include "rangequery.h"
#include "portable_intrinsics.h"
// This is only for _mm_prefetch
-#include <mmintrin.h>
+#include <xmmintrin.h>
#include "space.h"
#include "sort_arr_bi.h"
diff --git a/similarity_search/src/method/pivot_neighb_invindx.cc b/similarity_search/src/method/pivot_neighb_invindx.cc
index b6473bd..6dcb00f 100644
--- a/similarity_search/src/method/pivot_neighb_invindx.cc
+++ b/similarity_search/src/method/pivot_neighb_invindx.cc
@@ -21,7 +21,7 @@
#include <unordered_map>
// This is only for _mm_prefetch
-#include <mmintrin.h>
+#include <xmmintrin.h>
#include "portable_simd.h"
#include "space.h"
diff --git a/similarity_search/src/method/small_world_rand.cc b/similarity_search/src/method/small_world_rand.cc
index 59e13f7..0f3e0b9 100644
--- a/similarity_search/src/method/small_world_rand.cc
+++ b/similarity_search/src/method/small_world_rand.cc
@@ -16,7 +16,7 @@
#include <memory>
#include <iostream>
// This is only for _mm_prefetch
-#include <mmintrin.h>
+#include <xmmintrin.h>
#include "portable_simd.h"
#include "space.h"
diff --git a/similarity_search/src/method/vptree.cc b/similarity_search/src/method/vptree.cc
index d0262ad..0e5befc 100644
--- a/similarity_search/src/method/vptree.cc
+++ b/similarity_search/src/method/vptree.cc
@@ -20,7 +20,7 @@
#include <cmath>
// This is only for _mm_prefetch
-#include <mmintrin.h>
+#include <xmmintrin.h>
#include "portable_simd.h"
#include "space.h"
diff --git a/similarity_search/test/test_overlap.cc b/similarity_search/test/test_overlap.cc
index 326b26b..413d66d 100644
--- a/similarity_search/test/test_overlap.cc
+++ b/similarity_search/test/test_overlap.cc
@@ -12,7 +12,6 @@
* Apache License Version 2.0 http://www.apache.org/licenses/.
*
*/
-#include <sys/time.h>
#include <logging.h>
#include <idtype.h>
diff --git a/similarity_search/test/test_pow.cc b/similarity_search/test/test_pow.cc
index 1b46a68..faaa84e 100644
--- a/similarity_search/test/test_pow.cc
+++ b/similarity_search/test/test_pow.cc
@@ -29,8 +29,8 @@ using namespace std;
const float MAX_REL_DIFF = 1e-6f;
-vector<float> addExps = { 0, 0.125, 0.25, 0.5 };
-vector<float> vals = { 0.1, 0.5, 1, 1.5, 2, 4};
+vector<float> addExps = { 0, 0.125f, 0.25f, 0.5f };
+vector<float> vals = { 0.1f, 0.5f, 1, 1.5f, 2, 4};
vector<float> signs = { 1, -1};
template <typename T> bool runTest() {

View File

@ -0,0 +1,60 @@
include(vcpkg_common_functions)
if(VCPKG_LIBRARY_LINKAGE STREQUAL dynamic)
message(STATUS "nmslib only supports static linkage. Building statically.")
set(VCPKG_LIBRARY_LINKAGE static)
endif()
vcpkg_from_github(
OUT_SOURCE_PATH SOURCE_PATH
REPO searchivarius/nmslib
REF v1.7.2
SHA512 2f910f752bfb1146aa8d1765fd5faf64d718a92ab7edf9d8ac0a2d9c4359d42b07b3cd553e2aff93da8b009add52ab9cce6b841f5175f57163f73f643ff62c19
HEAD_REF master
)
vcpkg_apply_patches(
SOURCE_PATH ${SOURCE_PATH}
PATCHES
${CMAKE_CURRENT_LIST_DIR}/fix-headers.patch
${CMAKE_CURRENT_LIST_DIR}/fix-cmake-order.patch
)
set(WITH_EXTRAS OFF)
if("extra" IN_LIST FEATURES)
set(WITH_EXTRAS ON)
endif()
# TODO: check SSE and AVX avability and set corresponding tags
vcpkg_configure_cmake(
SOURCE_PATH ${SOURCE_PATH}/similarity_search
OPTIONS
-DWITH_EXTRAS=${WITH_EXTRAS}
)
vcpkg_install_cmake()
vcpkg_copy_pdbs()
# Move headers into separate folder
set(SUBFOLDERS factory method space)
file(MAKE_DIRECTORY ${CURRENT_PACKAGES_DIR}/include/nmslib)
foreach(SUBFOLER ${SUBFOLDERS})
file(MAKE_DIRECTORY ${CURRENT_PACKAGES_DIR}/include/nmslib/${SUBFOLER})
endforeach()
file(GLOB HEADERS ${CURRENT_PACKAGES_DIR}/include/*.h ${CURRENT_PACKAGES_DIR}/include/*/*.h)
foreach(HEADER ${HEADERS})
string(REPLACE "${CURRENT_PACKAGES_DIR}/include" "${CURRENT_PACKAGES_DIR}/include/nmslib"
MOVED_HEADER ${HEADER})
file(RENAME ${HEADER} ${MOVED_HEADER})
endforeach(HEADER ${HEADERS})
foreach(SUBFOLER ${SUBFOLDERS})
file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/include/${SUBFOLER}/)
endforeach()
file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/include)
# Put the license file where vcpkg expects it
file(COPY ${SOURCE_PATH}/README.md DESTINATION ${CURRENT_PACKAGES_DIR}/share/nmslib/)
file(RENAME ${CURRENT_PACKAGES_DIR}/share/nmslib/README.md ${CURRENT_PACKAGES_DIR}/share/nmslib/copyright)