Skip to content

Commit

Permalink
various windows build fixes
Browse files Browse the repository at this point in the history
'and' isn't a valid operator on C++ (though apparently works in linux), and
on some windows configurations we needed to include a different header file for
_mm_prefetch. Also if git wasn't configured with symlinks succesfully, fallback to a relative
path in setup.py.

Fixes https://github.com/nmslib/nmslib/issues/295 and https://github.com/nmslib/nmslib/issues/348
  • Loading branch information
Ben Frederickson committed Oct 1, 2018
1 parent aae2cbf commit 19bbb1b
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 2 deletions.
7 changes: 6 additions & 1 deletion python_bindings/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@
__version__ = '1.7.3.4'

libdir = os.path.join(".", "nmslib", "similarity_search")
if not os.path.isdir(libdir) and sys.platform.startswith("win"):
# If the nmslib symlink doesn't work (windows symlink support w/ git is
# a little iffy), fallback to use a relative path
libdir = os.path.join("..", "similarity_search")

library_file = os.path.join(libdir, "release", "libNonMetricSpaceLib.a")
source_files = ['nmslib.cc']

Expand All @@ -22,7 +27,7 @@
exclude_files = set("""bbtree.cc lsh.cc lsh_multiprobe.cc lsh_space.cc falconn.cc nndes.cc space_sqfd.cc
dummy_app.cc main.cc""".split())

for root, subdirs, files in os.walk(os.path.join("nmslib", "similarity_search", "src")):
for root, subdirs, files in os.walk(os.path.join(libdir, "src")):
source_files.extend(os.path.join(root, f) for f in files
if f.endswith(".cc") and f not in exclude_files)

Expand Down
2 changes: 1 addition & 1 deletion similarity_search/src/method/hnsw.cc
Original file line number Diff line number Diff line change
Expand Up @@ -684,7 +684,7 @@ namespace similarity {
void
Hnsw<dist_t>::Search(KNNQuery<dist_t> *query, IdType) const
{
if (this->data_.empty() and this->data_rearranged_.empty()) {
if (this->data_.empty() && this->data_rearranged_.empty()) {
return;
}
bool useOld = searchAlgoType_ == kOld || (searchAlgoType_ == kHybrid && ef_ >= 1000);
Expand Down
4 changes: 4 additions & 0 deletions similarity_search/src/method/small_world_rand.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@
// This is only for _mm_prefetch
#include <mmintrin.h>

#if defined(_WIN32) || defined(WIN32)
#include <intrin.h>
#endif

#include "portable_simd.h"
#include "space.h"
#include "knnquery.h"
Expand Down
3 changes: 3 additions & 0 deletions similarity_search/src/method/vptree.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@

// This is only for _mm_prefetch
#include <mmintrin.h>
#if defined(_WIN32) || defined(WIN32)
#include <intrin.h>
#endif

#include "portable_simd.h"
#include "space.h"
Expand Down

0 comments on commit 19bbb1b

Please sign in to comment.