-
Notifications
You must be signed in to change notification settings - Fork 126
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8f8fa56
commit 70ab9c6
Showing
9 changed files
with
189 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,142 @@ | ||
# Modified from https://github.com/axr/solar-cmake/blob/73cfea0db0284c5e2010aca23989046e5bda95c9/Solar.cmake | ||
# Based on the Qt 5 processor detection code, so should be very accurate | ||
# https://qt.gitorious.org/qt/qtbase/blobs/master/src/corelib/global/qprocessordetection.h | ||
# Currently handles arm (v5, v6, v7), x86 (32/64), ia64, and ppc (32/64) | ||
|
||
# Regarding POWER/PowerPC, just as is noted in the Qt source, | ||
# "There are many more known variants/revisions that we do not handle/detect." | ||
|
||
set(archdetect_c_code " | ||
#if defined(__arm__) || defined(__TARGET_ARCH_ARM) || defined(_M_ARM) || defined(_M_ARM64) || defined(__aarch64__) || defined(__ARM64__) | ||
#if defined(__ARM_ARCH_8__) || defined(__ARM_ARCH_8) \\ | ||
|| defined(__ARM_ARCH_8A__) || defined(__ARM_ARCH_8A) \\ | ||
|| defined(__ARM_ARCH_8R__) || defined(__ARM_ARCH_8R) \\ | ||
|| defined(__ARM_ARCH_8M__) || defined(__ARM_ARCH_8M) \\ | ||
|| (defined(__TARGET_ARCH_ARM) && __TARGET_ARCH_ARM-0 >= 8) | ||
#error cmake_ARCH armv8 | ||
#elif defined(__ARM_ARCH_7__) \\ | ||
|| defined(__ARM_ARCH_7A__) \\ | ||
|| defined(__ARM_ARCH_7R__) \\ | ||
|| defined(__ARM_ARCH_7M__) \\ | ||
|| (defined(__TARGET_ARCH_ARM) && __TARGET_ARCH_ARM-0 >= 7) | ||
#error cmake_ARCH armv7 | ||
#elif defined(__ARM_ARCH_6__) \\ | ||
|| defined(__ARM_ARCH_6J__) \\ | ||
|| defined(__ARM_ARCH_6T2__) \\ | ||
|| defined(__ARM_ARCH_6Z__) \\ | ||
|| defined(__ARM_ARCH_6K__) \\ | ||
|| defined(__ARM_ARCH_6ZK__) \\ | ||
|| defined(__ARM_ARCH_6M__) \\ | ||
|| (defined(__TARGET_ARCH_ARM) && __TARGET_ARCH_ARM-0 >= 6) | ||
#error cmake_ARCH armv6 | ||
#elif defined(__ARM_ARCH_5TEJ__) \\ | ||
|| (defined(__TARGET_ARCH_ARM) && __TARGET_ARCH_ARM-0 >= 5) | ||
#error cmake_ARCH armv5 | ||
#else | ||
#error cmake_ARCH arm | ||
#endif | ||
#elif defined(__i386) || defined(__i386__) || defined(_M_IX86) | ||
#error cmake_ARCH i386 | ||
#elif defined(__x86_64) || defined(__x86_64__) || defined(__amd64) || defined(_M_X64) | ||
#error cmake_ARCH x86_64 | ||
#elif defined(__ia64) || defined(__ia64__) || defined(_M_IA64) | ||
#error cmake_ARCH ia64 | ||
#elif defined(__ppc__) || defined(__ppc) || defined(__powerpc__) \\ | ||
|| defined(_ARCH_COM) || defined(_ARCH_PWR) || defined(_ARCH_PPC) \\ | ||
|| defined(_M_MPPC) || defined(_M_PPC) | ||
#if defined(__ppc64__) || defined(__powerpc64__) || defined(__64BIT__) | ||
#error cmake_ARCH ppc64 | ||
#else | ||
#error cmake_ARCH ppc | ||
#endif | ||
#endif | ||
#error cmake_ARCH unknown | ||
") | ||
|
||
|
||
# Set ppc_support to TRUE before including this file or ppc and ppc64 | ||
# will be treated as invalid architectures since they are no longer supported by Apple | ||
|
||
function(target_architecture output_var) | ||
if(APPLE AND CMAKE_OSX_ARCHITECTURES) | ||
# On OS X we use CMAKE_OSX_ARCHITECTURES *if* it was set | ||
# First let's normalize the order of the values | ||
|
||
# Note that it's not possible to compile PowerPC applications if you are using | ||
# the OS X SDK version 10.6 or later - you'll need 10.4/10.5 for that, so we | ||
# disable it by default | ||
# See this page for more information: | ||
# http://stackoverflow.com/questions/5333490/how-can-we-restore-ppc-ppc64-as-well-as-full-10-4-10-5-sdk-support-to-xcode-4 | ||
|
||
# Architecture defaults to i386 or ppc on OS X 10.5 and earlier, depending on the CPU type detected at runtime. | ||
# On OS X 10.6+ the default is x86_64 if the CPU supports it, i386 otherwise. | ||
|
||
foreach(osx_arch ${CMAKE_OSX_ARCHITECTURES}) | ||
if("${osx_arch}" STREQUAL "ppc" AND ppc_support) | ||
set(osx_arch_ppc TRUE) | ||
elseif("${osx_arch}" STREQUAL "i386") | ||
set(osx_arch_i386 TRUE) | ||
elseif("${osx_arch}" STREQUAL "x86_64") | ||
set(osx_arch_x86_64 TRUE) | ||
elseif("${osx_arch}" STREQUAL "ppc64" AND ppc_support) | ||
set(osx_arch_ppc64 TRUE) | ||
else() | ||
message(FATAL_ERROR "Invalid OS X arch name: ${osx_arch}") | ||
endif() | ||
endforeach() | ||
|
||
# Now add all the architectures in our normalized order | ||
if(osx_arch_ppc) | ||
list(APPEND ARCH ppc) | ||
endif() | ||
|
||
if(osx_arch_i386) | ||
list(APPEND ARCH i386) | ||
endif() | ||
|
||
if(osx_arch_x86_64) | ||
list(APPEND ARCH x86_64) | ||
endif() | ||
|
||
if(osx_arch_ppc64) | ||
list(APPEND ARCH ppc64) | ||
endif() | ||
else() | ||
file(WRITE "${CMAKE_BINARY_DIR}/arch.c" "${archdetect_c_code}") | ||
|
||
enable_language(C) | ||
|
||
# Detect the architecture in a rather creative way... | ||
# This compiles a small C program which is a series of ifdefs that selects a | ||
# particular #error preprocessor directive whose message string contains the | ||
# target architecture. The program will always fail to compile (both because | ||
# file is not a valid C program, and obviously because of the presence of the | ||
# #error preprocessor directives... but by exploiting the preprocessor in this | ||
# way, we can detect the correct target architecture even when cross-compiling, | ||
# since the program itself never needs to be run (only the compiler/preprocessor) | ||
try_run( | ||
run_result_unused | ||
compile_result_unused | ||
"${CMAKE_BINARY_DIR}" | ||
"${CMAKE_BINARY_DIR}/arch.c" | ||
COMPILE_OUTPUT_VARIABLE ARCH | ||
CMAKE_FLAGS CMAKE_OSX_ARCHITECTURES=${CMAKE_OSX_ARCHITECTURES} | ||
) | ||
|
||
# Parse the architecture name from the compiler output | ||
string(REGEX MATCH "cmake_ARCH ([a-zA-Z0-9_]+)" ARCH "${ARCH}") | ||
|
||
# Get rid of the value marker leaving just the architecture name | ||
string(REPLACE "cmake_ARCH " "" ARCH "${ARCH}") | ||
|
||
# If we are compiling with an unknown architecture this variable should | ||
# already be set to "unknown" but in the case that it's empty (i.e. due | ||
# to a typo in the code), then set it to unknown | ||
if (NOT ARCH) | ||
set(ARCH unknown) | ||
endif() | ||
endif() | ||
|
||
set(${output_var} "${ARCH}" PARENT_SCOPE) | ||
endfunction() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,6 +19,10 @@ | |
|
||
using namespace faiss; | ||
|
||
#ifdef ARM | ||
#include "3rd_party/simd_utils/simd_utils.h" | ||
#endif | ||
|
||
|
||
extern "C" { | ||
|
||
|
Submodule simd_utils
updated
33 files
+0 −0 | .clang-format | |
+0 −0 | LICENSE | |
+119 −145 | README.md | |
+0 −0 | TODO | |
+13 −43 | avx512_mathfun.h | |
+24 −41 | avx_mathfun.h | |
+0 −0 | latencies.txt | |
+1 −1 | mysincosf.h | |
+0 −0 | neon_mathfun.h | |
+1,562 −6,177 | simd_test.c | |
+1 −1 | simd_test_opencl.c | |
+29 −1,087 | simd_utils.h | |
+177 −4,157 | simd_utils_altivec_float.h | |
+0 −931 | simd_utils_altivec_int32.h | |
+62 −638 | simd_utils_avx512_double.h | |
+506 −697 | simd_utils_avx512_float.h | |
+20 −588 | simd_utils_avx512_int32.h | |
+46 −585 | simd_utils_avx_double.h | |
+395 −696 | simd_utils_avx_float.h | |
+21 −559 | simd_utils_avx_int32.h | |
+125 −1,047 | simd_utils_constants.h | |
+1 −1 | simd_utils_kernel.cl | |
+604 −0 | simd_utils_riscv.h | |
+0 −398 | simd_utils_riscv_double.h | |
+0 −3,188 | simd_utils_riscv_float.h | |
+0 −379 | simd_utils_riscv_int.h | |
+174 −676 | simd_utils_sse_double.h | |
+441 −746 | simd_utils_sse_float.h | |
+11 −490 | simd_utils_sse_int32.h | |
+13 −79 | simd_utils_svml.h | |
+2,185 −2,611 | sse2neon.h | |
+4 −9 | sse2neon_wrapper.h | |
+20 −43 | sse_mathfun.h |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
70ab9c6
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what's the cmake flags to compile this?
70ab9c6
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cmake .. -DCOMPILE_CUDA=OFF