Html:
http://blog.emake.run/CoreMark.html
Markdown:
## 将 CoreMark CPU跑分程序移植到 ESP32 上
_测试中,未针对ESP32优化, 仅供参考_
[前言]
- 衡量处理器的一个重要指标是功耗,另外一个重要指标便是性能。在处理器领域的 Benchmarks 非常众多,有某些个人开发的程序,也有某些标准组织,或者商业公司开发的Benchmarks, 本文在此不加以一一枚举。 在嵌入式处理器领域最为知名和常见的 Benchmarks 为Dhrystone 和 CoreMark。
- CoreMark是一个综合基准,用于测量嵌入式系统中使用的中央处理器(CPU)的性能。它是在2009由eembc的shay gal-on开发的,旨在成为一个行业标准,取代过时的dehrystone基准。代码用C编写,包含以下算法:列表处理(增删改查和排序)、矩阵操作(公共矩阵操作)、状态机(确定输入流是否包含有效数字)和CRC。用户可以自由的下载Coremark,并移植到自己的平台上运行,随后就可以看到分数。
[在ESP32上新建CoreMark工程]
- 拷贝hello_world例程
```bash
cp -r $IDF_PATH/examples/get-started/hello_world CoreMark
```
- clone `coremark`
```bash
cd CoreMark
git clone https://github.com/eembc/coremark.git
```
- 将测试代码拷贝出来
```bash
cd coremark
cp core_list_join.c core_main.c coremark.h core_matrix.c core_state.c core_util.c simple/core_portme.c simple/core_portme.h ../main/
cd ..
rm -rf coremark main/hello_world_main.c
```
- 修改`core_portme.c`文件
- 将`ITERATIONS`替换为你需要的迭代次数
- 38行
```c
volatile ee_s32 seed4_volatile=ITERATIONS;
```
->
```c
volatile ee_s32 seed4_volatile=10000;
```
- 修改`core_portme.h`文件
- 将`FLAGS_STR`替换为`"-Os"`
- 77行
```c
#define COMPILER_FLAGS FLAGS_STR /* "Please put compiler flags here (e.g. -o3)" */
```
->
```c
#define COMPILER_FLAGS "-Os" /* "Please put compiler flags here (e.g. -o3)" */
```
- 将`MAIN_HAS_NOARGC`宏定义为1
- 159行
```c
#define MAIN_HAS_NOARGC 0
```
->
```c
#define MAIN_HAS_NOARGC 1
```
- 修改`core_main.c`文件
- 将`main`替换为`app_main`
- 89行
```c
MAIN_RETURN_TYPE main(void) {
```
->
```c
MAIN_RETURN_TYPE app_main(void) {
```
- 将`%lu`替换为`%u`
- 287行
```c
ee_printf("CoreMark Size : %lu\n",(ee_u32)results[0].size);
```
->
```c
ee_printf("CoreMark Size : %u\n",(ee_u32)results[0].size);
```
- 288行
```c
ee_printf("Total ticks : %lu\n",(ee_u32)total_time);
```
->
```c
ee_printf("Total ticks : %u\n",(ee_u32)total_time);
```
- 303行
```c
ee_printf("Iterations : %lu\n",(ee_u32)default_num_contexts*results[0].iterations);
```
->
```c
ee_printf("Iterations : %u\n",(ee_u32)default_num_contexts*results[0].iterations);
```
- 配置`menuconfig`
```bash
make menuconfig
```
- 调整编译优化等级
`Compiler options → Optimization Level`
```bash
(X) Debug (-Og)
( ) Release (-Os)
```
->
```bash
( ) Debug (-Og)
(X) Release (-Os)
```
- 关闭`watchdog`
`Component config → ESP32-specific`
```bash
[*] Interrupt watchdog
```
->
```bash
[ ] Interrupt watchdog
```
- 调整`CPU frequency`
`Component config → ESP32-specific → CPU frequency`
```bash
( ) 80MHz
(X) 160MHz
( ) 240MHz
```
->
```bash
( ) 80MHz
( ) 160MHz
(X) 240MHz
```
- 目录树
```bash
tree -L 2
.
├── CMakeLists.txt
├── main
│ ├── CMakeLists.txt
│ ├── component.mk
│ ├── core_list_join.c
│ ├── core_main.c
│ ├── coremark.h
│ ├── core_matrix.c
│ ├── core_portme.c
│ ├── core_portme.h
│ ├── core_state.c
│ └── core_util.c
├── Makefile
├── README.md
├── sdkconfig
└── sdkconfig.old
```
- 编译下载
```bash
make -j4 flash monitor
```
[测试结果]
```bash
2K performance run parameters for coremark.
CoreMark Size : 666
Total ticks : 28190
Total time (secs): 28.190000
Iterations/Sec : 354.735722
Iterations : 10000
Compiler version : GCC5.2.0
Compiler flags : -Os
Memory location : STACK
seedcrc : 0xe9f5
[0]crclist : 0xe714
[0]crcmatrix : 0x1fd7
[0]crcstate : 0x8e3a
[0]crcfinal : 0x988c
Correct operation validated. See readme.txt for run and reporting rules.
CoreMark 1.0 : 354.735722 / GCC5.2.0 -Os / STACK
```
将 CoreMark CPU跑分程序移植到 ESP32 上
将 CoreMark CPU跑分程序移植到 ESP32 上
Last edited by Xiong Yu on Mon Nov 26, 2018 1:26 pm, edited 1 time in total.
-
- Posts: 184
- Joined: Fri Dec 15, 2017 2:45 am
Re: 将 CoreMark CPU跑分程序移植到 ESP32 上
goooood job!
Re: 将 CoreMark CPU跑分程序移植到 ESP32 上
Is there any comparison with other CPUs?
Re: 将 CoreMark CPU跑分程序移植到 ESP32 上
"https://www.eembc.org/coremark/scores.php"
This site has performance rankings for other processors.
Others have used esp32's dual core to run to 700 points.
This site has performance rankings for other processors.
Others have used esp32's dual core to run to 700 points.
Who is online
Users browsing this forum: No registered users and 133 guests