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; } }
int main (int argc, char *argv[]) { OilFunctionClass *klass; OilFunctionImpl *impl; OilTest *test; double ave, std; int n; oil_init (); if (argc < 2) { printf("oil-test <class_name>\n"); exit(0); } klass = oil_class_get (argv[1]); if (klass == NULL) { printf("class not found: %s\n", argv[1]); exit(0); } oil_class_optimize (klass); for (n = 0; n < 200; n+=1) { printf("%d", n); test = oil_test_new(klass); oil_test_set_iterations(test, 10); test->n = n; test->m = 10; impl = klass->reference_impl; ave = impl->profile_ave; std = impl->profile_std; oil_test_check_impl (test, impl); for (impl = klass->first_impl; impl; impl = impl->next) { if (oil_impl_is_usable (impl)) { oil_test_check_impl (test, impl); //printf(" %g %g", test->profile_ave, test->profile_std); printf(" %g", test->profile_ave); } } printf("\n"); } return 0; }
int main (int argc, char *argv[]) { oil_init(); if (argc > 1) { int i; for (i = 1; i < argc; i++) { OilFunctionClass *klass = oil_class_get (argv[i]); if (!klass) { printerr ("error: no class \"%s\" found\n", argv[i]); } else { oil_print_class (klass, 1); } } } else { oil_print_all (); } return retval; }
static void do_activate_impl (const char *section, char *key, char *value) { unsigned int flags; OilClass *cls; if (section == NULL) { fprintf (stderr, "No section defined, assume no flags need"); flags = 0; } else if (parse_flags_string (section, &flags) == 0) return; cls = oil_class_get (key); if (cls == NULL) fprintf (stderr, "No function class names \"%s\"\n", key); else if ((oil_cpu_get_flags () & flags) == flags) { oil_class_implements_get (cls, value, &flags); if ((oil_cpu_get_flags () & flags) == flags) { char *t; oil_class_activate_implement (cls, value); /* check, whether we'v activated the implement successfully */ t = oil_class_get_active_implement (cls); if (!t || strcmp (t, value) != 0) fprintf (stderr, "Activate %s.%s failed\n", key, value); } else { fprintf (stderr, "Implement %s.%s in section [%s], isn't runnable in current CPU\n", key, value, section); } } }
int main(int argc, char *argv[]) { char *s=NULL, *d=NULL; uint32_t *src, *dest; int16_t res=0; OilProfile prof; double ave, std; int i,j, cnt; double cpufreq; OilFunctionClass *klass; OilFunctionImpl *impl; int the_class; std_log(LOG_FILENAME_LINE,"Test Started memcpy-speed"); oil_init (); s = malloc(512*1024+1024); d = malloc(512*1024+1024); // src = ((void *)((unsigned long)(s) | 0xFF )); //dest = ((void *)((unsigned long)(d) | 0xFF )); src = ((void *)((unsigned long)(s) )); dest = ((void *)((unsigned long)(d) )); for(the_class=0; the_class<3; the_class++) { cpufreq = 1788e6; switch(the_class) { case 0: klass = oil_class_get ("splat_u32_ns"); break; case 1: klass = oil_class_get ("copy_u8"); break; case 2: klass = oil_class_get ("sum_s16"); break; } for(impl=klass->first_impl;impl;impl=impl->next) { std_log(LOG_FILENAME_LINE,"impl %s\n", impl->name); if (!oil_impl_is_usable(impl)) { std_log(LOG_FILENAME_LINE," not usable\n"); continue; } oil_class_choose_by_name (klass, impl->name); for(i=10;i<20;i++){ oil_profile_init (&prof); for(j=0;j<10;j++){ switch(the_class) { case 0: oil_profile_start(&prof); oil_splat_u32_ns (dest, src, 1<<(i-2)); oil_profile_stop(&prof); for(cnt=0; cnt<(1<<(i-2)); cnt++){ if(dest[cnt]!=*src){ std_log(LOG_FILENAME_LINE,"Failed at the_class=%d, cnt=%d, i=%d, j=%d, impl->name=%s\n", the_class, cnt, i, j, impl->name); assert_failed =1; } } break; case 1: oil_profile_start(&prof); oil_memcpy (dest, src, 1<<i); oil_profile_stop(&prof); for(cnt=0; cnt<(1<<(i-2)); cnt++){ //cnt is checked with 1<<(i-2) because dest & src are of type uint32_t* if(dest[cnt]!=src[cnt]){ std_log(LOG_FILENAME_LINE,"Failed at the_class=%d, cnt=%d, i=%d, j=%d, impl->name=%s\n", the_class, cnt, i, j, impl->name); assert_failed =1; } } break; case 2: { int16_t* src1 = (int16_t*)src; int16_t* dest1 = (int16_t*)dest; oil_profile_start(&prof); oil_sum_s16 (dest1, src1, 1<<(i-1)); oil_profile_stop(&prof); res=0; for(cnt=0; cnt<(1<<(i-1)); cnt++){ res += src1[cnt]; } if(*dest1 != res){ std_log(LOG_FILENAME_LINE,"Failed at the_class=%d, impl->name=%s\n", the_class, impl->name); assert_failed =1; } } break; } } oil_profile_get_ave_std (&prof, &ave, &std); std_log(LOG_FILENAME_LINE,"%d: %10.4g %10.4g %10.4g\n", i, ave, std, ave/(1<<i)); } } } free(s); free(d); if(!assert_failed) std_log(LOG_FILENAME_LINE, "Test Passed"); else std_log(LOG_FILENAME_LINE, "Test Failed"); create_xml(0); return 0; }