Browse Source

fix #1984 & fix cmake (#2000)

tags/20200916
Zhuo Zhang GitHub 5 years ago
parent
commit
418047661c
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 5 deletions
  1. +1
    -1
      examples/CMakeLists.txt
  2. +12
    -4
      src/cpu.cpp

+ 1
- 1
examples/CMakeLists.txt View File

@@ -13,7 +13,7 @@ if(NOT OpenCV_FOUND)
endif()

if(OpenCV_FOUND)
if(${OpenCV_VERSION_MAJOR} GREATER_EQUAL 4)
if(${OpenCV_VERSION_MAJOR} GREATER 3)
set(CMAKE_CXX_STANDARD 11)
endif()
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../src)


+ 12
- 4
src/cpu.cpp View File

@@ -214,8 +214,8 @@ int cpu_support_arm_asimdhp()

int cpu_support_x86_avx2()
{
#if defined(__x86_64__)
#ifdef _MSC_VER
#if (_M_AMD64 || __x86_64__) || (_M_IX86 || __i386__)
#if defined(_MSC_VER)
// TODO move to init function
int cpu_info[4];
__cpuid(cpu_info, 0);
@@ -235,10 +235,18 @@ int cpu_support_x86_avx2()

__cpuid(cpu_info, 7);
return cpu_info[1] & 0x00000020;
#else
// TODO gcc-specific
#elif defined(__clang__)
#if __clang_major__ >= 6
__builtin_cpu_init();
#endif
return __builtin_cpu_supports("avx2");
#elif defined(__GNUC__)
__builtin_cpu_init();
return __builtin_cpu_supports("avx2");
#else
// TODO: other x86 compilers checking avx2 here
NCNN_LOGE("AVX2 detection method is unknown for current compiler");
return 0;
#endif
#else
return 0;


Loading…
Cancel
Save