Comment on When static makes your C code 10 times fasterComments−api5yDivision is slow, which is something most programmers don't know. If you can binary AND instead of MOD this can be a huge win.Multiplication is also very fast, usually one or two cycles on larger chips.−perl4ever5yDivision is slowI wondered if that's really still true, since I haven't done much assembly language programming since PowerPC was new.Here, it says the M1 has 7-9 cycles latency for division instructions, but throughput of 2 cycles per.https://dougallj.github.io/applecpu/firestorm-int.html"The M1 is 10x faster than the Xeon at 64 bit divides. It’s…just wow."So, given all of the other things that can slow you up, I wonder if it really makes sense to avoid division any more?(I guess the energy efficient "Icestorm" cores have throughput equal to latency, so it's only the "Firestorm" ones where it's super fast)−astrange5yYou shouldn't assume you're running on the performance cores. Not everyone is writing an app, and even if you are, most of your code will be better off on the efficiency cores.−perl4ever5yIf you're not concerned enough about performance to run on the performance cores, then why worry about...performance?−astrange5yThey aren't always available because you can't always get what you ask for.−jeffbee5yIf your compiler doesn't do this for divisors known at compile time, get your money back.
Comments
Division is slow, which is something most programmers don't know. If you can binary AND instead of MOD this can be a huge win.
Multiplication is also very fast, usually one or two cycles on larger chips.
I wondered if that's really still true, since I haven't done much assembly language programming since PowerPC was new.
Here, it says the M1 has 7-9 cycles latency for division instructions, but throughput of 2 cycles per.
https://dougallj.github.io/applecpu/firestorm-int.html
"The M1 is 10x faster than the Xeon at 64 bit divides. It’s…just wow."
So, given all of the other things that can slow you up, I wonder if it really makes sense to avoid division any more?
(I guess the energy efficient "Icestorm" cores have throughput equal to latency, so it's only the "Firestorm" ones where it's super fast)
You shouldn't assume you're running on the performance cores. Not everyone is writing an app, and even if you are, most of your code will be better off on the efficiency cores.
If you're not concerned enough about performance to run on the performance cores, then why worry about...performance?
They aren't always available because you can't always get what you ask for.
If your compiler doesn't do this for divisors known at compile time, get your money back.