Skip to content

Commit

Permalink
add jni and docker files
Browse files Browse the repository at this point in the history
  • Loading branch information
raman-r-4978 committed Aug 26, 2020
1 parent ae8db65 commit fd7287d
Show file tree
Hide file tree
Showing 3 changed files with 1,099 additions and 0 deletions.
19 changes: 19 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
FROM centos:7

RUN yum install -y lapack lapack-devel

# Install necessary build tools
RUN yum install -y gcc-c++ make swig3
RUN yum install -y java-1.8.0-openjdk java-1.8.0-openjdk-devel maven

COPY . /opt/JFaiss
WORKDIR /opt/JFaiss/faiss

# Install faiss
RUN ./configure --prefix=/usr --libdir=/usr/lib64 --without-cuda
RUN make -j $(nproc)
RUN make install

# Create source files
WORKDIR /opt/JFaiss/jni
RUN make
47 changes: 47 additions & 0 deletions jni/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.

-include ../faiss/makefile.inc

ifneq ($(strip $(NVCC)),)
SWIGFLAGS += -DGPU_WRAPPER
endif

JAVACFLAGS = -I /usr/lib/jvm/java/include/ -I /usr/lib/jvm/java/include/linux/
SWIGJAVASRC = ../cpu/src/main/java/com/vectorsearch/faiss/swig

all: build

# Also silently generates swigfaiss.py.
swigfaiss.cpp: swigfaiss.swig ../faiss/libfaiss.a
mkdir -p $(SWIGJAVASRC)
$(SWIG) -java -c++ -Doverride= -I../ $(SWIGFLAGS) -package com.vectorsearch.faiss.swig -outdir $(SWIGJAVASRC) -o $@ $<

swigfaiss_avx2.cpp: swigfaiss.swig ../faiss/libfaiss.a
mkdir -p $(SWIGJAVASRC)
$(SWIG) -java -c++ -Doverride= -module swigfaiss_avx2 -I../ $(SWIGFLAGS) -package com.vectorsearch.faiss.swig -outdir $(SWIGJAVASRC) -o $@ $<

%.o: %.cpp
$(CXX) $(CPPFLAGS) $(CXXFLAGS) $(CPUFLAGS) $(JAVACFLAGS) \
-I../ -c $< -o $@

# Extension is .so even on OSX.
_%.so: %.o ../faiss/libfaiss.a
$(CXX) $(SHAREDFLAGS) $(LDFLAGS) -o $@ $^ $(LIBS)

build: _swigfaiss.so
mkdir -p ../cpu/src/main/resources
cp _swigfaiss.so ../cpu/src/main/resources/

# install: build
# $(PYTHON) setup.py install
#

clean:
rm -f swigfaiss*.cpp swigfaiss*.o _swigfaiss*.so
rm -rf $(SWIGJAVASRC)


.PHONY: all build install #clean install
Loading

0 comments on commit fd7287d

Please sign in to comment.