aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarissa Wall <marissaw@google.com>2017-10-16 14:12:25 -0700
committerMarissa Wall <marissaw@google.com>2017-11-29 12:10:59 -0800
commitedd4cac0d4abbd69d75918cd02013893f73c6333 (patch)
tree178bfb7e8429a7c5dc73dfe745938e16b14c5beb
parentbb96100dae2d5d0f4c61f4d0c1016edcecd17bf8 (diff)
downloadlisa-edd4cac0d4abbd69d75918cd02013893f73c6333.tar.gz
experiments/power: Refactor run_cpu_freq
Put the current power tests for a single cluster into a seperate function because next we will be adding tests accross multiple clusters. Rename the outfiles because it will help disambiguate which cpus at what frequency belong to which cluster. Test: ./run_cpu_frequency.py Change-Id: I8e8f705579edf2a3242efa538c6bcdeb78a04421
-rwxr-xr-xexperiments/power/eas/run_cpu_frequency.py123
1 files changed, 63 insertions, 60 deletions
diff --git a/experiments/power/eas/run_cpu_frequency.py b/experiments/power/eas/run_cpu_frequency.py
index a7fcb36..8cf9910 100755
--- a/experiments/power/eas/run_cpu_frequency.py
+++ b/experiments/power/eas/run_cpu_frequency.py
@@ -56,10 +56,10 @@ CRITICAL_TASKS = [
"/system/bin/sh", "adbd", "/init"
]
-def outfiles(on_cpus, freq):
- cpu_str = ''.join('{}-'.format(c) for c in on_cpus)
- samples = 'cpus{}freq{}-samples.csv'.format(cpu_str, freq)
- energy = 'cpus{}freq{}-energy.json'.format(cpu_str, freq)
+def outfiles(cluster, cpus, freq):
+ prefix = 'cluster{}-cores{}freq{}_'.format(str(cluster), ''.join('{}-'.format(cpu) for cpu in cpus), freq)
+ samples = '{}samples.csv'.format(prefix)
+ energy = '{}energy.json'.format(prefix)
return energy, samples
def update_cpus(target, on_cpus, off_cpus):
@@ -69,58 +69,9 @@ def update_cpus(target, on_cpus, off_cpus):
for cpu in off_cpus:
target.hotplug.offline(cpu)
-def experiment():
- # Check if the dhyrstone binary is on the device
- dhrystone = os.path.join(target.executables_directory, 'dhrystone')
- if not target.file_exists(dhrystone):
- raise RuntimeError('dhrystone could not be located here: {}'.format(
- dhrystone))
-
- # Create results directory
- outdir=te.res_dir + '_' + args.out_prefix
- if not args.cont:
- try:
- shutil.rmtree(outdir)
- except:
- print "couldn't remove " + outdir
- pass
- if not os.path.exists(outdir):
- os.makedirs(outdir)
-
- # Get clusters and cpus
- clusters = te.topology.get_level('cluster')
- cpus = [cpu for cluster in clusters for cpu in cluster]
-
- # Prevent screen from dozing
- Screen.set_doze_always_on(target, on=False)
-
- # Turn on airplane mode
- System.set_airplane_mode(target, on=True)
-
- # Turn off screen
- Screen.set_screen(target, on=False)
-
- # Stop thermal engine and perfd
- target.execute("stop thermal-engine")
- target.execute("stop perfd")
-
- # Take a wakelock
- System.wakelock(target, take=True)
-
- # Store governors so they can be restored later
- governors = [ target.cpufreq.get_governor(cpu) for cpu in cpus]
-
- # Set the governer to userspace so the cpu frequencies can be set
- target.hotplug.online_all()
- target.cpufreq.set_all_governors('userspace')
-
- # Freeze all non critical tasks
- target.cgroups.freeze(exclude=CRITICAL_TASKS)
-
+def single_cluster(cpus, sandbox_cg, isolated_cg, dhrystone, outdir):
# For each cluster
- for cluster in clusters:
- # Remove all userspace tasks from the cluster
- sandbox_cg, isolated_cg = target.cgroups.isolate(cluster)
+ for i, cluster in enumerate(clusters):
# For each frequency on the cluster
for freq in target.cpufreq.list_frequencies(cluster[0]):
@@ -137,7 +88,7 @@ def experiment():
off_cpus.remove(cpu)
# Switch the output file so the previous samples are not overwritten
- energy, samples = outfiles(on_cpus, freq)
+ energy, samples = outfiles(i, on_cpus, freq)
# If we are continuing from a previous experiment and this set has
# already been run, skip it
@@ -146,11 +97,9 @@ def experiment():
# Bring the on_cpus online take the off_cpus offline
update_cpus(target, on_cpus, off_cpus)
- for on_cpu in on_cpus:
- target.cpufreq.set_frequency(cpu, freq)
+ target.cpufreq.set_frequency(cpu, freq)
- # Update the target cgroup in case hotplugging has introduced
- # any errors
+ # Update sandbox and isolated cgroups
sandbox_cg.set(cpus=on_cpus)
isolated_cg.set(cpus=off_cpus)
@@ -176,6 +125,60 @@ def experiment():
# Restore all the cpus
target.hotplug.online_all()
+def experiment():
+ # Check if the dhyrstone binary is on the device
+ dhrystone = os.path.join(target.executables_directory, 'dhrystone')
+ if not target.file_exists(dhrystone):
+ raise RuntimeError('dhrystone could not be located here: {}'.format(
+ dhrystone))
+
+ # Create results directory
+ outdir=te.res_dir + '_' + args.out_prefix
+ if not args.cont:
+ try:
+ shutil.rmtree(outdir)
+ except:
+ print "couldn't remove " + outdir
+ pass
+ if not os.path.exists(outdir):
+ os.makedirs(outdir)
+
+ # Get clusters and cpus
+ clusters = te.topology.get_level('cluster')
+ cpus = [cpu for cluster in clusters for cpu in cluster]
+
+ # Prevent screen from dozing
+ Screen.set_doze_always_on(target, on=False)
+
+ # Turn on airplane mode
+ System.set_airplane_mode(target, on=True)
+
+ # Turn off screen
+ Screen.set_screen(target, on=False)
+
+ # Stop thermal engine and perfd
+ target.execute("stop thermal-engine")
+ target.execute("stop perfd")
+
+ # Take a wakelock
+ System.wakelock(target, take=True)
+
+ # Store governors so they can be restored later
+ governors = [ target.cpufreq.get_governor(cpu) for cpu in cpus]
+
+ # Set the governer to userspace so the cpu frequencies can be set
+ target.hotplug.online_all()
+ target.cpufreq.set_all_governors('userspace')
+
+ # Freeze all non critical tasks
+ target.cgroups.freeze(exclude=CRITICAL_TASKS)
+
+ # Remove all userspace tasks from the cluster
+ sandbox_cg, isolated_cg = target.cgroups.isolate([])
+
+ # Run measurements on single cluster
+ single_cluster(cpus, sandbox_cg, isolated_cg, dhrystone, outdir)
+
# Restore all governors
for i, governor in enumerate(governors):
target.cpufreq.set_governor(cpus[i], governor)