From e0a3563ce6a407e84174f0b86cd7fd8bcca3fc1e Mon Sep 17 00:00:00 2001 From: Tamas Petz Date: Mon, 7 Oct 2024 18:18:19 +0100 Subject: [PATCH 1/6] [CI] Check all shell scripts even in subfolders Due to this change shellcheck will be run on all files in scripts/ regardless of directory levels. --- scripts/ci.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/scripts/ci.sh b/scripts/ci.sh index e9b12ec71..00b387710 100755 --- a/scripts/ci.sh +++ b/scripts/ci.sh @@ -23,7 +23,9 @@ CHECK_ONLY=ON VERBOSE=ON scripts/format.sh scripts/cpplint.sh # Check format of shell scripts -shellcheck scripts/*.sh +# shellcheck disable=SC2046 +# Word splitting is essential here. +shellcheck $(find scripts -name '*.sh' | tr '\n' ' ') # Check license headers reuse lint -- GitLab From 344900baeed98a12e753ba3767a695fedc6f7863 Mon Sep 17 00:00:00 2001 From: Tamas Petz Date: Mon, 7 Oct 2024 18:30:09 +0100 Subject: [PATCH 2/6] [Benchmarks] Make perf_test_op.sh POSIX sh compliant This change fixes issues highlighted by shellcheck. --- scripts/benchmark/perf_test_op.sh | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/scripts/benchmark/perf_test_op.sh b/scripts/benchmark/perf_test_op.sh index 2ac97e9d5..8fe09d8c9 100755 --- a/scripts/benchmark/perf_test_op.sh +++ b/scripts/benchmark/perf_test_op.sh @@ -31,13 +31,15 @@ START_CDEV_TRANSITION_COUNT=$(cat "${CDEV_TRANSITION_COUNT_FILE}") THERMAL_ZONE_TEMPERATURE_FILE="${THERMAL_ZONE_DIR}/temp" wait_for_cooldown() { + # shellcheck disable=SC3043 + # Many shells support 'local', therefore this warning is ignored. local cur_tmp cur_tmp=$(cat "${THERMAL_ZONE_TEMPERATURE_FILE}") - if [[ "${cur_tmp}" > 40000 ]]; then + if [ "${cur_tmp}" -gt 40000 ]; then >&2 echo "Too hot (${cur_tmp})! Cooling..." fi - while [[ $(cat "${THERMAL_ZONE_TEMPERATURE_FILE}") > 40000 ]]; do + while [ "$(cat "${THERMAL_ZONE_TEMPERATURE_FILE}")" -gt 40000 ]; do sleep 0.2 done } @@ -46,7 +48,7 @@ FNAME=$$ run_test() { wait_for_cooldown - >&2 taskset ${CPU_MASK} \ + >&2 taskset "${CPU_MASK}" \ "${DEV_DIR}/${PERF_TEST_BINARY_BASENAME}_$1" \ --perf_min_samples=100 \ --gtest_output=json:"${DEV_DIR}/${FNAME}_$1" \ @@ -56,13 +58,13 @@ run_test() { run_test vanilla run_test kleidicv -if [[ -f "${DEV_DIR}/${PERF_TEST_BINARY_BASENAME}_kleidicv_${CUSTOM_BUILD_SUFFIX}" ]]; then +if [ -f "${DEV_DIR}/${PERF_TEST_BINARY_BASENAME}_kleidicv_${CUSTOM_BUILD_SUFFIX}" ]; then run_test "kleidicv_${CUSTOM_BUILD_SUFFIX}" fi echo "${PREV_FREQ_GOVERNOR}" > "${FREQ_GOVERNOR_FILE}" -if [[ "${START_CDEV_TRANSITION_COUNT}" != $(cat "${CDEV_TRANSITION_COUNT_FILE}") ]]; then +if [ "${START_CDEV_TRANSITION_COUNT}" != "$(cat "${CDEV_TRANSITION_COUNT_FILE}")" ]; then >&2 echo "BENCHMARK ERROR: CPU throttling happened, exiting..." exit 1 fi @@ -87,13 +89,13 @@ get_gstddev() { RES="${DISP_NAME}" collect_run_results() { - RES+="\t$(get_mean "${DEV_DIR}/${FNAME}_${1}")\t$(get_gstddev "${DEV_DIR}/${FNAME}_$1")" + RES="${RES}\t$(get_mean "${DEV_DIR}/${FNAME}_${1}")\t$(get_gstddev "${DEV_DIR}/${FNAME}_$1")" rm "${DEV_DIR}/${FNAME}_$1" } collect_run_results vanilla collect_run_results kleidicv -if [[ -f "${DEV_DIR}/${FNAME}_kleidicv_${CUSTOM_BUILD_SUFFIX}" ]]; then +if [ -f "${DEV_DIR}/${FNAME}_kleidicv_${CUSTOM_BUILD_SUFFIX}" ]; then collect_run_results "kleidicv_${CUSTOM_BUILD_SUFFIX}" fi -- GitLab From 075724c5f95585ed8ebf2d7a1e7d17782e3bc6ab Mon Sep 17 00:00:00 2001 From: Tamas Petz Date: Mon, 7 Oct 2024 18:30:39 +0100 Subject: [PATCH 3/6] [Benchmarks] Make DEV_DIR configurable DEV_DIR has a useful default value, however, users might choose to specify an alternative directory. --- scripts/benchmark/perf_test_op.sh | 2 +- scripts/benchmark/push.sh | 2 +- scripts/benchmark/run_benchmarks_4K.sh | 2 +- scripts/benchmark/run_benchmarks_FHD.sh | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/benchmark/perf_test_op.sh b/scripts/benchmark/perf_test_op.sh index 8fe09d8c9..e1604e564 100755 --- a/scripts/benchmark/perf_test_op.sh +++ b/scripts/benchmark/perf_test_op.sh @@ -14,7 +14,7 @@ PERF_TEST_BINARY_BASENAME=$5 GTEST_FILTER=$6 GTEST_PARAM_FILTER=$7 -DEV_DIR=/data/local/tmp +: "${DEV_DIR:=/data/local/tmp}" CPU_MASK=$(echo "obase=16;2^${CPU_NUMBER}" | bc) diff --git a/scripts/benchmark/push.sh b/scripts/benchmark/push.sh index a905c56d9..e68997ac1 100755 --- a/scripts/benchmark/push.sh +++ b/scripts/benchmark/push.sh @@ -23,7 +23,7 @@ BENCHMARK_SCRIPT_PATH="$(realpath "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) BUILD_ROOT_PATH="${BUILD_ROOT_PATH:-"${BENCHMARK_SCRIPT_PATH}/../../build"}" CUSTOM_BUILD_SUFFIX="${CUSTOM_BUILD_SUFFIX:-custom}" -DEV_DIR=/data/local/tmp +: "${DEV_DIR:=/data/local/tmp}" "${ADB}" push "${BUILD_ROOT_PATH}"/opencv-vanilla/bin/opencv_perf_core ${DEV_DIR}/opencv_perf_core_vanilla "${ADB}" push "${BUILD_ROOT_PATH}"/opencv-vanilla/bin/opencv_perf_imgproc ${DEV_DIR}/opencv_perf_imgproc_vanilla diff --git a/scripts/benchmark/run_benchmarks_4K.sh b/scripts/benchmark/run_benchmarks_4K.sh index 3621944f3..89cb74279 100755 --- a/scripts/benchmark/run_benchmarks_4K.sh +++ b/scripts/benchmark/run_benchmarks_4K.sh @@ -6,7 +6,7 @@ set -eu -DEV_DIR=/data/local/tmp +: "${DEV_DIR:=/data/local/tmp}" CPU=7 THERMAL=0 CUSTOM_BUILD_SUFFIX="${CUSTOM_BUILD_SUFFIX:-custom}" diff --git a/scripts/benchmark/run_benchmarks_FHD.sh b/scripts/benchmark/run_benchmarks_FHD.sh index 1045bf672..18993c6d6 100755 --- a/scripts/benchmark/run_benchmarks_FHD.sh +++ b/scripts/benchmark/run_benchmarks_FHD.sh @@ -6,7 +6,7 @@ set -eu -DEV_DIR=/data/local/tmp +: "${DEV_DIR:=/data/local/tmp}" CPU=7 THERMAL=0 CUSTOM_BUILD_SUFFIX="${CUSTOM_BUILD_SUFFIX:-custom}" -- GitLab From 36555c01b1c9b6e020d5515d7d38a9058bac28dc Mon Sep 17 00:00:00 2001 From: Tamas Petz Date: Mon, 7 Oct 2024 19:08:32 +0100 Subject: [PATCH 4/6] [Benchmarks] push.sh: Fix shellcheck findings This change attempts to fix issues highlighted by shellcheck. --- scripts/benchmark/push.sh | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/scripts/benchmark/push.sh b/scripts/benchmark/push.sh index e68997ac1..59ba14c63 100755 --- a/scripts/benchmark/push.sh +++ b/scripts/benchmark/push.sh @@ -25,18 +25,18 @@ CUSTOM_BUILD_SUFFIX="${CUSTOM_BUILD_SUFFIX:-custom}" : "${DEV_DIR:=/data/local/tmp}" -"${ADB}" push "${BUILD_ROOT_PATH}"/opencv-vanilla/bin/opencv_perf_core ${DEV_DIR}/opencv_perf_core_vanilla -"${ADB}" push "${BUILD_ROOT_PATH}"/opencv-vanilla/bin/opencv_perf_imgproc ${DEV_DIR}/opencv_perf_imgproc_vanilla +"${ADB}" push "${BUILD_ROOT_PATH}"/opencv-vanilla/bin/opencv_perf_core "${DEV_DIR}"/opencv_perf_core_vanilla +"${ADB}" push "${BUILD_ROOT_PATH}"/opencv-vanilla/bin/opencv_perf_imgproc "${DEV_DIR}"/opencv_perf_imgproc_vanilla -"${ADB}" push "${BUILD_ROOT_PATH}"/opencv-kleidicv/bin/opencv_perf_core ${DEV_DIR}/opencv_perf_core_kleidicv -"${ADB}" push "${BUILD_ROOT_PATH}"/opencv-kleidicv/bin/opencv_perf_imgproc ${DEV_DIR}/opencv_perf_imgproc_kleidicv +"${ADB}" push "${BUILD_ROOT_PATH}"/opencv-kleidicv/bin/opencv_perf_core "${DEV_DIR}"/opencv_perf_core_kleidicv +"${ADB}" push "${BUILD_ROOT_PATH}"/opencv-kleidicv/bin/opencv_perf_imgproc "${DEV_DIR}"/opencv_perf_imgproc_kleidicv -if [[ -f "${BUILD_ROOT_PATH}"/opencv-kleidicv-${CUSTOM_BUILD_SUFFIX}/bin/opencv_perf_core ]] && \ - [[ -f "${BUILD_ROOT_PATH}"/opencv-kleidicv-${CUSTOM_BUILD_SUFFIX}/bin/opencv_perf_imgproc ]]; then - "${ADB}" push "${BUILD_ROOT_PATH}"/opencv-kleidicv-${CUSTOM_BUILD_SUFFIX}/bin/opencv_perf_core ${DEV_DIR}/opencv_perf_core_kleidicv_${CUSTOM_BUILD_SUFFIX} - "${ADB}" push "${BUILD_ROOT_PATH}"/opencv-kleidicv-${CUSTOM_BUILD_SUFFIX}/bin/opencv_perf_imgproc ${DEV_DIR}/opencv_perf_imgproc_kleidicv_${CUSTOM_BUILD_SUFFIX} +if [[ -f "${BUILD_ROOT_PATH}"/opencv-kleidicv-"${CUSTOM_BUILD_SUFFIX}"/bin/opencv_perf_core ]] && \ + [[ -f "${BUILD_ROOT_PATH}"/opencv-kleidicv-"${CUSTOM_BUILD_SUFFIX}"/bin/opencv_perf_imgproc ]]; then + "${ADB}" push "${BUILD_ROOT_PATH}"/opencv-kleidicv-"${CUSTOM_BUILD_SUFFIX}"/bin/opencv_perf_core "${DEV_DIR}"/opencv_perf_core_kleidicv_"${CUSTOM_BUILD_SUFFIX}" + "${ADB}" push "${BUILD_ROOT_PATH}"/opencv-kleidicv-"${CUSTOM_BUILD_SUFFIX}"/bin/opencv_perf_imgproc "${DEV_DIR}"/opencv_perf_imgproc_kleidicv_"${CUSTOM_BUILD_SUFFIX}" fi -"${ADB}" push "${BENCHMARK_SCRIPT_PATH}"/perf_test_op.sh ${DEV_DIR}/ -"${ADB}" push "${BENCHMARK_SCRIPT_PATH}"/run_benchmarks_FHD.sh ${DEV_DIR}/ -"${ADB}" push "${BENCHMARK_SCRIPT_PATH}"/run_benchmarks_4K.sh ${DEV_DIR}/ +"${ADB}" push "${BENCHMARK_SCRIPT_PATH}"/perf_test_op.sh "${DEV_DIR}"/ +"${ADB}" push "${BENCHMARK_SCRIPT_PATH}"/run_benchmarks_FHD.sh "${DEV_DIR}"/ +"${ADB}" push "${BENCHMARK_SCRIPT_PATH}"/run_benchmarks_4K.sh "${DEV_DIR}"/ -- GitLab From 6ff89a47a6dec12e76edc64f47b4cfde4d14ef51 Mon Sep 17 00:00:00 2001 From: Tamas Petz Date: Mon, 7 Oct 2024 20:03:59 +0100 Subject: [PATCH 5/6] [Benchmarks] Update and unify scripts This change fixes issues raised by shellcheck and also tries to unify benchmarking on different resolutions. The already existing benchmark specification is extracted hoping that it will result in less maintenance cost. It is still possible to execute benchmarks specific to certain resolutions. --- scripts/benchmark/benchmarks.txt | 82 +++++++++++++ scripts/benchmark/benchmarks_4K.txt | 9 ++ scripts/benchmark/benchmarks_FHD.txt | 9 ++ scripts/benchmark/perf_test_op.sh | 6 +- scripts/benchmark/push.sh | 4 +- scripts/benchmark/run_benchmarks.sh | 149 ++++++++++++++++++++++++ scripts/benchmark/run_benchmarks_4K.sh | 107 ----------------- scripts/benchmark/run_benchmarks_FHD.sh | 107 ----------------- 8 files changed, 253 insertions(+), 220 deletions(-) create mode 100755 scripts/benchmark/benchmarks.txt create mode 100644 scripts/benchmark/benchmarks_4K.txt create mode 100644 scripts/benchmark/benchmarks_FHD.txt create mode 100755 scripts/benchmark/run_benchmarks.sh delete mode 100755 scripts/benchmark/run_benchmarks_4K.sh delete mode 100755 scripts/benchmark/run_benchmarks_FHD.sh diff --git a/scripts/benchmark/benchmarks.txt b/scripts/benchmark/benchmarks.txt new file mode 100755 index 000000000..d40d2dd9c --- /dev/null +++ b/scripts/benchmark/benchmarks.txt @@ -0,0 +1,82 @@ +# SPDX-FileCopyrightText: 2024 Arm Limited and/or its affiliates +# +# SPDX-License-Identifier: Apache-2.0 + +GRAY2BGR: opencv_perf_imgproc '*cvtColor8u/*' '($PIXEL_FORMAT, COLOR_GRAY2BGR)' +GRAY2BGRA: opencv_perf_imgproc '*cvtColor8u/*' '($PIXEL_FORMAT, COLOR_GRAY2BGRA)' + +BGR2RGB: opencv_perf_imgproc '*cvtColor8u/*' '($PIXEL_FORMAT, COLOR_BGR2RGB)' +BGRA2RGBA: opencv_perf_imgproc '*cvtColor8u/*' '($PIXEL_FORMAT, COLOR_BGRA2RGBA)' +BGR2RGBA: opencv_perf_imgproc '*cvtColor8u/*' '($PIXEL_FORMAT, COLOR_BGR2RGBA)' +BGR2BGRA: opencv_perf_imgproc '*cvtColor8u/*' '($PIXEL_FORMAT, COLOR_BGR2BGRA)' +RGBA2BGR: opencv_perf_imgproc '*cvtColor8u/*' '($PIXEL_FORMAT, COLOR_RGBA2BGR)' +BGRA2BGR: opencv_perf_imgproc '*cvtColor8u/*' '($PIXEL_FORMAT, COLOR_BGRA2BGR)' + +YUVSP2BGR: opencv_perf_imgproc '*cvtColorYUV420/*' '($PIXEL_FORMAT, COLOR_YUV2BGR_NV12)' +YUVSP2BGRA: opencv_perf_imgproc '*cvtColorYUV420/*' '($PIXEL_FORMAT, COLOR_YUV2BGRA_NV12)' +YUVSP2RGB: opencv_perf_imgproc '*cvtColorYUV420/*' '($PIXEL_FORMAT, COLOR_YUV2RGB_NV12)' +YUVSP2RGBA: opencv_perf_imgproc '*cvtColorYUV420/*' '($PIXEL_FORMAT, COLOR_YUV2RGBA_NV12)' + +RGB2YUV: opencv_perf_imgproc '*cvtColor8u/*' '($PIXEL_FORMAT, COLOR_RGB2YUV)' +BGR2YUV: opencv_perf_imgproc '*cvtColor8u/*' '($PIXEL_FORMAT, COLOR_BGR2YUV)' +RGBA2YUV: opencv_perf_imgproc '*cvtColor8u/*' '($PIXEL_FORMAT, CX_RGBA2YUV)' +BGRA2YUV: opencv_perf_imgproc '*cvtColor8u/*' '($PIXEL_FORMAT, CX_BGRA2YUV)' + +YUV2RGB: opencv_perf_imgproc '*cvtColor8u/*' '($PIXEL_FORMAT, COLOR_YUV2RGB)' +YUV2BGR: opencv_perf_imgproc '*cvtColor8u/*' '($PIXEL_FORMAT, COLOR_YUV2BGR)' + +BinaryThreshold: opencv_perf_imgproc '*ThreshFixture_Threshold.Threshold/*' '($PIXEL_FORMAT, 8UC1, THRESH_BINARY)' + +SepFilter2D_5x5_U8: opencv_perf_imgproc '*KleidiCV_SepFilter2D.SepFilter2D/*' '($PIXEL_FORMAT, 8UC1, 5, BORDER_REPLICATE)' +SepFilter2D_5x5_U16: opencv_perf_imgproc '*KleidiCV_SepFilter2D.SepFilter2D/*' '($PIXEL_FORMAT, 16UC1, 5, BORDER_REPLICATE)' +SepFilter2D_5x5_S16: opencv_perf_imgproc '*KleidiCV_SepFilter2D.SepFilter2D/*' '($PIXEL_FORMAT, 16SC1, 5, BORDER_REPLICATE)' + +GaussianBlur3x3: opencv_perf_imgproc '*gaussianBlur3x3/*' '($PIXEL_FORMAT, 8UC1, BORDER_REPLICATE)' +GaussianBlur5x5: opencv_perf_imgproc '*gaussianBlur5x5/*' '($PIXEL_FORMAT, 8UC1, BORDER_REPLICATE)' +GaussianBlur7x7: opencv_perf_imgproc '*gaussianBlur7x7/*' '($PIXEL_FORMAT, 8UC1, BORDER_REPLICATE)' +GaussianBlur15x15: opencv_perf_imgproc '*gaussianBlur15x15/*' '($PIXEL_FORMAT, 8UC1, BORDER_REPLICATE)' + +GaussianBlur3x3_CustomSigma: opencv_perf_imgproc '*gaussianBlur3x3_CustomSigma/*' '($PIXEL_FORMAT, 8UC1, BORDER_REPLICATE)' +GaussianBlur5x5_CustomSigma: opencv_perf_imgproc '*gaussianBlur5x5_CustomSigma/*' '($PIXEL_FORMAT, 8UC1, BORDER_REPLICATE)' +GaussianBlur7x7_CustomSigma: opencv_perf_imgproc '*gaussianBlur7x7_CustomSigma/*' '($PIXEL_FORMAT, 8UC1, BORDER_REPLICATE)' +GaussianBlur15x15_CustomSigma: opencv_perf_imgproc '*gaussianBlur15x15_CustomSigma/*' '($PIXEL_FORMAT, 8UC1, BORDER_REPLICATE)' + +Sobel_Gx: opencv_perf_imgproc '*Border3x3_sobelFilter.sobelFilter/*' '($PIXEL_FORMAT, 16SC1, (1, 0), BORDER_REPLICATE)' +Sobel_Gy: opencv_perf_imgproc '*Border3x3_sobelFilter.sobelFilter/*' '($PIXEL_FORMAT, 16SC1, (0, 1), BORDER_REPLICATE)' + +Dilate3x3: opencv_perf_imgproc '*Dilate_big.big/*' '($PIXEL_FORMAT, 8UC1, 3)' +Dilate5x5: opencv_perf_imgproc '*Dilate_big.big/*' '($PIXEL_FORMAT, 8UC1, 5)' +Dilate17x17: opencv_perf_imgproc '*Dilate_big.big/*' '($PIXEL_FORMAT, 8UC1, 17)' +Erode3x3: opencv_perf_imgproc '*Erode_big.big/*' '($PIXEL_FORMAT, 8UC1, 3)' +Erode5x5: opencv_perf_imgproc '*Erode_big.big/*' '($PIXEL_FORMAT, 8UC1, 5)' +Erode17x17: opencv_perf_imgproc '*Erode_big.big/*' '($PIXEL_FORMAT, 8UC1, 17)' + +Resize_0.5_8b: opencv_perf_imgproc '*ResizeAreaFast/*' '(8UC1, $PIXEL_FORMAT, 2)' + +Scale: opencv_perf_core '*convertTo/*' '($PIXEL_FORMAT, 8UC1, 8UC1, 1, 1.234, 4.567)' +Scale_float_1.0: opencv_perf_core '*convertTo/*' '($PIXEL_FORMAT, 32FC1, 32FC1, 1, 1, 4.567)' +Scale_float: opencv_perf_core '*convertTo/*' '($PIXEL_FORMAT, 32FC1, 32FC1, 1, 1.234, 4.567)' + +MinMax_S8: opencv_perf_core '*minMaxVals/*' '($PIXEL_FORMAT, 8SC1)' +MinMax_U8: opencv_perf_core '*minMaxVals/*' '($PIXEL_FORMAT, 8UC1)' +MinMax_S16: opencv_perf_core '*minMaxVals/*' '($PIXEL_FORMAT, 16SC1)' +MinMax_U16: opencv_perf_core '*minMaxVals/*' '($PIXEL_FORMAT, 16UC1)' +MinMax_S32: opencv_perf_core '*minMaxVals/*' '($PIXEL_FORMAT, 32SC1)' +MinMax_F32: opencv_perf_core '*minMaxVals/*' '($PIXEL_FORMAT, 32FC1)' + +MinMaxLoc_U8: opencv_perf_core '*minMaxLoc/*' '($PIXEL_FORMAT, 8UC1)' + +FloatToInt: opencv_perf_core '*convertTo/*' '($PIXEL_FORMAT, 32FC1, 8SC1, 1, 1, 0)' +FloatToUint: opencv_perf_core '*convertTo/*' '($PIXEL_FORMAT, 32FC1, 8UC1, 1, 1, 0)' +IntToFloat: opencv_perf_core '*convertTo/*' '($PIXEL_FORMAT, 8SC1, 32FC1, 1, 1, 0)' +UintToFloat: opencv_perf_core '*convertTo/*' '($PIXEL_FORMAT, 8UC1, 32FC1, 1, 1, 0)' + +CompareGt: opencv_perf_core '*compare/*' '($PIXEL_FORMAT, 8UC1, CMP_GT)' + +InRange_U8: opencv_perf_core '*inRangeScalar/*' '($PIXEL_FORMAT, 8UC1, 1, 2)' +InRange_F32: opencv_perf_core '*inRangeScalar/*' '($PIXEL_FORMAT, 32FC1, 1, 2)' + +Remap_S16_U8: opencv_perf_imgproc '*Remap/*' '($PIXEL_FORMAT, 8UC1, 16SC2, INTER_NEAREST, BORDER_REPLICATE)' +Remap_S16Point5_U8: opencv_perf_imgproc '*Remap/*' '($PIXEL_FORMAT, 8UC1, 16SC2, INTER_LINEAR, BORDER_REPLICATE)' + +BlurAndDownsample: opencv_perf_imgproc '*pyrDown/*' '($PIXEL_FORMAT, 8UC1)' diff --git a/scripts/benchmark/benchmarks_4K.txt b/scripts/benchmark/benchmarks_4K.txt new file mode 100644 index 000000000..79fd9a3cb --- /dev/null +++ b/scripts/benchmark/benchmarks_4K.txt @@ -0,0 +1,9 @@ +# SPDX-FileCopyrightText: 2024 Arm Limited and/or its affiliates +# +# SPDX-License-Identifier: Apache-2.0 + +Resize2x2_8b: opencv_perf_imgproc '*resizeUpLinearNonExact/*' '(8UC1, (1920x1080, 3840x2160))' +Resize2x2_float: opencv_perf_imgproc '*resizeUpLinearNonExact/*' '(32FC1, (1920x1080, 3840x2160))' +Resize4x4_8b: opencv_perf_imgproc '*resizeUpLinearNonExact/*' '(8UC1, (960x540, 3840x2160))' +Resize4x4_float: opencv_perf_imgproc '*resizeUpLinearNonExact/*' '(32FC1, (960x540, 3840x2160))' +Resize8x8_float: opencv_perf_imgproc '*resizeUpLinearNonExact/*' '(32FC1, (480x270, 3840x2160))' diff --git a/scripts/benchmark/benchmarks_FHD.txt b/scripts/benchmark/benchmarks_FHD.txt new file mode 100644 index 000000000..565bc5af1 --- /dev/null +++ b/scripts/benchmark/benchmarks_FHD.txt @@ -0,0 +1,9 @@ +# SPDX-FileCopyrightText: 2024 Arm Limited and/or its affiliates +# +# SPDX-License-Identifier: Apache-2.0 + +Resize2x2_8b: opencv_perf_imgproc '*resizeUpLinearNonExact/*' '(8UC1, (960x540, 1920x1080))' +Resize2x2_float: opencv_perf_imgproc '*resizeUpLinearNonExact/*' '(32FC1, (960x540, 1920x1080))' +Resize4x4_8b: opencv_perf_imgproc '*resizeUpLinearNonExact/*' '(8UC1, (480x270, 1920x1080))' +Resize4x4_float: opencv_perf_imgproc '*resizeUpLinearNonExact/*' '(32FC1, (480x270, 1920x1080))' +Resize8x8_float: opencv_perf_imgproc '*resizeUpLinearNonExact/*' '(32FC1, (240x135, 1920x1080))' diff --git a/scripts/benchmark/perf_test_op.sh b/scripts/benchmark/perf_test_op.sh index e1604e564..598348f09 100755 --- a/scripts/benchmark/perf_test_op.sh +++ b/scripts/benchmark/perf_test_op.sh @@ -7,7 +7,7 @@ set -eu CUSTOM_BUILD_SUFFIX=$1 -CPU_NUMBER=$2 +CPU=$2 THERMAL_ZONE_ID=$3 DISP_NAME=$4 PERF_TEST_BINARY_BASENAME=$5 @@ -16,9 +16,9 @@ GTEST_PARAM_FILTER=$7 : "${DEV_DIR:=/data/local/tmp}" -CPU_MASK=$(echo "obase=16;2^${CPU_NUMBER}" | bc) +CPU_MASK=$(echo "obase=16;2^${CPU}" | bc) -FREQ_GOVERNOR_FILE="/sys/devices/system/cpu/cpu${CPU_NUMBER}/cpufreq/scaling_governor" +FREQ_GOVERNOR_FILE="/sys/devices/system/cpu/cpu${CPU}/cpufreq/scaling_governor" PREV_FREQ_GOVERNOR=$(cat "${FREQ_GOVERNOR_FILE}") echo performance > "${FREQ_GOVERNOR_FILE}" diff --git a/scripts/benchmark/push.sh b/scripts/benchmark/push.sh index 59ba14c63..7043da31b 100755 --- a/scripts/benchmark/push.sh +++ b/scripts/benchmark/push.sh @@ -37,6 +37,4 @@ if [[ -f "${BUILD_ROOT_PATH}"/opencv-kleidicv-"${CUSTOM_BUILD_SUFFIX}"/bin/openc "${ADB}" push "${BUILD_ROOT_PATH}"/opencv-kleidicv-"${CUSTOM_BUILD_SUFFIX}"/bin/opencv_perf_imgproc "${DEV_DIR}"/opencv_perf_imgproc_kleidicv_"${CUSTOM_BUILD_SUFFIX}" fi -"${ADB}" push "${BENCHMARK_SCRIPT_PATH}"/perf_test_op.sh "${DEV_DIR}"/ -"${ADB}" push "${BENCHMARK_SCRIPT_PATH}"/run_benchmarks_FHD.sh "${DEV_DIR}"/ -"${ADB}" push "${BENCHMARK_SCRIPT_PATH}"/run_benchmarks_4K.sh "${DEV_DIR}"/ +"${ADB}" push "${BENCHMARK_SCRIPT_PATH}"/perf_test_op.sh "${BENCHMARK_SCRIPT_PATH}"/run_benchmarks.sh "${BENCHMARK_SCRIPT_PATH}"/benchmarks*.txt "${DEV_DIR}"/ diff --git a/scripts/benchmark/run_benchmarks.sh b/scripts/benchmark/run_benchmarks.sh new file mode 100755 index 000000000..c5d402ed2 --- /dev/null +++ b/scripts/benchmark/run_benchmarks.sh @@ -0,0 +1,149 @@ +#!/bin/sh + +# SPDX-FileCopyrightText: 2024 Arm Limited and/or its affiliates +# +# SPDX-License-Identifier: Apache-2.0 + +set -eu + +# ------------------------------------------------------------------------------ +# Runs benchmarks described in benchmark specification file(s). +# +# Benchmark specification should follow this pattern: +# : '' '' +# +# The number of spaces is meaningless in the pattern above. Empty lines and +# lines starting with '#' are ignored. +# +# The special word $PIXEL_FORMAT is replaced automatically with an appropriate MxN value +# depending on what RESOLUTION is set to. RESOLUTION defaults to 4K UHD. +# +# By default both the common 'benchmarks.txt' and resolution-specific 'benchmarks<_RES>.txt' +# are run, if exist. +# +# Environment: +# DEV_DIR: Directory on the devicewhere all relevant files are stored. +# Defaults to '/data/local/tmp'. +# CPU: Identifier of the core to run benchmarks on. +# Defaults to '4', which is most often a mid core. +# CUSTOM_BUILD_SUFFIX: Build name suffix for the extra build. +# Defaults to 'custom'. +# RESOLUTION: Sets the resolution to bechmark. See select_resolution() below for +# supported formats. Defaults to 4K. +# THERMAL_ZONE_ID: Identifier of the thermal zone to watch for changes. +# Defaults to '1', which is most often the zone associated with mid cores. +# ------------------------------------------------------------------------------ + +: "${DEV_DIR:=/data/local/tmp}" +: "${CPU:=4}" +: "${CUSTOM_BUILD_SUFFIX:=custom}" +: "${THERMAL_ZONE_ID:=1}" + +# ------------------------------------------------------------------------------ + +# Pixel format in MxN. +PIXEL_FORMAT= +# The number of benchmarks. +NUM_BENCHMARKS=0 +# The current benchmark which is being run. +CURRENT_BENCHMARK=0 + +# ------------------------------------------------------------------------------ + +# Prints a warning message. +# Arguments: +# 1: Message to print. +warn() { + >&2 echo "WARNING: $1" +} + +# Selects which resolution to use. +# Arguments: none +select_resolution() { + if [ -z "${RESOLUTION:-}" ]; then + warn "Resolution is not specified, falling back to 4K UHD." + RESOLUTION="4K" + fi + + case "${RESOLUTION:-}" in + FHD | 1080p) + PIXEL_FORMAT="1920x1080" + ;; + UHD | 4K | 2160p) + PIXEL_FORMAT="3840x2160" + ;; + *) + warn "Resolution is not recognized, falling back to 4K UHD." + RESOLUTION="4K" + PIXEL_FORMAT="3840x2160" + ;; + esac +} + +# Calls a user-supplied function for every benchmark. +# Arguments: +# 1: Path to a benchmark specification. +# 2: Function to call for a benchmark. +foreach_benchmark() { + [ ! -f "${1}" ] && return + + while IFS= read -r line; do + # Skip empty lines + [ -z "${line}" ] && continue + # Skip lines starting with '#' + [ -z "${line%\#*}" ] && continue + + "${2}" "${line}" + done < "${1}" +} + +# Counts the number of benchmarks. +# All arguments are ignored. +count_benchmark() { + NUM_BENCHMARKS=$((NUM_BENCHMARKS+1)) +} + +# Runs a given benchmark. +# Arguments: +# 1: Benchmark specification to run. +run_benchmark() { + # shellcheck disable=SC3043 + # Many shells support 'local', therefore this warning is ignored. + local spec="$1" + + # Replace multiple spaces with one. + spec="$(echo "${spec}" | tr -s ' ')" + + # Resolve $PIXEL_FORMAT + # shellcheck disable=SC3060 + # Targeted shell support string replacement. + spec="${spec//\$PIXEL_FORMAT/${PIXEL_FORMAT}}" + + # Be informative to user. + CURRENT_BENCHMARK=$((CURRENT_BENCHMARK+1)) + >&2 echo RUNNING ["${CURRENT_BENCHMARK}"/"${NUM_BENCHMARKS}"]: "${spec}" + + # shellcheck disable=SC3043 + # Many shells support 'local', therefore this warning is ignored. + local -r disp_name="${spec%%:*}" + + # shellcheck disable=SC2086 + # Word splitting at the end is required here to produce PERF_TEST_BINARY_BASENAME, GTEST_FILTER and GTEST_PARAM_FILTER. + eval "${DEV_DIR}"/perf_test_op.sh "${CUSTOM_BUILD_SUFFIX}" "${CPU}" "${THERMAL_ZONE_ID}" "${disp_name}" ${spec#*:} + >&2 echo +} + +# ------------------------------------------------------------------------------ + +select_resolution + +foreach_benchmark "${DEV_DIR}"/benchmarks.txt count_benchmark +foreach_benchmark "${DEV_DIR}"/benchmarks_"${RESOLUTION}".txt count_benchmark + +# Print tsv header overwriting any existing files. +printf "Operation\tOpenCV\tstd\tKleidiCV\tstd\tKleidiCV_%s\tstd\n" "${CUSTOM_BUILD_SUFFIX}" + +foreach_benchmark "${DEV_DIR}"/benchmarks.txt run_benchmark +foreach_benchmark "${DEV_DIR}"/benchmarks_"${RESOLUTION}".txt run_benchmark + +# ------------------------------------------------------------------------------ diff --git a/scripts/benchmark/run_benchmarks_4K.sh b/scripts/benchmark/run_benchmarks_4K.sh deleted file mode 100755 index 89cb74279..000000000 --- a/scripts/benchmark/run_benchmarks_4K.sh +++ /dev/null @@ -1,107 +0,0 @@ -#!/bin/sh - -# SPDX-FileCopyrightText: 2024 Arm Limited and/or its affiliates -# -# SPDX-License-Identifier: Apache-2.0 - -set -eu - -: "${DEV_DIR:=/data/local/tmp}" -CPU=7 -THERMAL=0 -CUSTOM_BUILD_SUFFIX="${CUSTOM_BUILD_SUFFIX:-custom}" - -echo "Operation\tOpenCV\tstd\tKleidiCV\tstd\tKleidiCV_$CUSTOM_BUILD_SUFFIX\tstd" - -benchmarks=( - "GRAY2BGR: opencv_perf_imgproc '*cvtColor8u/*' '(3840x2160, COLOR_GRAY2BGR)'" - "GRAY2BGRA: opencv_perf_imgproc '*cvtColor8u/*' '(3840x2160, COLOR_GRAY2BGRA)'" - - "BGR2RGB: opencv_perf_imgproc '*cvtColor8u/*' '(3840x2160, COLOR_BGR2RGB)'" - "BGRA2RGBA: opencv_perf_imgproc '*cvtColor8u/*' '(3840x2160, COLOR_BGRA2RGBA)'" - "BGR2RGBA: opencv_perf_imgproc '*cvtColor8u/*' '(3840x2160, COLOR_BGR2RGBA)'" - "BGR2BGRA: opencv_perf_imgproc '*cvtColor8u/*' '(3840x2160, COLOR_BGR2BGRA)'" - "RGBA2BGR: opencv_perf_imgproc '*cvtColor8u/*' '(3840x2160, COLOR_RGBA2BGR)'" - "BGRA2BGR: opencv_perf_imgproc '*cvtColor8u/*' '(3840x2160, COLOR_BGRA2BGR)'" - - "YUVSP2BGR: opencv_perf_imgproc '*cvtColorYUV420/*' '(3840x2160, COLOR_YUV2BGR_NV12)'" - "YUVSP2BGRA: opencv_perf_imgproc '*cvtColorYUV420/*' '(3840x2160, COLOR_YUV2BGRA_NV12)'" - "YUVSP2RGB: opencv_perf_imgproc '*cvtColorYUV420/*' '(3840x2160, COLOR_YUV2RGB_NV12)'" - "YUVSP2RGBA: opencv_perf_imgproc '*cvtColorYUV420/*' '(3840x2160, COLOR_YUV2RGBA_NV12)'" - - "RGB2YUV: opencv_perf_imgproc '*cvtColor8u/*' '(3840x2160, COLOR_RGB2YUV)'" - "BGR2YUV: opencv_perf_imgproc '*cvtColor8u/*' '(3840x2160, COLOR_BGR2YUV)'" - "RGBA2YUV: opencv_perf_imgproc '*cvtColor8u/*' '(3840x2160, CX_RGBA2YUV)'" - "BGRA2YUV: opencv_perf_imgproc '*cvtColor8u/*' '(3840x2160, CX_BGRA2YUV)'" - - "YUV2RGB: opencv_perf_imgproc '*cvtColor8u/*' '(3840x2160, COLOR_YUV2RGB)'" - "YUV2BGR: opencv_perf_imgproc '*cvtColor8u/*' '(3840x2160, COLOR_YUV2BGR)'" - - "BinaryThreshold: opencv_perf_imgproc '*ThreshFixture_Threshold.Threshold/*' '(3840x2160, 8UC1, THRESH_BINARY)'" - - "SepFilter2D_5x5_U8: opencv_perf_imgproc '*KleidiCV_SepFilter2D.SepFilter2D/*' '(3840x2160, 8UC1, 5, BORDER_REPLICATE)'" - "SepFilter2D_5x5_U16: opencv_perf_imgproc '*KleidiCV_SepFilter2D.SepFilter2D/*' '(3840x2160, 16UC1, 5, BORDER_REPLICATE)'" - "SepFilter2D_5x5_S16: opencv_perf_imgproc '*KleidiCV_SepFilter2D.SepFilter2D/*' '(3840x2160, 16SC1, 5, BORDER_REPLICATE)'" - - "GaussianBlur3x3: opencv_perf_imgproc '*gaussianBlur3x3/*' '(3840x2160, 8UC1, BORDER_REPLICATE)'" - "GaussianBlur5x5: opencv_perf_imgproc '*gaussianBlur5x5/*' '(3840x2160, 8UC1, BORDER_REPLICATE)'" - "GaussianBlur7x7: opencv_perf_imgproc '*gaussianBlur7x7/*' '(3840x2160, 8UC1, BORDER_REPLICATE)'" - "GaussianBlur15x15: opencv_perf_imgproc '*gaussianBlur15x15/*' '(3840x2160, 8UC1, BORDER_REPLICATE)'" - - "GaussianBlur3x3_CustomSigma: opencv_perf_imgproc '*gaussianBlur3x3_CustomSigma/*' '(3840x2160, 8UC1, BORDER_REPLICATE)'" - "GaussianBlur5x5_CustomSigma: opencv_perf_imgproc '*gaussianBlur5x5_CustomSigma/*' '(3840x2160, 8UC1, BORDER_REPLICATE)'" - "GaussianBlur7x7_CustomSigma: opencv_perf_imgproc '*gaussianBlur7x7_CustomSigma/*' '(3840x2160, 8UC1, BORDER_REPLICATE)'" - "GaussianBlur15x15_CustomSigma: opencv_perf_imgproc '*gaussianBlur15x15_CustomSigma/*' '(3840x2160, 8UC1, BORDER_REPLICATE)'" - - "Sobel_Gx: opencv_perf_imgproc '*Border3x3_sobelFilter.sobelFilter/*' '(3840x2160, 16SC1, (1, 0), BORDER_REPLICATE)'" - "Sobel_Gy: opencv_perf_imgproc '*Border3x3_sobelFilter.sobelFilter/*' '(3840x2160, 16SC1, (0, 1), BORDER_REPLICATE)'" - - "Dilate3x3: opencv_perf_imgproc '*Dilate_big.big/*' '(3840x2160, 8UC1, 3)'" - "Dilate5x5: opencv_perf_imgproc '*Dilate_big.big/*' '(3840x2160, 8UC1, 5)'" - "Dilate17x17: opencv_perf_imgproc '*Dilate_big.big/*' '(3840x2160, 8UC1, 17)'" - "Erode3x3: opencv_perf_imgproc '*Erode_big.big/*' '(3840x2160, 8UC1, 3)'" - "Erode5x5: opencv_perf_imgproc '*Erode_big.big/*' '(3840x2160, 8UC1, 5)'" - "Erode17x17: opencv_perf_imgproc '*Erode_big.big/*' '(3840x2160, 8UC1, 17)'" - - "Resize_0.5_8b: opencv_perf_imgproc '*ResizeAreaFast/*' '(8UC1, 3840x2160, 2)'" - "Resize2x2_8b: opencv_perf_imgproc '*resizeUpLinearNonExact/*' '(8UC1, (1920x1080, 3840x2160))'" - "Resize2x2_float: opencv_perf_imgproc '*resizeUpLinearNonExact/*' '(32FC1, (1920x1080, 3840x2160))'" - "Resize4x4_8b: opencv_perf_imgproc '*resizeUpLinearNonExact/*' '(8UC1, (960x540, 3840x2160))'" - "Resize4x4_float: opencv_perf_imgproc '*resizeUpLinearNonExact/*' '(32FC1, (960x540, 3840x2160))'" - "Resize8x8_float: opencv_perf_imgproc '*resizeUpLinearNonExact/*' '(32FC1, (480x270, 3840x2160))'" - - "Scale: opencv_perf_core '*convertTo/*' '(3840x2160, 8UC1, 8UC1, 1, 1.234, 4.567)'" - "Scale_float_1.0: opencv_perf_core '*convertTo/*' '(3840x2160, 32FC1, 32FC1, 1, 1, 4.567)'" - "Scale_float: opencv_perf_core '*convertTo/*' '(3840x2160, 32FC1, 32FC1, 1, 1.234, 4.567)'" - - "MinMax_S8: opencv_perf_core '*minMaxVals/*' '(3840x2160, 8SC1)'" - "MinMax_U8: opencv_perf_core '*minMaxVals/*' '(3840x2160, 8UC1)'" - "MinMax_S16: opencv_perf_core '*minMaxVals/*' '(3840x2160, 16SC1)'" - "MinMax_U16: opencv_perf_core '*minMaxVals/*' '(3840x2160, 16UC1)'" - "MinMax_S32: opencv_perf_core '*minMaxVals/*' '(3840x2160, 32SC1)'" - "MinMax_F32: opencv_perf_core '*minMaxVals/*' '(3840x2160, 32FC1)'" - - "MinMaxLoc_U8: opencv_perf_core '*minMaxLoc/*' '(3840x2160, 8UC1)'" - - "FloatToInt: opencv_perf_core '*convertTo/*' '(3840x2160, 32FC1, 8SC1, 1, 1, 0)'" - "FloatToUint: opencv_perf_core '*convertTo/*' '(3840x2160, 32FC1, 8UC1, 1, 1, 0)'" - "IntToFloat: opencv_perf_core '*convertTo/*' '(3840x2160, 8SC1, 32FC1, 1, 1, 0)'" - "UintToFloat: opencv_perf_core '*convertTo/*' '(3840x2160, 8UC1, 32FC1, 1, 1, 0)'" - - "CompareGt: opencv_perf_core '*compare/*' '(3840x2160, 8UC1, CMP_GT)'" - - "InRange_U8: opencv_perf_core '*inRangeScalar/*' '(3840x2160, 8UC1, 1, 2)'" - "InRange_F32: opencv_perf_core '*inRangeScalar/*' '(3840x2160, 32FC1, 1, 2)'" - - "Remap_S16_U8: opencv_perf_imgproc '*Remap/*' '(3840x2160, 8UC1, 16SC2, INTER_NEAREST, BORDER_REPLICATE)'" - "Remap_S16Point5_U8: opencv_perf_imgproc '*Remap/*' '(3840x2160, 8UC1, 16SC2, INTER_LINEAR, BORDER_REPLICATE)'" - - "BlurAndDownsample: opencv_perf_imgproc '*pyrDown/*' '(3840x2160, 8UC1)'" -) - -for idx in "${!benchmarks[@]}"; do - benchmark="${benchmarks[$idx]}" - >&2 echo - >&2 echo "RUNNING [$((${idx} + 1))/${#benchmarks[@]}]:" ${benchmark%%:*} ${benchmark#*:} - eval "${DEV_DIR}/perf_test_op.sh" "${CUSTOM_BUILD_SUFFIX}" "${CPU}" "${THERMAL}" ${benchmark%%:*} ${benchmark#*:} -done diff --git a/scripts/benchmark/run_benchmarks_FHD.sh b/scripts/benchmark/run_benchmarks_FHD.sh deleted file mode 100755 index 18993c6d6..000000000 --- a/scripts/benchmark/run_benchmarks_FHD.sh +++ /dev/null @@ -1,107 +0,0 @@ -#!/bin/sh - -# SPDX-FileCopyrightText: 2024 Arm Limited and/or its affiliates -# -# SPDX-License-Identifier: Apache-2.0 - -set -eu - -: "${DEV_DIR:=/data/local/tmp}" -CPU=7 -THERMAL=0 -CUSTOM_BUILD_SUFFIX="${CUSTOM_BUILD_SUFFIX:-custom}" - -echo "Operation\tOpenCV\tstd\tKleidiCV\tstd\tKleidiCV_$CUSTOM_BUILD_SUFFIX\tstd" - -benchmarks=( - "GRAY2BGR: opencv_perf_imgproc '*cvtColor8u/*' '(1920x1080, COLOR_GRAY2BGR)'" - "GRAY2BGRA: opencv_perf_imgproc '*cvtColor8u/*' '(1920x1080, COLOR_GRAY2BGRA)'" - - "BGR2RGB: opencv_perf_imgproc '*cvtColor8u/*' '(1920x1080, COLOR_BGR2RGB)'" - "BGRA2RGBA: opencv_perf_imgproc '*cvtColor8u/*' '(1920x1080, COLOR_BGRA2RGBA)'" - "BGR2RGBA: opencv_perf_imgproc '*cvtColor8u/*' '(1920x1080, COLOR_BGR2RGBA)'" - "BGR2BGRA: opencv_perf_imgproc '*cvtColor8u/*' '(1920x1080, COLOR_BGR2BGRA)'" - "RGBA2BGR: opencv_perf_imgproc '*cvtColor8u/*' '(1920x1080, COLOR_RGBA2BGR)'" - "BGRA2BGR: opencv_perf_imgproc '*cvtColor8u/*' '(1920x1080, COLOR_BGRA2BGR)'" - - "YUVSP2BGR: opencv_perf_imgproc '*cvtColorYUV420/*' '(1920x1080, COLOR_YUV2BGR_NV12)'" - "YUVSP2BGRA: opencv_perf_imgproc '*cvtColorYUV420/*' '(1920x1080, COLOR_YUV2BGRA_NV12)'" - "YUVSP2RGB: opencv_perf_imgproc '*cvtColorYUV420/*' '(1920x1080, COLOR_YUV2RGB_NV12)'" - "YUVSP2RGBA: opencv_perf_imgproc '*cvtColorYUV420/*' '(1920x1080, COLOR_YUV2RGBA_NV12)'" - - "RGB2YUV: opencv_perf_imgproc '*cvtColor8u/*' '(1920x1080, COLOR_RGB2YUV)'" - "BGR2YUV: opencv_perf_imgproc '*cvtColor8u/*' '(1920x1080, COLOR_BGR2YUV)'" - "RGBA2YUV: opencv_perf_imgproc '*cvtColor8u/*' '(1920x1080, CX_RGBA2YUV)'" - "BGRA2YUV: opencv_perf_imgproc '*cvtColor8u/*' '(1920x1080, CX_BGRA2YUV)'" - - "YUV2RGB: opencv_perf_imgproc '*cvtColor8u/*' '(1920x1080, COLOR_YUV2RGB)'" - "YUV2BGR: opencv_perf_imgproc '*cvtColor8u/*' '(1920x1080, COLOR_YUV2BGR)'" - - "BinaryThreshold: opencv_perf_imgproc '*ThreshFixture_Threshold.Threshold/*' '(1920x1080, 8UC1, THRESH_BINARY)'" - - "SepFilter2D_5x5_U8: opencv_perf_imgproc '*KleidiCV_SepFilter2D.SepFilter2D/*' '(1920x1080, 8UC1, 5, BORDER_REPLICATE)'" - "SepFilter2D_5x5_U16: opencv_perf_imgproc '*KleidiCV_SepFilter2D.SepFilter2D/*' '(1920x1080, 16UC1, 5, BORDER_REPLICATE)'" - "SepFilter2D_5x5_S16: opencv_perf_imgproc '*KleidiCV_SepFilter2D.SepFilter2D/*' '(1920x1080, 16SC1, 5, BORDER_REPLICATE)'" - - "GaussianBlur3x3: opencv_perf_imgproc '*gaussianBlur3x3/*' '(1920x1080, 8UC1, BORDER_REPLICATE)'" - "GaussianBlur5x5: opencv_perf_imgproc '*gaussianBlur5x5/*' '(1920x1080, 8UC1, BORDER_REPLICATE)'" - "GaussianBlur7x7: opencv_perf_imgproc '*gaussianBlur7x7/*' '(1920x1080, 8UC1, BORDER_REPLICATE)'" - "GaussianBlur15x15: opencv_perf_imgproc '*gaussianBlur15x15/*' '(1920x1080, 8UC1, BORDER_REPLICATE)'" - - "GaussianBlur3x3_CustomSigma: opencv_perf_imgproc '*gaussianBlur3x3_CustomSigma/*' '(1920x1080, 8UC1, BORDER_REPLICATE)'" - "GaussianBlur5x5_CustomSigma: opencv_perf_imgproc '*gaussianBlur5x5_CustomSigma/*' '(1920x1080, 8UC1, BORDER_REPLICATE)'" - "GaussianBlur7x7_CustomSigma: opencv_perf_imgproc '*gaussianBlur7x7_CustomSigma/*' '(1920x1080, 8UC1, BORDER_REPLICATE)'" - "GaussianBlur15x15_CustomSigma: opencv_perf_imgproc '*gaussianBlur15x15_CustomSigma/*' '(1920x1080, 8UC1, BORDER_REPLICATE)'" - - "Sobel_Gx: opencv_perf_imgproc '*Border3x3_sobelFilter.sobelFilter/*' '(1920x1080, 16SC1, (1, 0), BORDER_REPLICATE)'" - "Sobel_Gy: opencv_perf_imgproc '*Border3x3_sobelFilter.sobelFilter/*' '(1920x1080, 16SC1, (0, 1), BORDER_REPLICATE)'" - - "Dilate3x3: opencv_perf_imgproc '*Dilate_big.big/*' '(1920x1080, 8UC1, 3)'" - "Dilate5x5: opencv_perf_imgproc '*Dilate_big.big/*' '(1920x1080, 8UC1, 5)'" - "Dilate17x17: opencv_perf_imgproc '*Dilate_big.big/*' '(1920x1080, 8UC1, 17)'" - "Erode3x3: opencv_perf_imgproc '*Erode_big.big/*' '(1920x1080, 8UC1, 3)'" - "Erode5x5: opencv_perf_imgproc '*Erode_big.big/*' '(1920x1080, 8UC1, 5)'" - "Erode17x17: opencv_perf_imgproc '*Erode_big.big/*' '(1920x1080, 8UC1, 17)'" - - "Resize_0.5_8b: opencv_perf_imgproc '*ResizeAreaFast/*' '(8UC1, 1920x1080, 2)'" - "Resize2x2_8b: opencv_perf_imgproc '*resizeUpLinearNonExact/*' '(8UC1, (960x540, 1920x1080))'" - "Resize2x2_float: opencv_perf_imgproc '*resizeUpLinearNonExact/*' '(32FC1, (960x540, 1920x1080))'" - "Resize4x4_8b: opencv_perf_imgproc '*resizeUpLinearNonExact/*' '(8UC1, (480x270, 1920x1080))'" - "Resize4x4_float: opencv_perf_imgproc '*resizeUpLinearNonExact/*' '(32FC1, (480x270, 1920x1080))'" - "Resize8x8_float: opencv_perf_imgproc '*resizeUpLinearNonExact/*' '(32FC1, (240x135, 1920x1080))'" - - "Scale: opencv_perf_core '*convertTo/*' '(1920x1080, 8UC1, 8UC1, 1, 1.234, 4.567)'" - "Scale_float_1.0: opencv_perf_core '*convertTo/*' '(1920x1080, 32FC1, 32FC1, 1, 1, 4.567)'" - "Scale_float: opencv_perf_core '*convertTo/*' '(1920x1080, 32FC1, 32FC1, 1, 1.234, 4.567)'" - - "MinMax_S8: opencv_perf_core '*minMaxVals/*' '(1920x1080, 8SC1)'" - "MinMax_U8: opencv_perf_core '*minMaxVals/*' '(1920x1080, 8UC1)'" - "MinMax_S16: opencv_perf_core '*minMaxVals/*' '(1920x1080, 16SC1)'" - "MinMax_U16: opencv_perf_core '*minMaxVals/*' '(1920x1080, 16UC1)'" - "MinMax_S32: opencv_perf_core '*minMaxVals/*' '(1920x1080, 32SC1)'" - "MinMax_F32: opencv_perf_core '*minMaxVals/*' '(1920x1080, 32FC1)'" - - "MinMaxLoc_U8: opencv_perf_core '*minMaxLoc/*' '(1920x1080, 8UC1)'" - - "FloatToInt: opencv_perf_core '*convertTo/*' '(1920x1080, 32FC1, 8SC1, 1, 1, 0)'" - "FloatToUint: opencv_perf_core '*convertTo/*' '(1920x1080, 32FC1, 8UC1, 1, 1, 0)'" - "IntToFloat: opencv_perf_core '*convertTo/*' '(1920x1080, 8SC1, 32FC1, 1, 1, 0)'" - "UintToFloat: opencv_perf_core '*convertTo/*' '(1920x1080, 8UC1, 32FC1, 1, 1, 0)'" - - "CompareGt: opencv_perf_core '*compare/*' '(1920x1080, 8UC1, CMP_GT)'" - - "InRange_U8: opencv_perf_core '*inRangeScalar/*' '(1920x1080, 8UC1, 1, 2)'" - "InRange_F32: opencv_perf_core '*inRangeScalar/*' '(1920x1080, 32FC1, 1, 2)'" - - "Remap_S16_U8: opencv_perf_imgproc '*Remap/*' '(1920x1080, 8UC1, 16SC2, INTER_NEAREST, BORDER_REPLICATE)'" - "Remap_S16Point5_U8: opencv_perf_imgproc '*Remap/*' '(1920x1080, 8UC1, 16SC2, INTER_LINEAR, BORDER_REPLICATE)'" - - "BlurAndDownsample: opencv_perf_imgproc '*pyrDown/*' '(1920x1080, 8UC1)'" -) - -for idx in "${!benchmarks[@]}"; do - benchmark="${benchmarks[$idx]}" - >&2 echo - >&2 echo "RUNNING [$((${idx} + 1))/${#benchmarks[@]}]:" ${benchmark%%:*} ${benchmark#*:} - eval "${DEV_DIR}/perf_test_op.sh" "${CUSTOM_BUILD_SUFFIX}" "${CPU}" "${THERMAL}" ${benchmark%%:*} ${benchmark#*:} -done -- GitLab From da3082ed8e9025e59240571c68ce1ceef1d369c9 Mon Sep 17 00:00:00 2001 From: Tamas Petz Date: Tue, 8 Oct 2024 09:19:33 +0100 Subject: [PATCH 6/6] [Benchmarks] Update README As the last step of this series, README is update to reflect changes. --- scripts/benchmark/README.md | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/scripts/benchmark/README.md b/scripts/benchmark/README.md index ddb6dcb01..55798ea71 100644 --- a/scripts/benchmark/README.md +++ b/scripts/benchmark/README.md @@ -40,11 +40,12 @@ Then push the test binaries to the phone (replace 9A9A9A9A with your actual devi ``` ADB=adb ANDROID_SERIAL=9A9A9A9A ./push.sh ``` -Now you can run the benchmark set: +Now you can run the benchmark set for a given resolution: ``` -adb -s 9A9A9A9A shell /data/local/tmp/run_benchmarks_FHD.sh >your_phone_benchmarks_FHD.tsv -adb -s 9A9A9A9A shell /data/local/tmp/run_benchmarks_4K.sh >your_phone_benchmarks_4K.tsv +adb -s 9A9A9A9A shell 'RESOLUTION=FHD /data/local/tmp/run_benchmarks.sh' > your_phone_benchmarks_FHD.tsv ``` -To run on another core than BIG (CPU=7), set CPU and THERMAL to the desired value. -To find the correct thermal zone id, it's best to log /sys/devices/virtual/thermal/thermal_zone0/type and see what's dumped. -E.g. it can be BIG for 0, MID for 1 and LITTLE for 2, but it can be different for another phone. +To run on another core, set CPU and THERMAL_ZONE_ID to the desired values. THERMAL_ZONE_ID is important +to set correctly because benchmarks scripts check for changes of the temperature associated with selected CPU. +To find the correct thermal zone id, it's best to cat /sys/devices/virtual/thermal/thermal_zone${id}/type to find +the appropriate thermal zone identifier. E.g. it can be BIG for 0, MID for 1 and LITTLE for 2, +but it can be different for another device. -- GitLab