arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2012.12369cs.DS
收藏

常数除法:最优边界

Integer Division by Constants: Optimal Bounds

Daniel Lemire, Colin Bartlett, Owen Kaser

摘要:

分子n除以除数d得到商q和余数r。优化编译器通过将n除以d替换为c * n(或c * n + c)除以m来加速软件,c和m选择为方便的整数,以便它们近似于倒数:c/m ~= 1/d。当m被选择为2的幂并且当d是常数时,这样的技术是特别有利的,使得可以预先计算c和m。文献中有许多关于c/m和除数d之间距离的界。其中一些界限是最优紧的,而另一些则不是。我们提出了最佳紧界的商和剩余计算。

英文摘要:

The integer division of a numerator n by a divisor d gives a quotient q and a remainder r. Optimizing compilers accelerate software by replacing the division of n by d with the division of c * n (or c * n + c) by m for convenient integers c and m chosen so that they approximate the reciprocal: c/m ~= 1/d. Such techniques are especially advantageous when m is chosen to be a power of two and when d is a constant so that c and m can be precomputed. The literature contains many bounds on the distance between c/m and the divisor d. Some of these bounds are optimally tight, while others are not. We present optimally tight bounds for quotient and remainder computations.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑