diff --git a/CMakeLists.txt b/CMakeLists.txt index a30fa099828..7647a67b2c8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -368,14 +368,24 @@ elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^(powerpc|ppc)") if(NCNN_PPC64LE_VSX) set(NCNN_TARGET_ARCH x86) + set(CMAKE_REQUIRED_FLAGS "-DNO_WARN_X86_INTRINSICS -D__SSE2__") + check_cxx_source_compiles("#include \nint main() { return 0; }" NCNN_COMPILER_SUPPORT_PPC64LE_SSE2) + unset(CMAKE_REQUIRED_FLAGS) + set(CMAKE_REQUIRED_FLAGS "-DNO_WARN_X86_INTRINSICS -D__SSE4_1__") check_cxx_source_compiles("#include \nint main() { __m128i _v, _a, _b; _v = _mm_packus_epi32(_a, _b); return 0; }" NCNN_COMPILER_SUPPORT_PPC64LE_SSE41) unset(CMAKE_REQUIRED_FLAGS) + if(NCNN_COMPILER_SUPPORT_PPC64LE_SSE2) + option(NCNN_VSX_SSE2 "optimize ppc64le platform with sse2 extension" ON) + else() + message(WARNING "The compiler does not support sse2 extension. NCNN_VSX_SSE2 will be OFF.") + endif() + if(NCNN_COMPILER_SUPPORT_PPC64LE_SSE41) - option(NCNN_SSE41 "optimize ppc64le platform with sse4.1 extension" ON) + option(NCNN_VSX_SSE41 "optimize ppc64le platform with sse4.1 extension" ON) else() - message(WARNING "The compiler does not support sse4.1 extension. NCNN_SSE41 will be OFF.") + message(WARNING "The compiler does not support sse4.1 extension. NCNN_VSX_SSE41 will be OFF.") endif() endif() elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^(xtensa)") diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 204ac63870c..cb7be1f6e9c 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -503,8 +503,13 @@ if(NCNN_TARGET_ARCH STREQUAL "riscv" AND NOT C906) endif() if(NCNN_PPC64LE_VSX) + # Auto-translate SSE2 to VSX if compiler is new enough. + if(NCNN_VSX_SSE2) + target_compile_options(ncnn PRIVATE -DNO_WARN_X86_INTRINSICS -D__SSE2__) + endif() + # Auto-translate SSE4.1 to VSX if compiler is new enough. - if(NCNN_SSE41) + if(NCNN_VSX_SSE41) target_compile_options(ncnn PRIVATE -DNO_WARN_X86_INTRINSICS -D__SSE4_1__) endif() endif() diff --git a/toolchains/power9le-linux-gnu-vsx.clang.toolchain.cmake b/toolchains/power9le-linux-gnu-vsx.clang.toolchain.cmake index 67e2ba23fce..4a4438cf0bb 100644 --- a/toolchains/power9le-linux-gnu-vsx.clang.toolchain.cmake +++ b/toolchains/power9le-linux-gnu-vsx.clang.toolchain.cmake @@ -8,8 +8,8 @@ set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) -set(CMAKE_C_FLAGS "-target powerpc64le-linux-gnu -I/usr/powerpc64le-linux-gnu/include -mcpu=power9 -mtune=power9 -DNO_WARN_X86_INTRINSICS -D__MMX__ -D__SSE__ -D__SSE2__ -D__SSSE3__") -set(CMAKE_CXX_FLAGS "-target powerpc64le-linux-gnu -I/usr/powerpc64le-linux-gnu/include -I/usr/powerpc64le-linux-gnu/include/c++/10/powerpc64le-linux-gnu -mcpu=power9 -mtune=power9 -DNO_WARN_X86_INTRINSICS -D__MMX__ -D__SSE__ -D__SSE2__ -D__SSSE3__") +set(CMAKE_C_FLAGS "-target powerpc64le-linux-gnu -I/usr/powerpc64le-linux-gnu/include -mcpu=power9 -mtune=power9 -DNO_WARN_X86_INTRINSICS -D__MMX__ -D__SSE__ -D__SSSE3__") +set(CMAKE_CXX_FLAGS "-target powerpc64le-linux-gnu -I/usr/powerpc64le-linux-gnu/include -I/usr/powerpc64le-linux-gnu/include/c++/10/powerpc64le-linux-gnu -mcpu=power9 -mtune=power9 -DNO_WARN_X86_INTRINSICS -D__MMX__ -D__SSE__ -D__SSSE3__") # cache flags set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS}" CACHE STRING "c flags") diff --git a/toolchains/power9le-linux-gnu-vsx.toolchain.cmake b/toolchains/power9le-linux-gnu-vsx.toolchain.cmake index 5760efb3b26..5c0c9d8b299 100644 --- a/toolchains/power9le-linux-gnu-vsx.toolchain.cmake +++ b/toolchains/power9le-linux-gnu-vsx.toolchain.cmake @@ -8,8 +8,8 @@ set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) -set(CMAKE_C_FLAGS "-mcpu=power9 -mtune=power9 -DNO_WARN_X86_INTRINSICS -D__MMX__ -D__SSE__ -D__SSE2__ -D__SSSE3__") -set(CMAKE_CXX_FLAGS "-mcpu=power9 -mtune=power9 -DNO_WARN_X86_INTRINSICS -D__MMX__ -D__SSE__ -D__SSE2__ -D__SSSE3__") +set(CMAKE_C_FLAGS "-mcpu=power9 -mtune=power9 -DNO_WARN_X86_INTRINSICS -D__MMX__ -D__SSE__ -D__SSSE3__") +set(CMAKE_CXX_FLAGS "-mcpu=power9 -mtune=power9 -DNO_WARN_X86_INTRINSICS -D__MMX__ -D__SSE__ -D__SSSE3__") # cache flags set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS}" CACHE STRING "c flags")