// 系统:ubuntu 14.04,显卡:支持CUDA的显卡。建议换aliyun的源!先clean软件源再update。
// 在Ubuntu 16.04上试过,配好环境变量,编译出错(把14.04上编译好的cuda和sdk复制过去也不行),把编译好的gem5-gpu复制到16.04也不行(运行时缺少libprotobuf.so.8,16.04安装的so.9)
sudo apt-get update
// 之所以采用apt-get安装驱动,是因为用下载好的驱动二进制文件安装,提示关于 X 服务的问题。因为显卡比较老,所以安装了legacy drive。
sudo apt-get install nvidia-304 // 340 375也可以,可以去Ubuntu官网查看12.04 14.04 16.04所有的软件包及其依赖
sudo apt-get install nvidia-304-dev
// 下面两个好像已经安装好
sudo apt-get install nvidia-settings
sudo apt-get install nvidia-current
// 安装开发环境,opencl,cuda
sudo apt-get install nvidia-current-dev
sudo add-apt-repository ppa:xorg-edgers/ppa
sudo apt-get update
// 一些依赖,编译SDK用!
sudo apt-get install libxext-dev libxi-dev x11proto-xext-dev libice-dev libsm-dev libxt-dev libxmu-headers libxmu-dev freeglut3-dev libcr-dev libX11-dev libglu1-mesa
// Install all of gem5's dependencies
sudo apt-get update -y
sudo apt-get install -y
build-essential
python-dev
scons
swig
zlib1g-dev
m4
libprotobuf-dev
python-protobuf
protobuf-compiler
libgoogle-perftools-dev
// 安装水银分布式版本管理
sudo apt-get install --no-install-recommends -y mercurial
// 主目录下新建水银配置文件 .hgrc,内容如下:
[ui]
username=yourName<yourEmail@Address.com>
[extensions]
mq=
# Install dependencies for gem5-gpu (CUDA benchmarks)
sudo apt-get install -y
gcc-4.6
g++-4.6
python
wget
gcc-4.4
g++-4.4
gcc-4.8
g++-4.8
# if your system is ubuntu 12.04, to install gcc-4.8 is difficult, if your system is 14.04, skip following
//REF: http://blog.csdn.net/dezhihuang/article/details/53432465
//REF: http://highlightz.blog.163.com/blog/static/23801000420141115103727888
#sudo add-apt-repository ppa:ubuntu-sdk-team/ppa
#sudo add-apt-repository ppa:ubuntu-toolchain-r/test
#setup gcc & g++,4.4 4.6 4.8 都要设置!
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.4 40
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.4 40
# setup default c compiler
sudo update-alternatives --config g++
sudo update-alternatives --config gcc
# Obtaining CUDA Toolkit and CUDA SDK,目前该模拟器只支持 CUDA3.2!
wget http://developer.download.nvidia.com/compute/cuda/3_2_prod/toolkit/cudatoolkit_3.2.16_linux_64_ubuntu10.04.run
wget http://developer.download.nvidia.com/compute/cuda/3_2_prod/sdk/gpucomputingsdk_3.2.16_linux.run
# Note: need to make sure return is pressed
sudo bash cudatoolkit_3.2.16_linux_64_ubuntu10.04.run
# Note: 如果toolkit是默认路径,就不需手动输入toolkit路径,直接回车,如果要将SDK安装到非用户主目录下,需要root权限!
bash gpucomputingsdk_3.2.16_linux.run
# edit ~/.bashrc,需保证路径值与toolkit、sdk的安装路径一致,编辑后需要重新开启一个终端,使环境变量被读取!
export CUDAHOME=/usr/local/cuda;
export PATH=$PATH:/usr/local/cuda/bin;
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/cuda/lib64:/usr/local/cuda/lib;
export LIBRARY_PATH=$LIBRARY_PATH:/home/chen/NVIDIA_GPU_Computing_SDK/C/lib;
export NVIDIA_CUDA_SDK_LOCATION=/home/chen/NVIDIA_GPU_Computing_SDK;
// shift to gcc-4.4 & g++-4.4
# WORKDIR /home/chen/NVIDIA_GPU_Computing_SDK/C/common
make
# WORKDIR /home/chen/NVIDIA_GPU_Computing_SDK/C
make
# 安装 python-pydot,用于生成拓扑结构
sudo apt-get install python-pydot
# 新建文件夹“gem5-gpu”作为GEM5-GPU-HOME,这个文件夹可以是其他名字
# WORKDIR GEM5-GPU-HOME
# Clone gem5 and gem5-patches
hg qclone http://repo.gem5.org/gem5 -p http://gem5-gpu.cs.wisc.edu/repo/gem5-patches
cd gem5/
hg update -r 11061 # 执行完这条命令后,终端提示文件变动情况: N files updated, 0 files merged, M files removed, 0 files unresolved
hg qpush -a
cd ../
# Clone GPGPU-Sim and GPGPU-Sim patches (2 separate options)
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
cd ../
# Clone gem5-gpu glue code
hg clone http://gem5-gpu.cs.wisc.edu/repo/gem5-gpu
# 现在目录结构为:
# gem5-gpu // 这是GEM5-GPU-HOME
# -gem5-gpu
# -gem5
# -gpgpu-sim
# Build, gcc-4.8 & g++-4.8 are used
cd gem5
scons -j 3 build/X86_VI_hammer_GPU/gem5.opt --default=X86 EXTRAS=../gem5-gpu/src:../gpgpu-sim/ PROTOCOL=VI_hammer GPGPU_SIM=True
# Obtaining Benchmarks,make sure benchmarks' dir be located in GEM5-GPU-HOME!
# WORKDIR GEM5-GPU-HOME
hg clone https://gem5-gpu.cs.wisc.edu/repo/benchmarks/
# 现在目录结构为:
# gem5-gpu // GEM5-GPU-HOME
# -gem5-gpu
# -gem5
# -gpgpu-sim
# -benchmarks
# Compile libcuda,gcc-4.4 & g++-4.4 are used,libcuda是benchmarks的依赖,不可跳过libcuda直接编译benchmark!
[gem5-gpu/benchmarks] cd libcuda
[gem5-gpu/benchmarks/libcuda] make
# Example of Compiling a Benchmark,指定 makefile 为 gem5-fusion!
[gem5-gpu/benchmarks] cd rodinia/backprop
[gem5-gpu/benchmarks/rodinia/backprop] make gem5-fusion
# Example of Running a Benchmark
build/X86_VI_hammer_GPU/gem5.opt ../gem5-gpu/configs/se_fusion.py -c ../benchmarks/rodinia/backprop/gem5_fusion_backprop -o 16
// 注意:在ubuntu 14.04上使用相对路径可能会出现 fatal: syscall gettid (#186) unimplemented.将命令中的相对路径改为绝对路径.
// 编译 benchmark 脚本样例:
#!/bin/bash
extra=""
if [ ! -z "$1" ]
then
extra="$1"
fi
for i in BFS BS CEDD CEDT HSTI HSTO PAD RSCD RSCT SC SSSP TQ TQH TRNS
do
cd $i
make $extra
make clean
cd ..
done
cd ..