void test() { OilTest *test; OilParameter *p; int16_t *data; int n; int footer; int footer_increment = 10; OilFunctionClass *klass; OilFunctionImpl *impl; klass = oil_class_get("abs_f32_f32"); if(klass != NULL) { test = (OilTest *)oil_test_new(klass); if(test != NULL) { impl = (OilFunctionImpl*)calloc(sizeof(OilFunctionImpl), 0); impl->func = (void*)abs_f32_f32_test; impl->name = "abs_f32_f32_test"; impl->klass = klass; oil_test_set_impl(test, impl); if(test->impl != impl) { std_log(LOG_FILENAME_LINE,"oil_test_set_impl failed. errno = %d", errno); assert_failed = 1; } p = &test->params[1]; footer = p->test_footer; oil_test_set_test_footer(test, p, OIL_TEST_FOOTER+footer_increment); if(p->test_footer != footer+footer_increment) { std_log(LOG_FILENAME_LINE,"oil_test_set_test_footer failed. errno = %d", errno); assert_failed = 1; } data = (int16_t *)oil_test_get_source_data (test, OIL_ARG_SRC1); n = oil_test_get_arg_pre_n (test, OIL_ARG_SRC1); oil_test_cleanup(test); oil_test_free(test); } else { std_log(LOG_FILENAME_LINE,"oil_test_new returned NULL. errno = %d", errno); assert_failed = 1; } } else { std_log(LOG_FILENAME_LINE,"oil_class_get returned NULL. errno = %d", errno); assert_failed = 1; } }
static void oil_print_class (OilFunctionClass *klass, int verbose) { OilFunctionImpl *impl; OilFunctionImpl **list; int n; int i; OilTest *test; if (!verbose) { printf ("%s\n", klass->name); return; } printf ("%s (%s)\n", klass->name, klass->prototype); printf (" all implementations: \n"); n = 0; for (impl = klass->first_impl; impl; impl = impl->next) { n++; } list = malloc(n * sizeof(OilFunctionImpl *)); i = 0; for (impl = klass->first_impl; impl; impl = impl->next) { list[i] = impl; i++; } qsort (list, n, sizeof(OilFunctionImpl *), impl_compare); test = oil_test_new (klass); for (i=0;i<n;i++){ impl = list[i]; if ((impl->flags & OIL_IMPL_FLAG_REF) && klass->reference_impl != impl) { printerr ("warning: function %s is not reference implementation for class %s\n", impl->name, klass->name); } oil_print_impl (impl, test, " "); if (klass->chosen_impl == impl) { printf (" currently chosen\n"); } } oil_test_free (test); free(list); }
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;i<n; i++ ){ klass = oil_class_get_by_index(i); printf("%s\n", klass->name); 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;j<test->prof.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; }
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 = "stride"; std_log(LOG_FILENAME_LINE, "Test Started testsuite_stride"); if (argc > 1 && strcmp(argv[1],"-v") == 0) { verbose = 1; } 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); std_log(LOG_FILENAME_LINE,"Class Name %s %d\n",klass->name, i); test = oil_test_new (klass); if (test == NULL) { std_log(LOG_FILENAME_LINE,"class \"%s\" has bad prototype\n", klass->name); assert_failed = fail = 1; continue; } oil_test_set_iterations (test, 1); test->n = 1 + oil_rand_u8(); test->m = 1 + oil_rand_u8(); std_log(LOG_FILENAME_LINE, "ref impl %s",klass->reference_impl->name); oil_test_check_impl (test, klass->reference_impl); //Testing whether an appropriate implementation is suitable or not //Runs the testing procedure described by test on the implementation impl for(j=0;j<OIL_ARG_LAST;j++) { if (test->params[j].is_stride) { test->params[j].value += oil_type_sizeof(test->params[j].type) * (oil_rand_u8()&0xf); } } test->inited = 0; for (impl = klass->first_impl; impl; impl = impl->next) { std_log(LOG_FILENAME_LINE," %s\n", impl->name); if ((impl->flags & OIL_CPU_FLAG_MASK) & ~cpu_flags){ std_log(LOG_FILENAME_LINE, "Not supported"); } else { ret = oil_test_check_impl (test, impl); if (!ret) { assert_failed = fail = 1; oil_test_free (test); std_log(LOG_FILENAME_LINE, "Test Failed"); create_xml(1); return fail; } } } oil_test_free (test); } if(assert_failed) std_log(LOG_FILENAME_LINE,"Test Fail"); else std_log(LOG_FILENAME_LINE,"Test Successful"); create_xml(0); return fail; }