5 ms·
"Apple A12 in my iPhone is limited to 2.5 GHz, so I multiply the result by 2.5 to get the number of cycles." I can guarantee that unless he was going out his w
by TickleSteve 7y ago
"Apple A12 in my iPhone is limited to 2.5 GHz, so I multiply the result by 2.5 to get the number of cycles."
I can guarantee that unless he was going out his way to force it, the processor was not running at 2.5GHz... it would have been scaled way back as mobile processors are very aggressively tuned for power-saving.
Unless he can show how he managed to disable frequency scaling on the iPhone, the results are kind of meaningless.
If he wants to get the cycle count of the instructions, you don't have to run it, you need the datasheet from the manufacturer (which may be difficult to source admittedly).
- jcranmer 7y ago> If he wants to get the cycle count of the instructions, you don't have to run it, you need the datasheet from the manufacturer (which may be difficult to source admittedly). A12 is an out-of-order superscalar core. Counting the exact cycle counts of a sequence of instructions for such architectures by hand is basically a fool's errand, especially if you start running into issues such as exhausting register ports or issue stations.
- TickleSteve 7y agofair point, the point I was trying to make is that its an overly simplisitic way of measuring performance.
- zeusk 7y agoI'm quite sure Apple has a tool for profiling iOS applications. ARM has PMU (Performance Measuring Unit) as part of the architecture, for exactly this sort of testing.
- saagarjha 7y agoInstruments probably has this available; I know they do for Intel processors. Edit: Just checked, and my A10 shows a small but standard set of PMCs, many of which show up here: https://opensource.apple.com/source/xnu/xnu-4903.221.2/osfmk/arm64/kpc.c https://opensource.apple.com/source/xnu/xnu-4903.221.2/osfmk...
- astrange 7y agoAs long as the phone is plugged in, it doesn't particularly need to power save. You can also set the thread priority higher.
- mort96 7y agoDoesn't mean it will run at its max speed. Thermals are a huge issue in phone CPUs, and that's even worse when you add the heat generated by charging the battery. Maybe it's always running at 2.5GHz when plugged in, I don't know, but it seems extremely likely that it'll try to use less power just to reduce heat output.
- londons_explore 7y agoIndeed, but it will hit 2.5Ghz occasionally, or it wouldn't be worth designing the CPU to go that fast. My guess is it's designed for fast interactive use, so as long as you do your work in bursts of 300ms or less, you will probably get full speed. Beyond that, and you'll be power or thermally throttled.
- mort96 7y agoYou have absolutely nothing to base that guess on though? What if Apple made the CPU to usually peak at, say, 2GHz and only go up to 2.5 under very special circumstances? What if the author has a, say, iPhone Xs, and the Xs's CPU is limited to never exceed 2.3GHz while the same CPU in the Xs Max reaches 2.5GHz? Or any number of other factors which I couldn't even start guessing at because the CPUs in smartphones and the software and firmware which controls them is an extremely complicated matter which I'd bet neither of us has any first-hand experience with.
- londons_explore 7y agoI have experience with production CPU governing in some Android devices. It is more art than science - you want to get the best possible user experience while not using too much power and not exceeding thermal and power limits. Typically, governors are written as linux kernel modules. They get to choose the clock speed of groups of cores, and which cores are enabled. Some are in trustzone applications or android userland apps though. Some hardware has extra constraints. For example, the autofocus mechanism on one device I worked on used a lot of power, so while the autofocus was initializing, the CPU had to be scaled down to the slowest speed for a few milliseconds, and the radio transmit disabled. The code ends up a mess because you need to pipe that info from all the other device drivers with no proper interface. A large number of devices do similar shenanigans when the battery is <50% because the battery voltage drops at high loads, and if it's already quite low, then you'll trip a brownout detector and reboot the device. Thermal constraints are the main one - typically represented as some exponential curves. Ie. you may be at 2.0Ghz for 100ms, 1.8Ghz for 1 second, 1.6Ghz for 5 seconds, 1.4 Ghz for 30 seconds, etc. Depending on the history of the currently running process, the governor would try to decide if it was best to go to 2.0Ghz because this was going to be a quick task, or to only start at 1.6Ghz because it was going to be a long running thing. Hopefully thats some insight! Check out XDA forums where some devices have a community of people into modding governors for different use cases.
- gok 7y agoSo you think it uses even fewer cycles then?