Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
F
faiss
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
钟尚武
faiss
Commits
c056f1d3
Commit
c056f1d3
authored
May 31, 2017
by
Adeykin
Committed by
Matthijs Douze
May 31, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
mkl support in cmake (#123)
parent
d3c84568
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
87 additions
and
5 deletions
+87
-5
CMakeLists.txt
CMakeLists.txt
+12
-4
FindMKL.cmake
cmake/Modules/FindMKL.cmake
+74
-0
CMakeLists.txt
tests/CMakeLists.txt
+1
-1
No files found.
CMakeLists.txt
View file @
c056f1d3
...
...
@@ -6,15 +6,23 @@ 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
)
# openblas
find_package
(
OpenBLAS REQUIRED
)
include_directories
(
${
OpenBLAS_INCLUDE_DIR
}
)
# 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
)
...
...
@@ -30,7 +38,7 @@ 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
}
${
Open
BLAS_LIB
}
)
target_link_libraries
(
${
faiss_lib
}
${
OpenMP_CXX_FLAGS
}
${
BLAS_LIB
}
)
# build gpu lib
if
(
BUILD_WITH_GPU
)
...
...
cmake/Modules/FindMKL.cmake
0 → 100644
View file @
c056f1d3
# 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
)
tests/CMakeLists.txt
View file @
c056f1d3
...
...
@@ -12,7 +12,7 @@ foreach(source ${srcs})
# target
add_executable
(
${
name
}
${
source
}
)
target_link_libraries
(
${
name
}
${
faiss_lib
}
${
Open
BLAS_LIB
}
${
GTEST_BOTH_LIBRARIES
}
)
target_link_libraries
(
${
name
}
${
faiss_lib
}
${
BLAS_LIB
}
${
GTEST_BOTH_LIBRARIES
}
)
# Install
install
(
TARGETS
${
name
}
DESTINATION test
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment