Preface
According to the manual description, the coremark score is 403, so we actually test it.
process
Add code
Get the code
https://github.com/eembc/coremark
Add header file include path
Porting interface
core_portme.h
typedef size_t ee_size_t;
Change to
typedef ee_u32 ee_size_t;
In core_portme.h, change it to
"-O0" "-O3" "-Ofast" etc.
Increase
#include <stdio.h>
Comment out
//#define NULL ((void *)0)
#define ITERATIONS 1000
This macro controls the number of loops. If the time is insufficient, increase the value.
#define CLOCKS_PER_SEC 1000
This macro specifies the unit of time.
#define HAS_PRINTF 1
Output using printf
Comment out //int ee_printf(const char *fmt, ...);
core_portme.c
accomplish
barebones_clock()
{
#error \
"You must implement a method to measure time in barebones_clock()! This function should return current time.\n"
}
Change to
barebones_clock()
{
//#error \
// "You must implement a method to measure time in barebones_clock()! This function should return current time.\n"
return SYSTICK_GetTickCounter();
}
Add header file in front
#include "definitions.h"
Comment out
//#error \
// "Call board initialization routines in portable init (if needed), in particular initialize UART!\n"
We initialize it in the main function
Since we already have printf, we don't need to add ee_printf.c, otherwise we need to implement
uart_send_char
The main function in core_main.c is changed to
coremark_main
test
Declare in Main.c
int coremark_main(int argc, char *argv[]);
Call coremark_main in the main function
-O0
-O3 executes very quickly, not enough time
Change #define ITERATIONS 1000 to
#define ITERATIONS 10000
-Ofast is the same as -O3
You can see how the level of optimization makes a huge difference in the results.
There is still a slight gap between our running score and the 403 described in the manual, which may have something to do with the compiler and optimization environment.
https://www.eembc.org/coremark/scores.php
You can check other chips for comparison.
Summarize
Coremark is relatively simple to port. This article conducts a coremark benchmark test, and it can be seen that the values are slightly different from those in the manual because of the different compiler and other environments. Compiler optimization has a great impact on the score.