由于做混合内存,需要使用nvmain来做NVM的模拟,使用gem5做全系统的仿真,两者结合使用。
gem5的安装,包括相关依赖环境的安装见我的另外一篇博客:gem5的安装、编译及运行,这里使用的是mercurial版本控制系统下载的gem5,如果使用git版本控制系统下载的gem5或者自己网上直接找的解压版,相关的操作要稍有不同。
从https://bitbucket.org/mrp5060/nvmain/get/ab9ffcd06253.zip下载nvmain,并解压。
①打开hgrc文件:vim ~/gem5/.hg/hgrc
,将以下文件内容拷贝到里面,修改相关信息(username,style,from)为自己的,信息的修改只是一种标识,不影响编译和使用,这里添加的内容,最重要的是
[extensions]
hgext.mq =
这个为hg扩充了命令,如果没有这两行,后面有的命令无法执行。
[ui]
# Set the username you will commit code with
username=Your Name
ssh = ssh -C
# Always use git diffs since they contain permission changes and rename info
[defaults]
qrefresh = --git
email = --git
diff = --git
[extensions]
# These are various extensions we find useful
# Mercurial Queues -- allows managing of changes as a series of patches
hgext.mq =
# PatchBomb -- send a series of changesets as e-mailed patches
hgext.patchbomb =
# External Diff tool (e.g. kdiff3, meld, vimdiff, etc)
hgext.extdiff =
# Fetch allows for a pull/update operation to be done with one command and automatically commits a merge changeset
hgext.fetch =
# Path to the style file for the M5 repository
# This file enforces our coding style requirements
style = /path/to/your/m5/util/style.py
[email]
method = smtp
from = Your Name <your@email.address>
[smtp]
host = your.smtp.server.here
②在gem5根目录执行:hg qinit
,如果提示*** failed to import extension style from /home/ypf/gem5/util/style.py: No module named file_types
,不用理会,不会影响后面使用
③为gem5加入nvmain的补丁:hg qimport -f ../nvmain/patches/gem5/nvmain2-gem5-10688+
,nvmain的路径根据自己的来
④应用补丁:hg qpush
执行scons EXTRAS=../nvmain ./build/X86/gem5.opt
编译。
这一步我在实际操作中出现了一些问题,浪费了很多时间,网上查了很多资料,都没有看到有遇到类似问题的(o(╯□╰)o),最终还是自己动手,丰衣足食了
① ImportError: cannot import name Transform
ImportError: cannot import name Transform:
File "/home/ypf/gem5/SConstruct", line 1255:
SConscript('src/SConscript', variant_dir = variant_path, exports = 'env')
File "/usr/lib/scons/SCons/Script/SConscript.py", line 614:
return method(*args, **kw)
File "/usr/lib/scons/SCons/Script/SConscript.py", line 551:
return _SConscript(self.fs, *files, **subst_kw)
File "/usr/lib/scons/SCons/Script/SConscript.py", line 260:
exec _file_ in call_stack[-1].globals
File "/home/ypf/gem5/build/X86/SConscript", line 422:
SConscript(joinpath(root, 'SConscript'), variant_dir=build_dir)
File "/usr/lib/scons/SCons/Script/SConscript.py", line 614:
return method(*args, **kw)
File "/usr/lib/scons/SCons/Script/SConscript.py", line 551:
return _SConscript(self.fs, *files, **subst_kw)
File "/usr/lib/scons/SCons/Script/SConscript.py", line 260:
exec _file_ in call_stack[-1].globals
File "/home/ypf/gem5/build/X86/nvmain/SConscript", line 36:
from gem5_scons import Transform
找到对应位置File "/home/ypf/gem5/build/X86/nvmain/SConscript", line 36
,如下,
from gem5_scons import Transform
就是从gem5_scons导入Transform,但是没有找到gem5_scons,好吧,自己查找下
ypf@ypf:~/gem5$ find . -name 'gem5_scons'
./site_scons/gem5_scons
将整个gem5_scons文件夹拷贝到了nvmain根目录,重新编译这个问题解决
② SyntaxError: invalid syntax
File "/home/ypf/nvmain/Simulators/gem5/NVMainMemory.py", line 78
print "Setting %s to %s" % (param_name, param_value)
^
SyntaxError: invalid syntax
这个只是一个打印语句,将对应位置这一行注释一下,问题解决
......
[ SHCC] libfdt/fdt_ro.c -> .os
[ SHCC] libfdt/fdt_rw.c -> .os
[ SHCC] libfdt/fdt_sw.c -> .os
[ SHCC] libfdt/fdt_wip.c -> .os
[ SHCC] libfdt/fdt_empty_tree.c -> .os
[ SHCC] libfdt/fdt_strerror.c -> .os
[ LINK] -> X86/gem5.opt
scons: done building targets.
执行./build/X86/gem5.opt ./configs/example/se.py -c ./tests/test-progs/hello/bin/x86/linux/hello
ypf@ypf:~/gem5$ ./build/X86/gem5.opt ./configs/example/se.py -c ./tests/test-progs/hello/bin/x86/linux/hello
gem5 Simulator System. http://gem5.org
gem5 is copyrighted software; use the --copyright option for details.
gem5 compiled Jun 25 2018 17:15:57
gem5 started Jun 25 2018 17:18:08
gem5 executing on ypf, pid 18628
command line: ./build/X86/gem5.opt ./configs/example/se.py -c ./tests/test-progs/hello/bin/x86/linux/hello
Global frequency set at 1000000000000 ticks per second
warn: DRAM device capacity (8192 Mbytes) does not match the address range assigned (512 Mbytes)
0: system.remote_gdb: listening for remote gdb on port 7000
**** REAL SIMULATION ****
info: Entering event queue @ 0. Starting simulation...
Hello world!
Exiting @ tick 5984000 because exiting with last active thread context