aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArtem Kotsiuba <artem.kotsiuba@linaro.org>2021-09-16 15:18:25 +0100
committerArtem Kotsiuba <artem.kotsiuba@linaro.org>2021-09-17 14:02:15 +0000
commite753245a16d8265b504cb32793d829738e2d2a39 (patch)
treec0ba2c5d51d14dd9d18a7b3bbe9d962e6acbf6ce
parente9a6c9a5a32d40c68315b2f33590be603932de61 (diff)
downloadart-build-scripts-e753245a16d8265b504cb32793d829738e2d2a39.tar.gz
ART: Move functions that can be reused in other benchmark
scripts to utils file This change moves some functions that can be reused by other benchmark-related scripts (for example compile statistics) to the file utils_benchmark.sh to make work on future patches easier. Test: ./scripts/benchmarks/benchmarks_run_target.sh SystemArrayCopy --iterations 2 --mode 64 --skip-build and ./scripts/benchmarks/test-art-target.sh --default --skip-build Change-Id: Iedaf2604600329e84c6f8461baffdfc0ee4e9f6b
-rwxr-xr-xbenchmarks/benchmarks_run_target.sh102
-rwxr-xr-xbenchmarks/perf_profile_benchmarks_target.sh4
-rw-r--r--devices/cpu_freq_utils.sh40
-rwxr-xr-xtests/test_art_target.sh4
-rw-r--r--utils/utils_android_root.sh15
-rw-r--r--utils/utils_benchmarks.sh45
6 files changed, 123 insertions, 87 deletions
diff --git a/benchmarks/benchmarks_run_target.sh b/benchmarks/benchmarks_run_target.sh
index 754b3c84..56c3664c 100755
--- a/benchmarks/benchmarks_run_target.sh
+++ b/benchmarks/benchmarks_run_target.sh
@@ -96,7 +96,8 @@ usage() {
log I "Usage: $0 [OPTION]... [BENCHMARK]..."
log I ""
log I "This script should be used for running BENCHMARK(s) on a target device."
- log I "The script expects a device to be connected. Use --list-devices to show supported devices."
+ log I "The script expects a device to be connected. Use --list-devices to show supported"
+ log I "devices."
log I "With no BENCHMARK, all available benchmarks are run."
log I ""
log I "-------------------------------------------"
@@ -107,26 +108,31 @@ usage() {
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 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 pinned"
+ log I " For devices without big.LITTLE, all cores are enabled and"
+ log I " pinned"
log I " \"default\": Run with unaltered default CPU configuration"
log I " (no pinning)."
log I " (default: all)"
log I " --iterations <n> - The number of iterations to run the benchmarks for."
log I " (default: $default_iterations)"
- log I " --target-device <device> - Use specific lunch target and configuration for Arm target platform".
- log I " (default: \"\" - which will cause a default target arch to be used."
+ log I " --target-device <device> - Use specific lunch target and configuration for Arm target"
+ log I " platform"
+ log I " (default: \"\" - which will cause a default target arch"
+ log I " to be used."
log I " --linux - Compile ART for a non-android kernel"
log I " --x86 - Compile ART for x86 architecture (otherwise, arm is implied)"
log I " --sudo - Use \`sudo\` for \`adb shell\` commands in targets without"
log I " support for \`adb root\`"
- log I " --skip-build <false|true> - Skips the build step and runs benchmark with prebuilt artifacts"
- log I " from \$OUT directory."
+ log I " --skip-build <false|true> - Skips the build step and runs benchmark with prebuilt"
+ log I " artifacts from \$OUT directory."
log I " This option is mainly used for automation."
- log I " Make sure \`adb\` and \`dx\` are in your PATH when using this option."
+ log I " Make sure \`adb\` and \`dx\` are in your PATH when using"
+ log I " this option."
log I " (default: false)"
log I " --skip-run <false|true> - Skips the running benchmark but just builds the artifacts"
log I " (default: false)"
@@ -145,8 +151,8 @@ usage() {
log I " --isa-features - specify isa features to be used."
log I " Possible values: default, runtime, a list of comma-separated"
log I " feature names. When the list is used, '-' before a feature"
- log I " name means the ART compiler must not use the feature for code"
- log I " generation."
+ log I " name means the ART compiler must not use the feature for"
+ log I " code generation"
log I "-------------------------------------------"
log I "Default Configuration:"
log I " --default - Default benchmark configuration, equivalent to"
@@ -156,13 +162,7 @@ usage() {
}
list_devices() {
- log I "--- List of supported devices in devices/config ---"
- local f
- for f in ${local_path}/../devices/config/*; do
- local filename=${f##*/}
- safe source "$f"
- log I "${filename%.*}: $DEVICE_NAME"
- done
+ list_devices_from_config "${local_path}/../devices/config/*"
exit 0
}
@@ -262,66 +262,14 @@ run_benchmarks() {
return "${return_code}"
}
+# Arguments:
+# ${1} - CPU mode (bitness)
run_all_benchmarks() {
+ local -r bitness="$1"
local -r target_device=$(safe adb_shell getprop ro.product.device)
local -r cpu="${options["cpu"]}"
-
- if [[ "$cpu" == "default" ]]; then
- run_benchmarks "$1" "${target_device}" "default-cpu"
- return
- fi
-
- exit_on_failure get_device_settings "${target_device}" "${local_path}/../devices/config"
-
- if ${DEVICE_IS_BIG_LITTLE}; then
- if [[ "$cpu" == "little" || "$cpu" == "all" ]]; then
- safe "${local_path}/../devices/set_cpu_freq.sh" --little --pin-freq
- run_benchmarks "$1" "${target_device}" "${LITTLE_CPUS_NAME}"
- fi
- if [[ "$cpu" == "big" || "$cpu" == "all" ]]; then
- safe "${local_path}/../devices/set_cpu_freq.sh" --big --pin-freq
- run_benchmarks "$1" "${target_device}" "${BIG_CPUS_NAME}"
- fi
- else
- if [[ "$cpu" == "big" || "$cpu" == "little" ]]; then
- log E "Options \`--big\` and \`--little\` are only valid for big.LITTLE devices."
- exit 1
- fi
- safe "${local_path}/../devices/set_cpu_freq.sh" --all --pin-freq
- run_benchmarks "$1" "${target_device}" "${CPUS_NAME}"
- fi
- safe "${local_path}/../devices/set_cpu_freq.sh" --default
-}
-
-set_environment_for_benchmark_run() {
- set_environment_target
- if ${options["linux"]}; then
- set_environment_linux_target
- fi
- if ${options["sudo"]}; then
- set_environment_use_sudo
- fi
- if ${options["x86"]}; then
- select_android_target "x86" ""
- else
- local target_device="${options["target-device"]}"
-
- # When we actually are to run benchmark on the device and the target device is not specified try
- # to autodetect it.
- if [[ "${options["skip-run"]}" == "false" && "${target_device}" == "" ]]; then
- log I "Retrieve the target device using adb getprop..."
- # Skip building adb on CI bots: they run inside a container where adb is
- # already sourced, and the full Android tree is not available.
- if [[ ! -v SOURCE_BUILD_URL ]]; then
- prepare_adb
- fi
- target_device="$(retrieve_target_product_name)"
- log I "Target device to be used: ${target_device}."
- fi
-
- select_android_target "arm" "${target_device}"
- fi
- source_android_environment_default
+ local -r path_to_devices="${local_path}/../devices"
+ set_freq_and_run run_benchmarks "${bitness}" "${cpu}" "${target_device}" "${path_to_devices}"
}
main() {
@@ -349,7 +297,7 @@ main() {
log I "Starting ${bits}bit benchmarks."
# Set environment variables.
- set_environment_for_benchmark_run
+ set_environment_for_benchmark_run options
if [[ "${skip_build}" == "false" ]]; then
# Build target.
@@ -366,9 +314,7 @@ main() {
continue
fi
- buildbot_device_cleanup "${bits}"
- buildbot_device_setup "${bits}"
- buildbot_device_sync "${bits}"
+ buildbot_device_prepare "${bits}"
run_all_benchmarks "${bits}"
if ${options["dump-cfg"]}; then
copy_cfg_file_from_device
diff --git a/benchmarks/perf_profile_benchmarks_target.sh b/benchmarks/perf_profile_benchmarks_target.sh
index 2b103f78..e4ab8bda 100755
--- a/benchmarks/perf_profile_benchmarks_target.sh
+++ b/benchmarks/perf_profile_benchmarks_target.sh
@@ -312,9 +312,7 @@ main() {
source_android_environment_default
build_target "${bits}"
- buildbot_device_cleanup "${bits}"
- buildbot_device_setup "${bits}"
- buildbot_device_sync "${bits}"
+ buildbot_device_prepare "${bits}"
build_benchmarks "${benchmarks[@]}"
target_compile_benchmarks "${bits}"
copy_simpleperf_to_target
diff --git a/devices/cpu_freq_utils.sh b/devices/cpu_freq_utils.sh
index 18147f36..0d75c5ac 100644
--- a/devices/cpu_freq_utils.sh
+++ b/devices/cpu_freq_utils.sh
@@ -209,3 +209,43 @@ set_default_cpu_config() {
safe configure_cpus_to_default_governor "${CPUS[@]}"
fi
}
+
+# 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
+set_freq_and_run() {
+ local -r function_to_run="$1"
+ local -r mode="$2"
+ local -r cpu_freq="$3"
+ local -r target_device="$4"
+ local -r path_to_devices="$5"
+
+ if [[ "$cpu" == "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
+ 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}"
+ fi
+ safe "${path_to_devices}/set_cpu_freq.sh" --default
+}
diff --git a/tests/test_art_target.sh b/tests/test_art_target.sh
index 04b7074a..8d70a400 100755
--- a/tests/test_art_target.sh
+++ b/tests/test_art_target.sh
@@ -495,9 +495,7 @@ main() {
fi
add_prebuilt_adb_dir_to_PATH
- buildbot_device_cleanup "${bits}"
- buildbot_device_setup "${bits}"
- buildbot_device_sync "${bits}"
+ buildbot_device_prepare "${bits}"
if [[ -n ${options["single-test"]} ]]; then
test_single "${bits}" "target" "${job_count}" "$(declare -p options)"
diff --git a/utils/utils_android_root.sh b/utils/utils_android_root.sh
index b2ea631c..cabd3a84 100644
--- a/utils/utils_android_root.sh
+++ b/utils/utils_android_root.sh
@@ -222,7 +222,7 @@ build_host() {
# Cleanup the device. Environment should be sourced before calling.
# Arguments:
-# ${1}: product device
+# ${1}: bitness
buildbot_device_cleanup() {
start_section "device_cleanup_$1"
safe "$(get_art_tools_dir)"/buildbot-teardown-device.sh
@@ -232,7 +232,7 @@ buildbot_device_cleanup() {
# Setup the device. Environment should be sourced before calling.
# Arguments:
-# ${1}: product device
+# ${1}: bitness
buildbot_device_setup() {
start_section "device_setup_$1"
safe "$(get_art_tools_dir)"/buildbot-setup-device.sh
@@ -241,9 +241,18 @@ buildbot_device_setup() {
# Syncs binaries to the device. Environment should be sourced before calling.
# Arguments:
-# ${1}: product device
+# ${1}: bitness
buildbot_device_sync() {
start_section "device_sync_$1"
safe "$(get_art_tools_dir)"/buildbot-sync.sh
end_section "device_sync_$1" "$?"
}
+
+# Prepares the devices (setting it up + syncing)
+# Arguments:
+# ${1}: bitness
+buildbot_device_prepare() {
+ buildbot_device_cleanup "$1"
+ buildbot_device_setup "$1"
+ buildbot_device_sync "$1"
+}
diff --git a/utils/utils_benchmarks.sh b/utils/utils_benchmarks.sh
index cf36cc6c..c8899c3c 100644
--- a/utils/utils_benchmarks.sh
+++ b/utils/utils_benchmarks.sh
@@ -258,3 +258,48 @@ require_big_little_device() {
get_simpleperf_home() {
echo "$(get_workspace)/system/extras/simpleperf"
}
+
+# Arguments:
+# ${1} - path to devices config
+list_devices_from_config() {
+ log I "--- List of supported devices in devices/config ---"
+ local f
+ for f in $1; do
+ local filename=${f##*/}
+ safe source "$f"
+ log I "${filename%.*}: $DEVICE_NAME"
+ done
+}
+
+# Reads
+set_environment_for_benchmark_run() {
+ local -n bench_options=$1
+ set_environment_target
+ if ${bench_options["linux"]}; then
+ set_environment_linux_target
+ fi
+ if ${bench_options["sudo"]}; then
+ set_environment_use_sudo
+ fi
+ if ${bench_options["x86"]}; then
+ select_android_target "x86" ""
+ else
+ local target_device="${bench_options["target-device"]}"
+
+ # When we actually are to run benchmark on the device and the target device is not specified try
+ # to autodetect it.
+ if [[ "${bench_options["skip-run"]}" == "false" && "${target_device}" == "" ]]; then
+ log I "Retrieve the target device using adb getprop..."
+ # Skip building adb on CI bots: they run inside a container where adb is
+ # already sourced, and the full Android tree is not available.
+ if [[ ! -v SOURCE_BUILD_URL ]]; then
+ prepare_adb
+ fi
+ target_device="$(retrieve_target_product_name)"
+ log I "Target device to be used: ${target_device}."
+ fi
+
+ select_android_target "arm" "${target_device}"
+ fi
+ source_android_environment_default
+}