CoreMark 是由EEMBC(Embedded Microprocessor Benchmark Consortium) 的Shay Gla-On 于2009 年提出的一项基准测试程序,CoreMark 的主要目标是简化操作,并提供一套测试多核处理器核心的方法。测试标准是在配置参数的组合下单位时间内运行的CoreMark 程序次数(单位:CoreMark/MHz ),该数字值越大则说明测试的性能越好。 操作步骤如下: 一、获取源码
[root@ecs ~]# git clone https://github.com/eembc/coremark.git
或者直接下载zip格式皆可,本次测试用的是zip格式
二、解压查看目录结构
[root@ecs coremark-main]# tree
.
├── barebones
│ ├── core_portme.c
│ ├── core_portme.h
│ ├── core_portme.mak
│ ├── cvt.c
│ └── ee_printf.c
├── core_list_join.c
├── core_main.c
├── coremark.h
├── coremark.md5
├── core_matrix.c
├── core_state.c
├── core_util.c
├── cygwin #### --x86 cygwin和gcc的测试代码
│ └── core_portme.mak
├── docs
│ ├── balance_O0_joined.png
│ ├── coremark_profile_o0_joined.png
│ ├── html
│ │ ├── files
│ │ │ ├── core_list_join-c.html
│ │ │ ├── core_main-c.html
│ │ │ ├── coremark-h.html
│ │ │ ├── core_matrix-c.html
│ │ │ ├── core_state-c.html
│ │ │ ├── core_util-c.html
│ │ │ ├── docs
│ │ │ │ └── core_state.png
│ │ │ ├── linux
│ │ │ │ ├── core_portme-c.html
│ │ │ │ ├── core_portme-h.html
│ │ │ │ └── core_portme-mak.html
│ │ │ ├── PIC32
│ │ │ │ └── core_portme-mak.html
│ │ │ ├── readme-txt.html
│ │ │ └── release_notes-txt.html
│ │ ├── index
│ │ │ ├── BuildTargets.html
│ │ │ ├── Configuration.html
│ │ │ ├── Configurations.html
│ │ │ ├── Files.html
│ │ │ ├── Functions.html
│ │ │ ├── General2.html
│ │ │ ├── General.html
│ │ │ ├── Types.html
│ │ │ └── Variables.html
│ │ ├── index.html
│ │ ├── javascript
│ │ │ ├── main.js
│ │ │ └── searchdata.js
│ │ ├── search
│ │ │ ├── BuildTargetsP.html
│ │ │ ├── ConfigurationC.html
│ │ │ ├── ConfigurationH.html
│ │ │ ├── ConfigurationM.html
│ │ │ ├── ConfigurationsH.html
│ │ │ ├── ConfigurationS.html
│ │ │ ├── ConfigurationsM.html
│ │ │ ├── ConfigurationsS.html
│ │ │ ├── ConfigurationsT.html
│ │ │ ├── ConfigurationT.html
│ │ │ ├── ConfigurationU.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
│ └── READM.md
├── freebsd
│ └── core_portme.mak
├── LICENSE.md
├── linux
│ └── core_portme.mak
├── macos
│ └── core_portme.mak
├── Makefile
├── posix
│ ├── core_portme.c
│ ├── core_portme.h
│ ├── core_portme.mak
│ └── core_portme_posix_overrides.h
├── README.md
├── rtems
│ ├── core_portme.mak
│ └── init.c
└── simple
├── core_portme.c
├── core_portme.h
└── core_portme.mak
18 directories, 105 files
[root@ecs coremark-main]#
三、编译生成coremark.exe文件
可以直接执行make 命令,默认为单线层
如果要使用多线程,可以使用如下命令:
make XCFLAGS='-g -DMULTITHREAD=N -DUSE_FORK=1' ##N为要执行的线程数
如下:
[root@ecs coremark-main]# make XCFLAGS='-g -DMULTITHREAD=1 -DUSE_FORK=1'
make XCFLAGS="-g -DMULTITHREAD=1 -DUSE_FORK=1 -DPERFORMANCE_RUN=1" load run1.log
make[1]: Entering directory `/root/coremark-main'
make port_prebuild
make[2]: Entering directory `/root/coremark-main'
make[2]: Nothing to be done for `port_prebuild'.
make[2]: Leaving directory `/root/coremark-main'
make link
make[2]: Entering directory `/root/coremark-main'
cc -O2 -Ilinux -Iposix -I. -DFLAGS_STR=\""-O2 -g -DMULTITHREAD=1 -DUSE_FORK=1 -DPERFORMANCE_RUN=1 -lrt"\" -DITERATIONS=0 -g -DMULTITHREAD=1 -DUSE_FORK=1 -DPERFORMANCE_RUN=1 core_list_join.c core_main.c core_matrix.c core_state.c core_util.c posix/core_portme.c -o ./coremark.exe -lrt
Link performed along with compile
make[2]: Leaving directory `/root/coremark-main'
make port_postbuild
make[2]: Entering directory `/root/coremark-main'
make[2]: Nothing to be done for `port_postbuild'.
make[2]: Leaving directory `/root/coremark-main'
make port_preload
make[2]: Entering directory `/root/coremark-main'
make[2]: Nothing to be done for `port_preload'.
make[2]: Leaving directory `/root/coremark-main'
echo Loading done ./coremark.exe
Loading done ./coremark.exe
make port_postload
make[2]: Entering directory `/root/coremark-main'
make[2]: Nothing to be done for `port_postload'.
make[2]: Leaving directory `/root/coremark-main'
make port_prerun
make[2]: Entering directory `/root/coremark-main'
make[2]: Nothing to be done for `port_prerun'.
make[2]: Leaving directory `/root/coremark-main'
./coremark.exe 0x0 0x0 0x66 0 7 1 2000 > ./run1.log
make port_postrun
make[2]: Entering directory `/root/coremark-main'
make[2]: Nothing to be done for `port_postrun'.
make[2]: Leaving directory `/root/coremark-main'
make[1]: Leaving directory `/root/coremark-main'
make XCFLAGS="-g -DMULTITHREAD=1 -DUSE_FORK=1 -DVALIDATION_RUN=1" load run2.log
make[1]: Entering directory `/root/coremark-main'
make port_preload
make[2]: Entering directory `/root/coremark-main'
make[2]: Nothing to be done for `port_preload'.
make[2]: Leaving directory `/root/coremark-main'
echo Loading done ./coremark.exe
Loading done ./coremark.exe
make port_postload
make[2]: Entering directory `/root/coremark-main'
make[2]: Nothing to be done for `port_postload'.
make[2]: Leaving directory `/root/coremark-main'
make port_prerun
make[2]: Entering directory `/root/coremark-main'
make[2]: Nothing to be done for `port_prerun'.
make[2]: Leaving directory `/root/coremark-main'
./coremark.exe 0x3415 0x3415 0x66 0 7 1 2000 > ./run2.log
make port_postrun
make[2]: Entering directory `/root/coremark-main'
make[2]: Nothing to be done for `port_postrun'.
make[2]: Leaving directory `/root/coremark-main'
make[1]: Leaving directory `/root/coremark-main'
Check run1.log and run2.log for results.
See README.md for run and reporting rules.
[root@ecs coremark-main]#
四、查看结果
执行完上述命令之后,该目录下会生成coremark.exe run1.log run2.logw文件:
[root@ecs coremark-main]# ll
total 240
drwxr-xr-x 2 root root 4096 Nov 18 02:50 barebones
-rw-r--r-- 1 root root 18219 Nov 18 02:50 core_list_join.c
-rw-r--r-- 1 root root 15788 Nov 18 02:50 core_main.c
-rwxr-xr-x 1 root root 69720 Dec 24 15:26 coremark.exe
-rw-r--r-- 1 root root 4759 Nov 18 02:50 coremark.h
-rw-r--r-- 1 root root 283 Nov 18 02:50 coremark.md5
-rw-r--r-- 1 root root 9598 Nov 18 02:50 core_matrix.c
-rw-r--r-- 1 root root 9707 Nov 18 02:50 core_state.c
-rw-r--r-- 1 root root 6004 Nov 18 02:50 core_util.c
drwxr-xr-x 2 root root 4096 Dec 23 12:59 cygwin
drwxr-xr-x 3 root root 4096 Nov 18 02:50 docs
drwxr-xr-x 2 root root 4096 Nov 18 02:50 freebsd
-rw-r--r-- 1 root root 18582 Nov 18 02:50 LICENSE.md
drwxr-xr-x 2 root root 4096 Nov 18 02:50 linux
drwxr-xr-x 2 root root 4096 Nov 18 02:50 macos
-rw-r--r-- 1 root root 3576 Nov 18 02:50 Makefile
drwxr-xr-x 2 root root 4096 Dec 23 13:06 posix
-rw-r--r-- 1 root root 19484 Nov 18 02:50 README.md
drwxr-xr-x 2 root root 4096 Nov 18 02:50 rtems
-rw-r--r-- 1 root root 752 Dec 24 15:27 run1.log
-rw-r--r-- 1 root root 615 Dec 24 15:27 run2.log
drwxr-xr-x 2 root root 4096 Nov 18 02:50 simple
##########################################################
查看run1.log文件
[root@ecs coremark-main]# cat run1.log
2K performance run parameters for coremark.
CoreMark Size : 666
Total ticks : 12158
Total time (secs): 12.158000
Iterations/Sec : 16450.074025 ####此为跑的分数,该值越大代表性能越好
Iterations : 200000
Compiler version : GCC4.8.5 20150623 (Red Hat 4.8.5-44)
Compiler flags : -O2 -g -DMULTITHREAD=1 -DUSE_FORK=1 -DPERFORMANCE_RUN=1 -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 : 0x4983
Correct operation validated. See README.md for run and reporting rules.
CoreMark 1.0 : 16450.074025 / GCC4.8.5 20150623 (Red Hat 4.8.5-44) -O2 -g -DMULTITHREAD=1 -DUSE_FORK=1 -DPERFORMANCE_RUN=1 -lrt / Heap
五、可以跑多次计算平均值以或得最佳性能
提供脚本如下:
# -*- coding: UTF-8 -*-
import subprocess
import numpy as np
file_path = "/root/coremark-main" ####解压后的coremark目录路径
data_list = []
def make_core():
command = "make XCFLAGS='-g -DMULTITHREAD=N -DUSE_FORK=1'" ###修改N的值
for i in range(3): ###修改range的值,代表跑多少次
res1 = subprocess.check_output("rm -rf run* coremark.exe", shell=True, cwd=file_path)
a res2 = subprocess.check_output(command, shell=True, cwd=file_path)
res3 = subprocess.check_output("sed -n 5p run1.log | awk -F [:] '{print $2}'", shell=True, cwd=file_path)
data_list.append(int(res3.split(".")[0].strip()))
return data_list
data_res = make_core()
def arr_max():
arr = data_res
arr_mean = np.mean(arr) ####获得多次的平均值
arr_std = np.std(arr) ####获得标准方差
arr_res = format(float(arr_std)/float(arr_mean) * 100,'.6f') ###获得StdDev% 值
print("arr_mean %f" % arr_mean)
print("arr_std %f" % arr_std)
print(arr_res)
if __name__=="__main__":
arr_max()
执行脚本如下:
[root@ecs ~]# python make_coremark.py
arr_mean 32236.000000 ####平均值
arr_std 341.321940 ###标准方差
1.058822 ###StdDev% 值,为1.06%
对比不同cpu 多次测试结果如下:
|