[Liboil-commit] 3 commits - configure.ac examples/oil-test.c liboil/arm liboil/conv liboil/liboilclasses.h liboil/liboilfuncs-04.h liboil/liboilfuncs-doc.h liboil/liboilfuncs.h liboil/liboiltrampolines.c liboil/math liboil/ref liboil/sse

David Schleef ds at kemper.freedesktop.org
Thu Mar 13 13:27:48 PDT 2008


 configure.ac                  |    2 ++
 examples/oil-test.c           |    2 +-
 liboil/arm/math_vfp.c         |    2 +-
 liboil/conv/conv_c.c          |   16 ++++++++++++++++
 liboil/liboilclasses.h        |    1 +
 liboil/liboilfuncs-04.h       |    1 +
 liboil/liboilfuncs-doc.h      |    1 +
 liboil/liboilfuncs.h          |    3 +++
 liboil/liboiltrampolines.c    |   10 ++++++++++
 liboil/math/math.c            |   17 +++++++++++++++++
 liboil/ref/math.c             |   22 ++++++++++++++++++++++
 liboil/sse/math_sse.c         |   26 ++++++++++++++++++++++++++
 liboil/sse/math_sse_unroll2.c |   29 +++++++++++++++++++++++++++++
 13 files changed, 130 insertions(+), 2 deletions(-)

New commits:
commit 3297a4ee2e5a8f27f89206c79335c8af82ba863f
Author: David Schleef <ds at ginger.bigkitten.com>
Date:   Thu Mar 13 13:29:46 2008 -0700

    Add scalarmult_f64_ns.  From Sebastian Dröge <slomo at circular-chaos.org>, Bug #14878

diff --git a/liboil/arm/math_vfp.c b/liboil/arm/math_vfp.c
index 59ac3b7..ffd3981 100644
--- a/liboil/arm/math_vfp.c
+++ b/liboil/arm/math_vfp.c
@@ -67,7 +67,7 @@ OIL_DEFINE_IMPL_FULL (vfp_scalaradd_f32_ns, scalaradd_f32_ns, OIL_IMPL_FLAG_VFP)
 //OIL_DEFINE_IMPL_FULL (vfp_scalaradd_f64_ns, scalaradd_f64_ns, OIL_IMPL_FLAG_VFP);
 
 OIL_DEFINE_IMPL_FULL (vfp_scalarmultiply_f32_ns, scalarmultiply_f32_ns, OIL_IMPL_FLAG_VFP);
-//OIL_DEFINE_IMPL_FULL (vfp_scalarmultiply_f64_ns, scalarmultiply_f64_ns, OIL_IMPL_FLAG_VFP);
+OIL_DEFINE_IMPL_FULL (vfp_scalarmultiply_f64_ns, scalarmultiply_f64_ns, OIL_IMPL_FLAG_VFP);
 
 //OIL_DEFINE_IMPL_FULL (vfp_abs_f32_f32_ns, abs_f32_f32_ns, OIL_IMPL_FLAG_VFP);
 //OIL_DEFINE_IMPL_FULL (vfp_abs_f64_f64_ns, abs_f64_f64_ns, OIL_IMPL_FLAG_VFP);
diff --git a/liboil/liboilclasses.h b/liboil/liboilclasses.h
index 484b2eb..8cfa0b2 100644
--- a/liboil/liboilclasses.h
+++ b/liboil/liboilclasses.h
@@ -369,6 +369,7 @@ OIL_DECLARE_CLASS(scalarmult_u16);
 OIL_DECLARE_CLASS(scalarmult_u32);
 OIL_DECLARE_CLASS(scalarmult_u8);
 OIL_DECLARE_CLASS(scalarmultiply_f32_ns);
+OIL_DECLARE_CLASS(scalarmultiply_f64_ns);
 OIL_DECLARE_CLASS(scaleconv_f32_s16);
 OIL_DECLARE_CLASS(scaleconv_f32_s32);
 OIL_DECLARE_CLASS(scaleconv_f32_s8);
diff --git a/liboil/liboilfuncs-04.h b/liboil/liboilfuncs-04.h
index 75f1861..39a07de 100644
--- a/liboil/liboilfuncs-04.h
+++ b/liboil/liboilfuncs-04.h
@@ -369,6 +369,7 @@ void oil_scalarmult_u16 (uint16_t * d, int dstr, const uint16_t * s1, int sstr,
 void oil_scalarmult_u32 (uint32_t * d, int dstr, const uint32_t * s1, int sstr, const uint32_t * s2_1, int n);
 void oil_scalarmult_u8 (uint8_t * d, int dstr, const uint8_t * s1, int sstr, const uint8_t * s2_1, int n);
 void oil_scalarmultiply_f32_ns (float * d, const float * s1, const float * s2_1, int n);
+void oil_scalarmultiply_f64_ns (double * d, const double * s1, const double * s2_1, int n);
 void oil_scaleconv_f32_s16 (float * dest, const int16_t * src, int n, const double * s2_1, const double * s3_1);
 void oil_scaleconv_f32_s32 (float * dest, const int32_t * src, int n, const double * s2_1, const double * s3_1);
 void oil_scaleconv_f32_s8 (float * dest, const int8_t * src, int n, const double * s2_1, const double * s3_1);
diff --git a/liboil/liboilfuncs-doc.h b/liboil/liboilfuncs-doc.h
index e179f4c..c5b3b9e 100644
--- a/liboil/liboilfuncs-doc.h
+++ b/liboil/liboilfuncs-doc.h
@@ -333,6 +333,7 @@ void oil_scalarmult_u16 (uint16_t * d, int dstr, const uint16_t * s1, int sstr,
 void oil_scalarmult_u32 (uint32_t * d, int dstr, const uint32_t * s1, int sstr, const uint32_t * s2_1, int n);
 void oil_scalarmult_u8 (uint8_t * d, int dstr, const uint8_t * s1, int sstr, const uint8_t * s2_1, int n);
 void oil_scalarmultiply_f32_ns (float * d, const float * s1, const float * s2_1, int n);
+void oil_scalarmultiply_f64_ns (double * d, const double * s1, const double * s2_1, int n);
 void oil_scaleconv_f32_s16 (float * dest, const int16_t * src, int n, const double * s2_1, const double * s3_1);
 void oil_scaleconv_f32_s32 (float * dest, const int32_t * src, int n, const double * s2_1, const double * s3_1);
 void oil_scaleconv_f32_s8 (float * dest, const int8_t * src, int n, const double * s2_1, const double * s3_1);
diff --git a/liboil/liboilfuncs.h b/liboil/liboilfuncs.h
index 6dba267..e326a77 100644
--- a/liboil/liboilfuncs.h
+++ b/liboil/liboilfuncs.h
@@ -1035,6 +1035,9 @@ typedef void (*_oil_type_scalarmult_u8)(uint8_t * d, int dstr, const uint8_t * s
 OIL_EXPORT OilFunctionClass *oil_function_class_ptr_scalarmultiply_f32_ns;
 typedef void (*_oil_type_scalarmultiply_f32_ns)(float * d, const float * s1, const float * s2_1, int n);
 #define oil_scalarmultiply_f32_ns ((_oil_type_scalarmultiply_f32_ns)(*(void **)oil_function_class_ptr_scalarmultiply_f32_ns))
+OIL_EXPORT OilFunctionClass *oil_function_class_ptr_scalarmultiply_f64_ns;
+typedef void (*_oil_type_scalarmultiply_f64_ns)(double * d, const double * s1, const double * s2_1, int n);
+#define oil_scalarmultiply_f64_ns ((_oil_type_scalarmultiply_f64_ns)(*(void **)oil_function_class_ptr_scalarmultiply_f64_ns))
 OIL_EXPORT OilFunctionClass *oil_function_class_ptr_scaleconv_f32_s16;
 typedef void (*_oil_type_scaleconv_f32_s16)(float * dest, const int16_t * src, int n, const double * s2_1, const double * s3_1);
 #define oil_scaleconv_f32_s16 ((_oil_type_scaleconv_f32_s16)(*(void **)oil_function_class_ptr_scaleconv_f32_s16))
diff --git a/liboil/liboiltrampolines.c b/liboil/liboiltrampolines.c
index cf565e9..9009dff 100644
--- a/liboil/liboiltrampolines.c
+++ b/liboil/liboiltrampolines.c
@@ -3361,6 +3361,16 @@ oil_scalarmultiply_f32_ns (float * d, const float * s1, const float * s2_1, int
   ((void (*)(float * d, const float * s1, const float * s2_1, int n))(_oil_function_class_scalarmultiply_f32_ns.func))(d, s1, s2_1, n);
 }
 
+#undef oil_scalarmultiply_f64_ns
+void
+oil_scalarmultiply_f64_ns (double * d, const double * s1, const double * s2_1, int n)
+{
+  if (_oil_function_class_scalarmultiply_f64_ns.func == NULL) {
+    oil_class_optimize (&_oil_function_class_scalarmultiply_f64_ns);
+  }
+  ((void (*)(double * d, const double * s1, const double * s2_1, int n))(_oil_function_class_scalarmultiply_f64_ns.func))(d, s1, s2_1, n);
+}
+
 #undef oil_scaleconv_f32_s16
 void
 oil_scaleconv_f32_s16 (float * dest, const int16_t * src, int n, const double * s2_1, const double * s3_1)
diff --git a/liboil/math/math.c b/liboil/math/math.c
index a8704d8..b44af89 100644
--- a/liboil/math/math.c
+++ b/liboil/math/math.c
@@ -128,3 +128,20 @@ scalarmultiply_f32_ns_unroll4 (float *dest, float *src1, float *src2, int n)
 }
 OIL_DEFINE_IMPL (scalarmultiply_f32_ns_unroll4, scalarmultiply_f32_ns);
 
+static void
+scalarmultiply_f64_ns_unroll4 (double *dest, double *src1, double *src2, int n)
+{
+  int i;
+
+  for(i=0;i<(n&(~0x3));i+=4){
+    dest[i+0] = src1[i+0] * src2[0];
+    dest[i+1] = src1[i+1] * src2[0];
+    dest[i+2] = src1[i+2] * src2[0];
+    dest[i+3] = src1[i+3] * src2[0];
+  }
+  for(;i<n;i++){
+    dest[i] = src1[i] * src2[0];
+  }
+}
+OIL_DEFINE_IMPL (scalarmultiply_f64_ns_unroll4, scalarmultiply_f64_ns);
+
diff --git a/liboil/ref/math.c b/liboil/ref/math.c
index a31acaa..44ec929 100644
--- a/liboil/ref/math.c
+++ b/liboil/ref/math.c
@@ -274,6 +274,18 @@ OIL_DEFINE_CLASS (scalaradd_f32_ns, "float *d, float *s1, float *s2_1, int n");
  */
 OIL_DEFINE_CLASS (scalarmultiply_f32_ns, "float *d, float *s1, float *s2_1, int n");
 
+/**
+ * oil_scalarmultiply_f64_ns:
+ * @d: destination
+ * @s1: source
+ * @s2_1: source
+ * @n: number of elements
+ *
+ * Multiplies the constant value @s2_1 and each source element and places
+ * the result in @d.
+ */
+OIL_DEFINE_CLASS (scalarmultiply_f64_ns, "double *d, double *s1, double *s2_1, int n");
+
 static void
 add_s16_ref (int16_t *d, int16_t *src1, int16_t *src2, int n)
 {
@@ -514,4 +526,14 @@ scalarmultiply_f32_ns_ref (float *dest, float *src1, float *src2, int n)
 }
 OIL_DEFINE_IMPL_REF (scalarmultiply_f32_ns_ref, scalarmultiply_f32_ns);
 
+static void
+scalarmultiply_f64_ns_ref (double *dest, double *src1, double *src2, int n)
+{
+  int i;
+
+  for(i=0;i<n;i++){
+    dest[i] = src1[i] * src2[0];
+  }
+}
+OIL_DEFINE_IMPL_REF (scalarmultiply_f64_ns_ref, scalarmultiply_f64_ns);
 
diff --git a/liboil/sse/math_sse.c b/liboil/sse/math_sse.c
index 12a913b..70952b4 100644
--- a/liboil/sse/math_sse.c
+++ b/liboil/sse/math_sse.c
@@ -337,3 +337,29 @@ scalarmultiply_f32_ns_sse (float *dest, float *src1, float *val, int n)
   }
 }
 OIL_DEFINE_IMPL_FULL (scalarmultiply_f32_ns_sse, scalarmultiply_f32_ns, OIL_IMPL_FLAG_SSE);
+
+#ifdef ENABLE_BROKEN_IMPLS
+static void
+scalarmultiply_f64_ns_sse2 (double *dest, double *src1, double *val, int n)
+{
+  __m128d xmm1;
+
+  /* Initial operations to align the destination pointer */
+  for (; ((long)dest & 15) && (n > 0); n--) {
+    *dest++ = *src1++ * *val;
+  }
+  xmm1 = _mm_load_pd1(val);
+  for (; n >= 8; n -= 8) {
+    __m128d xmm0;
+    xmm0 = _mm_loadu_pd(src1);
+    xmm0 = _mm_mul_pd(xmm0, xmm1);
+    _mm_store_pd(dest, xmm0);
+    dest += 8;
+    src1 += 8;
+  }
+  for (; n > 0; n--) {
+    *dest++ = *src1++ * *val;
+  }
+}
+OIL_DEFINE_IMPL_FULL (scalarmultiply_f64_ns_sse2, scalarmultiply_f64_ns, OIL_IMPL_FLAG_SSE2);
+#endif
diff --git a/liboil/sse/math_sse_unroll2.c b/liboil/sse/math_sse_unroll2.c
index 3295968..b340031 100644
--- a/liboil/sse/math_sse_unroll2.c
+++ b/liboil/sse/math_sse_unroll2.c
@@ -311,3 +311,32 @@ scalarmultiply_f32_ns_sse_unroll2 (float *dest, float *src1, float *val, int n)
 }
 OIL_DEFINE_IMPL_FULL (scalarmultiply_f32_ns_sse_unroll2, scalarmultiply_f32_ns, OIL_IMPL_FLAG_SSE);
 
+#ifdef ENABLE_BROKEN_IMPLS
+static void
+scalarmultiply_f64_ns_sse2_unroll2 (double *dest, double *src1, double *val, int n)
+{
+  __m128d xmm1;
+
+  /* Initial operations to align the destination pointer */
+  for (; ((long)dest & 15) && (n > 0); n--) {
+    *dest++ = *src1++ * *val;
+  }
+  xmm1 = _mm_load_pd1(val);
+  for (; n >= 8; n -= 8) {
+    __m128d xmm0;
+    xmm0 = _mm_loadu_pd(src1);
+    xmm0 = _mm_mul_pd(xmm0, xmm1);
+    _mm_store_pd(dest, xmm0);
+    xmm0 = _mm_loadu_pd(src1 + 4);
+    xmm0 = _mm_mul_pd(xmm0, xmm1);
+    _mm_store_pd(dest + 4, xmm0);
+    dest += 8;
+    src1 += 8;
+  }
+  for (; n > 0; n--) {
+    *dest++ = *src1++ * *val;
+  }
+}
+OIL_DEFINE_IMPL_FULL (scalarmultiply_f64_ns_sse2_unroll2, scalarmultiply_f64_ns, OIL_IMPL_FLAG_SSE2);
+#endif
+
commit 873b7f253cf57730911da1716855541b28aedd9f
Author: David Schleef <ds at ginger.bigkitten.com>
Date:   Thu Mar 13 13:27:22 2008 -0700

    oil-test should try all runnable implementations

diff --git a/examples/oil-test.c b/examples/oil-test.c
index 10c372f..0d35762 100644
--- a/examples/oil-test.c
+++ b/examples/oil-test.c
@@ -267,7 +267,7 @@ int main (int argc, char *argv[])
   for (impl = klass->first_impl; impl; impl = impl->next) {
     if (impl == klass->reference_impl) continue;
     printf ("impl %s\n", impl->name);
-    if (oil_impl_is_usable (impl)) {
+    if (oil_impl_is_runnable (impl)) {
       printf("  ave=%g std=%g\n", impl->profile_ave, impl->profile_std);
       oil_test_check_impl (test, impl);
       printf("  (this test) ave=%g std=%g\n", test->profile_ave, test->profile_std);
commit 25e312e7d5b599bacb618b57d00c834b6eaad608
Author: David Schleef <ds at ginger.bigkitten.com>
Date:   Thu Mar 13 13:11:58 2008 -0700

    Add check for rint() and use it

diff --git a/configure.ac b/configure.ac
index b4c6902..bb83e9b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -121,6 +121,8 @@ fi
 AX_CREATE_STDINT_H([liboil/liboil-stdint.h])
 
 AC_FUNC_MMAP()
+AC_CHECK_LIB(m, rint,
+  AC_DEFINE(HAVE_RINT, 1, [Define if rint() is available]))
 AC_CHECK_LIB(m, rintf,
   AC_DEFINE(HAVE_RINTF, 1, [Define if rintf() is available]))
 AC_CHECK_LIB(m, lrint,
diff --git a/liboil/conv/conv_c.c b/liboil/conv/conv_c.c
index 9c05a0e..95cf8b3 100644
--- a/liboil/conv/conv_c.c
+++ b/liboil/conv/conv_c.c
@@ -52,6 +52,7 @@ static void conv_ ## desttype ## _ ## srctype ## _c ( \
 OIL_DEFINE_IMPL(conv_ ## desttype ## _ ## srctype ## _c,	\
 	conv_ ## desttype ## _ ## srctype);
 
+#ifdef HAVE_RINT
 #define CONV_DEFINE_FLOAT(desttype,srctype) \
 static void conv_ ## desttype ## _ ## srctype ## _c ( \
 	oil_type_ ## desttype *dest,	\
@@ -68,6 +69,9 @@ static void conv_ ## desttype ## _ ## srctype ## _c ( \
 }					\
 OIL_DEFINE_IMPL(conv_ ## desttype ## _ ## srctype ## _c,	\
 	conv_ ## desttype ## _ ## srctype);
+#else
+#define CONV_DEFINE_FLOAT(desttype,srctype)
+#endif
 
 CONV_DEFINE_CAST(s8,u8);
 CONV_DEFINE_CAST(s8,s16);
@@ -197,6 +201,7 @@ static void clipconv_ ## desttype ## _ ## srctype ## _c ( \
 OIL_DEFINE_IMPL(clipconv_ ## desttype ## _ ## srctype ## _c,	\
 	clipconv_ ## desttype ## _ ## srctype);
 
+#ifdef HAVE_RINT
 #define CLIPCONV_DEFINE_FLOAT(desttype,srctype) \
 static void clipconv_ ## desttype ## _ ## srctype ## _c ( \
 	oil_type_ ## desttype *dest,	\
@@ -217,6 +222,9 @@ static void clipconv_ ## desttype ## _ ## srctype ## _c ( \
 }					\
 OIL_DEFINE_IMPL(clipconv_ ## desttype ## _ ## srctype ## _c,	\
 	clipconv_ ## desttype ## _ ## srctype);
+#else
+#define CLIPCONV_DEFINE_FLOAT(desttype,srctype)
+#endif
 
 /* clip upper */
 CLIPCONV_DEFINE_UPPER(s8,u8);
@@ -285,6 +293,7 @@ static void conv_ ## desttype ## _ ## srctype ## _unroll2 ( \
 OIL_DEFINE_IMPL(conv_ ## desttype ## _ ## srctype ## _unroll2,	\
 	conv_ ## desttype ## _ ## srctype);
 
+#ifdef HAVE_RINT
 #define CONV_DEFINE_FLOAT_UNROLL2(desttype,srctype) \
 static void conv_ ## desttype ## _ ## srctype ## _unroll2 ( \
 	oil_type_ ## desttype *dest,	\
@@ -310,6 +319,9 @@ static void conv_ ## desttype ## _ ## srctype ## _unroll2 ( \
 }					\
 OIL_DEFINE_IMPL(conv_ ## desttype ## _ ## srctype ## _unroll2,	\
 	conv_ ## desttype ## _ ## srctype);
+#else
+#define CONV_DEFINE_FLOAT_UNROLL2(desttype,srctype)
+#endif
 
 CONV_DEFINE_CAST_UNROLL2(s8,u8);
 CONV_DEFINE_CAST_UNROLL2(s8,s16);
@@ -417,6 +429,7 @@ static void conv_ ## desttype ## _ ## srctype ## _unroll4 ( \
 OIL_DEFINE_IMPL(conv_ ## desttype ## _ ## srctype ## _unroll4,	\
 	conv_ ## desttype ## _ ## srctype);
 
+#ifdef HAVE_RINT
 #define CONV_DEFINE_FLOAT_UNROLL4(desttype,srctype) \
 static void conv_ ## desttype ## _ ## srctype ## _unroll4 ( \
 	oil_type_ ## desttype *dest,	\
@@ -456,6 +469,9 @@ static void conv_ ## desttype ## _ ## srctype ## _unroll4 ( \
 }					\
 OIL_DEFINE_IMPL(conv_ ## desttype ## _ ## srctype ## _unroll4,	\
 	conv_ ## desttype ## _ ## srctype);
+#else
+#define CONV_DEFINE_FLOAT_UNROLL4(desttype,srctype)
+#endif
 
 CONV_DEFINE_CAST_UNROLL4(s8,u8);
 CONV_DEFINE_CAST_UNROLL4(s8,s16);


More information about the Liboil-commit mailing list