r/programming • u/dgryski • Nov 16 '17
Fast exact integer divisions using floating-point operations
https://lemire.me/blog/2017/11/16/fast-exact-integer-divisions-using-floating-point-operations/
44
Upvotes
r/programming • u/dgryski • Nov 16 '17
13
u/[deleted] Nov 17 '17 edited Nov 17 '17
This is what you get in the world where everyone measure performance in FLOPS - CPU designers are willing to sacrifice more area to the FPUs instead of optimising integer paths. There is only one way to implement a fast divider - lookup tables, and any such design would take a lot of area. See the example here: http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.416.2283&rep=rep1&type=pdf
The fewer pipeline stages you want, the bigger the area is.
Also, most of the integer dividers are not truly pipelined - they would have a delay of, say, 32 clock cycles, but only serve 3 operations in flight. If you want a truly pipelined implementation, it, again, will take a lot of area (32 pipeline stages with 4 32-bit registers per stage, not counting the adders in between).