CPU性能測試——CoreMark-pro篇


本文目的:主要介紹CoreMark-pro的移植過程,本文將CoreMark-pro編譯為riscv64架構的可執行程序,使用CoreMark-pro測試程序對Xilinx的VC707-u500devkit進行性能的測試,記錄了CoreMarK-pro工具的使用以及對其測試結果進行分析
測試環境:
PC OS: Ubuntu20.04 LTS
FPGA的CPU核: u500(ARCH=riscv64,ISA=rv64imafdc)
Kernel: Linux4.15
CoreMark: CoreMark-pro
GNU: riscv64-unknown-linux-gnu

1、CoreMark-pro簡介

  CoreMark-pro是由EEMBC提供的一項全面的高級處理器基准測試,可與經市場驗證的行業標准EEMBC-CoreMark基准一起使用並增強其功能。在CoreMark強調CPU管線的同時,CoreMark-Pro測試了整個處理器,增加了對多核技術,整數和浮點工作負載以及用於利用更大內存子系統的數據集的全面支持。EEMBC CoreMarkCoreMark-Pro共同提供了一個標准基准,涵蓋了從低端微控制器到高性能計算處理器的范圍。

1.1、與CoreMark相比

  EEMBC CoreMark-Pro基准測試包含五個流行的整數工作負載和四個流行的浮點工作負載。整數工作負載包括JPEG壓縮,ZIP壓縮,XML解析器,SHA-256安全哈希算法以及原始CoreMark的內存密集型版本。浮點工作負載包括快速傅立葉變換(FFT),從LINPACK派生的線性代數例程,Livermore循環基准的大幅改進版本以及用於評估模式的神經網絡算法。

  總之,CoreMark-Pro中的工作負載代表了各種性能特征,內存利用率和指令級並行性。該基准保證可以突出顯示任何處理器的優點和缺點。

2、獲取源碼

  EEMBC在將CoreMark-pro源碼托管在GitHub上可以訪問github.com/eembc/coremark-pro直接點擊下載獲得源碼;也可以通過git命令下載到本地。

imaginemiracle@:Download$ git clone https://github.com/eembc/coremark-pro.git
imaginemiracle@:Download$ cd coremark-pro/
imaginemiracle@:coremark-pro$ ls
benchmarks  coremarkpro.md5  docs  LICENSE.md  Makefile  Makefile.mak  mith  README.md  util  workloads

CoreMark-pro項目的詳細介紹,可以查閱當前目錄下“EEMBC Symmetric Multicore Benchmark User Guide 2.1.4.pdf”

3、移植到riscv64架構

imaginemiracle@:coremark-pro$ cd util/make
imaginemiracle@:make$ ls
armcs.mak   fakeio.mak    fdlibm.mak     gcc64.mak            gcc.mak  linux32-x86.mak  linux.mak       suite.mak
common.mak  fdlibm64.mak  gcc32-x86.mak  gcc-cross-linux.mak  icc.mak  linux64.mak      run_target.ttl

3.1、添加riscv64.mak

linux64.mak文件拷貝一份重命名為riscv64.mak

imaginemiracle@:make$ cp linux64.mak riscv64.mak
imaginemiracle@:make$ vim riscv64.mak

  將PLATFORM修改為riscv64並修改TOOLCHAINgcc64-riscv(默認已經配置好riscv64-linux-gnu工具鏈,有很多優秀的博客介紹了riscv toolchain的編譯安裝過程可以自行查閱參考):

#util/make/riscv64.mak文件

# File: util/make/riscv64.mak                                                                                                                         
# Optional specific files for specialized run and results extraction
# ==============================Alter by me============================
PLATFORM=riscv64
SHELL=/bin/bash

ifndef TOOLCHAIN
TOOLCHAIN=gcc64-riscv
# ==============================End Alter==============================
endif

# Flag: LOAD
#   Use LOAD to define command used for loading the image to the target
LOAD =

# Flag: RUN
#   Use this flag to define a command needed to run the image
#
#   Example: if you need to run the image with a simulator, set this flag to point to the simulator executable
RUN         =
# Flag: RUN
#   Use this flag to supply flags before the image name and parameters
#
#   Example: if you need want to run the image using gdb, you probably need to set this flag to --args
RUN_FLAGS   =

ifeq ($(DO_PROFILE),yes)
    RUN_FLAGS           =
    RUN = function dorun() { \
    BENCHNAME=`basename $$1 .exe` && \
    $$@ &&\
    gprof $$1 gmon.out > $(DIR_LOG)/$$BENCHNAME.gprof && \
    mv gmon.out $(DIR_LOG)/$$BENCHNAME.gmon ;\
    } && dorun 
endif

3.2、添加riscv64-unknown-linux-gnu-gcc.mak

gcc64.mak文件拷貝一份重命名為riscv64-unknown-linux-gnu-gcc.mak

imaginemiracle@:make$ cp gcc64.mak gcc64-riscv.mak
imaginemiracle@:make$ vim gcc64-riscv.mak

  將TOOLS修改為存放riscv64-toolchain的目錄,將CC修改為$(TOOLS)/bin/riscv64-unknown-linux-gnu-gccAS修改為$(TOOLS)/bin/riscv64-unknown-linux-gnu-asLD修改為$(TOOLS)/bin/riscv64-unknown-linux-gnu-gccEXE修改為rvexeAR修改為$(TOOLS)/bin/riscv64-unknown-linux-gnu-ar即可。

#  File: util/make/gcc64-riscv.mak                                                                                                                                                                                                                                                        
#   GCC Tool Definitions, Host Compile and Run, for riscv64b system
#  
#  Author: wxn <imaginemiracle.wxn@outlook.com>
#  Date  : 2021-01-01
#==============================================================================

# RUN OPTIONS SECTION
# Build or run options (i.e. profiling, simulation)

# Enable profiling with 'yes'. All other strings disable profiling.
ifndef (DO_PROFILE)
DO_PROFILE=no
endif
ifndef (DO_VALGRIND)
DO_VALGRIND=no
endif

# ARCHITECTURE SECTION
# Any specific options (i.e. cpu, fpu)

# SYSTEM ENVIRONMENT SECTION
# =================================Alter by me==================================
# Tools Root Directory
TOOLS   = /home/imaginemiracle/Disk_D/Linux_Workspace/riscv-project/freedom-u-sdk/toolchain
# ==================================End Alter===================================
# For Solaris
#TOOLS  = /usr/local
# For Solaris
# (A shell which supports [ file1 -nt file2 ] for office, consumer)
#SHELL  = /bin/bash

# Tools Executables, Output File Flag and Output File Types

# NOTE :    Spacing between option and values can be compiler dependant.
#       The following is a trick to ensure that a space follows the -o flag. 
#       Do not remove the line continuation backslash or the following blank
#       line.
#       OBJOUT = -o \

# =================================Alter by me==================================
# Variable: CC
#   name of the compiler
CC      = $(TOOLS)/bin/riscv64-unknown-linux-gnu-gcc
# Solaris: /usr/ccs/bin/as requires space after -o passed from gcc.
#OBJOUT = -o \#
OBJOUT  = -o
COBJT   = -c
CINCD   = -I
CDEFN   = -D
OEXT = .o

AS      = $(TOOLS)/bin/riscv64-unknown-linux-gnu-as

LD      = $(TOOLS)/bin/riscv64-unknown-linux-gnu-gcc
EXEOUT  = -o
EXE     = .rvexe

AR      = $(TOOLS)/bin/riscv64-unknown-linux-gnu-ar
# ==================================End Alter===================================
LIBTYPE = .a
LIBOUT  =

4、編譯生成測試程序

編譯命令:

imaginemiracle@:coremark-pro$ make TARGET=riscv64 build
#編譯成功會生成build目錄,里面存放着每個測試程序(一共9個)
imaginemiracle@:coremark-pro$ ls
benchmarks  builds  coremarkpro.md5  docs  LICENSE.md  Makefile  Makefile.mak  mith  README.md  util  workloads
imaginemiracle@:coremark-pro$ cd builds/riscv64/gcc64-riscv/bin/
imaginemiracle@:bin$ tree
.
├── cjpeg-rose7-preset.rvexe			//JPEG compreesion using 7 workers.
├── core.rvexe							//CoreMark. 
├── data
├── linear_alg-mid-100x100-sp.rvexe		//Gaussian elimination with partial pivoting on a 100x100 single-precision matrix dataset;single worker.
├── loops-all-mid-10k-sp.rvexe			//Livermore Loops kernel with a 100x100 single-precision matrix;single worker.
├── nnet_test.rvexe						//Neural net simulation;single worker.
├── parser-125k.rvexe					//XML parser with a 125k dataset;single worker.
├── radix2-big-64k.rvexe				//FFT base-2 transform with 64k dataset;single worker.
├── sha-test.rvexe						//SHA256 benchmark.
└── zip-test.rvexe						//ZIP compression benchmark.

1 directory, 9 files

可以通過file命令查看可執行程序的信息,可以看到已經成功編譯出riscv64架構的應用程序。

imaginemiracle@:bin$ file cjpeg-rose7-preset.rvexe 
cjpeg-rose7-preset.rvexe: ELF 64-bit LSB executable, UCB RISC-V, version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux-riscv64-lp64d.so.1, for GNU/Linux 3.0.0, with debug_info, not stripped

5、在目標平台測試結果

由於暫時沒有保存在目標平台的測試結果,這里通過在x86_64架構的運行結果來介紹測試命令。[注]筆者提前編譯好的x86_64架構的測試程序,編譯流程與上面類似

  運行所有九個測試(具有四個上下文),收集其輸出分數,並通過Perl腳本對其進行處理以生成最終的CoreMark-PRO分數,這將對所有九個測試運行兩次,一次使用一個上下文,一次使用用戶定義數量的上下文(在這種情況下為四個),然后在兩個配置之間生成縮放比例。可以參考文檔以獲取有關如何更改上下文和工作程序數量的說明。

imaginemiracle@:coremark-pro$ make TARGET=linux64 XCMD='-c4' certify-all

測試結果如下:

WORKLOAD RESULTS TABLE

                                                 MultiCore SingleCore           
Workload Name                                     (iter/s)   (iter/s)    Scaling
----------------------------------------------- ---------- ---------- ----------
cjpeg-rose7-preset                                  833.33     212.77       3.92
core                                                  9.73       2.48       3.92
linear_alg-mid-100x100-sp                          1041.67     268.82       3.87
loops-all-mid-10k-sp                                 34.01       8.96       3.80
nnet_test                                            39.84      11.92       3.34
parser-125k                                         100.00      27.03       3.70
radix2-big-64k                                     2732.24     735.84       3.71
sha-test                                            909.09     270.27       3.36
zip-test                                            666.67     200.00       3.33

MARK RESULTS TABLE

Mark Name                                        MultiCore SingleCore    Scaling
----------------------------------------------- ---------- ---------- ----------
CoreMark-PRO                                      26611.03    7281.15       3.65

5.1、提交測試結果

CoreMark-PRO的測試結果可提交在EEMBC平台上。打開提交頁面。注冊帳戶后,輸入分數即可,具體步驟不在此介紹。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM