diff options
author | David Schleef <ds@schleef.org> | 2006-10-01 23:38:12 +0000 |
---|---|---|
committer | David Schleef <ds@schleef.org> | 2006-10-01 23:38:12 +0000 |
commit | 7272088204c7406a209add33ffadb275008f78c2 (patch) | |
tree | 3102b8a463b4b8e16f47cbc0e4bc7bae67b5d1c2 | |
parent | 36374a87273e4ee08495d1b70ccc7f98ee09e8a5 (diff) | |
download | liboil-7272088204c7406a209add33ffadb275008f78c2.tar.gz |
* examples/memcpy-speed.c:
Check read speed.
* liboil/ref/Makefile.am:
* liboil/ref/sum.c:
new class sum_s16.
* liboil/i386/Makefile.am:
* liboil/i386/sum.c:
* liboil/liboilclasses.h:
* liboil/liboilfuncs-04.h:
* liboil/liboilfuncs.h:
* liboil/liboiltrampolines.c:
update.
-rw-r--r-- | ChangeLog | 15 | ||||
-rw-r--r-- | examples/memcpy-speed.c | 42 | ||||
-rw-r--r-- | liboil/i386/Makefile.am | 1 | ||||
-rw-r--r-- | liboil/i386/sum.c | 44 | ||||
-rw-r--r-- | liboil/liboilclasses.h | 1 | ||||
-rw-r--r-- | liboil/liboilfuncs-04.h | 1 | ||||
-rw-r--r-- | liboil/liboilfuncs.h | 3 | ||||
-rw-r--r-- | liboil/liboiltrampolines.c | 10 | ||||
-rw-r--r-- | liboil/ref/Makefile.am | 1 | ||||
-rw-r--r-- | liboil/ref/sum.c | 61 |
10 files changed, 165 insertions, 14 deletions
@@ -1,3 +1,18 @@ +2006-10-01 David Schleef <ds@schleef.org> + + * examples/memcpy-speed.c: + Check read speed. + * liboil/ref/Makefile.am: + * liboil/ref/sum.c: + new class sum_s16. + * liboil/i386/Makefile.am: + * liboil/i386/sum.c: + * liboil/liboilclasses.h: + * liboil/liboilfuncs-04.h: + * liboil/liboilfuncs.h: + * liboil/liboiltrampolines.c: + update. + 2006-09-28 David Schleef <ds@schleef.org> * liboil/i386/resample.c: diff --git a/examples/memcpy-speed.c b/examples/memcpy-speed.c index c74295a..0693aef 100644 --- a/examples/memcpy-speed.c +++ b/examples/memcpy-speed.c @@ -20,9 +20,9 @@ main(int argc, char *argv[]) double cpufreq; OilFunctionClass *klass; OilFunctionImpl *impl; - int use_memset = 0; + int the_class; - //use_memset = 1; + the_class = 2; oil_init (); @@ -33,10 +33,16 @@ main(int argc, char *argv[]) src = ALIGN(s,128); dest = ALIGN(d,128); - if (use_memset) { - klass = oil_class_get ("splat_u32_ns"); - } else { - klass = oil_class_get ("copy_u8"); + switch(the_class) { + case 0: + klass = oil_class_get ("splat_u32_ns"); + break; + case 1: + klass = oil_class_get ("copy_u8"); + break; + case 2: + klass = oil_class_get ("sum_s16"); + break; } for(impl=klass->first_impl;impl;impl=impl->next) { @@ -52,14 +58,22 @@ main(int argc, char *argv[]) for(i=10;i<24;i++){ oil_profile_init (&prof); for(j=0;j<10;j++){ - if (use_memset) { - oil_profile_start(&prof); - oil_splat_u32_ns (dest, src, 1<<(i-2)); - oil_profile_stop(&prof); - } else { - oil_profile_start(&prof); - oil_memcpy (dest, src, 1<<i); - oil_profile_stop(&prof); + switch(the_class) { + case 0: + oil_profile_start(&prof); + oil_splat_u32_ns (dest, src, 1<<(i-2)); + oil_profile_stop(&prof); + break; + case 1: + oil_profile_start(&prof); + oil_memcpy (dest, src, 1<<i); + oil_profile_stop(&prof); + break; + case 2: + oil_profile_start(&prof); + oil_sum_s16 ((int16_t *)dest, (int16_t *)src, 1<<(i-1)); + oil_profile_stop(&prof); + break; } } diff --git a/liboil/i386/Makefile.am b/liboil/i386/Makefile.am index 51a9d2e..27774ac 100644 --- a/liboil/i386/Makefile.am +++ b/liboil/i386/Makefile.am @@ -20,6 +20,7 @@ libi386_la_SOURCES = \ sad8x8_i386.c \ sad8x8avg_i386.c \ splat_i386.c \ + sum.c \ swab.c \ trans8x8_i386.c \ wavelet.c diff --git a/liboil/i386/sum.c b/liboil/i386/sum.c new file mode 100644 index 0000000..8bf4de4 --- /dev/null +++ b/liboil/i386/sum.c @@ -0,0 +1,44 @@ + +#include <liboil/liboilfunction.h> +#include <liboil/liboilclasses.h> + + +void +sum_s16_mmx (int16_t *d, int16_t *s, int n) +{ + int16_t sum = 0; + int16_t a[4]; + + while(n&15) { + sum += s[0]; + s++; + n--; + } + if (n > 0) { + + n >>= 4; + asm volatile ("\n" + " pxor %%mm0, %%mm0\n" + "1:\n" + " paddw 0(%0), %%mm0\n" + " paddw 8(%0), %%mm0\n" + " paddw 16(%0), %%mm0\n" + " paddw 24(%0), %%mm0\n" + " add $32, %0\n" + " decl %1\n" + " jnz 1b\n" + " movq %%mm0, 0(%2)\n" + " emms\n" + : "+r" (s), "+r" (n) + : "r" (a)); + + sum += a[0]; + sum += a[1]; + sum += a[2]; + sum += a[3]; + } + + d[0] = sum; +} +OIL_DEFINE_IMPL_FULL (sum_s16_mmx, sum_s16, OIL_IMPL_FLAG_MMX); + diff --git a/liboil/liboilclasses.h b/liboil/liboilclasses.h index 5933354..3318c7b 100644 --- a/liboil/liboilclasses.h +++ b/liboil/liboilclasses.h @@ -361,6 +361,7 @@ OIL_DECLARE_CLASS(squaresum_f64); OIL_DECLARE_CLASS(squaresum_shifted_s16); OIL_DECLARE_CLASS(subtract_f32); OIL_DECLARE_CLASS(sum_f64); +OIL_DECLARE_CLASS(sum_s16); OIL_DECLARE_CLASS(swab_u16); OIL_DECLARE_CLASS(swab_u32); OIL_DECLARE_CLASS(synth_135); diff --git a/liboil/liboilfuncs-04.h b/liboil/liboilfuncs-04.h index 177b363..d859b3d 100644 --- a/liboil/liboilfuncs-04.h +++ b/liboil/liboilfuncs-04.h @@ -361,6 +361,7 @@ void oil_squaresum_f64 (double * d, const double * s, int n); void oil_squaresum_shifted_s16 (uint32_t * d, const int16_t * s, int n); void oil_subtract_f32 (float * d, const float * s1, const float * s2, int n); void oil_sum_f64 (double * d_1, const double * s, int sstr, int n); +void oil_sum_s16 (int16_t * d_1, const int16_t * s, int n); void oil_swab_u16 (uint16_t * d_n, const uint16_t * s_n, int n); void oil_swab_u32 (uint32_t * d_n, const uint32_t * s_n, int n); void oil_synth_135 (int16_t * d_2xn, const int16_t * s_2xn, int n); diff --git a/liboil/liboilfuncs.h b/liboil/liboilfuncs.h index dc8312c..22a2e83 100644 --- a/liboil/liboilfuncs.h +++ b/liboil/liboilfuncs.h @@ -1011,6 +1011,9 @@ typedef void (*_oil_type_subtract_f32)(float * d, const float * s1, const float extern OilFunctionClass *oil_function_class_ptr_sum_f64; typedef void (*_oil_type_sum_f64)(double * d_1, const double * s, int sstr, int n); #define oil_sum_f64 ((_oil_type_sum_f64)(*(void **)oil_function_class_ptr_sum_f64)) +extern OilFunctionClass *oil_function_class_ptr_sum_s16; +typedef void (*_oil_type_sum_s16)(int16_t * d_1, const int16_t * s, int n); +#define oil_sum_s16 ((_oil_type_sum_s16)(*(void **)oil_function_class_ptr_sum_s16)) extern OilFunctionClass *oil_function_class_ptr_swab_u16; typedef void (*_oil_type_swab_u16)(uint16_t * d_n, const uint16_t * s_n, int n); #define oil_swab_u16 ((_oil_type_swab_u16)(*(void **)oil_function_class_ptr_swab_u16)) diff --git a/liboil/liboiltrampolines.c b/liboil/liboiltrampolines.c index 9d6adb5..a898872 100644 --- a/liboil/liboiltrampolines.c +++ b/liboil/liboiltrampolines.c @@ -3281,6 +3281,16 @@ oil_sum_f64 (double * d_1, const double * s, int sstr, int n) ((void (*)(double * d_1, const double * s, int sstr, int n))(_oil_function_class_sum_f64.func))(d_1, s, sstr, n); } +#undef oil_sum_s16 +void +oil_sum_s16 (int16_t * d_1, const int16_t * s, int n) +{ + if (_oil_function_class_sum_s16.func == NULL) { + oil_class_optimize (&_oil_function_class_sum_s16); + } + ((void (*)(int16_t * d_1, const int16_t * s, int n))(_oil_function_class_sum_s16.func))(d_1, s, n); +} + #undef oil_swab_u16 void oil_swab_u16 (uint16_t * d_n, const uint16_t * s_n, int n) diff --git a/liboil/ref/Makefile.am b/liboil/ref/Makefile.am index ae41e17..edb30b3 100644 --- a/liboil/ref/Makefile.am +++ b/liboil/ref/Makefile.am @@ -33,6 +33,7 @@ c_sources = \ sincos_f64.c \ splat.c \ squaresum_f64.c \ + sum.c \ sum_f64.c \ swab.c \ trans8x8.c \ diff --git a/liboil/ref/sum.c b/liboil/ref/sum.c new file mode 100644 index 0000000..95d15f3 --- /dev/null +++ b/liboil/ref/sum.c @@ -0,0 +1,61 @@ +/* + * LIBOIL - Library of Optimized Inner Loops + * Copyright (c) 2003,2004 David A. Schleef <ds@schleef.org> + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <liboil/liboilfunction.h> +#include <liboil/simdpack/simdpack.h> +#include <math.h> + +/** + * oil_sum_s16: + * @d_1: destination + * @s: source array + * @n: number of elements + * + * Sums the elements in the source array and places the result in + * @d. + */ +OIL_DEFINE_CLASS (sum_s16, "int16_t *d_1, int16_t *s, int n"); + +static void +sum_s16_ref (int16_t *dest, int16_t *src, int n) +{ + int16_t sum = 0; + int i; + + for(i=0;i<n;i++){ + sum += src[i]; + } + + *dest = sum; +} +OIL_DEFINE_IMPL_REF (sum_s16_ref, sum_s16); + + |