What is CoreMark?
CoreMark is essentially a “tool” designed specifically for benchmarking embedded CPUs. Its goal is straightforward: to measure the computational power of the processor core without considering peripherals or operating systems, which are often seen as unnecessary distractions. Imagine you have a newly purchased MCU and want to know how fast it runs and whether it meets your project requirements—CoreMark serves as that “fitness tracker,” running a test and providing you with a score in Iterations/Sec (iterations per second) for direct comparison.
“Don’t try to fit the entire system’s performance into this; if the core performs well, other components can be a bit slower and still work fine.”
Why do we need CoreMark?
| Pain Points | Traditional Methods | CoreMark’s Solutions |
| Inconsistent benchmarks | Each vendor writes their own benchmarks, making results incomparable. | Unified source code and standardized execution rules. |
| Bulky code | Dhrystone and Linpack have thousands of lines of code, making them cumbersome to port. | Only 6 source files, totaling a few hundred lines. |
| Unreliable results | Compilers may pre-compute some operations, skewing scores. | Uses volatile variables and random seeds to enforce runtime calculations. |
| Cross-platform difficulties | Different architectures and toolchains require rewriting. | Simply modify <span>core_portme.*</span>, and porting can be completed in minutes. |
| Lack of parallel testing | Most benchmarks only run on a single core. | Supports MULTITHREAD, measuring multi-core throughput. |
In summary: If you want a lightweight, comparable, and reliable core performance evaluation, CoreMark is your best choice.
Installation & Getting Started
Linux (most common)
$ git clone https://github.com/eembc/coremark.git $ cd coremark $ make # By default, runs two sets: performance run + validation run $ cat run1.log # This is your score
- • run1.log → Performance run (Iterations/Sec)
- • run2.log → Validation run (CRC check to ensure correctness)
Want to customize the number of iterations?
$ make ITERATIONS=20 # Only run 20 times, suitable for simulators and power measurements
No make? You can compile the following files directly with gcc (remember to add <span>-DPERFORMANCE_RUN=1</span>):
gcc -O2 -o coremark.exe core_list_join.c core_main.c core_matrix.c \
core_state.c core_util.c simple/core_portme.c -DPERFORMANCE_RUN=1
./coremark.exe > run1.log
Porting to MCU
- 1. In the
<span>port</span>directory, copy an existing platform (e.g.,<span>linux</span>)mkdir my_mcu && cp -r linux/* my_mcu - 2. Modify
<span>my_mcu/core_portme.c/h/mak</span>to replace the clock and timer with your hardware implementation. - 3. Compile
make PORT_DIR=my_mcu
Tip: Ensure that the timing function returns in “ticks” and runs for more than 10 seconds, otherwise the score will not be officially recognized.
Usage Tips
| Scenario | Recommended Parameters | Purpose |
| Multi-core CPU | <span>make XCFLAGS="-DMULTITHREAD=4 -DUSE_PTHREAD -pthread"</span> |
Run 4 threads simultaneously to measure throughput. |
| Power measurement | <span>make ITERATIONS=10</span> |
Run for a short time, in conjunction with power measurement tools. |
| Validation of porting | <span>make XCFLAGS="-DPERFORMANCE_RUN=1" REBUILD=1 run1.log</span><span>make XCFLAGS="-DVALIDATION_RUN=1" REBUILD=1 run2.log</span> |
Ensure CRC is correct to prevent porting errors. |
| Large data sets | <span>make XCFLAGS="-DTOTAL_DATA_SIZE=6000"</span> |
Increase memory usage to approach real business scenarios. |
Advantages and Disadvantages of CoreMark
| Advantages | Disadvantages |
| Lightweight: Only 6 source files, a few hundred lines. | Narrow functionality: Only measures the core, does not involve peripherals or I/O. |
| Cross-platform: Can be ported with just a few lines of changes. | Sensitive to compiler optimizations: Scores can vary significantly with different -O levels. |
| Parallelizable: Supports multi-threading/multi-core. | Not suitable for high-power/high-frequency MCUs: Timing errors may be amplified. |
| Officially recognized: EEMBC standard benchmark. | Lacks graphical reporting: Requires manual data organization. |
Overall, if your goal is to quickly and reliably compare the computational power of different MCU cores, CoreMark is definitely the first choice. If you want a more comprehensive system evaluation (such as I/O, memory bandwidth), you may need to complement it with other benchmarks (like CoreMark-PRO, Dhrystone, Linpack).
Summary
- • CoreMark is a core performance benchmark designed for embedded CPUs, with concise code, easy portability, and comparable results.
- • Installation requires only
<span>make</span>, with flexible custom parameters, supporting single-core, multi-core, simulation, power measurement, and more. - • Advantages include being lightweight, cross-platform, and officially recognized, while disadvantages include only measuring the core and being sensitive to compiler optimizations.
- • It is very suitable for quickly evaluating new MCUs, comparing different compilation options, and conducting product performance presentations.
Remember, testing is not everything; true product performance also depends on power consumption, peripherals, and system integration. But with CoreMark, you can at least ensure that the “CPU core” is a solid foundation.
Project Address: https://github.com/eembc/coremark