**
重要的事情开头就说明,路径中不要有中文,要不然会报UnicodeDecodeError : 'ascii' codec can't decode byte 0xe6 in position 10: ordinal not in range(128)
。这个错误折腾了一下午和一晚上,啊啊啊啊啊啊啊,好烦阿!!!!! 这时候就看出来一个良好的习惯是多么重要!
**
hg qclone http://repo.gem5.org/gem5 -p http://gem5-gpu.cs.wisc.edu/repo/gem5-patches
使用此命令下载源代码,执行命令的时候终端处于哪个位置,则源代码就下载到哪个位置。第一次执行这个命令的时候,会报错
'qclone' is provided by the following extension: mq, manage a stack of patches
(use 'hg help extensions' for information on enabling extensions)
,需要打开hg的扩展选项,使得终端可以识别qclone命令,添加名字以便使用update功能。在~/.hgrc文件中添加如下选项
[ui]
username = jzy
[extensions]
mq =
之后再执行命令行即可完成识别,下载源码。
下载gem5:
hg qclone http://repo.gem5.org/gem5 -p http://gem5-gpu.cs.wisc.edu/repo/gem5-patches
cd gem5/
hg update -r 11061
hg qpush -a
下载gpgpu-sim:
hg qclone http://gem5-gpu.cs.wisc.edu/repo/gpgpu-sim -p http://gem5-gpu.cs.wisc.edu/repo/gpgpu-sim-patches
cd gpgpu-sim
hg qpush -a
下载粘合代码:
hg clone http://gem5-gpu.cs.wisc.edu/repo/gem5-gpu
使用这些命令安装依赖:
apt install xutils-dev bison flex libglu1-mesa-dev doxygen graphviz python-pmw python-ply python-numpy libpng-dev
再配置cuda的环境变量。
另一个重头戏就是卸载系统自带的protobuf,重新编译安装。首先卸载:
apt remove libprotobuf-dev
which protoc
rm /usr/bin/protoc
再安装新版protobuf,下载原文件在本机上编译。先配置环境:
apt install autoconf automake libtool curl make g++ unzip
下载源代码:
git clone https://github.com/google/protobuf.git
cd protobuf
git submodule update --init --recursive
检查环境:
./autogen.sh
./configure
make
make check
sudo make install
sudo ldconfig # refresh shared library cache.
之后检查版本号,验证是否正确安装。本次实验中,首先使用3.6版发现太高了,又实验了2.7版发现太低了。最终卸载系统自带的3.0版,重新手动安装3.0.0版,最终成功编译通过。
注意,出现如下情况则说明编译的文件使用新版本的protobuf,而你使用的是旧版本的protobuf。
error This file was generated by a newer version of protoc which is
error incompatible with your Protocol Buffer headers. Please update
error your headers.
反之则是编译的文件使用的旧版本的protobuf,而你使用的是新版本的protobuf
error This file was generated by an older version of protoc which is
error incompatible with your Protocol Buffer headers. Please
error regenerate this file with a newer version of protoc.
cd gem5
scons build/X86_VI_hammer_GPU/gem5.opt --default=X86 EXTRAS=../gem5-gpu/src:../gpgpu-sim/ PROTOCOL=VI_hammer GPGPU_SIM=True -j12
编译过程中会报未定义的错,去修改源代码,gem5/build/X86_VI_hammer_GPU/proto/packet.pb.h,build/X86_VI_hammer_GPU/proto/inst.pb.h,build/X86_VI_hammer_GPU/proto/inst.pb.cc
在最顶部增加一行:#define PROTOBUF_INLINE_NOT_IN_HEADERS 0
,接下来继续编译。出现头文件缺失情况后,在系统中找到这个头文件,再直接把绝对路径加到include里面。
使用如下命令简单测试:
build/X86_VI_hammer_GPU/gem5.opt ../gem5-gpu/configs/se_fusion.py -c ../gem5-gpu/tests/test-progs/hello/bin/x86/linux/hello -o 16
输出hello word则成功。测试内存相关的选项:
build/X86_VI_hammer_GPU/gem5.opt ../gem5-gpu/configs/se_fusion.py -c ../gem5-gpu/tests/test-progs/gem5_gpu_memcpy_load/bin/x86/linux/gem5_gpu_memcpy_load -o 16
再来一波测试
build/X86_VI_hammer_GPU/gem5.opt ../gem5-gpu/configs/se_fusion.py -c ../gem5-gpu/tests/test-progs/gem5_gpu_bh/bin/x86/linux/gem5_gpu_bh -o 16
从维基百科可以获得给的测试集,需要和gem5文件夹在统一级目录下。
hg clone https://gem5-gpu.cs.wisc.edu/repo/benchmarks/
再修改环境变量为
export CUDAHOME=/cuda
export PATH=$PATH:/bin/
export NVIDIA_CUDA_SDK_LOCATION=/C
编译libcuda,期间有两次找不到头文件,直接使用绝对路径即可。两个头文件的绝对路径是一样的。
cd benchmarks/libcuda
make
编译一个测试程序,以rodinia为例:
cd rodinia/bfs
make gem5-fusion
但是因为gcc和g++版本问题,需要手动安装4.4版。
官网下载gcc4.4:https://mirrors.ustc.edu.cn/gnu/gcc/gcc-4.4.7。
官网下载gmp:https://gmplib.org/
官网下载mpfr:https://www.mpfr.org/mpfr-current/#download
官网下载mpc:http://ftp.gnu.org/gnu/mpc/
安装gmp,执行命令
cd /usr/local/gmp-6.1.2
./configure
make -j12
make check -j12
make install -j12
安装mpfr:
cd /usr/local/mpfr-4.0.2
./configure
make -j12
make check -j12
make install -j12
安装mpc:
会出现一些小问题,将/src/mul.c内的所有mpfr_fmma函数改名为mpfr_fmma_mul
cd /usr/local/mpc-1.0.1
./configure --with-gmp-include=/usr/local/include --with-gmp-lib=/usr/local/lib --with-mpfr-include=/usr/local/include --with-mpfr-lib=/usr/local/lib
make -j12
make check -j12
make install -j12
终于完成了这些配置,接下来就要安装gcc-4.8了。编译过程中出现了错误,需要
cd /usr/local/gcc-4.4.7/gcc_temp
../configure --prefix=/usr --with-gmp=/usr/local --with-mpfr=/usr/local --with-mpc=/usr/local
make -j12
make install -j12
L I B R A R Y P A T H : / N V I D I A G P U C o m p u t i n g S D K / C / l i b / u s r / l o c a l / c u d a / l i b 64 : / u s r / l o c a l / c u d a / l i b : LIBRARY_PATH:~/NVIDIA_GPU_Computing_SDK/C/lib /usr/local/cuda/lib64:/usr/local/cuda/lib: LIBRARYPATH: /NVIDIAGPUComputingSDK/C/lib/usr/local/cuda/lib64:/usr/local/cuda/lib:LD_LIBRARY_PATH