]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - apps/arm_benchmarks.git/commitdiff
scripts/runDhrystone: set the frequency for k3 devices master
authorMinas Hambardzumyan <minas@ti.com>
Tue, 22 Mar 2022 11:27:12 +0000 (06:27 -0500)
committerMinas Hambardzumyan <minas@ti.com>
Fri, 8 Apr 2022 15:42:15 +0000 (10:42 -0500)
Current implementation of the runDhrystone script relies on
/sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_cur_freq file to get the
core frequency. This gives a frequency of 400MHz for most TI processors,
which is not the correct value. As a result, the benchmark
calculates/reports an incorrect value for DMIPS/MHz.

This update relies on `k3conf` program to get the correct frequency for
TI K3 platforms. Implemented logic relies on the frequency reported for
the first core and assumes all cores are operating at the same frequency.

Signed-off-by: Minas Hambardzumyan <minas@ti.com>
scripts/runDhrystone

index 44bbf659d2ae8f93ba64489f0917f4a183a0fd9a..1b51320e1aeb27d7696e3dbe8dede5c9b0b963e6 100755 (executable)
@@ -39,13 +39,45 @@ echo ""
 echo "Dhrystone running ..."
 echo ""
 echo "Execution time 10 seconds or longer depending on your CPU clock speed"
-if test -e /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_cur_freq; then
-CPUFREQ=`cat /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_cur_freq`
-else if test -e /proc/cpuinfo; then
-        a=(`cat /proc/cpuinfo | grep Bogo | awk '{print $3}'`)
-        b=`echo "($a+5)/10*10" | bc`
-        let CPUFREQ=b*1000
-     fi
+
+function k3conf_get_cpu_freq()
+{
+    if test -x /usr/bin/k3conf; then
+    # When available, use k3conf to find the core frequency. Output is expected in the following format,
+    # logic parses the frequency value in the first row of the printed frequncies table.
+    # |--------------------------------------------------------------------------------|
+    # | VERSION INFO                                                                   |
+    # |--------------------------------------------------------------------------------|
+    # | K3CONF | (version v0.1-45-g79f007c built Mon Nov 15 18:31:13 UTC 2021)         |
+    # | SoC    | AM64x SR1.0                                                           |
+    # | SYSFW  | ABI: 3.1 (firmware version 0x0015 '21.9.1--v2021.09a (Terrific Lla)') |
+    # |--------------------------------------------------------------------------------|
+
+    # |--------------------------------------------------------|
+    # | Processor Name | Processor State | Processor Frequency |
+    # |--------------------------------------------------------|
+    # | A53SS0_CORE_0  | DEVICE_STATE_ON | 1000000000          |
+    # | A53SS0_CORE_1  | DEVICE_STATE_ON | 1000000000          |
+    # |--------------------------------------------------------|
+        k3conf_freq=(`/usr/bin/k3conf --cpuinfo 2>&1 | grep 'Processor Frequency' -A 2 | tail -1 | awk '{ print $6}'`)
+        if [ -n "$k3conf_freq" ] && [[ $k3conf_freq =~ ^[0-9]+$ ]]; then
+            # use the value only if it is numeric
+            let CPUFREQ=k3conf_freq/1000  # CPU frequency in KHz
+        fi
+    fi
+}
+
+if  test -e /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_cur_freq; then
+    CPUFREQ=`cat /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_cur_freq`
+else
+    k3conf_get_cpu_freq
 fi
+
+if [ -z ${CPUFREQ} ] && test -e /proc/cpuinfo; then
+    a=(`cat /proc/cpuinfo | grep Bogo | awk '{print $3}'`)
+    b=`echo "($a+5)/10*10" | bc`
+    let CPUFREQ=b*1000
+fi
+
 dhrystone 200000000 $CPUFREQ
 echo ""