4.5.10. CPU Performance Test

4.5.10.1. Test Principles

CoreMark is a widely used benchmark program for evaluating CPU performance in embedded systems. Its core testing methodology simulates typical embedded computing tasks to assess CPU performance under common computational patterns. The test focuses on the following key elements:

  • Algorithm Selection: CoreMark employs several fundamental algorithms and operations:

    • Integer operations: including common operations such as addition, multiplication, and bitwise operations.

    • Data structures: the test includes operations on data structures such as linked lists and queues.

    • Control structures: involving basic control flows such as loops and conditional branching.

    • Matrix multiplication and basic computational tasks: used to simulate common numerical computing tasks.

  • Test Workload: The workload in the CoreMark test includes the following aspects:

    • Compute-intensive operations: for example, integer addition, multiplication, and bitwise operations.

    • Memory operations: simulating typical memory access patterns, including operations on linked lists and queues.

    • Task scheduling and control: involving complex control flows such as conditional branching and loops.

  • Test Environment: CoreMark tests are executed in an environment without interference from other processes or threads. This ensures that test results are not affected by factors such as OS scheduling or resource management, thus accurately reflecting the processor’s computational performance.

  • Performance Measurement: The performance metric used in CoreMark is the CoreMark Score, which reflects the average computational speed of the executed algorithms and tasks during the test. A higher score indicates better processor performance.

4.5.10.2. Test Preparation

1. Prolonged high-load testing may cause CPU temperature to rise, potentially triggering thermal throttling mechanisms (e.g., automatic frequency scaling), which can affect test results. Ensure the testing environment has good ventilation and proper cooling.

2. To avoid interference from other processes, it is recommended to close unnecessary background programs. You can use the top command to monitor and terminate unnecessary services.

3. Under the path app/samples/platform_samples/chip_base_test/08_cpu_performance/coremark-main, two tools have already been provided: coremark_O3_multi and coremark_O3_single, used for testing multi-core and single-core performance under O3 optimization, respectively.

If app.img has already been flashed, navigate to the following path to check:

cd /app/platform_samples/chip_base_test/08_cpu_performance/coremark-main/

root@buildroot:/app/platform_samples/chip_base_test/08_cpu_performance/coremark-main# ls
LICENSE.md  README.md  barebones         core_main.c    core_state.c  coremark.h    coremark_O3_multi   cygwin  freebsd  macos  rtems
Makefile    aarch64    core_list_join.c  core_matrix.c  core_util.c   coremark.md5  coremark_O3_single  docs    linux    posix  simple

Check CPU operating frequency and temperature: Use the hrut_somstatus command to view frequency and temperature information for CPU, GPU, BPU, and other modules:

hrut_somstatus
=====================1=====================
temperature-->
        DDR      : 54.1 (C)
        BPU      : 53.4 (C)
        CPU      : 53.5 (C)
cpu frequency-->
              min(M)    cur(M)  max(M)
        cpu0: 300       1500    1500
        cpu1: 300       1500    1500
        cpu2: 300       1500    1500
        cpu3: 300       1500    1500
        cpu4: 300       1500    1500
        cpu5: 300       1500    1500
        cpu6: 300       1500    1500
        cpu7: 300       1500    1500
bpu status information---->
              min(M)    cur(M)  max(M)  ratio
        bpu0: 500       1000    1000    0
ddr frequency information---->
              min(M)    cur(M)  max(M)
        ddr:  266       4266    4266
GPU gc8000 frequency information---->
              min(M)    cur(M)  max(M)
        gc8000:  200    1000    1000

Manually set CPU frequency: Set the CPU to run in performance mode using the following commands:

echo userspace >/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
echo 1500000 >/sys/devices/system/cpu/cpufreq/policy0/scaling_setspeed

4.5.10.3. Test Method

1. Run Single-Core Test (coremark_O3_single)

After ensuring consistency with the preparation steps, execute the command:

./coremark_O3_single

Wait for 10 seconds to obtain the following result:

2K performance run parameters for coremark.
CoreMark Size    : 666
Total ticks      : 16665
Total time (secs): 16.665000
Iterations/Sec   : 6600.660066
Iterations       : 110000
Compiler version : GCC11.3.1 20220712
Compiler flags   :  -O3 -funroll-all-loops -static --param max-inline-insns-auto=550 -DPERFORMANCE_RUN=1 -mcpu=cortex-a55  -lrt
Memory location  : Please put data memory location here
                        (e.g. code in flash, data on heap etc)
seedcrc          : 0xe9f5
[0]crclist       : 0xe714
[0]crcmatrix     : 0x1fd7
[0]crcstate      : 0x8e3a
[0]crcfinal      : 0x33ff
Correct operation validated. See README.md for run and reporting rules.
CoreMark 1.0 : 6600.660066 / GCC11.3.1 20220712  -O3 -funroll-all-loops -static --param max-inline-insns-auto=550 -DPERFORMANCE_RUN=1 -mcpu=cortex-a55  -lrt / Heap

2. Run Multi-Core Test (coremark_O3_multi)

After ensuring consistency with the preparation steps, execute the command:

./coremark_O3_multi
2K performance run parameters for coremark.
CoreMark Size    : 666
Total ticks      : 16620
Total time (secs): 16.620000
Iterations/Sec   : 52948.255114
Iterations       : 880000
Compiler version : GCC11.3.1 20220712
Compiler flags   :  -O3 -funroll-all-loops -static --param max-inline-insns-auto=550 -DPERFORMANCE_RUN=1 -mcpu=cortex-a55 -DMULTITHREAD=8 -DUSE_PTHREAD -DVALIDATION_RUN=1  -lrt -pthread  -lrt
Parallel PThreads : 8
Memory location  : Please put data memory location here
                        (e.g. code in flash, data on heap etc)
seedcrc          : 0xe9f5
[0]crclist       : 0xe714
[1]crclist       : 0xe714
[2]crclist       : 0xe714
[3]crclist       : 0xe714
[4]crclist       : 0xe714
[5]crclist       : 0xe714
[6]crclist       : 0xe714
[7]crclist       : 0xe714
[0]crcmatrix     : 0x1fd7
[1]crcmatrix     : 0x1fd7
[2]crcmatrix     : 0x1fd7
[3]crcmatrix     : 0x1fd7
[4]crcmatrix     : 0x1fd7
[5]crcmatrix     : 0x1fd7
[6]crcmatrix     : 0x1fd7
[7]crcmatrix     : 0x1fd7
[0]crcstate      : 0x8e3a
[1]crcstate      : 0x8e3a
[2]crcstate      : 0x8e3a
[3]crcstate      : 0x8e3a
[4]crcstate      : 0x8e3a
[5]crcstate      : 0x8e3a
[6]crcstate      : 0x8e3a
[7]crcstate      : 0x8e3a
[0]crcfinal      : 0x33ff
[1]crcfinal      : 0x33ff
[2]crcfinal      : 0x33ff
[3]crcfinal      : 0x33ff
[4]crcfinal      : 0x33ff
[5]crcfinal      : 0x33ff
[6]crcfinal      : 0x33ff
[7]crcfinal      : 0x33ff
Correct operation validated. See README.md for run and reporting rules.
CoreMark 1.0 : 52948.255114 / GCC11.3.1 20220712  -O3 -funroll-all-loops -static --param max-inline-insns-auto=550 -DPERFORMANCE_RUN=1 -mcpu=cortex-a55 -DMULTITHREAD=8 -DUSE_PTHREAD -DVALIDATION_RUN=1  -lrt -pthread  -lrt / Heap / 8:PThreads

Explanation of Result Parameters:

  • CoreMark Size: Indicates the code and data size of the CoreMark benchmark, in bytes. In this example, a CoreMark Size of 666 bytes refers to the total size of the CoreMark test code.

  • Total ticks: Represents the total number of CPU clock cycles used during the test. For example, 16665 means the test consumed 16665 clock cycles in total.

  • Total time (secs): Represents the total execution time of the test in seconds.

  • Iterations/Sec: Number of iterations executed per second; that is, the number of times the program runs per unit time. Here, 6600 iterations per second corresponds to the CoreMark score in the scoring formula.

  • Iterations: Total number of iterations executed during the entire test. For example, 110000 indicates that the CoreMark benchmark completed 110000 test loops in 16.665 seconds.

  • seedcrc: CRC checksums: These are Cyclic Redundancy Check (CRC) values used to verify the correctness of the test.

  • Compiler flags: Compiler flags used; in this case, -O3 and -lrt.

  • CoreMark 1.0: A summary of key information. The value 6600 is the CoreMark performance score, indicating iterations per second. A higher value indicates stronger processor performance.

4.5.10.4. Test Metrics

The following standards should be obtained when the system is idle and averaged over multiple runs. The standard CoreMark scoring formula is:

coremark_formula

  • CoreMark Iterations/Sec: The number of CoreMark benchmark iterations executed per second, typically reflecting processor performance. Higher iteration counts indicate stronger computational capability.

  • CPU Clock (MHz): The processor’s clock frequency in MHz (megahertz). It reflects the speed at which the processor operates—higher clock frequencies theoretically allow more operations per second.

  • CPU Cores: The number of processor cores. CoreMark can be tested in either single-core or multi-core mode.

Scoring Standards

  • CoreMark with O3 compilation optimization: On the x5 platform, the single-core score should reach X > 4.2.

  • CoreMark with O2 compilation optimization: On the x5 platform, the single-core score should reach X > 3.7.

Understanding the Scoring Standards

These two scoring standards (-O3 and -O2) set minimum performance expectations for the processor under different optimization levels. The significance of these scores lies in the following:

  • -O3 optimization is the highest optimization level in GCC and other compilers, employing aggressive optimization strategies to improve execution speed. The -O3 level enables many performance-enhancing features such as loop unrolling and function inlining, aiming to achieve higher computational performance.

  • -O2 optimization is a relatively conservative optimization level. Compared to -O3, -O2 does not enable some aggressive optimizations that may increase code size. Therefore, -O2 typically provides a more balanced performance while maintaining good portability.

Based on the single-core test result under -O3 optimization:
CoreMark Iterations/Sec = 6600 iterations/sec,
CPU Clock (MHz) = 1500 MHz,
CPU Cores = 1 (single-core test),
the calculation is:
CoreMark Score = 6600 / (1500 × 1) = 4.4,
which exceeds 4.2, indicating good single-core performance under this optimization level and meeting the test requirements.

Based on the multi-core test result under -O3 optimization:
CoreMark Iterations/Sec = 52948 iterations/sec,
CPU Clock (MHz) = 1500 MHz,
CPU Cores = 8 (multi-core test),
the calculation is:
CoreMark Score = 52948 / (1500 × 8) 4.41,
which also exceeds 4.2, indicating good multi-core performance under this optimization level and meeting the test requirements.

4.5.10.5. Common Issues

1. Q: How to test CoreMark metrics under -O2 and -O3 compilation optimizations for multi-core configurations?

1. A: To test multi-core CoreMark metrics under -O2 and -O3 compilation optimizations, you need to recompile the CoreMark source code by setting appropriate compilation flags to generate the desired executable. Under the path app/samples/platform_samples/chip_base_test/08_cpu_performance/coremark-main, use the following commands to recompile.

Compile single-core CoreMark with -O2 optimization:

make PORT_DIR=aarch64 XCFLAGS="-O2 -funroll-all-loops -static --param max-inline-insns-auto=550 -DPERFORMANCE_RUN=1 -mcpu=cortex-a55" REBUILD=1 run1.log

mv coremark.exe coremark_O2_single

Compile 8-core CoreMark with -O2 optimization:

make PORT_DIR=aarch64 XCFLAGS="-O2 -funroll-all-loops -static --param max-inline-insns-auto=550 -DPERFORMANCE_RUN=1 -mcpu=cortex-a55 -DMULTITHREAD=8 -DUSE_PTHREAD -DVALIDATION_RUN=1  -lrt -pthread" REBUILD=1 run2.log

mv coremark.exe coremark_O2_mutli

Compile single-core CoreMark with -O3 optimization:

make PORT_DIR=aarch64 XCFLAGS="-O3 -funroll-all-loops -static --param max-inline-insns-auto=550 -DPERFORMANCE_RUN=1 -mcpu=cortex-a55" REBUILD=1 run1.log

mv coremark.exe coremark_O3_single

Compile 8-core CoreMark with -O3 optimization:

make PORT_DIR=aarch64 XCFLAGS="-O3 -funroll-all-loops -static --param max-inline-insns-auto=550 -DPERFORMANCE_RUN=1 -mcpu=cortex-a55 -DMULTITHREAD=8 -DUSE_PTHREAD -DVALIDATION_RUN=1  -lrt -pthread" REBUILD=1 run2.log

mv coremark.exe coremark_O3_multi