3 ms·
In which way do you reckon doing modular arithmetic is an improvement over two 3x3 look-up tables?
by ZoomZoomZoom 4y ago
In which way do you reckon doing modular arithmetic is an improvement over two 3x3 look-up tables?
- neonsunset 4y agoThe rationale is as following - if the compiler cannot fold the lookup table, then math with 1-2 branches will be much cheaper because it involves no memory access and has constant (low) latency (keep in mind that when for example selecting a literal, a conditional select might be emitted which is usually cheaper than a regular branch e.g. Aarch64). In addition, unlike in C, in many other languages indexing into array will involve bounds check if the compiler cannot prove that the access is always in bounds. Obviously most branches will be predicted but branch retire throughput is always lower than math operations throughput.
- ZoomZoomZoom 4y agoThanks for the reply. The bounds checking is a valid reason I haven't thought of. In my case, using 3x3 array is roughly 3-4 times faster.