2018-02-26 10:23:17 +00:00
|
|
|
# Copyright (c) 2015-present, Facebook, Inc.
|
|
|
|
# All rights reserved.
|
|
|
|
#
|
|
|
|
# This source code is licensed under the BSD+Patents license found in the
|
|
|
|
# LICENSE file in the root directory of this source tree.
|
|
|
|
|
|
|
|
.SUFFIXES: .cpp .o
|
|
|
|
|
|
|
|
# C API with GPU support
|
|
|
|
|
|
|
|
include ../../makefile.inc
|
|
|
|
DEBUGFLAG=-DNDEBUG # no debugging
|
|
|
|
|
|
|
|
LIBNAME=libgpufaiss
|
|
|
|
CLIBNAME=libgpufaiss_c
|
|
|
|
LIBGPUCOBJ=GpuAutoTune_c.o GpuClonerOptions_c.o GpuIndex_c.o GpuResources_c.o \
|
|
|
|
StandardGpuResources_c.o
|
2018-05-15 09:26:40 +01:00
|
|
|
LIBCOBJ=../libfaiss_c.a
|
2018-02-26 10:23:17 +00:00
|
|
|
|
|
|
|
# Build shared object file by default
|
2018-05-15 09:26:40 +01:00
|
|
|
all: $(CLIBNAME).$(SHAREDEXT)
|
2018-02-26 10:23:17 +00:00
|
|
|
|
2018-05-15 09:26:40 +01:00
|
|
|
# Build static object file containing the wrapper implementation only.
|
|
|
|
# Consumers are required to link with the C++ standard library and remaining
|
|
|
|
# portions of this library: libfaiss_c.a, libfaiss.a, libgpufaiss.a, and libstdc++.
|
2018-02-26 10:23:17 +00:00
|
|
|
$(CLIBNAME).a: $(LIBGPUCOBJ) ../../gpu/$(LIBNAME).a
|
|
|
|
ar r $@ $^
|
|
|
|
|
|
|
|
# Build dynamic library
|
|
|
|
$(CLIBNAME).$(SHAREDEXT): $(LIBCOBJ) $(LIBGPUCOBJ) ../../libfaiss.a ../../gpu/$(LIBNAME).a
|
2018-06-04 10:58:23 +01:00
|
|
|
$(CXX) $(LDFLAGS) $(SHAREDFLAGS) $(CUDACFLAGS) $(LIBS) -o $@ \
|
|
|
|
-Wl,--whole-archive $(LIBCOBJ) ../../libfaiss.a \
|
2018-02-26 10:23:17 +00:00
|
|
|
-Wl,--no-whole-archive -static-libstdc++ $(LIBGPUCOBJ) ../../gpu/$(LIBNAME).a \
|
2018-06-04 10:58:23 +01:00
|
|
|
$(NVCCLDFLAGS) $(NVCCLIBS)
|
2018-02-26 10:23:17 +00:00
|
|
|
|
|
|
|
# Build GPU example
|
|
|
|
bin/example_gpu_c: example_gpu_c.c $(CLIBNAME).$(SHAREDEXT)
|
|
|
|
$(CC) $(CFLAGS) $(CUDACFLAGS) -std=c99 -I. -I.. -o $@ example_gpu_c.c \
|
|
|
|
-L. -lgpufaiss_c
|
|
|
|
|
|
|
|
clean:
|
|
|
|
rm -f $(CLIBNAME).a $(CLIBNAME).$(SHAREDEXT)* *.o bin/example_gpu_c
|
|
|
|
|
|
|
|
# Dependencies
|
|
|
|
|
2018-06-04 10:58:23 +01:00
|
|
|
GpuAutoTune_c.o: CXXFLAGS += -I.. -I../.. $(CUDACFLAGS) $(DEBUGFLAG)
|
2018-02-26 10:23:17 +00:00
|
|
|
GpuAutoTune_c.o: GpuAutoTune_c.cpp GpuAutoTune_c.h ../../gpu/GpuAutoTune.h ../Index_c.h ../macros_impl.h
|
|
|
|
|
2018-06-04 10:58:23 +01:00
|
|
|
GpuClonerOptions_c.o: CXXFLAGS += -I.. -I../.. $(CUDACFLAGS) $(DEBUGFLAG)
|
2018-02-26 10:23:17 +00:00
|
|
|
GpuClonerOptions_c.o: GpuClonerOptions_c.cpp GpuClonerOptions_c.h GpuIndicesOptions_c.h ../../gpu/GpuClonerOptions.h ../macros_impl.h
|
|
|
|
|
2018-06-04 10:58:23 +01:00
|
|
|
GpuIndex_c.o: CXXFLAGS += -I.. -I../.. $(CUDACFLAGS) $(DEBUGFLAG)
|
2018-02-26 10:23:17 +00:00
|
|
|
GpuIndex_c.o: GpuIndex_c.cpp GpuIndex_c.h ../../gpu/GpuIndex.h ../macros_impl.h
|
|
|
|
|
2018-06-04 10:58:23 +01:00
|
|
|
GpuResources_c.o: CXXFLAGS += -I.. -I../.. $(CUDACFLAGS) $(DEBUGFLAG)
|
2018-02-26 10:23:17 +00:00
|
|
|
GpuResources_c.o: GpuResources_c.cpp GpuResources_c.h ../../gpu/GpuResources.h ../macros_impl.h
|
|
|
|
|
2018-06-04 10:58:23 +01:00
|
|
|
StandardGpuResources_c.o: CXXFLAGS += -I.. -I../.. $(CUDACFLAGS) $(DEBUGFLAG)
|
2018-02-26 10:23:17 +00:00
|
|
|
StandardGpuResources_c.o: StandardGpuResources_c.cpp StandardGpuResources_c.h ../../gpu/StandardGpuResources.h ../macros_impl.h
|