diff options
author | David Schleef <ds@schleef.org> | 2005-08-01 09:49:20 +0000 |
---|---|---|
committer | David Schleef <ds@schleef.org> | 2005-08-01 09:49:20 +0000 |
commit | 6221d08ea2092d1e8d8429ea4b24554f88ada1c9 (patch) | |
tree | 97138e634276d5d241dd7ba948610e02ad35114e /examples | |
parent | 48c9a788517b68892535519456a3fb4424408890 (diff) | |
download | liboil-6221d08ea2092d1e8d8429ea4b24554f88ada1c9.tar.gz |
* Makefile.am: add 'foreign' to automake flags
* configure.ac: add some dirs
* examples/Makefile.am: same
* examples/memcpy-speed.c: (main): change back to gromit's cpu
* examples/oil-inspect.c: (oil_print_impl): Don't run non-runnable
implementations.
* examples/oil-test.c: (dump_array), (main): minor fixes
* examples/taylor/Makefile.am: new
* examples/taylor/example1.c: new
* liboil/Makefile.am: add dirs
* liboil/colorspace/composite.c: (composite_over_argb_noclamp_2):
alternate clamping version
* liboil/simdpack/scalarmult.c: add unrolled impls
* testsuite/instruction/check-instructions.pl: fixes
* liboil/fb/Makefile.am: new
* liboil/fb/fbmmx.h: new
* liboil/fb/fbmmx.c: new
Diffstat (limited to 'examples')
-rw-r--r-- | examples/Makefile.am | 2 | ||||
-rw-r--r-- | examples/memcpy-speed.c | 2 | ||||
-rw-r--r-- | examples/oil-inspect.c | 4 | ||||
-rw-r--r-- | examples/oil-test.c | 7 | ||||
-rw-r--r-- | examples/taylor/Makefile.am | 8 | ||||
-rw-r--r-- | examples/taylor/example1.c | 123 |
6 files changed, 140 insertions, 6 deletions
diff --git a/examples/Makefile.am b/examples/Makefile.am index f38c12a..baefa28 100644 --- a/examples/Makefile.am +++ b/examples/Makefile.am @@ -1,5 +1,5 @@ -SUBDIRS = jpeg md5 uberopt work huffman +SUBDIRS = jpeg md5 uberopt work huffman taylor noinst_PROGRAMS = example1 oil-inspect oil-test report memcpy-speed diff --git a/examples/memcpy-speed.c b/examples/memcpy-speed.c index 0e9bba2..c74295a 100644 --- a/examples/memcpy-speed.c +++ b/examples/memcpy-speed.c @@ -26,7 +26,7 @@ main(int argc, char *argv[]) oil_init (); - cpufreq = 400e6/16; + cpufreq = 1788e6; s = malloc(1024*1024*64+1024); d = malloc(1024*1024*64+1024); diff --git a/examples/oil-inspect.c b/examples/oil-inspect.c index 95e8e21..6ab2e14 100644 --- a/examples/oil-inspect.c +++ b/examples/oil-inspect.c @@ -105,7 +105,9 @@ oil_print_impl (OilFunctionImpl *impl, OilTest *test, char* prefix) char *c; unsigned int cpu_flags = oil_cpu_get_flags(); - oil_test_check_impl (test, impl); + if (oil_impl_is_runnable (impl)) { + oil_test_check_impl (test, impl); + } printf ("%s%s\n", prefix, impl->name); c = oil_flags_to_string (impl->flags); diff --git a/examples/oil-test.c b/examples/oil-test.c index 9072da4..7fa6192 100644 --- a/examples/oil-test.c +++ b/examples/oil-test.c @@ -75,9 +75,9 @@ dump_array (void *data, void *ref_data, OilType type, int pre_n, int stride, printf(" "); \ for(j=0;j<pre_n;j++){ \ x = fabs(OIL_GET(data, i*stride + j*s2, type) - \ - OIL_GET(data, i*stride + j*s2, type)); \ + OIL_GET(ref_data, i*stride + j*s2, type)); \ if (x >= 1.0) { \ - printf("[" format "] ", OIL_GET(data, i*stride + j*s2, type)); \ + printf("*" format "* ", OIL_GET(data, i*stride + j*s2, type)); \ } else { \ printf(format " ", OIL_GET(data, i*stride + j*s2, type)); \ } \ @@ -104,6 +104,7 @@ dump_array (void *data, void *ref_data, OilType type, int pre_n, int stride, break; case OIL_TYPE_u32p: DUMP(uint32_t, "%u"); + //DUMP(uint32_t, "%08x"); break; case OIL_TYPE_f32p: DUMP(float, "%g"); @@ -173,7 +174,7 @@ int main (int argc, char *argv[]) test = oil_test_new(klass); oil_test_set_iterations(test, 1); - test->n = 100; + test->n = 10; test->m = 10; impl = klass->reference_impl; diff --git a/examples/taylor/Makefile.am b/examples/taylor/Makefile.am new file mode 100644 index 0000000..7cad1e8 --- /dev/null +++ b/examples/taylor/Makefile.am @@ -0,0 +1,8 @@ + +noinst_PROGRAMS = example1 + + +example1_SOURCES = example1.c +example1_CFLAGS = $(LIBOIL_CFLAGS) +example1_LDADD = $(LIBOIL_LIBS) + diff --git a/examples/taylor/example1.c b/examples/taylor/example1.c new file mode 100644 index 0000000..7893b4e --- /dev/null +++ b/examples/taylor/example1.c @@ -0,0 +1,123 @@ +/* + * LIBOIL - Library of Optimized Inner Loops + * Copyright (c) 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. + */ + + +#include <liboil/liboil.h> +#include <liboil/liboilprofile.h> +#include <stdio.h> +#include <stdlib.h> + +#define N 1000 + +static void taylor4_f32_ref (float *dest, float *src, float *a, int n); +static void taylor4_f32_oil (float *dest, float *src, float *a, int n); + +int main(int argc, char *argv[]) +{ + float *dest; + float *src; + float a[4]; + int i; + OilProfile prof; + double ave, std; + + oil_init(); + + src = malloc(N*sizeof(float)); + dest = malloc(N*sizeof(float)); + + for(i=0;i<N;i++){ + src[i] = i; + } + a[0] = 1; + a[1] = 1; + a[2] = 1; + a[3] = 1; + + oil_profile_init(&prof); + for(i=0;i<10;i++){ + oil_profile_start(&prof); + taylor4_f32_ref (dest, src, a, N); + oil_profile_stop(&prof); + } + oil_profile_get_ave_std (&prof, &ave, &std); + printf("ref: %10.4g %10.4g\n", ave, std); + for(i=0;i<10;i++){ + printf("%g\n", dest[i]); + } + + oil_profile_init(&prof); + for(i=0;i<10;i++){ + oil_profile_start(&prof); + taylor4_f32_oil (dest, src, a, N); + oil_profile_stop(&prof); + } + oil_profile_get_ave_std (&prof, &ave, &std); + printf("oil: %10.4g %10.4g\n", ave, std); + for(i=0;i<10;i++){ + printf("%g\n", dest[i]); + } + + return 0; +} + +static void +taylor4_f32_ref (float *dest, float *src, float *a, int n) +{ + int i; + float x; + for(i=0;i<n;i++){ + x = src[i]; + dest[i] = a[0]; + dest[i] += a[1] * x; + dest[i] += a[2] * x * x; + dest[i] += a[3] * x * x * x; + } + +} + + +static void +taylor4_f32_oil (float *dest, float *src, float *a, int n) +{ + float tmp1[N]; + float tmp2[N]; + float tmp3[N]; + + oil_scalarmultiply_f32_ns (tmp1, src, a+1, n); + + oil_scalaradd_f32_ns (tmp1, tmp1, a, n); + + oil_multiply_f32 (tmp2, src, src, n); + oil_scalarmultiply_f32_ns (tmp3, tmp2, a+2, n); + oil_add_f32 (tmp1, tmp1, tmp3, n); + + oil_multiply_f32 (tmp2, tmp2, src, n); + oil_scalarmultiply_f32_ns (tmp3, tmp2, a+3, n); + oil_add_f32 (dest, tmp1, tmp3, n); +} + |