diff --git a/CMakeLists.txt b/CMakeLists.txt deleted file mode 100644 index 9f74fdf6c..000000000 --- a/CMakeLists.txt +++ /dev/null @@ -1,62 +0,0 @@ -cmake_minimum_required(VERSION 2.8.7) - -# faiss project -project(faiss C CXX) - -option(BUILD_TUTORIAL "Build tutorials" ON) -option(BUILD_TEST "Build tests" ON) -option(BUILD_WITH_GPU "Build faiss with gpu (cuda) support" ON) -option(WITH_MKL "Build with MKL if ON (OpenBLAS if OFF)" OFF) - -list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake/Modules) - -# OpenMP -find_package(OpenMP REQUIRED) - -# BLAS (MKL os OpenBLAS) -if(WITH_MKL) - find_package(MKL REQUIRED) - include_directories(${MKL_INCLUDE_DIRS}) - set(BLAS_LIB ${MKL_LIBRARIES}) -else() - find_package(OpenBLAS REQUIRED) - include_directories(${OpenBLAS_INCLUDE_DIR}) - set(BLAS_LIB ${OpenBLAS_LIB}) -endif() - -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -fPIC -m64 -Wall -g -O3 -msse4 -mpopcnt -fopenmp -Wno-sign-compare") -add_definitions(-DFINTEGER=int) - -# specify output bin_path and lib_path -set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) -set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) -set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) - -# specify header and cpp files -file(GLOB faiss_cpu_headers ${CMAKE_CURRENT_SOURCE_DIR}/*.h) -file(GLOB faiss_cpu_cpp ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp) - -set(faiss_lib faiss) -add_library(${faiss_lib} STATIC ${faiss_cpu_headers} ${faiss_cpu_cpp}) -target_link_libraries(${faiss_lib} ${OpenMP_CXX_FLAGS} ${BLAS_LIB}) - -# build gpu lib -if(BUILD_WITH_GPU) - include(cmake/Cuda.cmake) - add_subdirectory(gpu) -endif(BUILD_WITH_GPU) - -# build tutorial examples -if(BUILD_TUTORIAL) - add_subdirectory(tutorial) -endif(BUILD_TUTORIAL) - -# build tests -if(BUILD_TEST) - add_subdirectory(tests) -endif(BUILD_TEST) -# Install libraries -install(TARGETS ${faiss_lib} - ARCHIVE DESTINATION lib - ) -install(FILES ${faiss_cpu_headers} DESTINATION include/faiss) diff --git a/INSTALL.md b/INSTALL.md index 4f8225837..3cd983999 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -384,41 +384,3 @@ Then Faiss can be used in python with ```python import faiss ``` - - -CMake build instructions: -========================= -Alternatively, Faiss can be built via the experimental cmake scripts. -The installation process is similar to using Makefiles. After installing -the necessary dependencies (OpenBLAS, OpenMP, and CUDA, if BUILD_WITH_GPU -is enabled), the build process can be done by the following commands: - -``` -mkdir build -cd build -cmake .. -make # use -j to enable parallel build -``` - -Notes for build on Mac: The native compiler on Mac does not support OpenMP. -So to make it work on Mac, you have to install a new compiler using either -Macports or Homebrew. For example, after installing the compiler `g++-mp-6` -from Macports (`port install g++-mp-6`), you need to set the two flags -`CMAKE_CXX_COMPILER` and `CMAKE_C_COMPILER`: - -`cmake -DCMAKE_CXX_COMPILER=/opt/local/bin/g++-mp-6 -DCMAKE_C_COMPILER=/opt/local/bin/gcc-mp-6 ..` - -Similarly, you can use Homebrew to install clang++ (`brew install llvm`) and -then set the two flags to `/usr/local/opt/llvm/bin/clang++`. - -CMake supports the OpenBLAS and MKL implementations. CMake limitations: the python interface is -NOT supported at this point. - -Use Faiss as a 3rd-party library: Using Faiss as a 3rd-party lib via CMake is easy. -If the parental project is also build via CMake, just add a line `add_subdirectory(faiss)` -in CMake where faiss is the sub-folder name. To link Faiss to your application, use - -``` -add_executable(my_app my_app.cpp) -target_link_libraries(my_app gpufaise faiss) -``` diff --git a/cmake/Cuda.cmake b/cmake/Cuda.cmake deleted file mode 100644 index 7f8dc39d5..000000000 --- a/cmake/Cuda.cmake +++ /dev/null @@ -1,19 +0,0 @@ -# configure cuda - -find_package(CUDA QUIET REQUIRED) -if(CUDA_FOUND) - include_directories(SYSTEM ${CUDA_INCLUDE_DIRS}) - list(APPEND CUDA_LINKER_LIBS ${CUDA_CUDART_LIBRARY} ${CUDA_curand_LIBRARY} ${CUDA_CUBLAS_LIBRARIES}) -else(CUDA_FOUND) - message(STATUS "Could not locate cuda, disabling cuda support.") - set(BUILD_WITH_GPU OFF) - return() -endif(CUDA_FOUND) - -# set cuda flags -if (CMAKE_BUILD_TYPE STREQUAL "Debug") - list(APPEND CUDA_NVCC_FLAGS "-arch=sm_35;-std=c++11;-DVERBOSE;-g;-lineinfo;-Xcompiler;-ggdb") -else() - list(APPEND CUDA_NVCC_FLAGS "-arch=sm_35;-std=c++11;-DVERBOSE;-O3;-DNDEBUG;-Xcompiler;-DNDEBU") -endif() -set(CUDA_PROPAGATE_HOST_FLAGS OFF) diff --git a/cmake/Modules/FindMKL.cmake b/cmake/Modules/FindMKL.cmake deleted file mode 100644 index de93d5ccf..000000000 --- a/cmake/Modules/FindMKL.cmake +++ /dev/null @@ -1,74 +0,0 @@ -# defines: -# MKL_INCLUDE_DIRS -# MKL_LIBRARIES -# MKL_COMPILER_LIBRARIES - a list of compiler libraries (file names) required for MKL - -#unset(MKL_LIB_DIR CACHE) -#unset(MKL_COMPILER_LIB_DIR CACHE) -#unset(MKL_COMPILER_REDIST_PATH CACHE) - -if(NOT HAVE_MKL) - find_path(MKL_INCLUDE_DIRS "mkl.h" PATHS ${MKL_INCLUDE_DIR} DOC "The path to MKL headers") - - if(MKL_INCLUDE_DIRS) - - get_filename_component(_MKL_LIB_PATH "${MKL_INCLUDE_DIRS}/../lib" ABSOLUTE) - - if(APPLE) - # MKL 2017 for mac has only 64 bit libraries without directory prefix - set(_MKL_COMPILER_LIB_PATH ${MKL_INCLUDE_DIRS}/../../compiler/lib) - else() - if(CMAKE_SIZEOF_VOID_P EQUAL 8) - set(_MKL_LIB_PATH "${_MKL_LIB_PATH}/intel64") - set(_MKL_COMPILER_LIB_PATH ${MKL_INCLUDE_DIRS}/../../compiler/lib/intel64) - if(WIN32) - set(_MKL_COMPILER_REDIST_PATH ${MKL_INCLUDE_DIRS}/../../redist/intel64/compiler) - endif() - else() - set(_MKL_LIB_PATH "${_MKL_LIB_PATH}/ia32") - set(_MKL_COMPILER_LIB_PATH ${MKL_INCLUDE_DIRS}/../../compiler/lib/ia32) - if(WIN32) - set(_MKL_COMPILER_REDIST_PATH ${MKL_INCLUDE_DIRS}/../../redist/ia32/compiler) - endif() - endif() - endif() - - # On Linux and Apple take libraries for redistribution from the same location that is used for linking - if(UNIX) - set(_MKL_COMPILER_REDIST_PATH ${_MKL_COMPILER_LIB_PATH}) - endif() - - if(WIN32) - set(MKL_COMPILER_LIBRARIES libiomp5md.dll) - set(MKL_LIBRARIES ${MKL_LIBRARIES} mkl_intel_lp64 mkl_core mkl_intel_thread libiomp5md) - elseif(APPLE) - set(MKL_COMPILER_LIBRARIES libiomp5.dylib) - # generated by https://software.intel.com/en-us/articles/intel-mkl-link-line-advisor - # with the following options: OSX; Clang; Intel64; static; 32 bit integer; OpenMP; Intel OpenMP - set(MKL_LIBRARIES ${MKL_LIBRARIES} libmkl_intel_lp64.a libmkl_intel_thread.a libmkl_core.a iomp5 pthread m dl) - else() - set(MKL_COMPILER_LIBRARIES libiomp5.so) - # a --start-group / --end-group pair is required when linking with static MKL on GNU. - # see https://software.intel.com/en-us/forums/topic/280974#comment-1478780 - # and https://software.intel.com/en-us/articles/intel-mkl-link-line-advisor - set(MKL_LIBRARIES ${MKL_LIBRARIES} - "-Wl,--start-group" - libmkl_intel_lp64.a libmkl_core.a libmkl_intel_thread.a - "-Wl,--end-group" - "-Wl,--exclude-libs,libmkl_intel_lp64.a,--exclude-libs,libmkl_core.a,--exclude-libs,libmkl_intel_thread.a,--exclude-libs,iomp5" - iomp5 dl pthread m) - endif() - - set(MKL_LIB_DIR "${_MKL_LIB_PATH}" - CACHE PATH "Full path of MKL library directory") - set(MKL_COMPILER_LIB_DIR "${_MKL_COMPILER_LIB_PATH}" - CACHE PATH "Full path of MKL compiler library directory") - set(MKL_COMPILER_REDIST_PATH "${_MKL_COMPILER_REDIST_PATH}" - CACHE PATH "Full path of MKL compiler redistributable library directory") - - link_directories(${MKL_LIB_DIR} ${MKL_COMPILER_LIB_DIR}) - - set(HAVE_MKL 1) - - endif(MKL_INCLUDE_DIRS) -endif(NOT HAVE_MKL) diff --git a/cmake/Modules/FindOpenBLAS.cmake b/cmake/Modules/FindOpenBLAS.cmake deleted file mode 100644 index d7b9f595e..000000000 --- a/cmake/Modules/FindOpenBLAS.cmake +++ /dev/null @@ -1,66 +0,0 @@ - - -SET(Open_BLAS_INCLUDE_SEARCH_PATHS - /usr/include - /usr/include/openblas - /usr/include/openblas-base - /usr/local/include - /usr/local/include/openblas - /usr/local/include/openblas-base - /opt/OpenBLAS/include - /opt/local/include - $ENV{OpenBLAS_HOME} - $ENV{OpenBLAS_HOME}/include -) - -SET(Open_BLAS_LIB_SEARCH_PATHS - /lib/ - /lib/openblas-base - /lib64/ - /usr/lib - /usr/lib/openblas-base - /usr/lib64 - /usr/local/lib - /usr/local/lib64 - /opt/OpenBLAS/lib - /opt/local/lib - $ENV{OpenBLAS}cd - $ENV{OpenBLAS}/lib - $ENV{OpenBLAS_HOME} - $ENV{OpenBLAS_HOME}/lib - ) - -FIND_PATH(OpenBLAS_INCLUDE_DIR NAMES openblas_config.h PATHS ${Open_BLAS_INCLUDE_SEARCH_PATHS}) -FIND_LIBRARY(OpenBLAS_LIB NAMES openblas PATHS ${Open_BLAS_LIB_SEARCH_PATHS}) - -SET(OpenBLAS_FOUND ON) - -# Check include files -IF(NOT OpenBLAS_INCLUDE_DIR) - SET(OpenBLAS_FOUND OFF) - MESSAGE(STATUS "Could not find OpenBLAS include. Turning OpenBLAS_FOUND off") -ENDIF() - -# Check libraries -IF(NOT OpenBLAS_LIB) - SET(OpenBLAS_FOUND OFF) - MESSAGE(STATUS "Could not find OpenBLAS lib. Turning OpenBLAS_FOUND off") -ENDIF() - -IF (OpenBLAS_FOUND) - IF (NOT OpenBLAS_FIND_QUIETLY) - MESSAGE(STATUS "Found OpenBLAS libraries: ${OpenBLAS_LIB}") - MESSAGE(STATUS "Found OpenBLAS include: ${OpenBLAS_INCLUDE_DIR}") - ENDIF (NOT OpenBLAS_FIND_QUIETLY) -ELSE (OpenBLAS_FOUND) - IF (OpenBLAS_FIND_REQUIRED) - MESSAGE(FATAL_ERROR "Could not find OpenBLAS") - ENDIF (OpenBLAS_FIND_REQUIRED) -ENDIF (OpenBLAS_FOUND) - -MARK_AS_ADVANCED( - OpenBLAS_INCLUDE_DIR - OpenBLAS_LIB - OpenBLAS -) - diff --git a/gpu/CMakeLists.txt b/gpu/CMakeLists.txt deleted file mode 100644 index 918fd2676..000000000 --- a/gpu/CMakeLists.txt +++ /dev/null @@ -1,28 +0,0 @@ -# specify header and cpp files -file(GLOB_RECURSE faiss_gpu_headers ${CMAKE_CURRENT_SOURCE_DIR}/*.h) -file(GLOB_RECURSE faiss_gpu_cpp ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp) -file(GLOB_RECURSE faiss_gpu_cuh ${CMAKE_CURRENT_SOURCE_DIR}/*.cuh) -file(GLOB_RECURSE faiss_gpu_cu ${CMAKE_CURRENT_SOURCE_DIR}/*.cu) - -set(faiss_lib_gpu gpufaiss) - -list(REMOVE_ITEM faiss_gpu_cpp ${CMAKE_CURRENT_SOURCE_DIR}/test/demo_ivfpq_indexing_gpu.cpp) -list(REMOVE_ITEM faiss_gpu_cpp ${CMAKE_CURRENT_SOURCE_DIR}/test/TestGpuIndexFlat.cpp) -list(REMOVE_ITEM faiss_gpu_cpp ${CMAKE_CURRENT_SOURCE_DIR}/test/TestGpuIndexIVFFlat.cpp) -list(REMOVE_ITEM faiss_gpu_cpp ${CMAKE_CURRENT_SOURCE_DIR}/test/TestGpuIndexIVFPQ.cpp) -list(REMOVE_ITEM faiss_gpu_cpp ${CMAKE_CURRENT_SOURCE_DIR}/test/TestUtils.cpp) -list(REMOVE_ITEM faiss_gpu_cu ${CMAKE_CURRENT_SOURCE_DIR}/test/TestGpuSelect.cu) -list(REMOVE_ITEM faiss_gpu_headers ${CMAKE_CURRENT_SOURCE_DIR}/test/TestUtils.h) -list(REMOVE_ITEM faiss_gpu_headers ${CMAKE_CURRENT_SOURCE_DIR}/perf/IndexWrapper.h) -list(REMOVE_ITEM faiss_gpu_headers ${CMAKE_CURRENT_SOURCE_DIR}/perf/IndexWrapper-inl.h) -list(REMOVE_ITEM faiss_gpu_cu ${CMAKE_CURRENT_SOURCE_DIR}/perf/CompareFlat.cu) -list(REMOVE_ITEM faiss_gpu_cu ${CMAKE_CURRENT_SOURCE_DIR}/perf/CompareIVFFlat.cu) -list(REMOVE_ITEM faiss_gpu_cu ${CMAKE_CURRENT_SOURCE_DIR}/perf/CompareIVFPQ.cu) -list(REMOVE_ITEM faiss_gpu_cu ${CMAKE_CURRENT_SOURCE_DIR}/perf/CompareIVFPQGrid.cu) -list(REMOVE_ITEM faiss_gpu_cu ${CMAKE_CURRENT_SOURCE_DIR}/perf/PerfSelect.cu) -list(REMOVE_ITEM faiss_gpu_cpp ${CMAKE_CURRENT_SOURCE_DIR}/perf/PerfClustering.cpp) -list(REMOVE_ITEM faiss_gpu_cpp ${CMAKE_CURRENT_SOURCE_DIR}/perf/PerfIVFPQAdd.cpp) -list(REMOVE_ITEM faiss_gpu_cpp ${CMAKE_CURRENT_SOURCE_DIR}/perf/WriteIndex.cpp) - -cuda_add_library(${faiss_lib_gpu} STATIC ${faiss_gpu_headers} ${faiss_gpu_cpp} ${faiss_gpu_cuh} ${faiss_gpu_cu}) -add_subdirectory(test) diff --git a/gpu/test/CMakeLists.txt b/gpu/test/CMakeLists.txt deleted file mode 100644 index 6a3fd4f3a..000000000 --- a/gpu/test/CMakeLists.txt +++ /dev/null @@ -1,8 +0,0 @@ -list(APPEND srcs - ${CMAKE_CURRENT_SOURCE_DIR}/demo_ivfpq_indexing_gpu.cpp) - -foreach(source ${srcs}) - get_filename_component(name ${source} NAME_WE) - add_executable(${name} ${source}) - target_link_libraries(${name} ${faiss_lib_gpu} ${faiss_lib} ${CUDA_LINKER_LIBS}) -endforeach(source) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt deleted file mode 100644 index 57005e78a..000000000 --- a/tests/CMakeLists.txt +++ /dev/null @@ -1,19 +0,0 @@ -file(GLOB srcs ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp) - -# Build each source file independently -include_directories(../../) # faiss root directory - -# gtest -find_package(GTest REQUIRED) -include_directories(${GTEST_INCLUDE_DIRS}) - -foreach(source ${srcs}) - get_filename_component(name ${source} NAME_WE) - - # target - add_executable(${name} ${source}) - target_link_libraries(${name} ${faiss_lib} ${BLAS_LIB} ${GTEST_BOTH_LIBRARIES}) - - # Install - install(TARGETS ${name} DESTINATION test) -endforeach(source) diff --git a/tutorial/CMakeLists.txt b/tutorial/CMakeLists.txt deleted file mode 100644 index 2322a85f7..000000000 --- a/tutorial/CMakeLists.txt +++ /dev/null @@ -1 +0,0 @@ -add_subdirectory(cpp) diff --git a/tutorial/cpp/CMakeLists.txt b/tutorial/cpp/CMakeLists.txt deleted file mode 100644 index d65a2a545..000000000 --- a/tutorial/cpp/CMakeLists.txt +++ /dev/null @@ -1,15 +0,0 @@ -file(GLOB srcs ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp) - -# Build each source file independently -include_directories(../../../) # faiss root directory - -foreach(source ${srcs}) - get_filename_component(name ${source} NAME_WE) - - # target - add_executable(${name} ${source}) - target_link_libraries(${name} ${faiss_lib}) - - # Install - install(TARGETS ${name} DESTINATION bin) -endforeach(source)