Bugfix for #111 and #112
authorPhil Wang <phil.wang@arm.com>
Tue, 26 May 2015 17:45:17 +0000 (18:45 +0100)
committerPhil Wang <phil.wang@arm.com>
Mon, 8 Jun 2015 08:38:04 +0000 (09:38 +0100)
    - Link stdc++ for static build
    - Switch to intrinsic on iOS

Change-Id: I42e741058241f2ea133d98ba67c7a747d3712bec

CMakeLists.txt
modules/CMakeLists.txt
modules/dsp/NE10_fft_generic_int32.neonintrinsic.h

index 7bee4cc..fc2a5e3 100644 (file)
@@ -99,6 +99,9 @@ else(BUILD_DEBUG)
     message("-- Building type: RELEASE")
 endif(BUILD_DEBUG)
 
+# By default, we compile c intrinsic.
+set(NE10_ASM_OPTIMIZATION off)
+
 if(ANDROID_PLATFORM)
     if(NE10_ARM_HARD_FLOAT)
         set(FLOAT_ABI "hard")
@@ -121,6 +124,8 @@ if(ANDROID_PLATFORM)
             # Refer $NDK/tests/device/hard-float/jni/Android.mk for more details.
             set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wl,--no-warn-mismatch")
         endif()
+        # Turn on asm optimization for Android on ARM v7.
+        set(NE10_ASM_OPTIMIZATION on)
     endif()
     message("-- Loaded toolchain:
     ${CMAKE_C_COMPILER}
@@ -132,6 +137,8 @@ elseif(GNULINUX_PLATFORM)
     if(${NE10_TARGET_ARCH} STREQUAL "armv7")
       set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mthumb-interwork -mthumb -march=armv7-a -mfpu=vfp3 -funsafe-math-optimizations")
       set(CMAKE_ASM_FLAGS "${CMAKE_C_FLAGS} -mthumb-interwork -mthumb -march=armv7-a -mfpu=neon")
+      # Turn on asm optimization for Linux on ARM v7.
+      set(NE10_ASM_OPTIMIZATION on)
     endif()
 elseif(IOS_PLATFORM)
     #set minimal target ios version.If not provided this option, Xcode
index f8a488d..c047208 100644 (file)
@@ -172,6 +172,10 @@ endif()
 if(NE10_ENABLE_DSP)
     #enable NE10_init_dsp
     add_definitions(-DNE10_ENABLE_DSP)
+
+    set(NE10_DSP_INTRINSIC_SRCS )
+    set(NE10_DSP_NEON_SRCS )
+
     # Add dsp C files.
     set(NE10_DSP_C_SRCS
         ${PROJECT_SOURCE_DIR}/common/NE10_mask_table.c
@@ -190,50 +194,64 @@ if(NE10_ENABLE_DSP)
 
     # Tell CMake these files need to be compiled with "-mfpu=neon"
     if(${NE10_TARGET_ARCH} STREQUAL "armv7")
-        # Following definition is only available under armv7.
-        add_definitions(-DENABLE_NE10_FIR_FLOAT_NEON)
-        add_definitions(-DENABLE_NE10_FIR_DECIMATE_FLOAT_NEON)
-        add_definitions(-DENABLE_NE10_FIR_INTERPOLATE_FLOAT_NEON)
-        add_definitions(-DENABLE_NE10_FIR_LATTICE_FLOAT_NEON)
-        add_definitions(-DENABLE_NE10_FIR_SPARSE_FLOAT_NEON)
-        add_definitions(-DENABLE_NE10_IIR_LATTICE_FLOAT_NEON)
-
-        # Add dsp intrinsic NEON files.
-        set(NE10_DSP_INTRINSIC_SRCS
-           ${PROJECT_SOURCE_DIR}/modules/dsp/NE10_fft_float32.neon.c
-           ${PROJECT_SOURCE_DIR}/modules/dsp/NE10_fft_int32.neon.c
-           ${PROJECT_SOURCE_DIR}/modules/dsp/NE10_fft_int16.neon.c
-           ${PROJECT_SOURCE_DIR}/modules/dsp/NE10_fft_generic_float32.neonintrinsic.cpp
-           ${PROJECT_SOURCE_DIR}/modules/dsp/NE10_fft_generic_int32.neonintrinsic.cpp
-           )
-
-      foreach(intrinsic_file ${NE10_DSP_INTRINSIC_SRCS})
-        set_source_files_properties(${intrinsic_file} PROPERTIES COMPILE_FLAGS "-mfpu=neon" )
-      endforeach(intrinsic_file)
+        if(IOS_PLATFORM)
+        else()
+            # Following definition is only available under armv7.
+            add_definitions(-DENABLE_NE10_FIR_FLOAT_NEON)
+            add_definitions(-DENABLE_NE10_FIR_DECIMATE_FLOAT_NEON)
+            add_definitions(-DENABLE_NE10_FIR_INTERPOLATE_FLOAT_NEON)
+            add_definitions(-DENABLE_NE10_FIR_LATTICE_FLOAT_NEON)
+            add_definitions(-DENABLE_NE10_FIR_SPARSE_FLOAT_NEON)
+            add_definitions(-DENABLE_NE10_IIR_LATTICE_FLOAT_NEON)
+
+            # Add dsp NEON files.
+            set(NE10_DSP_NEON_SRCS
+                ${NE10_DSP_NEON_SRCS}
+                ${PROJECT_SOURCE_DIR}/modules/dsp/NE10_fir.neon.s
+                ${PROJECT_SOURCE_DIR}/modules/dsp/NE10_iir.neon.s
+                )
+            endif()
+    endif()
 
-        # Add dsp NEON files.
+    if(NE10_ASM_OPTIMIZATION)
         set(NE10_DSP_NEON_SRCS
+            ${NE10_DSP_NEON_SRCS}
             ${PROJECT_SOURCE_DIR}/modules/dsp/NE10_fft_float32.neon.s
             ${PROJECT_SOURCE_DIR}/modules/dsp/NE10_fft_int32.neon.s
             ${PROJECT_SOURCE_DIR}/modules/dsp/NE10_fft_int16.neon.s
-            ${PROJECT_SOURCE_DIR}/modules/dsp/NE10_fir.neon.s
-            ${PROJECT_SOURCE_DIR}/modules/dsp/NE10_iir.neon.s
-            )
+        )
+        set(NE10_DSP_INTRINSIC_SRCS
+            ${NE10_DSP_INTRINSIC_SRCS}
+            ${PROJECT_SOURCE_DIR}/modules/dsp/NE10_fft_float32.neon.c
+            ${PROJECT_SOURCE_DIR}/modules/dsp/NE10_fft_int32.neon.c
+            ${PROJECT_SOURCE_DIR}/modules/dsp/NE10_fft_int16.neon.c
+        )
     else()
-        # Add dsp intrinsic NEON files.
+        add_definitions(-DNE10_UNROLL_LEVEL=1)
         set(NE10_DSP_INTRINSIC_SRCS
-        ${PROJECT_SOURCE_DIR}/modules/dsp/NE10_rfft_float32.neonintrinsic.c
-        ${PROJECT_SOURCE_DIR}/modules/dsp/NE10_fft_float32.neonintrinsic.c
-        ${PROJECT_SOURCE_DIR}/modules/dsp/NE10_fft_int32.neonintrinsic.c
-        ${PROJECT_SOURCE_DIR}/modules/dsp/NE10_fft_int16.neonintrinsic.c
+            ${NE10_DSP_INTRINSIC_SRCS}
+            ${PROJECT_SOURCE_DIR}/modules/dsp/NE10_fft_float32.neonintrinsic.c
+            ${PROJECT_SOURCE_DIR}/modules/dsp/NE10_fft_int32.neonintrinsic.c
+            ${PROJECT_SOURCE_DIR}/modules/dsp/NE10_fft_int16.neonintrinsic.c
+            ${PROJECT_SOURCE_DIR}/modules/dsp/NE10_rfft_float32.neonintrinsic.c
+            )
+    endif()
+
+    # Add dsp intrinsic NEON files.
+    set(NE10_DSP_INTRINSIC_SRCS
+        ${NE10_DSP_INTRINSIC_SRCS}
         ${PROJECT_SOURCE_DIR}/modules/dsp/NE10_fft_generic_float32.neonintrinsic.cpp
         ${PROJECT_SOURCE_DIR}/modules/dsp/NE10_fft_generic_int32.neonintrinsic.cpp
-        )
+    )
+
+    if(${NE10_TARGET_ARCH} STREQUAL "armv7")
+        foreach(intrinsic_file ${NE10_DSP_INTRINSIC_SRCS})
+            set_source_files_properties(${intrinsic_file} PROPERTIES COMPILE_FLAGS "-mfpu=neon" )
+        endforeach(intrinsic_file)
     endif()
 
 if(IOS_PLATFORM)
-    convert_gas(NE10_DSP_NEON_SRCS NE10_DSP_IOS_NEON_SRCS)
-    set_file_to_c(NE10_DSP_IOS_NEON_SRCS)
+    set_file_to_c(NE10_DSP_NEON_SRCS)
 else(IOS_PLATFORM)
     set_file_to_c(NE10_DSP_NEON_SRCS)
 endif(IOS_PLATFORM)
@@ -372,6 +390,12 @@ if(NE10_BUILD_STATIC OR ANDROID_PLATFORM OR IOS_DEMO)
         VERSION ${NE10_VERSION}
     )
 
+    target_link_libraries(NE10 stdc++)
+
+    set_target_properties(NE10 PROPERTIES
+        LINKER_LANGUAGE C
+    )
+
   if(IOS_DEMO)
     install(TARGETS NE10
       DESTINATION ${CMAKE_CURRENT_SOURCE_DIR}/../ios/NE10Demo/libs/)
index c798e8e..0ded4a3 100644 (file)
@@ -193,7 +193,7 @@ struct NE10_FFT_SCALING {
     inline void operator() (CPLX scratch_out[RADIX])
     {
 #ifdef NE10_DSP_CFFT_SCALING
-        const static int32x4_t one_by_RADIX =
+        const int32x4_t one_by_RADIX =
         {
             (ne10_int32_t) floor(1.0 / RADIX * NE10_F2I32_MAX + 0.5f),
             (ne10_int32_t) floor(1.0 / RADIX * NE10_F2I32_MAX + 0.5f),
@@ -212,7 +212,7 @@ struct NE10_FFT_SCALING<RADIX, 1> {
     inline void operator () (CPLX scratch_out[1])
     {
 #ifdef NE10_DSP_CFFT_SCALING
-        const static int32x4_t one_by_RADIX =
+        const int32x4_t one_by_RADIX =
         {
             (ne10_int32_t) floor(1.0 / RADIX * NE10_F2I32_MAX + 0.5f),
             (ne10_int32_t) floor(1.0 / RADIX * NE10_F2I32_MAX + 0.5f),
@@ -239,7 +239,7 @@ inline void NE10_CPX_SUB_NEON_S32 (CPLX &result, const CPLX a, const CPLX b)
 
 inline REAL NE10_HALF (REAL src)
 {
-    const static int32x4_t CONST_HALF_NEON = { -1, -1, -1, -1};
+    const int32x4_t CONST_HALF_NEON = { -1, -1, -1, -1};
     src = vshlq_s32 (src, CONST_HALF_NEON);
     return src;
 }