summaryrefslogtreecommitdiff
path: root/liboil/simdpack
diff options
context:
space:
mode:
authorDavid Schleef <ds@schleef.org>2005-03-17 05:49:50 +0000
committerDavid Schleef <ds@schleef.org>2005-03-17 05:49:50 +0000
commitd4b73429db72ff1a68e64ee19945c4cfdb6e9a91 (patch)
tree5afdc1c87576559577f6844714dacfeb97725eb9 /liboil/simdpack
parentf426ab2ae9cb19d7e788e0e11ab91ac0e043ed7c (diff)
downloadliboil-d4b73429db72ff1a68e64ee19945c4cfdb6e9a91.tar.gz
Patch from Jakub Stachowski <stachowski@hypair.net> to add a
few classes and implementations. They're not correct -- requires fixage before release. * examples/work/Makefile.am: * examples/work/work.c: * liboil/simdpack/Makefile.am: * liboil/simdpack/abs_sse.c: (abs_u8_s8_sse): * liboil/simdpack/clip_ref.c: * liboil/simdpack/scalaradd.c: (scalaradd_s8_mmx): * liboil/simdpack/simdpack.h: * liboil/simdpack/vectoradd_s.c:
Diffstat (limited to 'liboil/simdpack')
-rw-r--r--liboil/simdpack/Makefile.am11
-rw-r--r--liboil/simdpack/abs_sse.c40
-rw-r--r--liboil/simdpack/clip_ref.c18
-rw-r--r--liboil/simdpack/scalaradd.c53
-rw-r--r--liboil/simdpack/simdpack.h13
-rw-r--r--liboil/simdpack/vectoradd_s.c43
6 files changed, 173 insertions, 5 deletions
diff --git a/liboil/simdpack/Makefile.am b/liboil/simdpack/Makefile.am
index f923315..c1c6bbb 100644
--- a/liboil/simdpack/Makefile.am
+++ b/liboil/simdpack/Makefile.am
@@ -23,17 +23,24 @@ c_sources = \
sincos_f64.c \
squaresum_f64.c \
sum_f64.c \
+ vectoradd_s.c \
vectoradd_f64.c
if HAVE_CPU_I386
i386_sources = \
abs_i386.c \
mult8x8_i386.c \
- scalarmult_i386.c
+ abs_sse.c \
+ scalarmult_i386.c \
+ vectoradd_s_i386.c
else
i386_sources =
endif
+libsimdpack_la_abs_sse_o_CFLAGS = -msse
+libsimdpack_la_scalaradd_o_CFLAGS = -mmmx
+libsimdpack_la_vectoradd_s_o_CFLAGS = -mmmx -msse
+
if HAVE_CPU_POWERPC
powerpc_sources = \
abs_powerpc.c \
@@ -49,7 +56,7 @@ libsimdpack_la_SOURCES = \
$(c_sources) $(i386_sources) $(powerpc_sources)
libsimdpack_la_LIBADD = \
$(opt_libs)
-libsimdpack_la_CFLAGS = $(LIBOIL_CFLAGS)
+libsimdpack_la_CFLAGS = $(LIBOIL_CFLAGS) -mmmx -msse
noinst_HEADERS = \
simdpack.h
diff --git a/liboil/simdpack/abs_sse.c b/liboil/simdpack/abs_sse.c
new file mode 100644
index 0000000..989bce3
--- /dev/null
+++ b/liboil/simdpack/abs_sse.c
@@ -0,0 +1,40 @@
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <liboil/liboilfunction.h>
+#include <liboil/simdpack/simdpack.h>
+#include <math.h>
+#include <liboil/liboilgcc.h>
+
+#define ABS(x) ((x)>0 ? (x) : -(x))
+
+
+static void
+abs_u8_s8_sse (uint8_t *dest, int dstr, int8_t *src, int sstr, int n)
+{
+ register vec_s8 zero;
+ vec_s8 *vdest;
+ vec_s8 *vsrc;
+
+ while (n & 7) {
+ *dest = ABS (*src);
+ OIL_INCREMENT (dest, dstr);
+ OIL_INCREMENT (src, sstr);
+ n--;
+ }
+ n /= 8;
+ vsrc=(vec_s8*)src;
+ vdest=(vec_s8*)dest;
+
+ while (n>0)
+ {
+ zero = (vec_s8)((long long) 0);
+ zero=zero-(*vsrc);
+ *vdest=__builtin_ia32_pminub(*vsrc,zero);
+ OIL_INCREMENT (vdest, 8);
+ OIL_INCREMENT (vsrc, 8);
+ n--;
+ }
+}
+OIL_DEFINE_IMPL_FULL (abs_u8_s8_sse, abs_u8_s8,OIL_IMPL_FLAG_SSE);
diff --git a/liboil/simdpack/clip_ref.c b/liboil/simdpack/clip_ref.c
index 461edaa..06517a4 100644
--- a/liboil/simdpack/clip_ref.c
+++ b/liboil/simdpack/clip_ref.c
@@ -30,6 +30,7 @@
#endif
#include <liboil/liboilfunction.h>
+#include <liboil/liboiltest.h>
#define CLIP_DEFINE_REF(type) \
static void clip_ ## type ## _ref ( \
@@ -48,12 +49,25 @@ static void clip_ ## type ## _ref ( \
OIL_GET(dest,i*dstr,type_ ## type) = x; \
} \
} \
-OIL_DEFINE_CLASS(clip_ ## type, \
+static void \
+clip_ ## type ## _test (OilTest *test) \
+{ \
+ type_ ## type *s2 = (type_ ## type *)(test->params[OIL_ARG_SRC2].src_data + \
+ OIL_TEST_HEADER); \
+ type_ ## type *s3 = (type_ ## type *)(test->params[OIL_ARG_SRC3].src_data + \
+ OIL_TEST_HEADER); \
+ if (*s2 > *s3) { \
+ type_ ## type tmp; \
+ tmp = *s2; *s2 = *s3; *s3 = tmp; \
+ } \
+} \
+OIL_DEFINE_CLASS_FULL(clip_ ## type, \
"type_" #type " *dest, " \
"int dstr, " \
"type_" #type " *src, " \
"int sstr, int n, " \
- "type_" #type " *s2_1, type_" #type " *s3_1"); \
+ "type_" #type " *s2_1, type_" #type " *s3_1", \
+ clip_ ## type ## _test); \
OIL_DEFINE_IMPL_REF(clip_ ## type ## _ref, clip_ ## type)
CLIP_DEFINE_REF (s8);
diff --git a/liboil/simdpack/scalaradd.c b/liboil/simdpack/scalaradd.c
index f5f8857..96cbe67 100644
--- a/liboil/simdpack/scalaradd.c
+++ b/liboil/simdpack/scalaradd.c
@@ -31,6 +31,8 @@
#include <liboil/liboilfunction.h>
#include <liboil/simdpack/simdpack.h>
+#include <liboil/liboilgcc.h>
+#include <string.h>
#define SCALARADD_DEFINE_REF(type) \
static void scalaradd_ ## type ## _ref( \
@@ -176,4 +178,53 @@ SCALARADD_DEFINE_UNROLL4 (f32);
SCALARADD_DEFINE_UNROLL4 (f64);
-
+static void scalaradd_s8_mmx(
+ type_s8 *dest, int dstr,
+ type_s8 *src, int sstr,
+ type_s8 *val, int n)
+{
+ vec_s8 vval;
+ vec_s8 *vsrc;
+ vec_s8 *vdest;
+// int i;
+ vsrc = (vec_s8*)src;
+ vdest = (vec_s8*)dest;
+ memset(&vval,*val,8);
+// for (i=0;i<8;i++) vval[i]=*val;
+ if(n&1) {
+ *dest = *src + *val;
+ OIL_INCREMENT(dest, dstr); \
+ OIL_INCREMENT(src, sstr);
+ }
+ if(n&2) { \
+ *dest = *src + *val;
+ OIL_INCREMENT(dest, dstr);
+ OIL_INCREMENT(src, sstr);
+ *dest = *src + *val;
+ OIL_INCREMENT(dest, dstr);
+ OIL_INCREMENT(src, sstr);
+ }
+ if(n&4) { \
+ *dest = *src + *val;
+ OIL_INCREMENT(dest, dstr);
+ OIL_INCREMENT(src, sstr);
+ *dest = *src + *val;
+ OIL_INCREMENT(dest, dstr);
+ OIL_INCREMENT(src, sstr);
+ *dest = *src + *val;
+ OIL_INCREMENT(dest, dstr);
+ OIL_INCREMENT(src, sstr);
+ *dest = *src + *val;
+ OIL_INCREMENT(dest, dstr);
+ OIL_INCREMENT(src, sstr);
+ }
+ n /= 8;
+
+ while(n>0){
+ *vdest = *vsrc + vval;
+ OIL_INCREMENT(vdest,8);
+ OIL_INCREMENT(vsrc,8);
+ n--;
+ }
+}
+OIL_DEFINE_IMPL_FULL(scalaradd_s8_mmx,scalaradd_s8,OIL_IMPL_FLAG_MMX);
diff --git a/liboil/simdpack/simdpack.h b/liboil/simdpack/simdpack.h
index 5116809..e5fe549 100644
--- a/liboil/simdpack/simdpack.h
+++ b/liboil/simdpack/simdpack.h
@@ -128,6 +128,19 @@ OIL_DECLARE_CLASS(vectoradd_u32);
OIL_DECLARE_CLASS(vectoradd_f32);
OIL_DECLARE_CLASS(vectoradd_f64);
+
+OIL_DECLARE_CLASS(vectoradd_s_s8);
+OIL_DECLARE_CLASS(vectoradd_s_u8);
+OIL_DECLARE_CLASS(vectoradd_s_s16);
+OIL_DECLARE_CLASS(vectoradd_s_u16);
+OIL_DECLARE_CLASS(vectoradd_s_s32);
+OIL_DECLARE_CLASS(vectoradd_s_u32);
+OIL_DECLARE_CLASS(vectoradd_s_f32);
+OIL_DECLARE_CLASS(vectoradd_s_f64);
+
+
+
+
OIL_DECLARE_CLASS(zigzag8x8_s16);
diff --git a/liboil/simdpack/vectoradd_s.c b/liboil/simdpack/vectoradd_s.c
new file mode 100644
index 0000000..2c45b5b
--- /dev/null
+++ b/liboil/simdpack/vectoradd_s.c
@@ -0,0 +1,43 @@
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <liboil/liboilfunction.h>
+#include <liboil/simdpack/simdpack.h>
+#include <liboil/liboilgcc.h>
+
+#define CLAMP(x, low, high) (((x) > (high)) ? (high) : (((x) < (low)) ? (low) : (x)))
+#define type_min_f32 -1.0
+#define type_max_f32 1.0
+#define type_min_f64 -1.0
+#define type_max_f64 1.0
+
+#define VECTORADD_S_DEFINE_IMPL(type,bigger) \
+static void vectoradd_s_ ## type ## _ref ( \
+ type_ ## type *dest, int dstr, \
+ type_ ## type *src1, int sstr1, \
+ type_ ## type *src2, int sstr2, \
+ int n) \
+{ \
+ int i; \
+ for(i=0;i<n;i++) { \
+ OIL_GET(dest,i*dstr, type_ ## type) = CLAMP((type_ ## bigger)OIL_GET(src1,i*sstr1, type_ ## type) + \
+ (type_ ## bigger)OIL_GET(src2,i*sstr2, type_ ## type),type_min_ ## type, type_max_ ## type); \
+ } \
+} \
+OIL_DEFINE_CLASS (vectoradd_s_ ## type, \
+ "type_" #type " *dest, int dstr, " \
+ "type_" #type " *src1, int sstr1, " \
+ "type_" #type " *src2, int sstr2, " \
+ "int n"); \
+OIL_DEFINE_IMPL_REF (vectoradd_s_ ## type ## _ref, vectoradd_s_ ## type);
+
+VECTORADD_S_DEFINE_IMPL (s8,s16);
+VECTORADD_S_DEFINE_IMPL (u8,u16);
+VECTORADD_S_DEFINE_IMPL (s16,s32);
+VECTORADD_S_DEFINE_IMPL (u16,u32);
+//VECTORADD_S_DEFINE_IMPL (s32,s64);
+//VECTORADD_S_DEFINE_IMPL (u32,u64);
+VECTORADD_S_DEFINE_IMPL (f32,f32);
+VECTORADD_S_DEFINE_IMPL (f64,f64);
+