/* Timing of floating point ops (from flt.h) */ /* Last edited on 2016-12-26 18:30:26 by stolfilocal */ #include #include #include #include // #if (defined(SunOS4)) // # include // int ieee_flags(char *a, char *b, char *c, char **out); // #endif // // #if (defined(SunOS5)) // # include // #endif #include #include #define APPSECS 5 /* Approximate time for each test in seconds. */ // #if (defined(OSF1V4)) // /* # include */ // #endif int main (int argc, char **argv); int64_t do_empty(int64_t nloop); int64_t do_conversion(int64_t nloop); int64_t do_single_add(int64_t nloop); int64_t do_single_mul(int64_t nloop); int64_t do_single_div(int64_t nloop); int64_t do_double_add(int64_t nloop); int64_t do_double_mul(int64_t nloop); int64_t do_double_div(int64_t nloop); int64_t do_FMIN_FMAX(int64_t nloop); int64_t do_my_set_round(int64_t nloop); int64_t do_sys_set_round(int64_t nloop); int64_t do_flt_mul(int64_t nloop); int64_t do_flt_mix(int64_t nloop); int main (int argc, char **argv) { flt_init(); { /* Tests flt_mul overflow: */ Float x, y, z, err; x = (Float)(MaxFloat/2.0); y = (Float)(MaxFloat/4.0); err = 0; flt_mul(x, y, &z, &err); ROUND_NEAR; fprintf(stderr, " x = %18.8f\n", x); fprintf(stderr, " y = %18.8f\n", y); fprintf(stderr, " z = %18.8f\n", z); fprintf(stderr, " err = %18.8f\n", err); fprintf(stderr, " +Inf = %18.8f\n", PlusInfinity); fprintf(stderr, " -Inf = %18.8f\n", MinusInfinity); fprintf(stderr, " MaxF = %18.8f\n", MaxFloat); } time_func("empty loop", do_empty, do_empty, 75000000*APPSECS); time_func("conversion", do_conversion, do_empty, 50000000*APPSECS); time_func("single add", do_single_add, do_empty, 10000000*APPSECS); time_func("single mul", do_single_mul, do_empty, 10000000*APPSECS); time_func("single div", do_single_div, do_empty, 5000000*APPSECS); time_func("double add", do_double_add, do_empty, 10000000*APPSECS); time_func("double mul", do_double_mul, do_empty, 10000000*APPSECS); time_func("double div", do_double_div, do_empty, 5000000*APPSECS); time_func("FMIN/FMAX", do_FMIN_FMAX, do_empty, 50000000*APPSECS); time_func("ROUND_UP/DOWN", do_my_set_round, do_empty, 1500000*APPSECS); time_func("sys set_round", do_sys_set_round, do_empty, 1500000*APPSECS); time_func("flt_mul", do_flt_mul, do_empty, 300000*APPSECS); time_func("flt_mix", do_flt_mix, do_empty, 500000*APPSECS); return(0); } int64_t do_empty(int64_t nloop) { int64_t i; Float x1, x2, x3, x4, x5, x6, x7, x8, x9, t; x1 = (Float)0.1; x2 = (Float)0.2; x3 = (Float)0.3; x4 = (Float)0.4; x5 = (Float)0.5; x6 = (Float)0.6; x7 = (Float)0.7; x8 = (Float)0.8; x9 = (Float)0.9; for (i=0; i