diff options
author | David Schleef <ds@schleef.org> | 2005-06-02 21:17:46 +0000 |
---|---|---|
committer | David Schleef <ds@schleef.org> | 2005-06-02 21:17:46 +0000 |
commit | 7ffccb74ac2ebfd0b6f8361d4016b0ceb3c9581f (patch) | |
tree | 9c62211c01b69d152ffba0705909fcdbdd87d480 /examples | |
parent | 4e61bd45cbda321471bb1feadff7ea624a73b563 (diff) | |
download | liboil-7ffccb74ac2ebfd0b6f8361d4016b0ceb3c9581f.tar.gz |
* examples/Makefile.am:
* examples/memcpy-speed.c: (main):
New memory speed test program
* examples/oil-test.c: (main):
Use n=100 for test.
* liboil/copy/Makefile.am:
* liboil/copy/copy_i386.c: (copy_u8_mmx3):
movntq based copy
* liboil/copy/splat_i386.c: (splat_u32_ns_mmx):
movntq based splat
Diffstat (limited to 'examples')
-rw-r--r-- | examples/Makefile.am | 6 | ||||
-rw-r--r-- | examples/memcpy-speed.c | 70 | ||||
-rw-r--r-- | examples/oil-test.c | 4 |
3 files changed, 78 insertions, 2 deletions
diff --git a/examples/Makefile.am b/examples/Makefile.am index d648f68..f38c12a 100644 --- a/examples/Makefile.am +++ b/examples/Makefile.am @@ -1,7 +1,7 @@ SUBDIRS = jpeg md5 uberopt work huffman -noinst_PROGRAMS = example1 oil-inspect oil-test report +noinst_PROGRAMS = example1 oil-inspect oil-test report memcpy-speed example1_SOURCES = example1.c @@ -20,3 +20,7 @@ report_SOURCES = report.c report_CFLAGS = $(LIBOIL_CFLAGS) report_LDADD = $(LIBOIL_LIBS) +memcpy_speed_SOURCES = memcpy-speed.c +memcpy_speed_CFLAGS = $(LIBOIL_CFLAGS) +memcpy_speed_LDADD = $(LIBOIL_LIBS) + diff --git a/examples/memcpy-speed.c b/examples/memcpy-speed.c new file mode 100644 index 0000000..394625c --- /dev/null +++ b/examples/memcpy-speed.c @@ -0,0 +1,70 @@ + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +#include <liboil/liboil.h> +#include <liboil/liboilprofile.h> +#include <liboil/liboilfunction.h> + +#define ALIGN(ptr,n) ((void *)((unsigned long)(ptr) & (~(unsigned long)(n-1)))) + +int +main(int argc, char *argv[]) +{ + char *s, *d; + uint32_t *src, *dest; + OilProfile prof; + double ave, std; + int i,j; + double cpufreq; + OilFunctionClass *klass; + OilFunctionImpl *impl; + int use_memset = 0; + + //use_memset = 1; + + oil_init (); + + cpufreq = 1788.699e6; + + s = malloc(1024*1024*64+1024); + d = malloc(1024*1024*64+1024); + 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"); + } + + for(impl=klass->first_impl;impl;impl=impl->next) { + printf("impl %s\n", impl->name); + + oil_class_choose_by_name (klass, impl->name); + + for(i=10;i<26;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); + } + } + + oil_profile_get_ave_std (&prof, &ave, &std); + + printf("%d: %10.4g %10.4g %10.4g %10.4g\n", i, ave, std, + ave/(1<<i), cpufreq/(ave/(1<<i))); + } + } + + return 0; +} + diff --git a/examples/oil-test.c b/examples/oil-test.c index c7f369c..9072da4 100644 --- a/examples/oil-test.c +++ b/examples/oil-test.c @@ -173,7 +173,7 @@ int main (int argc, char *argv[]) test = oil_test_new(klass); oil_test_set_iterations(test, 1); - test->n = 10; + test->n = 100; test->m = 10; impl = klass->reference_impl; @@ -184,6 +184,7 @@ int main (int argc, char *argv[]) dump_source(test); printf ("reference impl %s\n", impl->name); printf(" ave=%g std=%g\n", ave, std); + printf(" (this test) ave=%g std=%g\n", impl->profile_ave, impl->profile_std); dump_test(test); for (impl = klass->first_impl; impl; impl = impl->next) { @@ -192,6 +193,7 @@ int main (int argc, char *argv[]) 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", impl->profile_ave, impl->profile_std); dump_test(test); } } |