aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Jones <christopher.jones@linaro.org>2022-02-10 15:13:01 +0000
committerChris Jones <christopher.jones@linaro.org>2022-03-24 19:27:37 +0000
commitcba52c6e6b01b912cc20c3efc474798aec823296 (patch)
tree18e46c70f8c66547890b8f5f957663c44d514c2d
parenta642ec1b360497acb591cb1416fb164d9bba2138 (diff)
downloadart-build-scripts-cba52c6e6b01b912cc20c3efc474798aec823296.tar.gz
Support new CPU structure format for benchmarks
Change benchmark device config files to use a new generalised CPU structure. The new structure uses a "2d" associative array to define the CPU ID's, grouped into separate clusters, and associates them with a frequency. To support these changes to config files, changes have also been made to the benchmarking, and supporting utility scripts. This includes allowing a cluster name to be given as an argument to each script to replace the old "--cpu <big/little>" and "--<big/little>" options. The new cluster name is checked against the device config at run time. Test: ./scripts/benchmarks/benchmarks_run_target.sh --cpu little \ --iterations 2 benchmarks/algorithm/DeltaBlue Test: ./scripts/benchmarks/perf_profile_benchmarks_target.sh \ --cpu big benchmarks/algorithm/DeltaBlue Test: ./scripts/benchmarks/compilation_stats_target.sh --cpu middle \ ./external-benchmarks/apks/DuckDuckGo/duckduckgo-5.97.0-play-release.apk \ boot.oat --iterations 2 Change-Id: Id8456f03bed7b35ea8fabfff96add78184ce74cf
-rwxr-xr-xbenchmarks/benchmarks_run_target.sh23
-rwxr-xr-xbenchmarks/calibrate_benchmark_target.sh36
-rwxr-xr-xbenchmarks/compilation_stats_target.sh18
-rwxr-xr-xbenchmarks/perf_profile_benchmarks_target.sh12
-rw-r--r--devices/config/NUC6i5SYH.sh27
-rw-r--r--devices/config/VOYOv1.sh27
-rw-r--r--devices/config/angler.sh35
-rw-r--r--devices/config/blueline.sh37
-rw-r--r--devices/config/bullhead.sh35
-rw-r--r--devices/config/flame.sh37
-rw-r--r--devices/config/flounder.sh27
-rw-r--r--devices/config/fugu.sh27
-rw-r--r--devices/config/hikey960.sh37
-rw-r--r--devices/config/sailfish.sh27
-rw-r--r--devices/config/walleye.sh37
-rw-r--r--devices/cpu_freq_utils.sh159
-rw-r--r--devices/flash_device.sh3
-rwxr-xr-xdevices/set_cpu_freq.sh114
-rwxr-xr-xperf/sperf_target_dalvikvm.sh47
-rw-r--r--utils/utils_benchmarks.sh33
20 files changed, 479 insertions, 319 deletions
diff --git a/benchmarks/benchmarks_run_target.sh b/benchmarks/benchmarks_run_target.sh
index bc3a621a..d550aa59 100755
--- a/benchmarks/benchmarks_run_target.sh
+++ b/benchmarks/benchmarks_run_target.sh
@@ -57,8 +57,12 @@ declare -a benchmarks=()
validate_options() {
local -r mode="${options["mode"]}"
validate_mode_option "${mode}"
+
local -r cpu="${options["cpu"]}"
- validate_cpu_option "${cpu}"
+ if ! [[ ${cpu} == "all" || ${cpu} == "default" ]]; then
+ validate_cluster "${cpu}"
+ fi
+
local -r iterations="${options["iterations"]}"
if [[ ! ${iterations} =~ ^[0-9]+$ ]]; then
log E "Invalid number of iterations: ${iterations}"
@@ -106,15 +110,12 @@ usage() {
log I " --list-devices - List the devices supported by this script."
log I " --mode <all|32|64> - Run benchmarks for the specified mode(s)."
log I " (default: all)"
- log I " --cpu <all|big|little|default> - CPU mode."
- log I " \"big\": Run with only big cores and pin their frequency"
- log I " \"little\": Run with only little cores and pin their"
- log I " frequency"
- log I " \"all\": With big.LITTLE devices:"
- log I " Run consecutively with only little cores enabled and pinned,"
- log I " and then with only big cores enabled and pinned."
- log I " For devices without big.LITTLE, all cores are enabled and"
- log I " pinned"
+ log I " --cpu <all|cluster_name|default> - CPU mode."
+ log I " \"cluster_name\": Run with only cores specified by"
+ log I " \`cluster_name\` and pin their frequency."
+ log I " \"all\": Run one cluster of cores at a time until all"
+ log I " clusters/cores have been run. Each cluster is run pinned to"
+ log I " a specific frequency to ensure consistency between tests."
log I " \"default\": Run with unaltered default CPU configuration"
log I " (no pinning)."
log I " (default: all)"
@@ -272,7 +273,7 @@ run_benchmarks() {
# ${1} - CPU mode (bitness)
run_all_benchmarks() {
local -r bitness="$1"
- local -r target_device=$(safe adb_shell getprop ro.product.device)
+ local -r target_device=$(retrieve_target_product_name)
local -r cpu="${options["cpu"]}"
local -r path_to_devices="${local_path}/../devices"
set_freq_and_run run_benchmarks "${bitness}" "${cpu}" "${target_device}" "${path_to_devices}"
diff --git a/benchmarks/calibrate_benchmark_target.sh b/benchmarks/calibrate_benchmark_target.sh
index 6c9bcc98..50f2c573 100755
--- a/benchmarks/calibrate_benchmark_target.sh
+++ b/benchmarks/calibrate_benchmark_target.sh
@@ -54,15 +54,7 @@ set_default_options() {
}
validate_options() {
- if [[ -z "${options["cpu"]}" ]]; then
- log E "CPU is not provided."
- exit 1
- fi
- if [[ "${options["cpu"]}" != @(big|little) ]]; then
- log E "Invalid CPU option: ${cpu}"
- exit 1
- fi
-
+ validate_cluster "${options["cpu"]}"
validate_benchmarks_names "${options["benchmark"]}"
}
@@ -74,10 +66,10 @@ usage() {
log I ""
log I "-------------------------------------------"
log I " -h, --help - help"
- log I " --cpu <big|little> - CPU mode."
- log I " 'big': Run dalvikvm on big cores."
- log I " 'little': Run dalvikvm on little cores."
- log I " Note: The frequency of the specified cores will be pinned."
+ log I " --cpu <cluster_name> - Cluster name."
+ log I " Run dalvikvm on the cluster specified by"
+ log I " cluster_name."
+ log I " Note: The frequency of the specified cores will be pinned."
log I " --classpath <classpath> - Classpath for dalvikvm on a target device."
log I " --target_running_time <time in ms>"
log I " - The target running time for benchmark methods."
@@ -131,8 +123,9 @@ set_environment_for_run() {
run_target_cmdline() {
local -r sh="chroot ${ART_TEST_CHROOT} sh"
+ local -r cpu="${options["cpu"]}"
- safe "${local_path}/../devices/set_cpu_freq.sh" --all --pin-freq
+ safe "${local_path}/../devices/set_cpu_freq.sh" --cpu "${cpu}" --pin-freq
echo -n "CALIBRATION_RESULT:"
adb_shell "${sh}" "${target_virtual_work_dir}/cmdline.sh"
@@ -143,22 +136,17 @@ run_target_cmdline() {
generate_target_cmdline() {
local -r work_dir="${target_virtual_work_dir}"
- local -r target_device=$(safe adb_shell getprop ro.product.device)
- local -r cpu="${options["cpu"]}"
+ local -r target_device=$(retrieve_target_product_name)
+ local -r cluster_name="${options["cpu"]}"
local -r classpath="${options["classpath"]}"
local -r target_running_time="${options["target_running_time"]}"
local -r benchmark="${options["benchmark"]}"
exit_on_failure get_device_settings "${target_device}" "${local_path}/../devices/config"
- require_big_little_device "${target_device}"
-
- local dalvikvm_cpus
- if [[ "$cpu" == "big" ]]; then
- dalvikvm_cpus="$(get_cpu_affinity_mask "${BIG_CPUS[@]}")"
- else
- dalvikvm_cpus="$(get_cpu_affinity_mask "${LITTLE_CPUS[@]}")"
- fi
+ local -r -a cluster=(${!CPUS[${cluster_name}]})
+ local -r -a cpu_ids=($(get_ids_from_cluster "${cluster[*]}"))
+ local -r dalvikvm_cpus="$(get_cpu_affinity_mask "${cpu_ids[@]}")"
local target_script
read -r -d '' target_script << EOM
diff --git a/benchmarks/compilation_stats_target.sh b/benchmarks/compilation_stats_target.sh
index 6bef4795..4de1810e 100755
--- a/benchmarks/compilation_stats_target.sh
+++ b/benchmarks/compilation_stats_target.sh
@@ -76,16 +76,12 @@ usage() {
log I " --list-devices - List the devices supported by this script."
log I " --mode <all|32|64> - Get compile stats for the specified mode(s)."
log I " (default: all)"
- log I " --cpu <all|big|little|default> - CPU mode."
- log I " \"big\": Run with only big cores and pin their frequency"
- log I " \"little\": Run with only little cores and pin their"
- log I " frequency"
- log I " \"all\": With big.LITTLE devices:"
- log I " Run consecutively with only little cores enabled and"
- log I " pinned,"
- log I " and then with only big cores enabled and pinned."
- log I " For devices without big.LITTLE, all cores are enabled and"
- log I " pinned"
+ log I " --cpu <all|cluster_name|default> - CPU mode."
+ log I " \"cluster_name\": Run with only cores specified by"
+ log I " \`cluster_name\` and pin their frequency."
+ log I " \"all\": Run one cluster of cores at a time until all"
+ log I " clusters/cores have been run. Each cluster is run pinned to"
+ log I " a specific frequency to ensure consistency between tests."
log I " \"default\": Run with unaltered default CPU configuration"
log I " (no pinning)."
log I " (default: all)"
@@ -233,7 +229,7 @@ run_apks() {
# ${1}: bitness
run_all_apks() {
local -r bitness="${1}"
- local -r target_device=$(safe adb_shell getprop ro.product.device)
+ local -r target_device=$(retrieve_target_product_name)
local -r cpu="${options["cpu"]}"
local -r path_to_devices="${local_path}/../devices"
set_freq_and_run run_apks "${bitness}" "${cpu}" "${target_device}" "${path_to_devices}"
diff --git a/benchmarks/perf_profile_benchmarks_target.sh b/benchmarks/perf_profile_benchmarks_target.sh
index e4ab8bda..d4358f10 100755
--- a/benchmarks/perf_profile_benchmarks_target.sh
+++ b/benchmarks/perf_profile_benchmarks_target.sh
@@ -25,6 +25,7 @@ source "${local_path}/../utils/utils_test.sh"
source "${local_path}/../utils/utils_android.sh"
source "${local_path}/../utils/utils_android_root.sh"
source "${local_path}/../utils/utils_benchmarks.sh"
+source "${local_path}/../devices/cpu_freq_utils.sh"
readonly timer_name="Perf Target Benchmarks"
readonly LOG_DIRECTORY="$(get_workspace)"
@@ -55,7 +56,7 @@ validate_options() {
validate_mode_option "${mode}"
local -r cpu="${options[cpu]}"
- validate_cpu_option "${cpu}"
+ validate_cluster "${cpu}"
}
usage() {
@@ -68,10 +69,9 @@ usage() {
log I " -h|--help - help"
log I " -v|--verbose - verbose"
log I "-------------------------------------------"
- log I " --cpu <big|little> - CPU cores."
- log I " \"big\": Run benchmarks on big cores."
- log I " \"little\": Run benchmarks on little cores."
- log I " (default: little)"
+ log I " --cpu <cluster_name> - CPU cores."
+ log I " \"cluster_name\": Run benchmarks on specified cores."
+ log I " (default: none)"
log I " --no-calibration - Run benchmarks without calibration. Benchmarks are run"
log I " directly using their main() method."
log I " (default: use calibration)"
@@ -82,7 +82,7 @@ usage() {
}
init_options() {
- options["cpu"]="little"
+ options["cpu"]=""
# TODO: Currently only the 64-bit mode is supported. The 32-bit mode needs investigation
# whether it can be profiled in the chroot mode.
options["mode"]="64"
diff --git a/devices/config/NUC6i5SYH.sh b/devices/config/NUC6i5SYH.sh
index f76763fd..faddbc3d 100644
--- a/devices/config/NUC6i5SYH.sh
+++ b/devices/config/NUC6i5SYH.sh
@@ -1,7 +1,7 @@
#!/bin/bash
# shellcheck disable=SC2034
#
-# Copyright (c) 2016-2017, Linaro Ltd.
+# Copyright (c) 2016-2022, Linaro Ltd.
# All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -18,11 +18,22 @@
# Helper script used for setting the NUC6i5SYH frequency.
-DEVICE_NAME="Intel NUC i5"
+readonly DEVICE_NAME="Intel NUC i5"
-NUMBER_OF_CPUS=4
-DEVICE_IS_BIG_LITTLE=false
-CPUS=(0 1 2 3)
-TARGET_FREQ=1300000
-CPUS_NAME=i5-6260U
-DEFAULT_GOVERNOR=ondemand
+readonly NUMBER_OF_CPUS=4
+
+# Define CPU name.
+readonly CPUS_NAME="i5-6260U"
+
+# Define CPU frequency.
+readonly CPUS_FREQ=1300000
+
+# Define CPU ID's and embed the name and frequency.
+readonly I5_CPUS=(${CPUS_NAME} ${CPUS_FREQ} 0 1 2 3)
+
+# Bash does not support 2d arrays so instead store the name of the array and
+# later dereference by using "!" e.g: "arr=(${!CPUS[big]})".
+declare -A -g CPUS
+CPUS[i5]="I5_CPUS[@]"
+
+readonly DEFAULT_GOVERNOR=ondemand
diff --git a/devices/config/VOYOv1.sh b/devices/config/VOYOv1.sh
index a91761f5..957ec7a7 100644
--- a/devices/config/VOYOv1.sh
+++ b/devices/config/VOYOv1.sh
@@ -1,7 +1,7 @@
#!/bin/bash
# shellcheck disable=SC2034
#
-# Copyright (c) 2016-2017, Linaro Ltd.
+# Copyright (c) 2016-2022, Linaro Ltd.
# All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -18,11 +18,22 @@
# Helper script used for setting the VOYOv1 frequency.
-DEVICE_NAME="VOYOv1 pentium N4200"
+readonly DEVICE_NAME="VOYOv1 pentium N4200"
-NUMBER_OF_CPUS=4
-DEVICE_IS_BIG_LITTLE=false
-CPUS=(0 1 2 3)
-TARGET_FREQ=1101000
-CPUS_NAME=Pentium-N4200
-DEFAULT_GOVERNOR=schedutil
+readonly NUMBER_OF_CPUS=4
+
+# Define CPU name.
+readonly CPUS_NAME="Pentium-N4200"
+
+# Define CPU frequency.
+readonly CPUS_FREQ=1101000
+
+# Define CPU ID's and embed the name and frequency.
+readonly PENTIUM_CPUS=(${CPUS_NAME} ${CPUS_FREQ} 0 1 2 3)
+
+# Bash does not support 2d arrays so instead store the name of the array and
+# later dereference by using "!" e.g: "arr=(${!CPUS[big]})".
+declare -A -g CPUS
+CPUS[pentium]="PENTIUM_CPUS[@]"
+
+readonly DEFAULT_GOVERNOR=schedutil
diff --git a/devices/config/angler.sh b/devices/config/angler.sh
index 8a765bbd..b37ffdbe 100644
--- a/devices/config/angler.sh
+++ b/devices/config/angler.sh
@@ -1,7 +1,7 @@
#!/bin/bash
# shellcheck disable=SC2034
#
-# Copyright (c) 2016-2017, Linaro Ltd.
+# Copyright (c) 2016-2022, Linaro Ltd.
# All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -18,14 +18,25 @@
# Helper script used for setting the Nexus 6P frequency.
-DEVICE_NAME="Nexus 6P"
-
-NUMBER_OF_CPUS=8
-DEVICE_IS_BIG_LITTLE=true
-LITTLE_CPUS=(0 1 2 3)
-BIG_CPUS=(4 5 6 7)
-CPUS=(0 1 2 3 4 5 6 7)
-TARGET_FREQ=1248000
-LITTLE_CPUS_NAME=a53
-BIG_CPUS_NAME=a57
-DEFAULT_GOVERNOR=interactive
+readonly DEVICE_NAME="Nexus 6P"
+
+readonly NUMBER_OF_CPUS=8
+
+# Define CPU names.
+readonly BIG_CPUS_NAME="a57"
+readonly LITTLE_CPUS_NAME="a53"
+
+# Define CPU frequencies.
+readonly CPUS_FREQ=1248000
+
+# Define CPU ID's and embed the name and frequency.
+readonly BIG_CPUS=(${BIG_CPUS_NAME} ${CPUS_FREQ} 4 5 6 7)
+readonly LITTLE_CPUS=(${LITTLE_CPUS_NAME} ${CPUS_FREQ} 0 1 2 3)
+
+# Bash does not support 2d arrays so instead store the name of the array and
+# later dereference by using "!" e.g: "arr=(${!CPUS[big]})".
+declare -A -g CPUS
+CPUS[big]="BIG_CPUS[@]"
+CPUS[little]="LITTLE_CPUS[@]"
+
+readonly DEFAULT_GOVERNOR=interactive
diff --git a/devices/config/blueline.sh b/devices/config/blueline.sh
index 448582d5..d6cfee4e 100644
--- a/devices/config/blueline.sh
+++ b/devices/config/blueline.sh
@@ -1,7 +1,7 @@
#!/bin/bash
# shellcheck disable=SC2034
#
-# Copyright (c) 2018, Linaro Ltd.
+# Copyright (c) 2018-2022, Linaro Ltd.
# All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -18,15 +18,26 @@
# Helper script used for setting the Pixel 3 frequency.
-DEVICE_NAME="Pixel 3"
-
-NUMBER_OF_CPUS=8
-DEVICE_IS_BIG_LITTLE=true
-LITTLE_CPUS=(0 1 2 3)
-BIG_CPUS=(4 5 6 7)
-CPUS=(0 1 2 3 4 5 6 7)
-LITTLE_CPUS_NAME=kryo385-silver
-BIG_CPUS_NAME=kryo385-gold
-TARGET_FREQ_LITTLE=1228800
-TARGET_FREQ_BIG=1209600
-DEFAULT_GOVERNOR=schedutil
+readonly DEVICE_NAME="Pixel 3"
+
+readonly NUMBER_OF_CPUS=8
+
+# Define CPU names.
+readonly BIG_CPUS_NAME="kryo385-gold"
+readonly LITTLE_CPUS_NAME="kryo385-silver"
+
+# Define CPU frequencies.
+readonly BIG_CPUS_FREQ=1209600
+readonly LITTLE_CPUS_FREQ=1228800
+
+# Define CPU ID's and embed the name and frequency.
+readonly BIG_CPUS=(${BIG_CPUS_NAME} ${BIG_CPUS_FREQ} 4 5 6 7)
+readonly LITTLE_CPUS=(${LITTLE_CPUS_NAME} ${LITTLE_CPUS_FREQ} 0 1 2 3)
+
+# Bash does not support 2d arrays so instead store the name of the array and
+# later dereference by using "!" e.g: "arr=(${!CPUS[big]})".
+declare -A -g CPUS
+CPUS[big]="BIG_CPUS[@]"
+CPUS[little]="LITTLE_CPUS[@]"
+
+readonly DEFAULT_GOVERNOR=schedutil
diff --git a/devices/config/bullhead.sh b/devices/config/bullhead.sh
index 6bbccd1e..899d00a0 100644
--- a/devices/config/bullhead.sh
+++ b/devices/config/bullhead.sh
@@ -1,7 +1,7 @@
#!/bin/bash
# shellcheck disable=SC2034
#
-# Copyright (c) 2016-2017, Linaro Ltd.
+# Copyright (c) 2016-2022, Linaro Ltd.
# All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -18,14 +18,25 @@
# Helper script used for setting the Nexus 5X frequency.
-DEVICE_NAME="Nexus 5X"
-
-NUMBER_OF_CPUS=6
-DEVICE_IS_BIG_LITTLE=true
-LITTLE_CPUS=(0 1 2 3)
-BIG_CPUS=(4 5)
-CPUS=(0 1 2 3 4 5)
-TARGET_FREQ=1248000
-LITTLE_CPUS_NAME=a53
-BIG_CPUS_NAME=a57
-DEFAULT_GOVERNOR=interactive
+readonly DEVICE_NAME="Nexus 5X"
+
+readonly NUMBER_OF_CPUS=6
+
+# Define CPU names.
+readonly BIG_CPUS_NAME="a57"
+readonly LITTLE_CPUS_NAME="a53"
+
+# Define CPU frequencies.
+readonly CPUS_FREQ=1248000
+
+# Define CPU ID's and embed the name and frequency.
+readonly BIG_CPUS=(${BIG_CPUS_NAME} ${CPUS_FREQ} 4 5)
+readonly LITTLE_CPUS=(${LITTLE_CPUS_NAME} ${CPUS_FREQ} 0 1 2 3)
+
+# Bash does not support 2d arrays so instead store the name of the array and
+# later dereference by using "!" e.g: "arr=(${!CPUS[big]})".
+declare -A -g CPUS
+CPUS[big]="BIG_CPUS[@]"
+CPUS[little]="LITTLE_CPUS[@]"
+
+readonly DEFAULT_GOVERNOR=interactive
diff --git a/devices/config/flame.sh b/devices/config/flame.sh
index fd4ee517..77a642ab 100644
--- a/devices/config/flame.sh
+++ b/devices/config/flame.sh
@@ -1,7 +1,7 @@
#!/bin/bash
# shellcheck disable=SC2034
#
-# Copyright (c) 2020, Linaro Ltd.
+# Copyright (c) 2020-2022, Linaro Ltd.
# All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -18,15 +18,26 @@
# Helper script used for setting the Pixel 4 frequency.
-DEVICE_NAME="Pixel 4"
-
-NUMBER_OF_CPUS=8
-DEVICE_IS_BIG_LITTLE=true
-LITTLE_CPUS=(0 1 2 3)
-BIG_CPUS=(4 5 6 7)
-CPUS=(0 1 2 3 4 5 6 7)
-LITTLE_CPUS_NAME=kryo485-silver
-BIG_CPUS_NAME=kryo485-gold
-TARGET_FREQ_LITTLE=1209600
-TARGET_FREQ_BIG=1286400
-DEFAULT_GOVERNOR=schedutil
+readonly DEVICE_NAME="Pixel 4"
+
+readonly NUMBER_OF_CPUS=8
+
+# Define CPU names.
+readonly BIG_CPUS_NAME="kryo485-gold"
+readonly LITTLE_CPUS_NAME="kryo485-silver"
+
+# Define CPU frequencies.
+readonly BIG_CPUS_FREQ=1286400
+readonly LITTLE_CPUS_FREQ=1209600
+
+# Define CPU ID's and embed the name and frequency.
+readonly BIG_CPUS=(${BIG_CPUS_NAME} ${BIG_CPUS_FREQ} 4 5 6 7)
+readonly LITTLE_CPUS=(${LITTLE_CPUS_NAME} ${LITTLE_CPUS_FREQ} 0 1 2 3)
+
+# Bash does not support 2d arrays so instead store the name of the array and
+# later dereference by using "!" e.g: "arr=(${!CPUS[big]})".
+declare -A -g CPUS
+CPUS[big]="BIG_CPUS[@]"
+CPUS[little]="LITTLE_CPUS[@]"
+
+readonly DEFAULT_GOVERNOR=schedutil
diff --git a/devices/config/flounder.sh b/devices/config/flounder.sh
index 3bae083d..4140d815 100644
--- a/devices/config/flounder.sh
+++ b/devices/config/flounder.sh
@@ -1,7 +1,7 @@
#!/bin/bash
# shellcheck disable=SC2034
#
-# Copyright (c) 2016-2017, Linaro Ltd.
+# Copyright (c) 2016-2022, Linaro Ltd.
# All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -18,11 +18,22 @@
# Helper script used for setting the Nexus 9 frequency.
-DEVICE_NAME="Nexus 9"
+readonly DEVICE_NAME="Nexus 9"
-NUMBER_OF_CPUS=2
-DEVICE_IS_BIG_LITTLE=false
-CPUS=(0 1)
-TARGET_FREQ=1224000
-CPUS_NAME=denver
-DEFAULT_GOVERNOR=interactive
+readonly NUMBER_OF_CPUS=2
+
+# Define CPU name.
+readonly CPUS_NAME="denver"
+
+# Define CPU frequency.
+readonly CPUS_FREQ=1224000
+
+# Define CPU ID's and embed the name and frequency.
+readonly DENVER_CPUS=(${CPUS_NAME} ${CPUS_FREQ} 0 1)
+
+# Bash does not support 2d arrays so instead store the name of the array and
+# later dereference by using "!" e.g: "arr=(${!CPUS[big]})".
+declare -A -g CPUS
+CPUS[denver]="DENVER_CPUS[@]"
+
+readonly DEFAULT_GOVERNOR=interactive
diff --git a/devices/config/fugu.sh b/devices/config/fugu.sh
index c93506be..0a513392 100644
--- a/devices/config/fugu.sh
+++ b/devices/config/fugu.sh
@@ -1,7 +1,7 @@
#!/bin/bash
# shellcheck disable=SC2034
#
-# Copyright (c) 2016-2017, Linaro Ltd.
+# Copyright (c) 2016-2022, Linaro Ltd.
# All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -18,11 +18,22 @@
# Helper script used for setting the Nexus Player frequency.
-DEVICE_NAME="Nexus Player"
+readonly DEVICE_NAME="Nexus Player"
-NUMBER_OF_CPUS=4
-DEVICE_IS_BIG_LITTLE=false
-CPUS=(0 1 2 3)
-TARGET_FREQ=1333000
-CPUS_NAME=atom-Z3560
-DEFAULT_GOVERNOR=ondemand
+readonly NUMBER_OF_CPUS=4
+
+# Define CPU name.
+readonly CPUS_NAME="atom-Z3560"
+
+# Define CPU frequency.
+readonly CPUS_FREQ=1333000
+
+# Define CPU ID's and embed the name and frequency.
+readonly ATOM_CPUS=(${CPUS_NAME} ${CPUS_FREQ} 0 1 2 3)
+
+# Bash does not support 2d arrays so instead store the name of the array and
+# later dereference by using "!" e.g: "arr=(${!CPUS[big]})".
+declare -A -g CPUS
+CPUS[atom]="ATOM_CPUS[@]"
+
+readonly DEFAULT_GOVERNOR=ondemand
diff --git a/devices/config/hikey960.sh b/devices/config/hikey960.sh
index 40edc9e4..190bbf74 100644
--- a/devices/config/hikey960.sh
+++ b/devices/config/hikey960.sh
@@ -1,7 +1,7 @@
#!/bin/bash
# shellcheck disable=SC2034
#
-# Copyright (c) 2016-2017, Linaro Ltd.
+# Copyright (c) 2016-2022, Linaro Ltd.
# All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -18,15 +18,26 @@
# Helper script used for setting the hikey960 frequency.
-DEVICE_NAME="hikey960"
-
-NUMBER_OF_CPUS=8
-DEVICE_IS_BIG_LITTLE=true
-LITTLE_CPUS=(0 1 2 3)
-BIG_CPUS=(4 5 6 7)
-CPUS=(0 1 2 3 4 5 6 7)
-TARGET_FREQ_LITTLE=1402000
-TARGET_FREQ_BIG=1421000
-LITTLE_CPUS_NAME=a53
-BIG_CPUS_NAME=a73
-DEFAULT_GOVERNOR=schedutil
+readonly DEVICE_NAME="hikey960"
+
+readonly NUMBER_OF_CPUS=8
+
+# Define CPU names.
+readonly BIG_CPUS_NAME="a73"
+readonly LITTLE_CPUS_NAME="a53"
+
+# Define CPU frequencies.
+readonly BIG_CPUS_FREQ=1421000
+readonly LITTLE_CPUS_FREQ=1402000
+
+# Define CPU ID's and embed the name and frequency.
+readonly BIG_CPUS=(${BIG_CPUS_NAME} ${BIG_CPUS_FREQ} 4 5 6 7)
+readonly LITTLE_CPUS=(${LITTLE_CPUS_NAME} ${LITTLE_CPUS_FREQ} 0 1 2 3)
+
+# Bash does not support 2d arrays so instead store the name of the array and
+# later dereference by using "!" e.g: "arr=(${!CPUS[big]})".
+declare -A -g CPUS
+CPUS[big]="BIG_CPUS[@]"
+CPUS[little]="LITTLE_CPUS[@]"
+
+readonly DEFAULT_GOVERNOR=schedutil
diff --git a/devices/config/sailfish.sh b/devices/config/sailfish.sh
index 49176a63..b5cfe127 100644
--- a/devices/config/sailfish.sh
+++ b/devices/config/sailfish.sh
@@ -1,7 +1,7 @@
#!/bin/bash
# shellcheck disable=SC2034
#
-# Copyright (c) 2016-2017, Linaro Ltd.
+# Copyright (c) 2016-2022, Linaro Ltd.
# All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -18,12 +18,23 @@
# Helper script used for setting the Pixel frequency.
-DEVICE_NAME="Google Pixel"
+readonly DEVICE_NAME="Google Pixel"
-NUMBER_OF_CPUS=4
# The 2 types of cores do not differ in performance at the pinned `TARGET_FREQ`
-DEVICE_IS_BIG_LITTLE=false
-CPUS=(0 1 2 3)
-TARGET_FREQ=1363200
-CPUS_NAME=kryo
-DEFAULT_GOVERNOR=sched
+readonly NUMBER_OF_CPUS=4
+
+# Define CPU name.
+readonly CPUS_NAME="kryo"
+
+# Define CPU frequency.
+readonly CPUS_FREQ=1363200
+
+# Define CPU ID's and embed the name and frequency.
+readonly KRYO_CPUS=(${CPUS_NAME} ${CPUS_FREQ} 0 1 2 3)
+
+# Bash does not support 2d arrays so instead store the name of the array and
+# later dereference by using "!" e.g: "arr=(${!CPUS[big]})".
+declare -A -g CPUS
+CPUS[kryo]="KRYO_CPUS[@]"
+
+readonly DEFAULT_GOVERNOR=sched
diff --git a/devices/config/walleye.sh b/devices/config/walleye.sh
index 7b2c3c63..0df005bc 100644
--- a/devices/config/walleye.sh
+++ b/devices/config/walleye.sh
@@ -1,7 +1,7 @@
#!/bin/bash
# shellcheck disable=SC2034
#
-# Copyright (c) 2018, Linaro Ltd.
+# Copyright (c) 2018-2022, Linaro Ltd.
# All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -18,15 +18,26 @@
# Helper script used for setting the Pixel 2 frequency.
-DEVICE_NAME="Pixel 2"
-
-NUMBER_OF_CPUS=8
-DEVICE_IS_BIG_LITTLE=true
-LITTLE_CPUS=(0 1 2 3)
-BIG_CPUS=(4 5 6 7)
-CPUS=(0 1 2 3 4 5 6 7)
-LITTLE_CPUS_NAME=kryo280-little
-BIG_CPUS_NAME=kryo280-big
-TARGET_FREQ_LITTLE=1248000
-TARGET_FREQ_BIG=1267200
-DEFAULT_GOVERNOR=schedutil
+readonly DEVICE_NAME="Pixel 2"
+
+readonly NUMBER_OF_CPUS=8
+
+# Define CPU names.
+readonly BIG_CPUS_NAME="kryo280-big"
+readonly LITTLE_CPUS_NAME="kryo280-little"
+
+# Define CPU frequencies.
+readonly BIG_CPUS_FREQ=1267200
+readonly LITTLE_CPUS_FREQ=1248000
+
+# Define CPU ID's and embed the name and frequency.
+readonly BIG_CPUS=(${BIG_CPUS_NAME} ${BIG_CPUS_FREQ} 4 5 6 7)
+readonly LITTLE_CPUS=(${LITTLE_CPUS_NAME} ${LITTLE_CPUS_FREQ} 0 1 2 3)
+
+# Bash does not support 2d arrays so instead store the name of the array and
+# later dereference by using "!" e.g: "arr=(${!CPUS[big]})".
+declare -A -g CPUS
+CPUS[big]="BIG_CPUS[@]"
+CPUS[little]="LITTLE_CPUS[@]"
+
+readonly DEFAULT_GOVERNOR=schedutil
diff --git a/devices/cpu_freq_utils.sh b/devices/cpu_freq_utils.sh
index 0d75c5ac..4794aded 100644
--- a/devices/cpu_freq_utils.sh
+++ b/devices/cpu_freq_utils.sh
@@ -1,6 +1,6 @@
#!/bin/bash
#
-# Copyright (c) 2016-2017, Linaro Ltd.
+# Copyright (c) 2016-2022, Linaro Ltd.
# All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -15,7 +15,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.
+source "$(dirname "$0")/../utils/utils_android_root.sh"
+
readonly sys_cpu_path="/sys/devices/system/cpu"
+readonly config_path="$(dirname "$0")/../devices/config"
# Check that the device has given CPUs.
# Arguments:
@@ -41,6 +44,22 @@ validate_cpus() {
return 0
}
+# Assert that the cluster specified by the cluster name exists.
+# Args:
+# $1: the cluster name.
+validate_cluster() {
+ local -r cluster_name="$1"
+
+ # Ensure that the device config has been run.
+ local -r target_device="$(retrieve_target_product_name)"
+ exit_on_failure get_device_settings "${target_device}" "${config_path}"
+
+ if [[ ! -v "CPUS[${cluster_name}]" ]]; then
+ log E "Unknown CPU cluster name '${cluster_name}'."
+ exit 1
+ fi
+}
+
# Turn CPUs on or off through hotplug.
# Arguments:
# ${1} - 1 to enable, 0 to disable.
@@ -49,7 +68,6 @@ set_state_cpus() {
local -r state=$1
shift
validate_cpus "$@" || return 1
-
local -r max_trials=10
for cpu; do
local online_file="${sys_cpu_path}/cpu${cpu}/online"
@@ -78,6 +96,8 @@ set_state_cpus() {
return 1
fi
fi
+
+ log I "Successfully set CPU ${cpu} to state ${state}"
done
return 0
@@ -87,14 +107,18 @@ set_state_cpus() {
# Arguments:
# ${*} - IDs of the CPU to enable.
enable_cpus() {
- set_state_cpus 1 "$@"
+ local -r -a cpu_ids=($@)
+ log I "Enabling CPU(s) ${cpu_ids[*]}"
+ set_state_cpus 1 "${cpu_ids[@]}"
}
# Turn off CPUs through hotplug.
# Arguments:
# ${*} - IDs of the CPU to disable.
disable_cpus() {
- set_state_cpus 0 "$@"
+ local -r -a cpu_ids=(${@})
+ log I "Disabling CPU(s) ${cpu_ids[*]}"
+ set_state_cpus 0 "${cpu_ids[@]}"
}
# Set CPU frequency through cpufreq.
@@ -129,19 +153,41 @@ set_freq_cpus() {
fi
done
- # Set the governor to userspace (fixed frequency) and the frequency.
+ # Set the frequency.
local output=
for cpu; do
+ local cpufreq_path="${sys_cpu_path}/cpu${cpu}/cpufreq"
+
# Like in set_state_cpus, we cannot rely on adb shell to forward return
# status, so let's check that we don't get any unexpected message.
- output+=$(safe adb_shell "echo userspace > \
- ${sys_cpu_path}/cpu${cpu}/cpufreq/scaling_governor")
- output+=$(safe adb_shell "echo $freq > \
- ${sys_cpu_path}/cpu${cpu}/cpufreq/scaling_setspeed")
- output+=$(safe adb_shell "echo $freq > \
- ${sys_cpu_path}/cpu${cpu}/cpufreq/scaling_max_freq")
- output+=$(safe adb_shell "echo $freq > \
- ${sys_cpu_path}/cpu${cpu}/cpufreq/scaling_min_freq")
+ output+=$(adb_shell "echo userspace > ${cpufreq_path}/scaling_governor")
+
+ # Some devices do not support the userspace governor, if that is the case
+ # use the performance governor instead which is limited to scaling_max_freq.
+ # See
+ # https://www.kernel.org/doc/html/latest/admin-guide/pm/cpufreq.html#generic-scaling-governors.
+ #
+ # shellcheck disable=SC2181
+ if [[ ${output} || $? -ne 0 ]]; then
+ log I "CPU ${cpu} unable to be set to userspace governor"
+ output=$(safe adb_shell "echo performance > \
+ ${cpufreq_path}/scaling_governor")
+ log I "CPU ${cpu} set to performance governor"
+ else
+ log I "CPU ${cpu} set to userspace governor"
+ # scaling_setspeed is only supported when using the userspace governor.
+ output+=$(safe adb_shell "echo $freq > \
+ ${cpufreq_path}/scaling_setspeed")
+ log I "CPU ${cpu} scaling_setspeed set to ${freq}"
+ fi
+
+ # `scaling_max_freq` must be set before `scaling_min_freq`. See
+ # https://www.kernel.org/doc/Documentation/cpu-freq/user-guide.txt.
+ output+=$(safe adb_shell "echo $freq > ${cpufreq_path}/scaling_max_freq")
+ log I "CPU ${cpu} max_freq set to ${freq}"
+
+ output+=$(safe adb_shell "echo $freq > ${cpufreq_path}/scaling_min_freq")
+ log I "CPU ${cpu} min_freq set to ${freq}"
done
if [[ ${output} ]]; then
@@ -152,6 +198,30 @@ set_freq_cpus() {
fi
}
+# Return the name of the CPU cluster.
+# Arguments:
+# ${1} - CPU cluster
+get_name_from_cluster() {
+ local -r -a cluster=(${1})
+ echo "${cluster[0]}"
+}
+
+# Return the frequency associated with the cluster.
+# Arguments:
+# ${1} - CPU cluster
+get_freq_from_cluster() {
+ local -r -a cluster=(${1})
+ echo "${cluster[1]}"
+}
+
+# Return an array of CPU ID's from the cluster.
+# Arguments:
+# ${1} - CPU cluster
+get_ids_from_cluster() {
+ local -r -a cluster=(${1})
+ echo "${cluster[@]:2}"
+}
+
# Define environment variables describing the device.
# Arguments:
# ${1} - name of the device.
@@ -165,6 +235,11 @@ get_device_settings() {
return 1
fi
+ # Don't rerun the config script if it's already been run.
+ if [[ -v "DEVICE_NAME" ]]; then
+ return 0
+ fi
+
safe source "${cpu_freq_script}"
}
@@ -199,53 +274,53 @@ configure_cpus_to_default_governor() {
set_default_cpu_config() {
validate_cpus "$@" || return 1
- if ${DEVICE_IS_BIG_LITTLE}; then
- safe enable_cpus "${BIG_CPUS[@]}"
- safe enable_cpus "${LITTLE_CPUS[@]}"
- safe configure_cpus_to_default_governor "${BIG_CPUS[@]}"
- safe configure_cpus_to_default_governor "${LITTLE_CPUS[@]}"
- else
- safe enable_cpus "${CPUS[@]}"
- safe configure_cpus_to_default_governor "${CPUS[@]}"
- fi
+ for cluster_name in "${!CPUS[@]}"; do
+ local -a cluster=(${!CPUS[${cluster_name}]})
+ local -a cpu_ids=($(get_ids_from_cluster "${cluster[*]}"))
+
+ safe enable_cpus "${cpu_ids[@]}"
+ safe configure_cpus_to_default_governor "${cpu_ids[@]}"
+ done
}
-# Sets the CPU frequency and calls the function passed as an argument
+# Sets the CPU frequency and calls the function passed as an argument.
# Arguments:
# ${1} - function to run
# ${2} - CPU mode (bitness)
-# ${3} - target device
-# ${4} - path to devices directory
+# ${3} - CPU option
+# ${4} - target device
+# ${5} - path to devices directory
set_freq_and_run() {
local -r function_to_run="$1"
local -r mode="$2"
- local -r cpu_freq="$3"
+ local -r cpu_option="$3"
local -r target_device="$4"
local -r path_to_devices="$5"
- if [[ "$cpu" == "default" ]]; then
+ if [[ "${cpu_option}" == "default" ]]; then
"${function_to_run}" "${mode}" "${target_device}" "default-cpu"
return
fi
exit_on_failure get_device_settings "${target_device}" "${path_to_devices}/config"
- if ${DEVICE_IS_BIG_LITTLE}; then
- if [[ "$cpu_freq" == "little" || "$cpu_freq" == "all" ]]; then
- safe "${path_to_devices}/set_cpu_freq.sh" --little --pin-freq
- "${function_to_run}" "${mode}" "${target_device}" "${LITTLE_CPUS_NAME}"
- fi
- if [[ "$cpu_freq" == "big" || "$cpu_freq" == "all" ]]; then
- safe "${path_to_devices}/set_cpu_freq.sh" --big --pin-freq
- "${function_to_run}" "${mode}" "${target_device}" "${BIG_CPUS_NAME}"
- fi
+ # Set frequency of cluster and run benchmarks with that cluster.
+ if [[ "${cpu_option}" == "all" ]]; then
+ for cluster_name in "${!CPUS[@]}"; do
+ local -a cluster=(${!CPUS[${cluster_name}]})
+ local cpu_cluster_name=$(get_name_from_cluster "${cluster[*]}")
+
+ safe "${path_to_devices}/set_cpu_freq.sh" --cpu "${cluster_name}" --pin-freq
+ "${function_to_run}" "${mode}" "${target_device}" "${cpu_cluster_name}"
+ done
else
- if [[ "$cpu_freq" == "big" || "$cpu_freq" == "little" ]]; then
- log E "Options \`--big\` and \`--little\` are only valid for big.LITTLE devices."
- exit 1
- fi
- safe "${path_to_devices}/set_cpu_freq.sh" --all --pin-freq
- "${function_to_run}" "${mode}" "${target_device}" "${CPUS_NAME}"
+ local -r -a cluster=(${!CPUS[${cpu_option}]})
+ local -r cluster_name=$(get_name_from_cluster "${cluster[*]}")
+
+ safe "${path_to_devices}/set_cpu_freq.sh" --cpu "${cpu_option}" --pin-freq
+ "${function_to_run}" "${mode}" "${target_device}" "${cluster_name}"
fi
+
+ # Reset all clusters to their default settings.
safe "${path_to_devices}/set_cpu_freq.sh" --default
}
diff --git a/devices/flash_device.sh b/devices/flash_device.sh
index 3abbf33c..3df38336 100644
--- a/devices/flash_device.sh
+++ b/devices/flash_device.sh
@@ -21,6 +21,7 @@
# shellcheck disable=SC2154
source "${local_path}/../utils/utils.sh"
source "${local_path}/../utils/utils_android.sh"
+source "${local_path}/../utils/utils_android_root.sh"
temp_dir=
booted_to_fastboot="false"
@@ -130,7 +131,7 @@ adb_check_device() {
fi
# Check that the device is what we expect.
- local adb_device=$(safe adb_shell getprop ro.product.device)
+ local adb_device=$(retrieve_target_product_name)
if [[ ! ${adb_device} =~ ${BOARD} ]]; then
log E "Unsupported device ${adb_device}."
log E "This script works for ${BOARD}."
diff --git a/devices/set_cpu_freq.sh b/devices/set_cpu_freq.sh
index 1c7249c1..f7deeebc 100755
--- a/devices/set_cpu_freq.sh
+++ b/devices/set_cpu_freq.sh
@@ -1,6 +1,6 @@
#!/bin/bash
#
-# Copyright (c) 2016-2017, Linaro Ltd.
+# Copyright (c) 2016-2022, Linaro Ltd.
# All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -15,26 +15,32 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-# Used for setting the freq of Nexus devices.
+# Used for setting the freq of Android devices.
readonly local_path=$(dirname "$0")
source "${local_path}/../utils/utils.sh"
source "${local_path}/../utils/utils_android.sh"
+source "${local_path}/../utils/utils_android_root.sh"
+source "${local_path}/../utils/utils_benchmarks.sh"
source "${local_path}/cpu_freq_utils.sh"
declare -A options
target_device=
init_options() {
- options["cpus"]="all"
+ options["cpus"]=""
options["pin-freq"]="false"
options["default"]="false"
}
validate_options() {
- if ${options["default"]} && ( ${options["pin-freq"]} || [[ "${options["cpus"]}" != "all" ]] ); then
- log E "The option \`--default\` is incompatible with \`--pin-freq\`, \`--big\`, and \`--little\` options."
- exit 1
+ if ${options["default"]}; then
+ if ${options["pin-freq"]}; then
+ log E "The option \`--default\` is incompatible with the \`--pin-freq\` option."
+ exit 1
+ fi
+ elif [[ ${options["cpus"]} != "all" ]]; then
+ validate_cluster ${options["cpus"]}
fi
}
@@ -45,14 +51,15 @@ usage() {
log I " -v|--verbose - verbose"
log I "-------------------------------------------"
log I "Cluster: (does not pin the frequency by default)."
- log I " --all - Enable all CPUs (default)."
- log I " --big - Enable only the big cluster in a big.LITTLE SoC."
- log I " --little - Enable only the little cluster in a big.LITTLE SoC."
+ log I " --cpu <all|cluster_name> - CPU mode."
+ log I " \"cluster_name\": Enable only the cluster specified"
+ log I " by cluster_name."
+ log I " \"all\": Enable all CPUs"
log I ""
- log I " --pin-freq - Pin the frequency of enabled cores."
- log I " --default - Restore the CPUs to the default configuration."
+ log I " --pin-freq - Pin the frequency of enabled cores."
+ log I " --default - Restore the CPUs to the default configuration."
log I ""
- log I "Example Usage: ./set_cpu_freq.sh --big --pin-freq"
+ log I "Example Usage: ./set_cpu_freq.sh --cpu big --pin-freq"
log I "-------------------------------------------"
}
@@ -67,8 +74,9 @@ arguments_parser() {
usage
exit 0
;;
- --all|--big|--little)
- set_option "cpus" "${1#--}"
+ --cpu)
+ shift
+ set_option "cpus" "$1"
;;
--pin-freq|--default)
set_option "$1"
@@ -88,53 +96,59 @@ print_freq() {
printf "%'u Hz" "${TARGET_FREQ}"
}
+# Enable/Disable CPU clusters.
+enable_clusters() {
+ local -r cpu_option=${options["cpus"]}
+
+ # Enable the requested cluster when we encounter it otherwise add it to the
+ # list of cpus to disable.
+ local cpus_to_disable=()
+ for cluster_name in "${!CPUS[@]}"; do
+ local -a cluster=(${!CPUS[${cluster_name}]})
+ local -a cpu_ids=($(get_ids_from_cluster "${cluster[*]}"))
+
+ if [[ "${cpu_option}" == "all" || "${cluster_name}" == "${cpu_option}" ]]; then
+ safe enable_cpus "${cpu_ids[@]}"
+ else
+ cpus_to_disable+=(${cpu_ids[@]})
+ fi
+ done
+
+ if [[ ${#cpus_to_disable[@]} -ne 0 ]]; then
+ safe disable_cpus "${cpus_to_disable[@]}"
+ fi
+}
+
+# Set CPU clusters frequency.
+set_clusters_freq() {
+ local -r cpu_option=${options["cpus"]}
+
+ for cluster_name in "${!CPUS[@]}"; do
+ local -a cluster=(${!CPUS[${cluster_name}]})
+ local -a cpu_ids=($(get_ids_from_cluster "${cluster[*]}"))
+ local freq=$(get_freq_from_cluster "${cluster[*]}")
+
+ if [[ "${cpu_option}" == "all" || "${cpu_option}" == "${cluster_name}" ]]; then
+ log I "Pinning ${cluster_name} cores frequency to ${freq}."
+ safe set_freq_cpus "${freq}" "${cpu_ids[@]}"
+ fi
+ done
+}
+
set_device_freq() {
# We need root for writing to /sys files.
adb_root
- if ! ${DEVICE_IS_BIG_LITTLE} && [[ ${options["cpus"]} != "all" ]]; then
- log E "Device ${target_device} is single-cluster, do not use \`--big\` or \`little\` options."
- fi
-
if ${options["default"]}; then
log I "Restoring CPUs configuration to defaults."
set_default_cpu_config
exit 0
fi
- case ${options["cpus"]} in
- all)
- log I "Enabling all CPUs."
- safe enable_cpus "${CPUS[@]}"
- ;;
- big)
- log I "Enabling only the big cluster."
- safe enable_cpus "${BIG_CPUS[@]}"
- safe disable_cpus "${LITTLE_CPUS[@]}"
- ;;
- little)
- log I "Enabling only the little cluster."
- safe enable_cpus "${LITTLE_CPUS[@]}"
- safe disable_cpus "${BIG_CPUS[@]}"
- ;;
- esac
+ enable_clusters
if ${options["pin-freq"]}; then
- if ! ${DEVICE_IS_BIG_LITTLE}; then
- log I "Pinning the frequency on all cores."
- safe set_freq_cpus "${TARGET_FREQ}" "${CPUS[@]}"
- else
- case ${options["cpus"]} in
- big|all)
- log I "Pinning the frequency on the big cores."
- safe set_freq_cpus "${TARGET_FREQ_BIG:-${TARGET_FREQ}}" "${BIG_CPUS[@]}"
- ;;&
- little|all)
- log I "Pinning the frequency on the little cores."
- safe set_freq_cpus "${TARGET_FREQ_LITTLE:-${TARGET_FREQ}}" "${LITTLE_CPUS[@]}"
- ;;
- esac
- fi
+ set_clusters_freq
fi
}
@@ -144,7 +158,7 @@ main() {
# Make sure that adb is started before checking the board name.
safe adb start-server
- readonly target_device=$(safe adb_shell getprop ro.product.device)
+ readonly target_device=$(retrieve_target_product_name)
log I "Detected device ${target_device}"
exit_on_failure get_device_settings "${target_device}" "${local_path}/config"
diff --git a/perf/sperf_target_dalvikvm.sh b/perf/sperf_target_dalvikvm.sh
index c403423c..e2b27d6b 100755
--- a/perf/sperf_target_dalvikvm.sh
+++ b/perf/sperf_target_dalvikvm.sh
@@ -56,14 +56,7 @@ set_default_options() {
}
validate_options() {
- if [[ -z "${options["cpu"]}" ]]; then
- log E "CPU is not provided."
- exit 1
- fi
- if [[ "${options["cpu"]}" != @(big|little) ]]; then
- log E "Invalid CPU option: ${cpu}"
- exit 1
- fi
+ validate_cluster "${options["cpu"]}"
}
usage() {
@@ -74,9 +67,9 @@ usage() {
log I ""
log I "-------------------------------------------"
log I " -h, --help - help"
- log I " --cpu <big|little> - CPU mode."
- log I " 'big': Run dalvikvm on big cores."
- log I " 'little': Run dalvikvm on little cores."
+ log I " --cpu <cluster_name> - Cluster name."
+ log I " Run dalvikvm on the cluster specified by"
+ log I " cluster_name."
log I " Note: The frequency of the specified cores will be pinned."
log I " --classpath <classpath> - Classpath for dalvikvm on a target device."
log I " --event event1[:modifier1],event2[:modifier2],..."
@@ -153,12 +146,13 @@ set_environment_for_run() {
# Run the generated cmdline.sh on a target device.
run_target_cmdline() {
+ local -r cpu="${options["cpu"]}"
local sh="sh"
if ${options["chroot"]}; then
sh="chroot ${ART_TEST_CHROOT} sh"
fi
- safe "${local_path}/../devices/set_cpu_freq.sh" --all --pin-freq
+ safe "${local_path}/../devices/set_cpu_freq.sh" --cpu "all" --pin-freq
adb_shell "${sh}" "${target_virtual_work_dir}/cmdline.sh" "${class_cmd[@]}"
echo ""
@@ -169,22 +163,25 @@ run_target_cmdline() {
# Generate target cmdline.sh script which is a wrapper for a simpleperf run on a target.
generate_target_cmdline() {
local -r work_dir="${target_virtual_work_dir}"
- local -r target_device=$(safe adb_shell getprop ro.product.device)
- local -r cpu="${options["cpu"]}"
+ local -r target_device=$(retrieve_target_product_name)
+ local -r cpu_option="${options["cpu"]}"
exit_on_failure get_device_settings "${target_device}" "${local_path}/../devices/config"
- require_big_little_device "${target_device}"
+ local -a simpleperf_cpus
+ local -a dalvikvm_cpus
+ for cluster_name in "${!CPUS[@]}"; do
+ local -a cluster=(${!CPUS[${cluster_name}]})
+ local -a cpu_ids=($(get_ids_from_cluster "${cluster[*]}"))
+
+ if [[ "${cluster_name}" == "${cpu_option}" ]]; then
+ dalvikvm_cpus="$(get_cpu_affinity_mask "${cpu_ids[@]}")"
+ else
+ simpleperf_cpus+=(${cpu_ids[@]})
+ fi
+ done
- local simpleperf_cpus
- local dalvikvm_cpus
- if [[ "$cpu" == "big" ]]; then
- simpleperf_cpus="$(get_cpu_affinity_mask "${LITTLE_CPUS[@]}")"
- dalvikvm_cpus="$(get_cpu_affinity_mask "${BIG_CPUS[@]}")"
- else
- simpleperf_cpus="$(get_cpu_affinity_mask "${BIG_CPUS[@]}")"
- dalvikvm_cpus="$(get_cpu_affinity_mask "${LITTLE_CPUS[@]}")"
- fi
+ local simpleperf_cpus_mask="$(get_cpu_affinity_mask "${simpleperf_cpus[@]}")"
local simpleperf_command="record -g"
if ${options["stat"]}; then
@@ -223,7 +220,7 @@ ${env_vars_exports}
cd ${work_dir}
-taskset ${simpleperf_cpus} \
+taskset ${simpleperf_cpus_mask} \
/system/bin/simpleperf ${simpleperf_command} \
${event_arg} \
${group_arg} \
diff --git a/utils/utils_benchmarks.sh b/utils/utils_benchmarks.sh
index 19552949..ce6a5d0c 100644
--- a/utils/utils_benchmarks.sh
+++ b/utils/utils_benchmarks.sh
@@ -139,18 +139,6 @@ get_target_dex2oat_boot_oat_cmd() {
--instruction-set-features=${isa_features}"
}
-# Assert that the cpu option is valid.
-# Args:
-# $1: the cpu option.
-validate_cpu_option() {
- local -r cpu="$1"
-
- if [[ "${cpu}" != @(all|big|little|default) ]]; then
- log E "Invalid CPU option: ${cpu}"
- exit 1
- fi
-}
-
# Assert that the mode option is valid.
# Args:
# $1: the mode option.
@@ -262,27 +250,6 @@ get_target_physical_dir() {
echo "${ART_TEST_CHROOT}/$1"
}
-# Require a target device to support big.LITTLE.
-# If big.LITTLE is supported, it is checked that
-# BIG_CPUS and LITTLE_CPUS are defined.
-# Args:
-# $1: a target device
-require_big_little_device() {
- local -r target_device="$1"
- if ! ${DEVICE_IS_BIG_LITTLE}; then
- log E "${target_device} is not big.LITTLE device."
- exit 1
- fi
- if [[ ! -v BIG_CPUS ]]; then
- log E "BIG_CPUS is not defined for ${target_device}."
- exit 1
- fi
- if [[ ! -v LITTLE_CPUS ]]; then
- log E "LITTLE_CPUS is not defined for ${target_device}."
- exit 1
- fi
-}
-
# Get the path to the simpleperf directory.
get_simpleperf_home() {
echo "$(get_workspace)/system/extras/simpleperf"