libdvbcsa - NEON acceleration
Nikolay Nikolaev <[email protected]>
| Newsgroups | gmane.comp.video.videolan.libdvbpsi.devel |
|---|---|
| Message-ID | <CAL7hd5+yarEACvr-w9bHZTn91DSfaFo73A=d229z8Y=dxnh1Ag@mail.gmail.com> |
Hello, I am sending a patch to libdvbcsa whcih implements ARM NEON acceleration. All development and verification is done with chroot/qemu-arm-static on a x86. All test are passing fine. I don't have currently ARM board where I can test the speedup. My benchmarks show slower speed with NEON, which probably is due to the complex emulation of the vector instructions. The current implementation uses 64 bit wide batch size. I am also working on a 128 bit version. Since I am doing my first steps in NEON - any comments and recommendations are more than welcome. If someone can run the benchmarks on a real board and post some numbers, I'll be very thankful. Lastly, I send this mail to these 2 mailing lists as I was recommended to do in #videolan channel. If this is not the proper place - please point me where I can post/discuss these matters. best regards Nikolay Nikolaev _______________________________________________ libdvbpsi-devel mailing list [email protected] http://mailman.videolan.org/listinfo/libdvbpsi-devel
neon.patch
(text/x-patch, 4.8 KB)
Index: configure.ac
===================================================================
--- configure.ac (revision 12)
+++ configure.ac (working copy)
@@ -14,6 +14,7 @@
AC_ARG_ENABLE(mmx, AC_HELP_STRING(--enable-mmx, [Use MMX for bitslice]), mmx_debug=$enableval, enable_mmx=no)
AC_ARG_ENABLE(sse2, AC_HELP_STRING(--enable-sse2, [Use SSE2 for bitslice]), sse2_debug=$enableval, enable_sse2=no)
AC_ARG_ENABLE(altivec, AC_HELP_STRING(--enable-altivec, [Use AltiVec for bitslice]), altivec_debug=$enableval, enable_altivec=no)
+AC_ARG_ENABLE(neon, AC_HELP_STRING(--enable-neon, [Use NEON for bitslice]), neon_debug=$enableval, enable_neon=no)
AM_INIT_AUTOMAKE(libdvbcsa, 1.1.0)
AM_CONFIG_HEADER(config.h)
@@ -46,6 +47,11 @@
AC_DEFINE(DVBCSA_USE_ALTIVEC, 1, Using AltiVec bitslice.)
GCC_CFLAGS="$GCC_CFLAGS -maltivec -mabi=altivec"
+elif test "$enable_neon" = "yes" ; then
+ transpose_64=yes
+ AC_DEFINE(DVBCSA_USE_NEON, 1, Using NEON bitslice.)
+ GCC_CFLAGS="$GCC_CFLAGS -mfpu=neon"
+
elif test "$enable_uint32" = "yes" ; then
transpose_32=yes
AC_DEFINE(DVBCSA_USE_UINT32, 1, Using 32 bits integer bitslice.)
Index: AUTHORS
===================================================================
--- AUTHORS (revision 12)
+++ AUTHORS (working copy)
@@ -8,5 +8,7 @@
PowerPC Altivec support by Nicolas Pouillon <[email protected]>.
+ARM NEON support by Nikolay Nikolaev <[email protected]>
+
Key schedule optimization by Erik Tews <e_tews at cdc.informatik.tu-darmstadt.de>
Index: INSTALL
===================================================================
--- INSTALL (revision 12)
+++ INSTALL (working copy)
@@ -61,7 +61,9 @@
* Altivec 128 bits operation, available on PowerPC targets
+ * NEON 64 bits operation, available on recent ARM targets
+
The default choice can be changed with `--enable-uint32',
`--enable-uint64', `--enable-mmx', `--enable-sse2' and
-`--enable-altivec' switches of the `configure' script.
+`--enable-altivec' `--enable-neon` switches of the `configure' script.
Index: src/dvbcsa_bs_neon.h
===================================================================
--- src/dvbcsa_bs_neon.h (revision 0)
+++ src/dvbcsa_bs_neon.h (revision 0)
@@ -0,0 +1,57 @@
+/*
+
+ This file is part of libdvbcsa.
+
+ libdvbcsa is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published
+ by the Free Software Foundation; either version 2 of the License,
+ or (at your option) any later version.
+
+ libdvbcsa is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with libdvbcsa; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA
+
+ Based on FFdecsa, Copyright (C) 2003-2004 fatih89r
+
+ (c) 2006-2008 Alexandre Becoulet <[email protected]>
+
+*/
+
+#ifndef DVBCSA_NEON_H_
+#define DVBCSA_NEON_H_
+
+# include <arm_neon.h>
+
+typedef uint64x1_t dvbcsa_bs_word_t;
+
+#define BS_BATCH_SIZE 64
+#define BS_BATCH_BYTES 8
+
+#define BS_VAL(n) ((dvbcsa_bs_word_t) (n))
+#define BS_VAL64(n) BS_VAL(0x##n##ULL)
+#define BS_VAL32(n) BS_VAL64(n##n)
+#define BS_VAL16(n) BS_VAL32(n##n)
+#define BS_VAL8(n) BS_VAL16(n##n)
+
+#define BS_AND(a, b) vand_u64 ((a), (b))
+#define BS_OR(a, b) vorr_u64 ((a), (b))
+#define BS_XOR(a, b) veor_u64 ((a), (b))
+#define BS_XOREQ(a, b) { dvbcsa_bs_word_t *_t = &(a); *_t = veor_u64 (*_t, (b)); }
+#define BS_NOT(a) veor_u64 ((a), BS_VAL8(ff))
+
+#define BS_SHL(a, n) vshl_u64 ((a), n)
+#define BS_SHR(a, n) vshr_n_u64 ((a), n)
+#define BS_SHL8(a, n) BS_SHL(a, 8 * (n))
+#define BS_SHR8(a, n) BS_SHR(a, 8 * (n))
+#define BS_EXTRACT8(a, n) ((uint8_t*)&(a))[n]
+
+#define BS_EMPTY()
+
+#endif
+
Index: src/Makefile.am
===================================================================
--- src/Makefile.am (revision 12)
+++ src/Makefile.am (working copy)
@@ -7,7 +7,8 @@
dvbcsa_bs_block.c dvbcsa_bs_key.c dvbcsa_bs_stream.c \
dvbcsa_stream.c dvbcsa_bs.h dvbcsa_pv.h dvbcsa_bs_uint64.h \
dvbcsa_bs_uint32.h dvbcsa_bs_mmx.h dvbcsa_bs_sse.h \
- dvbcsa_bs_altivec.h dvbcsa_bs_transpose.c dvbcsa_key.c
+ dvbcsa_bs_altivec.h dvbcsa_bs_neon.h dvbcsa_bs_transpose.c \
+ dvbcsa_key.c
if TRANSPOSE_128
libdvbcsa_la_SOURCES += dvbcsa_bs_transpose128.c
Index: src/dvbcsa_bs.h
===================================================================
--- src/dvbcsa_bs.h (revision 12)
+++ src/dvbcsa_bs.h (working copy)
@@ -43,6 +43,9 @@
#elif defined(DVBCSA_USE_ALTIVEC)
# include "dvbcsa_bs_altivec.h"
+#elif defined(DVBCSA_USE_NEON)
+# include "dvbcsa_bs_neon.h"
+
#else
# error No dvbcsa word size defined
#endif