SPEC,全称Standard Performance Evaluation Corporation。官网为https://www.spec.org
前期准备
安装编译器
- 安装本地编译器gcc-4.9、g++-4.9以及gfortran-4.9
 
1  | 逗号左右不能有空格  | 
查看gcc的安装位置:
1  | [root@hgs ~]# which {gcc,g++,gfortran}-4.9  | 
也可以使用源码安装,具体参看通过源码安装GCC。
- 安装交叉编译工具
 
1  | apt install -y {gcc,g++,gfortran}-4.9-aarch64-linux-gnu  | 
查看安装位置:
1  | [root@hgs ~]# which aarch64-linux-gnu-{gcc,g++,gfortran}-4.9  | 
注意安装时和使用时的区别:安装时gcc在库名的开头,使用时gcc在命令的结尾。
SPEC CPU2006环境
1.下载SPEC CPU2006(目前,SPEC CPU2006需要付费下载)
2.解压
1  | [root@hgs ~]# mkdir spec2006  | 
3.执行安装脚本
1  | [root@hgs spec2006]# ./install.sh  | 
这里输入linux-suse101-i386:
1  | linux-suse101-i386  | 
修改配置文件
1  | [root@hgs spec2006]# cd config/  | 
4.设置环境变量
1  | [root@hgs spec2006]# source shrc  | 
之后,就可以使用SPEC提供的各种工具了,比如runspec等。
Integer Benchmark
整数测试
本地编译
1  | [root@hgs spec2006]# runspec -a build -c qemurio-x86.cfg -i ref --tuning=base int  | 
运行结果:
1  | Build errors: 483.xalancbmk(base)  | 
查看错误信息:
1  | FormatterToHTML.cpp:139:42: error: 'memset' was not declared in this scope  | 
原因分析:FormatterToHTML.cpp使用了string.h中的memset函数,但是在编译时找不到“memset”。因此,需要在g++中添加编译参数-include cstring。
1  | CC = /usr/bin/gcc-4.9  | 
运行
1  | [root@hgs spec2006]# runspec -a run -c qemurio-x86.cfg -i ref --tuning=base int  | 
使用ARM64交叉编译
修改配置文件中的编译器CC
1  | CC = /usr/bin/aarch64-linux-gnu-gcc-4.9  | 
Floating Point Benchmark
浮点数测试
本地编译和运行
编译
1  | [root@hgs spec2006]# runspec -a build -c qemurio-x86.cfg -i ref --tuning=base fp  | 
输出结果:
1  | Build errors: 410.bwaves(base), 416.gamess(base), 434.zeusmp(base), 435.gromacs(base), 436.cactusADM(base), 437.leslie3d(base), 447.dealII(base), 454.calculix(base), 459.GemsFDTD(base), 465.tonto(base), 481.wrf(base)  | 
错误分析:
- 410、416、434、435、436、437、454的问题为
 
1  | specmake: /usr/local/gcc42-0715-32/bin/gfortran: Command not found  | 
解决办法:安装gfortran
1  | [root@hgs spec2006]# apt install -y gfortran-4.9  | 
并修改配置文件中的FC值:
1  | FC = /usr/local/gcc42-0715-32/bin/gfortran  | 
- 447的问题比较多
 
1.xx does not name a type
1  | include/lac/block_vector.h:227:17: error: 'ptrdiff_t' does not name a type  | 
解决办法:添加编译参数-include cstddef
1  | CXX = /usr/local/bin/g++ -include cstddef  | 
2.'atof' is not a member of 'std'
1  | quadrature.cc:64:26: error: 'atof' is not a member of 'std'  | 
解决办法:添加编译参数-include cstdlib
1  | CXX = /usr/local/bin/g++ -include cstddef -include cstdlib  | 
3.'strcat' is not a member of 'std'
1  | include/lac/vector.templates.h:750:3: error: 'strcat' is not a member of 'std'  | 
解决办法:添加编译参数-include cstring
1  | CXX = /usr/local/bin/g++ -include cstddef -include cstdlib -include cstring  | 
运行
1  | [root@hgs spec2006]# runspec -a run -c qemurio-x86.cfg -i ref --tuning=base fp  | 
交叉编译
编译结果:
1  | Build errors: 435.gromacs(base), 436.cactusADM(base), 454.calculix(base), 481.wrf(base)  | 
其中,435、436、454以及481编译失败的原因为:
1  | /usr/bin/ld: xxx.o: Relocations in generic ELF (EM: 183)  | 
解决办法:安装gfortran-4.9-aarch64-linux-gnu
1  | [root@hgs spec2006]# apt install -y gfortran-4.9-aarch64-linux-gnu  | 
并修改配置文件中的FC值:
1  | FC = /usr/bin/gfortran-4.9  |