diff -r e4d67989cc36 -r 47c74d1534e1 genericopenlibs/liboil/tsrc/testsuite/test1/src/test1.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/genericopenlibs/liboil/tsrc/testsuite/test1/src/test1.c Fri Apr 16 16:46:38 2010 +0300 @@ -0,0 +1,170 @@ +/* + * LIBOIL - Library of Optimized Inner Loops + * Copyright (c) 2004 David A. Schleef + * 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 +#include +#include +#include +#include +#include + +#include +#include +#include +#define LOG_FILE "c:\\logs\\testsuite_test1_log1.txt" +#include "std_log_result.h" +#define LOG_FILENAME_LINE __FILE__, __LINE__ + +void create_xml(int result) +{ + if(result) + assert_failed = 1; + + testResultXml("testsuite_test1"); + close_log_file(); +} + +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; + //xmlfile = "test1"; + std_log(LOG_FILENAME_LINE, "Test Started testsuite_test1"); + + oil_init (); + + cpu_flags = oil_cpu_get_flags (); //Returns a bitmask containing the available CPU features + n = oil_class_get_n_classes (); + for (i=0;iname); + std_log(LOG_FILENAME_LINE, "class name = %s\n",klass->name); + + test = oil_test_new (klass); //Creates a new OilTest(structure describing how to test an OilFunctionImpl for an OilFunctionClass) for the OilFunctionClass represented by klass + if (test == NULL) { + std_log(LOG_FILENAME_LINE, "bad prototype"); + printf(" bad prototype\n"); + continue; + } + + for (impl = klass->first_impl; impl; impl = impl->next) + { + printf(" %s\n", impl->name); + if ((impl->flags & OIL_CPU_FLAG_MASK) & ~cpu_flags) + { + std_log(LOG_FILENAME_LINE, "not supported"); + printf("not supported\n"); + } + else + { + test->n = 1600; + ret = oil_test_check_impl (test, impl); //Runs the testing procedure described by test on the implementation impl + if (ret) + { + #if 0 + printf(" %lu %g\n",test->prof.min, + (double)test->prof.total/test->prof.n); + for(j=0;jprof.hist_n;j++){ + printf(" %lu %d\n",test->prof.hist_time[j],test->prof.hist_count[j]); + } + #endif + printf(" ave=%g std=%g\n", impl->profile_ave, impl->profile_std); + //hist(test); + } + else + { + printf(" not tested\n"); + oil_test_free (test); + std_log(LOG_FILENAME_LINE, "Test Failed"); + create_xml(1); + return 1; + } + } + }//for loop + + oil_test_free (test); //Frees memory associated with test(OilTest) + } + std_log(LOG_FILENAME_LINE, "Test Successful"); + create_xml(0); + 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); +} + +