ShiqiYu / libfacedetection

An open source library for face detection in images. The face detection speed can reach 1000FPS.
Other
12.27k stars 3.05k forks source link

Build without avx2 #194

Closed Exdenta closed 4 years ago

Exdenta commented 4 years ago

Hi, I am just wondering, is there a way to build and use libfacedetection on cpu without avx2? My cpu supports only avx and when i'm building this project with -DENABLE_AVX2=OFF, build craches with this error:

[ 10%] Building CXX object CMakeFiles/facedetection.dir/src/facedetectcnn.cpp.o
/home/shershakov/Projects/Face_Detection/libfacedetection/src/facedetectcnn.cpp: In function ‘int dotProductUint8Int8(unsigned char*, signed char*, int, int)’:
/home/shershakov/Projects/Face_Detection/libfacedetection/src/facedetectcnn.cpp:117:41: warning: AVX vector return without AVX enabled changes the ABI [-Wpsabi]
     __m256i ones16 = _mm256_set1_epi16(1);
                                         ^
In file included from /usr/lib/gcc/x86_64-linux-gnu/7/include/immintrin.h:41:0,
                 from /home/shershakov/Projects/Face_Detection/libfacedetection/src/facedetectcnn.h:52,
                 from /home/shershakov/Projects/Face_Detection/libfacedetection/src/facedetectcnn.cpp:39:
/usr/lib/gcc/x86_64-linux-gnu/7/include/avxintrin.h:1234:1: error: inlining failed in call to always_inline ‘__m256i _mm256_setzero_si256()’: target specific option mismatch
 _mm256_setzero_si256 (void)
 ^~~~~~~~~~~~~~~~~~~~
/home/shershakov/Projects/Face_Detection/libfacedetection/src/facedetectcnn.cpp:118:48: note: called from here
     __m256i sum_int32x8 = _mm256_setzero_si256();
                                                ^
In file included from /usr/lib/gcc/x86_64-linux-gnu/7/include/immintrin.h:41:0,
                 from /home/shershakov/Projects/Face_Detection/libfacedetection/src/facedetectcnn.h:52,
                 from /home/shershakov/Projects/Face_Detection/libfacedetection/src/facedetectcnn.cpp:39:
/usr/lib/gcc/x86_64-linux-gnu/7/include/avxintrin.h:1325:1: error: inlining failed in call to always_inline ‘__m256i _mm256_set1_epi16(short int)’: target specific option mismatch
 _mm256_set1_epi16 (short __A)
 ^~~~~~~~~~~~~~~~~
/home/shershakov/Projects/Face_Detection/libfacedetection/src/facedetectcnn.cpp:117:41: note: called from here
     __m256i ones16 = _mm256_set1_epi16(1);
                                         ^
In file included from /usr/lib/gcc/x86_64-linux-gnu/7/include/immintrin.h:43:0,
                 from /home/shershakov/Projects/Face_Detection/libfacedetection/src/facedetectcnn.h:52,
                 from /home/shershakov/Projects/Face_Detection/libfacedetection/src/facedetectcnn.cpp:39:
/usr/lib/gcc/x86_64-linux-gnu/7/include/avx2intrin.h:333:1: error: inlining failed in call to always_inline ‘__m256i _mm256_maddubs_epi16(__m256i, __m256i)’: target specific option mismatch
 _mm256_maddubs_epi16 (__m256i __X, __m256i __Y)
 ^~~~~~~~~~~~~~~~~~~~
/home/shershakov/Projects/Face_Detection/libfacedetection/src/facedetectcnn.cpp:123:22: note: called from here
         sum_int16x16 = _mm256_maddubs_epi16(a_uint8x32, b_int8x32);
         ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/lib/gcc/x86_64-linux-gnu/7/include/immintrin.h:41:0,
                 from /home/shershakov/Projects/Face_Detection/libfacedetection/src/facedetectcnn.h:52,
                 from /home/shershakov/Projects/Face_Detection/libfacedetection/src/facedetectcnn.cpp:39:
/usr/lib/gcc/x86_64-linux-gnu/7/include/avxintrin.h:907:1: error: inlining failed in call to always_inline ‘__m256i _mm256_load_si256(const __m256i*)’: target specific option mismatch
 _mm256_load_si256 (__m256i const *__P)
 ^~~~~~~~~~~~~~~~~
/home/shershakov/Projects/Face_Detection/libfacedetection/src/facedetectcnn.cpp:122:19: note: called from here
         b_int8x32 = _mm256_load_si256((__m256i const *)(p2 + i));
         ~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/lib/gcc/x86_64-linux-gnu/7/include/immintrin.h:41:0,
                 from /home/shershakov/Projects/Face_Detection/libfacedetection/src/facedetectcnn.h:52,
                 from /home/shershakov/Projects/Face_Detection/libfacedetection/src/facedetectcnn.cpp:39:
/usr/lib/gcc/x86_64-linux-gnu/7/include/avxintrin.h:907:1: error: inlining failed in call to always_inline ‘__m256i _mm256_load_si256(const __m256i*)’: target specific option mismatch
 _mm256_load_si256 (__m256i const *__P)
 ^~~~~~~~~~~~~~~~~
/home/shershakov/Projects/Face_Detection/libfacedetection/src/facedetectcnn.cpp:121:20: note: called from here
         a_uint8x32 = _mm256_load_si256((__m256i const *)(p1 + i));
         ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/lib/gcc/x86_64-linux-gnu/7/include/immintrin.h:43:0,
                 from /home/shershakov/Projects/Face_Detection/libfacedetection/src/facedetectcnn.h:52,
                 from /home/shershakov/Projects/Face_Detection/libfacedetection/src/facedetectcnn.cpp:39:
/usr/lib/gcc/x86_64-linux-gnu/7/include/avx2intrin.h:341:1: error: inlining failed in call to always_inline ‘__m256i _mm256_madd_epi16(__m256i, __m256i)’: target specific option mismatch
 _mm256_madd_epi16 (__m256i __A, __m256i __B)
 ^~~~~~~~~~~~~~~~~
/home/shershakov/Projects/Face_Detection/libfacedetection/src/facedetectcnn.cpp:124:21: note: called from here
         tmp_int32x8 = _mm256_madd_epi16(sum_int16x16, ones16);
         ~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/lib/gcc/x86_64-linux-gnu/7/include/immintrin.h:43:0,
                 from /home/shershakov/Projects/Face_Detection/libfacedetection/src/facedetectcnn.h:52,
                 from /home/shershakov/Projects/Face_Detection/libfacedetection/src/facedetectcnn.cpp:39:
/usr/lib/gcc/x86_64-linux-gnu/7/include/avx2intrin.h:119:1: error: inlining failed in call to always_inline ‘__m256i _mm256_add_epi32(__m256i, __m256i)’: target specific option mismatch
 _mm256_add_epi32 (__m256i __A, __m256i __B)
 ^~~~~~~~~~~~~~~~
/home/shershakov/Projects/Face_Detection/libfacedetection/src/facedetectcnn.cpp:125:21: note: called from here
         sum_int32x8 = _mm256_add_epi32(sum_int32x8, tmp_int32x8);
         ~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/lib/gcc/x86_64-linux-gnu/7/include/immintrin.h:43:0,
                 from /home/shershakov/Projects/Face_Detection/libfacedetection/src/facedetectcnn.h:52,
                 from /home/shershakov/Projects/Face_Detection/libfacedetection/src/facedetectcnn.cpp:39:
/usr/lib/gcc/x86_64-linux-gnu/7/include/avx2intrin.h:295:1: error: inlining failed in call to always_inline ‘__m256i _mm256_hadd_epi32(__m256i, __m256i)’: target specific option mismatch
 _mm256_hadd_epi32 (__m256i __X, __m256i __Y)
 ^~~~~~~~~~~~~~~~~
/home/shershakov/Projects/Face_Detection/libfacedetection/src/facedetectcnn.cpp:127:17: note: called from here
     sum_int32x8 = _mm256_hadd_epi32(sum_int32x8, sum_int32x8);
     ~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/lib/gcc/x86_64-linux-gnu/7/include/immintrin.h:43:0,
                 from /home/shershakov/Projects/Face_Detection/libfacedetection/src/facedetectcnn.h:52,
                 from /home/shershakov/Projects/Face_Detection/libfacedetection/src/facedetectcnn.cpp:39:
/usr/lib/gcc/x86_64-linux-gnu/7/include/avx2intrin.h:295:1: error: inlining failed in call to always_inline ‘__m256i _mm256_hadd_epi32(__m256i, __m256i)’: target specific option mismatch
 _mm256_hadd_epi32 (__m256i __X, __m256i __Y)
 ^~~~~~~~~~~~~~~~~
/home/shershakov/Projects/Face_Detection/libfacedetection/src/facedetectcnn.cpp:128:17: note: called from here
     sum_int32x8 = _mm256_hadd_epi32(sum_int32x8, sum_int32x8);
     ~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/lib/gcc/x86_64-linux-gnu/7/include/immintrin.h:41:0,
                 from /home/shershakov/Projects/Face_Detection/libfacedetection/src/facedetectcnn.h:52,
                 from /home/shershakov/Projects/Face_Detection/libfacedetection/src/facedetectcnn.cpp:39:
/usr/lib/gcc/x86_64-linux-gnu/7/include/avxintrin.h:913:1: error: inlining failed in call to always_inline ‘void _mm256_store_si256(__m256i*, __m256i)’: target specific option mismatch
 _mm256_store_si256 (__m256i *__P, __m256i __A)
 ^~~~~~~~~~~~~~~~~~
/home/shershakov/Projects/Face_Detection/libfacedetection/src/facedetectcnn.cpp:129:23: note: called from here
     _mm256_store_si256((__m256i*)sumarray, sum_int32x8);
     ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
CMakeFiles/facedetection.dir/build.make:88: recipe for target 'CMakeFiles/facedetection.dir/src/facedetectcnn.cpp.o' failed
make[2]: *** [CMakeFiles/facedetection.dir/src/facedetectcnn.cpp.o] Error 1
CMakeFiles/Makefile2:109: recipe for target 'CMakeFiles/facedetection.dir/all' failed
make[1]: *** [CMakeFiles/facedetection.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2
SunnyFog commented 4 years ago

(warning: I do not have more experience with this project than you do!)

In facedetectcnn.h lines 41..43: _ENABLE_AVX2 will be defined even if it previously wasn't. I commented out line 42 to allow it to run.

Exdenta commented 4 years ago

(warning: I do not have more experience with this project than you do!)

In facedetectcnn.h lines 41..43: _ENABLE_AVX2 will be defined even if it previously wasn't. I commented out line 42 to allow it to run.

Thanks, that helped!