xnsticks_t xnclock_core_ticks_to_ns(xnsticks_t ticks) { return xnarch_llimd(ticks, 1000000000, clockfreq); }
xnsticks_t xnclock_core_ticks_to_ns_rounded(xnsticks_t ticks) { return (xnarch_llimd(ticks, 1000000000, clockfreq/2) + 1) / 2; }
xnsticks_t xnclock_core_ns_to_ticks(xnsticks_t ns) { return xnarch_llimd(ns, clockfreq, 1000000000); }
long long xnclock_core_ns_to_ticks(long long ns) { return xnarch_llimd(ns, 1 << tsc_shift, tsc_scale); }
static int run_arith(struct smokey_test *t, int argc, char *const argv[]) { unsigned int mul, shft, rejected; long long avg, calib = 0; #ifdef XNARCH_HAVE_NODIV_LLIMD struct xnarch_u32frac frac; #endif int i; /* Prepare. */ xnarch_init_llmulshft(nsec_per_sec, sample_freq, &mul, &shft); smokey_trace("mul: 0x%08x, shft: %d", mul, shft); #ifdef XNARCH_HAVE_NODIV_LLIMD xnarch_init_u32frac(&frac, nsec_per_sec, sample_freq); smokey_trace("integ: %d, frac: 0x%08llx", frac.integ, frac.frac); #endif /* XNARCH_HAVE_NODIV_LLIMD */ smokey_trace("\nsigned positive operation: 0x%016llx * %u / %d", arg, nsec_per_sec, sample_freq); bench("inline calibration", 0); calib = avg; bench("inlined llimd", xnarch_llimd(arg, nsec_per_sec, sample_freq)); bench("inlined llmulshft", xnarch_llmulshft(arg, mul, shft)); #ifdef XNARCH_HAVE_NODIV_LLIMD bench("inlined nodiv_llimd", xnarch_nodiv_llimd(arg, frac.frac, frac.integ)); #endif /* XNARCH_HAVE_NODIV_LLIMD */ calib = 0; bench("out of line calibration", dummy()); calib = avg; bench("out of line llimd", do_llimd(arg, nsec_per_sec, sample_freq)); bench("out of line llmulshft", do_llmulshft(arg, mul, shft)); #ifdef XNARCH_HAVE_NODIV_LLIMD bench("out of line nodiv_llimd", do_nodiv_llimd(arg, frac.frac, frac.integ)); #endif /* XNARCH_HAVE_NODIV_LLIMD */ smokey_trace("\nsigned negative operation: 0x%016llx * %u / %d", -arg, nsec_per_sec, sample_freq); calib = 0; bench("inline calibration", 0); calib = avg; bench("inlined llimd", xnarch_llimd(-arg, nsec_per_sec, sample_freq)); bench("inlined llmulshft", xnarch_llmulshft(-arg, mul, shft)); #ifdef XNARCH_HAVE_NODIV_LLIMD bench("inlined nodiv_llimd", xnarch_nodiv_llimd(-arg, frac.frac, frac.integ)); #endif /* XNARCH_HAVE_NODIV_LLIMD */ calib = 0; bench("out of line calibration", dummy()); calib = avg; bench("out of line llimd", do_llimd(-arg, nsec_per_sec, sample_freq)); bench("out of line llmulshft", do_llmulshft(-arg, mul, shft)); #ifdef XNARCH_HAVE_NODIV_LLIMD bench("out of line nodiv_llimd", do_nodiv_llimd(-arg, frac.frac, frac.integ)); #endif /* XNARCH_HAVE_NODIV_LLIMD */ #ifdef XNARCH_HAVE_NODIV_LLIMD smokey_trace("\nunsigned operation: 0x%016llx * %u / %d", arg, nsec_per_sec, sample_freq); calib = 0; bench("inline calibration", 0); calib = avg; bench("inlined nodiv_ullimd", xnarch_nodiv_ullimd(arg, frac.frac, frac.integ)); calib = 0; bench("out of line calibration", dummy()); calib = avg; bench("out of line nodiv_ullimd", do_nodiv_ullimd(arg, frac.frac, frac.integ)); #endif /* XNARCH_HAVE_NODIV_LLIMD */ return 0; }
xnsticks_t cobalt_ns_to_ticks(xnsticks_t ns) { return xnarch_llimd(ns, clockfreq, 1000000000); }
xnsticks_t cobalt_ticks_to_ns_rounded(xnsticks_t ticks) { return (xnarch_llimd(ticks, 1000000000, clockfreq/2) + 1) / 2; }
xnsticks_t cobalt_ticks_to_ns(xnsticks_t ticks) { return xnarch_llimd(ticks, 1000000000, clockfreq); }
long long cobalt_ns_to_ticks(long long ns) { return xnarch_llimd(ns, 1 << tsc_shift, tsc_scale); }