Ubuntu12.04安装gem5/M5模拟器

写论文需要模拟多核CPU调度,在其他论文里面看到有采用gem5做模拟仿真的,于是就尝试了下如何在Ubuntu 12.04 上面安装 gem5 ,详细安装过程如下:

主要的参考资料:

http://blog.sina.com.cn/s/blog_548b0a230101cagk.html

http://www.linuxidc.com/Linux/2012-09/70086.htm

External tools and required versions

To build gem5, you will need the following software:

  • g++ version 4.7 or newer or clang version 3.1 or newer.
  • Python, version 2.5 - 2.7 (we don't support Python 3.X). gem5 links in the Python interpreter, so you need the Python header files and shared library (e.g., /usr/lib/libpython2.5.so) in addition to the interpreter executable. These may or may not be installed by default. For example, on Debian/Ubuntu, you need the "python-dev" package in addition to the "python" package. If you need a newer or different Python installation but can't or don't want to upgrade the default Python on your system, see our page on using a non-default Python installation.
  • SCons, version 0.98.1 or newer. SCons is a powerful replacement for make. See here to download SCons. If you don't have administrator privileges on your machine, you can use the "scons-local" package to install scons in your m5 directory, or install SCons in your home directory using the '--prefix=' option.
  • SWIG, version 2.0.4 or newer.
  • zlib, any recent version. For Debian/Ubuntu, you will need the "zlib-dev" or "zlib1g-dev" package to get the zlib.h header file as well as the library itself.
  • m4, the macro processor.
  • protobuf, version 2.1 or newer for trace capture and playback support.

There a few utility scripts written in Perl, but Perl is not necessary to build or run the simulator.

必要的安装包(译文)

gem5:到http://www.m5sim.org/Download下载stable版本源代码包。

g++: 使用g++ 4.6以上版本,否则会出现编译无法通过!!

可以通过命令:

sudo apt-get install g++    =>安装最新g++

sudo rm /usr/bin/g++           =>删除旧的g++符号链接

sudo ln -s /usr/bin/g++-4.6 /usr/bin/g++]   =>建立新的g++符号链接

python:版本2.4或更高        =>系统自带,不用安装

在ubuntu或Debian系统下,需要安装python-dev

sudo apt-get install python-dev

SCons:版本0.98.1或更高。 ***注:我使用的是scons-local包。***

http://sourceforge.net/projects/scons/files/

也可以使用sudo apt-get install scons进行安装最新的scons

SWIG:版本3.0.7。***注意:版本太高的话,其中有个pcre包,需要Perl支持,如果不需要pcre的话,可以在配置时添加—without-pcre即可。

http://www.swig.org/

zlib:最近的版本。

http://www.zlib.net/

m4:宏处理器。

http://www.gnu.org/software/m4/

官方说明,参见:http://www.m5sim.org/Compiling_M5

protobuf: https://github.com/google/protobuf/releases/download/v2.6.1/protobuf-2.6.1.tar.bz2

假设将这些下载的文件放在用户主目录 gem5 下面。

编译gem5之前必须先安装这些必要的文件包。每个包里都有一个install文件说明了安装了方法,基本就是三部曲。

%-------------------------------------------------------------------------------%

具体的安装过程如下:[具体情况,文件包名字略有不同]

%-------------------------------------------------------------------------------%

解压gem5源文件:

bzip2 -d gem5-stable-1.tar.bz2

假设将gem5解压后的文件夹重命名为:gem5-stable

%-------------------------------------------------------------------------------%

1、安装zlib:

解压下载的压缩包:

tar -xzvf zlib-1.2.7.tar.gz

进入解压之后的文件夹 zlib-1.2.7

cd zlib-1.2.7

执行命令:

./configure

sudo make install

%-------------------------------------------------------------------------------%

2、安装SWIG:(注意最新版需要安装perl依赖,但是perl并不是必须的,可以采用如下命令进行安装!)

解压下载的压缩包:

tar -xzvf swig-3.0.7.tar.gz

进入解压后的文件夹:

cd swig-3.0.7

执行命令:

./configure  --without-pcre

make

sudo make install

%-------------------------------------------------------------------------------%

3、安装M4:

解压下载的压缩包:

tar -xzvf m4-latest.tar.gz

进入解压之后的文件夹 m4-1.4.16

cd m4-1.4.16

执行命令:

./configure

make 

sudo make install

%-------------------------------------------------------------------------------%

4、安装protobuf:

解压缩后,使用如下命令安装:

./configure

make

sudo make install

然后,修改/root/.bashrc,添加如下:

export LIBRARY_PATH=$LIBRARY_PATH:/usr/local/lib
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib // 是protobuf默认的安装路径

export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/root/gem5/protobuf-2.6.1 // 是protobuf的解压缩路径

如果不加最后一句话,那么在编译gem5的时候,会出现下面的警告:

Package protobuf was not found in the pkg-config search path.
Perhaps you should add the directory containing `protobuf.pc'
to the PKG_CONFIG_PATH environment variable
No package 'protobuf' found
Warning: pkg-config could not get protobuf flags.
接下来,应用bashrc修改:

source ~/.bashrc

%-------------------------------------------------------------------------------%

5、安装scons:

Scons的安装很简单,可以使用命令sudo apt-get install scons进行安装

%-------------------------------------------------------------------------------%

6、编译gem5:(编译过程很慢,请耐心等候)

进入gem5-stable文件夹:

cd gem5-stable

执行:

python scons.py build/<arch>/m5.<binary>

指定编译的选项,及目标文件,例如:

python scons.py build/ALPHA/m5.opt

【说明】

1、针对Debian或Ubuntu操作系统,可能会出现如下错误,只需安装python-dev即可。

错误:can't find Python.h header in ['/usr/include/python2.7']

解决:sudo apt-get install python-dev

重新执行命令,没有错误则说明编译成功。

%-------------------------------------------------------------------------------%

%-------------------------------------------------------------------------------%

测试:

se模式下执行hello测试程序。

执行命令:

build/ARM/m5.opt configs/example/se.py -c tests/test-progs/hello/bin/arm/linux/hello

部分输出:

**** REAL SIMULATION ****

info: Entering event queue @ 0.  Starting simulation...

Hello world!

%-------------------------------------------------------------------------------%

到此,安装测试成功!!

 

posted on 2015-08-25 17:14  woshibutian  阅读(642)  评论(1)    收藏  举报
努力加载评论中...

点击右上角即可分享
微信分享提示