CoreMark

本文介绍了如何使用CoreMark测试工具对自研芯片进行性能评估,详细阐述了从获取源码、移植到Linux环境、编译到运行测试的全过程。在Ubuntu20.04系统上,通过修改CoreMark的配置并编译,最终在自研CPU上运行CoreMark,得到了性能测试结果。
摘要由CSDN通过智能技术生成

本文将介绍使用CoreMark测试程序对我们小组自研芯片进行性能的测试,记录了CoreMarK工具的使用以及对其测试结果进行分析
测试环境:
PC OS: Ubuntu20.04 LTS
Kernel: GNU/Linux 5.10.16.3-microsoft-standard-WSL2 x86_64
CoreMark: CoreMark v1.0

1、CoreMark简介
  CoreMark是由EEMBC(Embedded Microprocessor Benchmark Consortium)的Shay Gla-On于2009年提出的一项基准测试程序,CoreMark的主要目标是简化操作,并提供一套测试单核处理器核心的方法。测试标准是在配置参数的组合下单位时间内运行的CoreMark程序次数(单位:CoreMark/MHz),该数字值越大则说明测试的性能越好。
  目前在嵌入式CPU行业中普遍公认的性能测试指标的标准主要使用以下三种,MIPS、Dhrystone、Coremark,而CoreMark与Dhrystone一样,拥有体积小、方便移植、易于理解、免费并且显示单个数字基准分数。与Dhrystone不同的是,Dhrystone的主要部分实际上暴露了编译器优化工作负载的能力,而不是实际MCU或CPU的能力,的性能,而CoreMark具有特定的运行和报告规则,从而可以避免由于所使用的编译库不同而导致的测试结果难以比较。
 

2、获取源码

  EEMBC在将CoreMark源码托管在GitHub上可以访问github.com/eembc/coremark直接点击下载获得源码;也可以通过git命令下载到本地。

lyb@SZ-1-04532:/mnt/d/coremark$ git clone https://github.com/eembc/coremark.git
lyb@SZ-1-04532:/mnt/d/coremark$ ls
LICENSE.md  Makefile  README.md  barebones  core_list_join.c  core_main.c  core_matrix.c  core_state.c  core_util.c  coremark.exe  coremark.h  coremark.md5  cygwin  docs  freebsd  linux  macos  posix  rtems  run1.log  run2.log  simple

CoreMark项目的详细介绍,可以查阅当前目录下“coremark/docs/html/index.html”。该项目以下是当前目录的个文件介绍:

lyb@SZ-1-04532:/mnt/d/coremark$ tree
.
├── LICENSE.md
├── Makefile
├── README.md
├── barebones        --移植到裸机环境下需要修改的目录
│   ├── core_portme.c      --移植的目标平台配置信息
│   ├── core_portme.h      --计时以及板级初始化实现
│   ├── core_portme.mak    --该子目录的makefile
│   ├── cvt.c
│   └── ee_printf.c        --打印函数串口发送实现
├── core_list_join.c       --列表操作程序
├── core_main.c            --主程序
├── core_matrix.c          --矩阵运算程序
├── core_state.c           --状态机控制程序
├── core_util.c            --CRC计算程序
├── coremark.exe
├── coremark.h             --项目配置与数据结构的定义头文件
├── coremark.md5
├── cygwin    --x86 cygwin和gcc 3.4(四核,双核和单核系统)的测试代码
│   └── core_portme.mak
├── docs
│   ├── READM.md     --自述文件,CoreMark项目的基本介绍
│   ├── balance_O0_joined.png
│   ├── coremark_profile_o0_joined.png
│   └── html
│       ├── files
│       │   ├── PIC32
│       │   │   └── core_portme-mak.html
│       │   ├── core_list_join-c.html
│       │   ├── core_main-c.html
│       │   ├── core_matrix-c.html
│       │   ├── core_state-c.html
│       │   ├── core_util-c.html
│       │   ├── coremark-h.html
│       │   ├── docs
│       │   │   └── core_state.png
│       │   ├── linux
│       │   │   ├── core_portme-c.html
│       │   │   ├── core_portme-h.html
│       │   │   └── core_portme-mak.html
│       │   ├── readme-txt.html
│       │   └── release_notes-txt.html
│       ├── index
│       │   ├── BuildTargets.html
│       │   ├── Configuration.html
│       │   ├── Configurations.html
│       │   ├── Files.html
│       │   ├── Functions.html
│       │   ├── General.html
│       │   ├── General2.html
│       │   ├── Types.html
│       │   └── Variables.html
│       ├── index.html
│       ├── javascript
│       │   ├── main.js
│       │   └── searchdata.js
│       ├── search
│       │   ├── BuildTargetsP.html
│       │   ├── ConfigurationC.html
│       │   ├── ConfigurationH.html
│       │   ├── ConfigurationM.html
│       │   ├── ConfigurationS.html
│       │   ├── ConfigurationT.html
│       │   ├── ConfigurationU.html
│       │   ├── ConfigurationsH.html
│       │   ├── ConfigurationsM.html
│       │   ├── ConfigurationsS.html
│       │   ├── ConfigurationsT.html
│       │   ├── FilesC.html
│       │   ├── FilesR.html
│       │   ├── FunctionsC.html
│       │   ├── FunctionsG.html
│       │   ├── FunctionsI.html
│       │   ├── FunctionsM.html
│       │   ├── FunctionsP.html
│       │   ├── FunctionsS.html
│       │   ├── FunctionsT.html
│       │   ├── GeneralB.html
│       │   ├── GeneralC.html
│       │   ├── GeneralD.html
│       │   ├── GeneralF.html
│       │   ├── GeneralG.html
│       │   ├── GeneralH.html
│       │   ├── GeneralI.html
│       │   ├── GeneralL.html
│       │   ├── GeneralM.html
│       │   ├── GeneralO.html
│       │   ├── GeneralP.html
│       │   ├── GeneralR.html
│       │   ├── GeneralS.html
│       │   ├── GeneralT.html
│       │   ├── GeneralU.html
│       │   ├── GeneralV.html
│       │   ├── GeneralW.html
│       │   ├── NoResults.html
│       │   ├── TypesS.html
│       │   ├── VariablesC.html
│       │   ├── VariablesD.html
│       │   ├── VariablesL.html
│       │   ├── VariablesO.html
│       │   ├── VariablesP.html
│       │   ├── VariablesR.html
│       │   └── VariablesS.html
│       └── styles
│           ├── 1.css
│           ├── 2.css
│           └── main.css
├── freebsd      --以下同理,是在不同操作系统下的测试代码
│   └── core_portme.mak
├── linux
│   └── core_portme.mak
├── macos
│   └── core_portme.mak
├── posix
│   ├── core_portme.c
│   ├── core_portme.h
│   ├── core_portme.mak
│   └── core_portme_posix_overrides.h
├── rtems
│   ├── core_portme.mak
│   └── init.c
├── run1.log
├── run2.log
└── simple
    ├── core_portme.c
    ├── core_portme.h
    └── core_portme.mak

3、移植到Linux架构

[注]:若移植的平台是ARM Cortex-M系列的裸机系统,只需要修改“coremark/barebones”目录下的文件即可。

imaginemiracle@:coremark$ cp -rf linux64/ riscv64
imaginemiracle@:coremark$ vim riscv64/core_portme.mak

修改CCgcc即可:

#core_portme.mak文件

OUTFLAG= -o
# Flag: CC
#   Use this flag to define compiler to use
# ===========================Alter by me===========================
CC = gcc
# ============================End Alter============================
# Flag: CFLAGS
#   Use this flag to define compiler options. Note, you can add compiler options from the command line using XCFLAGS="other flags"
PORT_CFLAGS = -O2
FLAGS_STR = "$(PORT_CFLAGS) $(XCFLAGS) $(XLFLAGS) $(LFLAGS_END)"
CFLAGS = $(PORT_CFLAGS) -I$(PORT_DIR) -I. -DFLAGS_STR=\"$(FLAGS_STR)\"
#Flag: LFLAGS_END
#   Define any libraries needed for linking or other flags that should come at the end of the link line (e.g. linker scripts). 
#   Note: On certain platforms, the default clock_gettime implementation is supported but requires linking of librt.
LFLAGS_END += -lrt
# Flag: PORT_SRCS
# Port specific source files can be added here
PORT_SRCS = $(PORT_DIR)/core_portme.c

LOAD = echo Loading done
RUN = 

OEXT = .o
# ===========================Alter by me===========================
EXE = .rvexe
# ============================End Alter============================

4、编译生成coremark.exe

4.1、编译在单核上运行的coremark.exe

<1> 编译命令:

imaginemiracle@:coremark$ make PORT_DIR=Linux

<2> 编译结果如下,会出现错误。

仔细查看,该错误并不是编译过程发生的错误,而是在运行编译出的coremark.exe报错,答案是肯定的,编译生成coremark.exe

4、在目标平台上运行coremark.exe测试性能
下图是在我们自研CPU上CoreMark的测试结果,其中Iterations/Sec就是在跑分榜上CoreMark的值,根据该值和其它参数可以对比各微处理器的性能。

<1> 运行coremark.exe
执行命令:./coremark.exe
[注] 多核与单核coremark测试相同,直接运行coremark的可执行程序即可,下图是单核coremark的测试结果

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值