1*288bf522SAndroid Build Coastguard Worker# CPU test loads 2*288bf522SAndroid Build Coastguard Worker 3*288bf522SAndroid Build Coastguard WorkerThese are a collection of simple workloads designed to induce various levels of power consumption on the CPU and memory subsystems of an SOC. All of these workloads run in an infinite loop and are designed to be measured across a fixed duration. They are not benchmarks and provide no information about the performance of various cores; they are only designed to generate different amounts of load for the purposes of measuring power consumption. 4*288bf522SAndroid Build Coastguard Worker 5*288bf522SAndroid Build Coastguard Worker## Workloads 6*288bf522SAndroid Build Coastguard Worker 7*288bf522SAndroid Build Coastguard Worker- `simd` is a large double-precision matrix multiplication using Eigen 8*288bf522SAndroid Build Coastguard Worker- `memcpy` copies a 1GB buffer to a second 1GB buffer using bionic `memcpy` 9*288bf522SAndroid Build Coastguard Worker- `memcpy-16kb` copies a 16KB buffer to a second 16KB buffer using bionic `memcpy` 10*288bf522SAndroid Build Coastguard Worker- `memcpy-2048kb` copies a 2048KB buffer to a second 2048KB buffer using bionic `memcpy` 11*288bf522SAndroid Build Coastguard Worker- `memcpy-byte` copies a 1GB buffer to a second 1GB buffer using byte assignment 12*288bf522SAndroid Build Coastguard Worker- `while-true` stalls at a `while (true);`, which becomes an unconditional branch to the same instruction 13*288bf522SAndroid Build Coastguard Worker- `pss` allocates a 1GB buffer and repeatedly measures the process's PSS 14*288bf522SAndroid Build Coastguard Worker 15*288bf522SAndroid Build Coastguard Worker## Usage 16*288bf522SAndroid Build Coastguard Worker 17*288bf522SAndroid Build Coastguard Worker1. Build the tests for a given device with `mm`. 18*288bf522SAndroid Build Coastguard Worker2. Push the tests to the device; usually this is something like 19*288bf522SAndroid Build Coastguard Worker 20*288bf522SAndroid Build Coastguard Worker``` 21*288bf522SAndroid Build Coastguard Workeradb push out/target/product/<device target>/system/bin/simd /data/local/tmp 22*288bf522SAndroid Build Coastguard Worker``` 23*288bf522SAndroid Build Coastguard Worker 24*288bf522SAndroid Build Coastguard Worker3. Prepare the device to run the test. This usually means stopping the framework, locking a sustainable CPU frequency, and moving the shell to a cpuset containing only a single core. For example: 25*288bf522SAndroid Build Coastguard Worker 26*288bf522SAndroid Build Coastguard Worker``` 27*288bf522SAndroid Build Coastguard Workerstop 28*288bf522SAndroid Build Coastguard Workermkdir /dev/cpuset/cpu7 29*288bf522SAndroid Build Coastguard Workerecho 0 > /dev/cpuset/cpu7/mems 30*288bf522SAndroid Build Coastguard Workerecho 7 > /dev/cpuset/cpu7/cpus 31*288bf522SAndroid Build Coastguard Workerecho $$ > /dev/cpuset/cpu7/cgroup.procs 32*288bf522SAndroid Build Coastguard Worker 33*288bf522SAndroid Build Coastguard Workercat /sys/devices/system/cpu/cpu7/cpufreq/scaling_available_frequencies 34*288bf522SAndroid Build Coastguard Worker# 500000 851000 984000 1106000 1277000 1426000 1582000 1745000 1826000 2048000 2188000 2252000 2401000 2507000 2630000 2704000 2802000 2850000 35*288bf522SAndroid Build Coastguard Workerecho 1826000 > /sys/devices/system/cpu/cpu7/cpufreq/scaling_min_freq 36*288bf522SAndroid Build Coastguard Workerecho 1826000 > /sys/devices/system/cpu/cpu7/cpufreq/scaling_max_freq 37*288bf522SAndroid Build Coastguard Worker``` 38*288bf522SAndroid Build Coastguard Worker 39*288bf522SAndroid Build Coastguard Worker4. Run the tests on the device; there are no arguments. 40*288bf522SAndroid Build Coastguard Worker5. Measure power somehow. On a device with ODPM capabilities, this could be something like 41*288bf522SAndroid Build Coastguard Worker 42*288bf522SAndroid Build Coastguard Worker``` 43*288bf522SAndroid Build Coastguard Workerdumpsys android.hardware.power.stats.IPowerStats/default | tail -27 && sleep 120 && killall memcpy-2048kb && echo "done" && dumpsys android.hardware.power.stats.IPowerStats/default | tail -27 44*288bf522SAndroid Build Coastguard Worker``` 45*288bf522SAndroid Build Coastguard Worker 46*288bf522SAndroid Build Coastguard Workerfrom a separate `adb shell` to the shell running the test. Alternately, a breakout board with per-rail measurements or a separate battery monitor could be used. 47