aboutsummaryrefslogtreecommitdiff
path: root/sumsq.c
diff options
context:
space:
mode:
authorBill Yi <byi@google.com>2015-06-23 13:53:11 -0700
committerBill Yi <byi@google.com>2015-06-23 13:53:11 -0700
commit4e213d510f437769f8a28578dd4f786fb7d16c44 (patch)
tree0d5cbd5a7eee87b3dca5820d282ef618a7e25991 /sumsq.c
downloadfec-4e213d510f437769f8a28578dd4f786fb7d16c44.tar.gz
Initial codenougat-mr1-arc
Diffstat (limited to 'sumsq.c')
-rw-r--r--sumsq.c40
1 files changed, 40 insertions, 0 deletions
diff --git a/sumsq.c b/sumsq.c
new file mode 100644
index 0000000..9ed6a39
--- /dev/null
+++ b/sumsq.c
@@ -0,0 +1,40 @@
+/* Compute the sum of the squares of a vector of signed shorts
+
+ * Copyright 2004 Phil Karn, KA9Q
+ * May be used under the terms of the GNU Lesser General Public License (LGPL)
+ */
+
+#include <stdlib.h>
+#include "fec.h"
+
+unsigned long long sumsq_port(signed short *,int);
+
+#ifdef __i386__
+unsigned long long sumsq_mmx(signed short *,int);
+unsigned long long sumsq_sse(signed short *,int);
+unsigned long long sumsq_sse2(signed short *,int);
+#endif
+
+#ifdef __VEC__
+unsigned long long sumsq_av(signed short *,int);
+#endif
+
+unsigned long long sumsq(signed short *in,int cnt){
+ switch(Cpu_mode){
+ case PORT:
+ default:
+ return sumsq_port(in,cnt);
+#ifdef __i386__
+ case SSE:
+ case MMX:
+ return sumsq_mmx(in,cnt);
+ case SSE2:
+ return sumsq_sse2(in,cnt);
+#endif
+
+#ifdef __VEC__
+ case ALTIVEC:
+ return sumsq_av(in,cnt);
+#endif
+ }
+}