[x265] [PATCH] arm: Enable asm by default, allow gcc to auto-detect cpu

Pradeep Ramachandran pradeep at multicorewareinc.com
Wed May 4 23:51:15 CEST 2016


# HG changeset patch
# User Pradeep Ramachandran <pradeep at multicorewareinc.com>
# Date 1462396089 0
#      Wed May 04 21:08:09 2016 +0000
# Node ID 60fe7b04571855b6329bcf0561efa37be41968e4
# Parent  00ea3784bd36c164c5f799c998d7a09f2cb244bf
arm: Enable asm by default, allow gcc to auto-detect cpu

- Enabled ASM by default, and fixed compilation problem without asm
- GCC now auto-detects CPU instead of forcing armv6; significant speed boost
- Convert ARM compile to be native by default - cross compile requires special
work now

diff -r 00ea3784bd36 -r 60fe7b045718 build/arm-linux/crosscompile.cmake
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/build/arm-linux/crosscompile.cmake	Wed May 04 21:08:09 2016 +0000
@@ -0,0 +1,15 @@
+# CMake toolchain file for cross compiling x265 for ARM arch
+# This feature is only supported as experimental. Use with caution.
+# Please report bugs on bitbucket
+# Run cmake with: cmake -DCMAKE_TOOLCHAIN_FILE=crosscompile.cmake -G "Unix Makefiles" ../../source && ccmake ../../source
+
+set(CROSS_COMPILE_ARM 1)
+set(CMAKE_SYSTEM_NAME Linux)
+set(CMAKE_SYSTEM_PROCESSOR armv6l)
+
+# specify the cross compiler
+set(CMAKE_C_COMPILER arm-linux-gnueabi-gcc)
+set(CMAKE_CXX_COMPILER arm-linux-gnueabi-g++)
+
+# specify the target environment
+SET(CMAKE_FIND_ROOT_PATH  /usr/arm-linux-gnueabi)
diff -r 00ea3784bd36 -r 60fe7b045718 build/arm-linux/make-Makefiles.bash
--- a/build/arm-linux/make-Makefiles.bash	Thu Apr 28 09:59:30 2016 +0200
+++ b/build/arm-linux/make-Makefiles.bash	Wed May 04 21:08:09 2016 +0000
@@ -1,4 +1,4 @@
 #!/bin/bash
 # Run this from within a bash shell
 
-cmake -DCMAKE_TOOLCHAIN_FILE=toolchain.cmake -G "Unix Makefiles" ../../source && ccmake ../../source
+cmake -G "Unix Makefiles" ../../source && ccmake ../../source
diff -r 00ea3784bd36 -r 60fe7b045718 build/arm-linux/toolchain.cmake
--- a/build/arm-linux/toolchain.cmake	Thu Apr 28 09:59:30 2016 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,12 +0,0 @@
-# CMake toolchain file for cross compiling x265 for ARM arch
-
-set(CROSS_COMPILE_ARM 1)
-set(CMAKE_SYSTEM_NAME Linux)
-set(CMAKE_SYSTEM_PROCESSOR armv6l)
-
-# specify the cross compiler
-set(CMAKE_C_COMPILER arm-linux-gnueabi-gcc)
-set(CMAKE_CXX_COMPILER arm-linux-gnueabi-g++)
-
-# specify the target environment
-SET(CMAKE_FIND_ROOT_PATH  /usr/arm-linux-gnueabi)
diff -r 00ea3784bd36 -r 60fe7b045718 source/CMakeLists.txt
--- a/source/CMakeLists.txt	Thu Apr 28 09:59:30 2016 +0200
+++ b/source/CMakeLists.txt	Wed May 04 21:08:09 2016 +0000
@@ -185,11 +185,16 @@
     endif()
     if(ARM AND CROSS_COMPILE_ARM)
         set(ARM_ARGS -march=armv6 -mfloat-abi=soft -mfpu=vfp -marm)
-        add_definitions(${ARM_ARGS})
     elseif(ARM)
-        set(ARM_ARGS -march=armv6 -mfloat-abi=hard -mfpu=vfp -marm)
-        add_definitions(${ARM_ARGS})
+		find_package(Neon)
+		if(CPU_HAS_NEON)
+			set(ARM_ARGS -mcpu=native -mfloat-abi=hard -mfpu=neon -marm)
+			add_definitions(-DHAVE_NEON)
+		else()
+			set(ARM_ARGS -mcpu=native -mfloat-abi=hard -mfpu=vfp -marm)
+		endif()
     endif()
+	add_definitions(${ARM_ARGS})
     if(FPROFILE_GENERATE)
         if(INTEL_CXX)
             add_definitions(-prof-gen -prof-dir="${CMAKE_CURRENT_BINARY_DIR}")
@@ -281,7 +286,7 @@
 
 find_package(Yasm)
 if(ARM OR CROSS_COMPILE_ARM)
-    option(ENABLE_ASSEMBLY "Enable use of assembly coded primitives" OFF)
+    option(ENABLE_ASSEMBLY "Enable use of assembly coded primitives" ON)
 elseif(YASM_FOUND AND X86)
     if (YASM_VERSION_STRING VERSION_LESS "1.2.0")
         message(STATUS "Yasm version ${YASM_VERSION_STRING} is too old. 1.2.0 or later required")
diff -r 00ea3784bd36 -r 60fe7b045718 source/cmake/FindNeon.cmake
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/source/cmake/FindNeon.cmake	Wed May 04 21:08:09 2016 +0000
@@ -0,0 +1,10 @@
+include(FindPackageHandleStandardArgs)
+
+# Check the version of neon supported by the ARM CPU
+execute_process(COMMAND cat /proc/cpuinfo | grep Features | grep neon
+				OUTPUT_VARIABLE neon_version
+				ERROR_QUIET
+				OUTPUT_STRIP_TRAILING_WHITESPACE)
+if(neon_version)
+	set(CPU_HAS_NEON 1)
+endif()
diff -r 00ea3784bd36 -r 60fe7b045718 source/common/primitives.cpp
--- a/source/common/primitives.cpp	Thu Apr 28 09:59:30 2016 +0200
+++ b/source/common/primitives.cpp	Wed May 04 21:08:09 2016 +0000
@@ -261,9 +261,9 @@
 void PFX(cpu_cpuid)(uint32_t, uint32_t *eax, uint32_t *, uint32_t *, uint32_t *) { *eax = 0; }
 void PFX(cpu_xgetbv)(uint32_t, uint32_t *, uint32_t *) {}
 
-#if ENABLE_ASSEMBLY && X265_ARCH_ARM == 0
+#if X265_ARCH_ARM
 void PFX(cpu_neon_test)(void) {}
 int PFX(cpu_fast_neon_mrc_test)(void) { return 0; }
-#endif
+#endif // X265_ARCH_ARM
 }
 #endif


More information about the x265-devel mailing list