summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Schleef <ds@schleef.org>2005-01-05 23:31:42 +0000
committerDavid Schleef <ds@schleef.org>2005-01-05 23:31:42 +0000
commit9e7d1e7c99c7d238cf2d87db12321349d5f4aeb5 (patch)
treec119932c0d10d969a30089cef27080dbe3259e34
parent199e85f573a9239f1693862d3fd03fa612987f62 (diff)
downloadliboil-9e7d1e7c99c7d238cf2d87db12321349d5f4aeb5.tar.gz
* testsuite/stride.c: (main), (hist): new test
-rw-r--r--ChangeLog4
-rw-r--r--testsuite/stride.c148
2 files changed, 152 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index d863883..3b5555b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2005-01-05 David Schleef <ds@schleef.org>
+
+ * testsuite/stride.c: (main), (hist): new test
+
2005-01-01 David Schleef <ds@schleef.org>
* liboil/colorspace/argb_paint_i386.c:
diff --git a/testsuite/stride.c b/testsuite/stride.c
new file mode 100644
index 0000000..d03546e
--- /dev/null
+++ b/testsuite/stride.c
@@ -0,0 +1,148 @@
+/*
+ * 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 <stdio.h>
+#include <liboil/liboil.h>
+#include <ctype.h>
+#include <stdlib.h>
+#include <string.h>
+#include <math.h>
+
+#include <liboil/liboilprototype.h>
+#include <liboil/liboiltest.h>
+#include <liboil/liboilcpu.h>
+
+void hist(OilTest *Test);
+
+int main (int argc, char *argv[])
+{
+ OilFunctionClass *klass;
+ OilFunctionImpl *impl;
+ OilTest *test;
+ int i;
+ int n;
+ int j;
+ int ret;
+ unsigned int cpu_flags;
+
+ oil_init ();
+
+ cpu_flags = oil_cpu_get_flags ();
+ n = oil_class_get_n_classes ();
+ for (i=0;i<n; i++ ){
+ klass = oil_class_get_by_index(i);
+
+ printf("%s\n", klass->name);
+
+ test = oil_test_new (klass);
+ if (test == NULL) {
+ printf(" bad prototype\n");
+ continue;
+ }
+ oil_test_set_iterations (test, 1);
+
+ oil_test_check_impl (test, klass->reference_impl);
+ for(j=0;j<OIL_ARG_LAST;j++){
+ if (test->params[j].is_stride) {
+ test->params[j].value *= 2;
+ }
+ }
+ test->inited = 0;
+
+ for (impl = klass->first_impl; impl; impl = impl->next) {
+ printf(" %s\n", impl->name);
+ if ((impl->flags & OIL_CPU_FLAG_MASK) & ~cpu_flags) {
+ printf(" not supported\n");
+ } else {
+ ret = oil_test_check_impl (test, impl);
+ if (!ret) {
+ printf(" failed stride test\n");
+ }
+#if 0
+ printf(" %lu %g\n",test->prof.min,
+ (double)test->prof.total/test->prof.n);
+ for(j=0;j<test->prof.hist_n;j++){
+ printf(" %lu %d\n",test->prof.hist_time[j],test->prof.hist_count[j]);
+ }
+ printf(" ave=%g std=%g\n", impl->profile_ave, impl->profile_std);
+ //hist(test);
+#endif
+ }
+ }
+
+ oil_test_free (test);
+ }
+
+ return 0;
+}
+
+
+void
+hist(OilTest *test)
+{
+ double ave;
+ double std;
+ int max_i;
+ double off;
+ double s;
+ double s2;
+ int i;
+ int n;
+ double x;
+
+ do {
+ s = s2 = 0;
+ n = 0;
+ max_i = -1;
+ for(i=0;i<10;i++){
+ x = test->prof.hist_time[i];
+ s2 += x * x * test->prof.hist_count[i];
+ s += x * test->prof.hist_count[i];
+ n += test->prof.hist_count[i];
+ if (test->prof.hist_count[i] > 0) {
+ if (max_i == -1 || test->prof.hist_time[i] > test->prof.hist_time[max_i]) {
+ max_i = i;
+ }
+ }
+ }
+
+ ave = s / n;
+ std = sqrt (s2 - s * s / n + n*n) / (n-1);
+ off = (test->prof.hist_time[max_i] - ave)/std;
+
+ printf(" ave=%g std=%g max=%ld off=%g %s\n",
+ ave, std, test->prof.hist_time[max_i], off, (off>4.0)?"yes":"no");
+
+ if (off > 4.0) {
+ test->prof.hist_count[max_i] = 0;
+ }
+ } while (off > 4.0);
+ printf(" ave=%g std=%g\n", ave, std);
+}
+
+