Use of -funroll-loops option to improve SBC encoder performance
PATCH 1/1 Use of -funroll-loops option to improve SBC encoder performance
Hello,
Benchmark of a loop doing './sbcenc big_buck_bunny_480p_stereo.au > /dev/null' is listed below. The number of iterations was different for ARM and x86, so absolute times for x86 and ARM can't be directly compared :)
=== ARM Cortex-A8 ===
before:
real 0m 12.51s user 0m 11.00s sys 0m 0.58s
after:
real 0m 11.50s user 0m 10.04s sys 0m 0.54s
=== Intel Core2 ===
before:
real 0m12.139s user 0m11.817s sys 0m0.300s
after:
real 0m10.074s user 0m9.797s sys 0m0.256s
===
Overall improvement is more visible on x86, but it is still good for ARM too. Code size increases quite noticeably, but this seems to pay off anyway.
Signature · 2 lines
Best regards, Siarhei Siamashka
Quoted 1 line
From
91d800ecc5f48692588ff908ca212d70eef5d0d3Mon Sep 17 00:00:00 2001
From: Siarhei Siamashka <[email protected]>
Date: Wed, 21 Jan 2009 21:08:34 +0200
Subject: [PATCH] Use of -funroll-loops option to improve SBC encoder performance
Added the use of -funroll-loops gcc option for SBC. Also in order to gain better effect, 'sbc_pack_frame' function body moved to an inline function, which gets instantiated for 4 different subbands/channels combinations. So that 'frame_subbands' and 'frame_channels' arguments become compile time constants and can be better optimized by the compiler.
--- sbc/Makefile.am | 3 ++- sbc/sbc.c | 49 +++++++++++++++++++++++++++++++++---------------- sbc/sbc_primitives.h | 6 ++++++ 3 files changed, 41 insertions(+), 17 deletions(-)
sbc/Makefile.am +2 -1
@@ -12,7 +12,8 @@ libsbc_la_SOURCES = sbc.h sbc.c sbc_math.h sbc_tables.h \ sbc_primitives.h sbc_primitives_mmx.h sbc_primitives_neon.h \ sbc_primitives.c sbc_primitives_mmx.c sbc_primitives_neon.c -libsbc_la_CFLAGS = -finline-functions -funswitch-loops -fgcse-after-reload +libsbc_la_CFLAGS = -finline-functions -funswitch-loops -fgcse-after-reload \ + -funroll-loops noinst_PROGRAMS = sbcinfo sbcdec sbcenc $(sndfile_programs)
sbc/sbc.c +33 -16
115 lines not on this page · raw message
sbc/sbc_primitives.h +6 -0
@@ -28,6 +28,12 @@#define SCALE_OUT_BITS 15 +#ifdef __GNUC__ +#define SBC_ALWAYS_INLINE __attribute__((always_inline)) +#else +#define SBC_ALWAYS_INLINE inline +#endif +struct sbc_encoder_state {int subbands;int position[2 ];
Signature · 1 line
1.5.6.5
Hi Siarhei,
Quoted 6 lines · Siarhei Siamashka
Added the use of -funroll-loops gcc option for SBC. Also in order to gain better effect, '
sbc_pack_frame' function body moved to an inline function, which gets instantiated for 4 different subbands/channels combinations. So that 'frame_subbands' and 'frame_channels' arguments become compile time constants and can be better optimized by the compiler.
The patch has been pushed upstream. Thanks.
Johan