• Ganesh Ajjanagadde's avatar
    lavc/cook: get rid of wasteful pow in init_pow2table · 05434b0e
    Ganesh Ajjanagadde authored
    The table is highly structured, so pow (or exp2 for that matter) can entirely
    be avoided, yielding a ~ 40x speedup with no loss of accuracy.
    
    sample benchmark (Haswell, GNU/Linux):
    new:
    4449 decicycles in init_pow2table(loop 1000),     254 runs,      2 skips
    4411 decicycles in init_pow2table(loop 1000),     510 runs,      2 skips
    4391 decicycles in init_pow2table(loop 1000),    1022 runs,      2 skips
    
    old:
    183673 decicycles in init_pow2table(loop 1000),     256 runs,      0 skips
    182142 decicycles in init_pow2table(loop 1000),     512 runs,      0 skips
    182104 decicycles in init_pow2table(loop 1000),    1024 runs,      0 skips
    Reviewed-by: 's avatarClément Bœsch <u@pkh.me>
    Signed-off-by: 's avatarGanesh Ajjanagadde <gajjanagadde@gmail.com>
    05434b0e
cook.c 44.7 KB