3 ms·
> The % operation is quite efficient (although it’s usually two times more expensive than multiplication); I though it was much more than two times slower? Div
by ufo 5y ago
> The % operation is quite efficient (although it’s usually two times more expensive than multiplication);
I though it was much more than two times slower? Division and modulus are the slowest integer operation.
- veltas 5y agoIt makes a significant difference in profiling, versus i.e. a bitwise mask to find a modulus for a power-of-two size.
- pansa2 5y agoAgner Fog’s manual lists a latency/reciprocal-throughput of 15/10 for 64-bit divide on Ivy Lake & Tiger Lake, vs 3/1 for 64-bit multiply. So division is 5-10x slower than multiplication. https://www.agner.org/optimize/#manuals https://www.agner.org/optimize/#manuals