欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

NVMain和Gem5环境搭建(二)

程序员文章站 2022-05-29 07:52:13
...

环境说明

由于前几天搞scala(当然主要原因是穷),就把腾讯云的学生机拿出来鼓捣鼓捣然后宝塔连进去+VSCODE SSH

 配置如下
 操作系统
Ubuntu Server 16.04.1 LTS 64位
CPU
1核
内存
2GB
公网带宽
1Mbps

这里一直有个问题,就是vscode ssh连进去由于没有sudo权限导致每次改文件都很麻烦,以往用centos倒是没有这个问题,记下来想办法解决一下。

正式开工

NVMain环境搭建

  1. 下载NVMain
    根据简书这里这里!这个网址下载已经没了。找到了百度云的链接我叫百度云

    人不能一棵树上吊死啊,赶紧找了个华科的大神这里去看看他怎么办的。
    额然后我发现是自己firefox代理和chorme设的不一样,跳一跳就出去了可以正常访问(还害我找了百度云。。)

大概长这个样子(强烈推荐用sourcetree代码管理,自从有了它每天github停不下来)
NVMain和Gem5环境搭建(二) 当然啦你要是下载那个压缩包就是这样
NVMain和Gem5环境搭建(二)
调整下路径
NVMain和Gem5环境搭建(二)

然后就是下载安装,实测腾讯云100k左右,换成国外的vps大概1m左右

sudo wget https://bitbucket.org/mrp5060/nvmain/get/9c0e87b164bc.zip -O nvmain.zip
sudo unzip nvmain.zip
sudo mv mrp5060-nvmain-9c0e87b164bc nvmain 

这样一般不会出现问题(我都没出现问题)

  1. 下载安装scons
    安装编译工具scons, scons是一个开放源码、以Python语言编码的自动化构建工具,可用来替代make编写复杂的makefile。并且scons是跨平台的,只要scons脚本写的好,可以在Linux和Windows下随意编译。
    以前从来没用过,顶多就cmake写一点点,不过硬着头皮也要上啊。

  2. 配置
    官网如下

The trace simulation can be build using scons:

$ scons --build-type=[fast|debug|prof]

Compiling with scons will automatically set 
the compile flags needed for trace-based
simulation. You can use --build-type=fast
for -O3 optimization, --build-type=debug
to add debugging symbol, or --build-type=prof
to add support for profiling the simulator.

然后兴高采烈开始安装,果不其然,直接报错

aaa@qq.com-0-5-ubuntu:/skywf_memory$ sudo scons --build-type=fast

scons: *** No SConstruct file found.
File "/usr/lib/scons/SCons/Script/Main.py", line 923, in _main
aaa@qq.com-0-5-ubuntu:/skywf_memory$ ls
benchmark  fs-image  gem5  nvmain  nvmain.zip
aaa@qq.com-0-5-ubuntu:/skywf_memory$ cd nvmain/
aaa@qq.com-0-5-ubuntu:/skywf_memory/nvmain$ sudo scons --build-type=fast

scons: *** No SConstruct file found.
File "/usr/lib/scons/SCons/Script/Main.py", line 923, in _main
aaa@qq.com-0-5-ubuntu:/skywf_memory/nvmain$ ls
mrp5060-nvmain-9c0e87b164bc
aaa@qq.com-0-5-ubuntu:/skywf_memory/nvmain$ cd mrp5060-nvmain-9c0e87b164bc/
aaa@qq.com-0-5-ubuntu:/skywf_memory/nvmain/mrp5060-nvmain-9c0e87b164bc$ ls
Banks         Endurance     MemControl   Ranks       Scripts       Tests        Utils
Config        FaultModels   NVM          README      SimInterface  traceReader  Verification
DataEncoders  include       patches      SConscript  Simulators    traceSim
Decoders      Interconnect  Prefetchers  SConstruct  src           traceWriter
aaa@qq.com-0-5-ubuntu:/skywf_memory/nvmain/mrp5060-nvmain-9c0e87b164bc$ sudo scons --build-type=fastscons: Reading SConscript files ...
ImportError: No module named gem5_scons:

瞟了一眼发现路径问题,切过去就ok了

在编译的过程中,报了如下的错误,无须紧张,这只是个小问题,是因为我们暂时还没有用到gem5,所以只需将这个报错的那一行代码注释即可.

aaa@qq.com-0-5-ubuntu:/skywf_memory/nvmain/mrp5060-nvmain-9c0e87b164bc$ sudo scons --build-type=fastscons: Reading SConscript files ...
ImportError: No module named gem5_scons:
  File "/skywf_memory/nvmain/mrp5060-nvmain-9c0e87b164bc/SConstruct", line 253:
    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 "/skywf_memory/nvmain/mrp5060-nvmain-9c0e87b164bc/build/SConscript", line 36:
    from gem5_scons import Transform

这也说的很明显,进去把那行注释掉就ok了(vim真的不好用,nano真香)

sudo nano /skywf_memory/nvmain/mrp5060-nvmain-9c0e87b164bc/build/SConscript

等安装的时候看了下这篇文章,VFS的(因为看到了.fo文件有点忘了那是啥了,之前爬qq的那个项目还用过)
这里这里这里

scons: Reading SConscript files ...
scons: done reading SConscript files.
scons: Building targets ...
scons: building associated VariantDir targets: build
[CXX] Compiling Bank Factory "BankFactory" ==> BankFactory.fo
[CXX] Compiling Bank "CachedDDR3Bank" ==> CachedDDR3Bank.fo
[CXX] Compiling Bank "DDR3Bank" ==> DDR3Bank.fo
[CXX] Compiling Data Encoder Factory "DataEncoderFactory" ==> DataEncoderFactory.fo
[CXX] Compiling Data Encoder "FlipNWrite" ==> FlipNWrite.fo
[CXX] Compiling Address Translator "DRCDecoder" ==> DRCDecoder.fo
[CXX] Compiling Address Translator Factory "DecoderFactory" ==> DecoderFactory.fo
[CXX] Compiling Address Translator "Migrator" ==> Migrator.fo
[CXX] Compiling Endurance Model "BitModel" ==> BitModel.fo
[CXX] Compiling Endurance Model "ByteModel" ==> ByteModel.fo
[CXX] Compiling Endurance Model "Normal" ==> Normal.fo
[CXX] Compiling Endurance Model "Uniform" ==> Uniform.fo
[CXX] Compiling Endurance Model Factory "EnduranceDistributionFactory" ==> EnduranceDistributionFactory.fo
[CXX] Compiling Endurance Model Factory "EnduranceModelFactory" ==> EnduranceModelFactory.fo
[CXX] Compiling Endurance Model "NullModel" ==> NullModel.fo
[CXX] Compiling Endurance Model "RowModel" ==> RowModel.fo
[CXX] Compiling Endurance Model "WordModel" ==> WordModel.fo
[CXX] Compiling Hard-Error Model "ECP" ==> ECP.fo
[CXX] Compiling Interconnect Factory "InterconnectFactory" ==> InterconnectFactory.fo
[CXX] Compiling Interconnect "OffChipBus" ==> OffChipBus.fo
[CXX] Compiling Interconnect "OnChipBus" ==> OnChipBus.fo
[CXX] Compiling Memory Controller "DRAMCache" ==> DRAMCache.fo
[CXX] Compiling Memory Controller "FCFS" ==> FCFS.fo
[CXX] Compiling Memory Controller "FRFCFS" ==> FRFCFS.fo
[CXX] Compiling Memory Controller "FRFCFS-WQF" ==> FRFCFS-WQF.fo
[CXX] Compiling Memory Controller "LH-Cache" ==> LH-Cache.fo
[CXX] Compiling Memory Controller "LO-Cache" ==> LO-Cache.fo
[CXX] Compiling Memory Controller Factory "MemoryControllerFactory" ==> MemoryControllerFactory.fo
[CXX] Compiling Memory Controller "MissMap" ==> MissMap.fo
[CXX] Compiling Memory Controller "PerfectMemory" ==> PerfectMemory.fo
[CXX] Compiling Memory Controller "PredictorDRC" ==> PredictorDRC.fo
[CXX] Compiling Source "nvmain" ==> nvmain.fo
[CXX] Compiling Source "NaivePrefetcher" ==> NaivePrefetcher.fo
[CXX] Compiling Source Factory "PrefetcherFactory" ==> PrefetcherFactory.fo
[CXX] Compiling Source "STeMS" ==> STeMS.fo
[CXX] Compiling Rank Factory "RankFactory" ==> RankFactory.fo
[CXX] Compiling Rank "StandardRank" ==> StandardRank.fo
[CXX] Compiling Simulation Interface "NullInterface" ==> NullInterface.fo
[CXX] Compiling Utility Feature "AccessPredictor" ==> AccessPredictor.fo
[CXX] Compiling Utility Feature Factory "AccessPredictorFactory" ==> AccessPredictorFactory.fo
[CXX] Compiling Utility Feature "PerfectPredictor" ==> PerfectPredictor.fo
[CXX] Compiling Utility Feature "VariablePredictor" ==> VariablePredictor.fo
[CXX] Compiling Utility Feature "CacheBank" ==> CacheBank.fo
[CXX] Compiling Utility Feature "CoinMigrator" ==> CoinMigrator.fo
[CXX] Compiling Utility Feature Factory "HookFactory" ==> HookFactory.fo
[CXX] Compiling Utility Feature "PostTrace" ==> PostTrace.fo
[CXX] Compiling Utility Feature "Visualizer" ==> Visualizer.fo
[CXX] Compiling Include Source "NVMAddress" ==> NVMAddress.fo
[CXX] Compiling Include Source "NVMDataBlock" ==> NVMDataBlock.fo
[CXX] Compiling Include Source "NVMHelpers" ==> NVMHelpers.fo
[CXX] Compiling Backend Source "AddressTranslator" ==> AddressTranslator.fo
[CXX] Compiling Backend Source "Bank" ==> Bank.fo
[CXX] Compiling Backend Source "Config" ==> Config.fo
[CXX] Compiling Backend Source "DataEncoder" ==> DataEncoder.fo
[CXX] Compiling Backend Source "Debug" ==> Debug.fo
[CXX] Compiling Backend Source "EnduranceModel" ==> EnduranceModel.fo
[CXX] Compiling Backend Source "EventQueue" ==> EventQueue.fo
[CXX] Compiling Backend Source "Interconnect" ==> Interconnect.fo
[CXX] Compiling Backend Source "MemoryController" ==> MemoryController.fo
[CXX] Compiling Backend Source "NVMObject" ==> NVMObject.fo
[CXX] Compiling Backend Source "Params" ==> Params.fo
[CXX] Compiling Backend Source "Prefetcher" ==> Prefetcher.fo
[CXX] Compiling Backend Source "Rank" ==> Rank.fo
[CXX] Compiling Backend Source "SimInterface" ==> SimInterface.fo
[CXX] Compiling Backend Source "Stats" ==> Stats.fo
[CXX] Compiling Backend Source "SubArray" ==> SubArray.fo
[CXX] Compiling Backend Source "TagGenerator" ==> TagGenerator.fo
[CXX] Compiling Backend Source "TranslationMethod" ==> TranslationMethod.fo
[CXX] Compiling Trace Reader "NVMainTraceReader" ==> NVMainTraceReader.fo
[CXX] Compiling Trace Reader "RubyTraceReader" ==> RubyTraceReader.fo
[CXX] Compiling Trace Reader "TraceLine" ==> TraceLine.fo
[CXX] Compiling Trace Reader Factory "TraceReaderFactory" ==> TraceReaderFactory.fo
[CXX] Compiling Trace main() "traceMain" ==> traceMain.fo
[CXX] Compiling Trace Writer "DRAMPower2TraceWriter" ==> DRAMPower2TraceWriter.fo
[CXX] Compiling Trace Writer "GenericTraceWriter" ==> GenericTraceWriter.fo
[CXX] Compiling Trace Writer "NVMainTraceWriter" ==> NVMainTraceWriter.fo
[CXX] Compiling Trace Writer Factory "TraceWriterFactory" ==> TraceWriterFactory.fo
[CXX] Compiling Trace Writer "VerilogTraceWriter" ==> VerilogTraceWriter.fo
[LINK] Linking Program "nvmain" ==> nvmain.fast
scons: done building targets.
  1. nvm测试
    官网给出的使用说明
Running NVMain

NVMain can be run on the command line with trace-based simulation via:

./nvmain CONFIG_FILE TRACE_FILE [Cycles [PARAM=value]]

The CONFIG_FILE is the path to the configuration file for the memory system being simulated. The TRACE_FILE is the path to the trace file with the memory requests to simulate. Cycles is optional and specifies the max number of cycles to simulate. By default the entire trace file is simulated. This is equivalent to providing "0" as the value for Cycles. Additionally, CONFIG_FILE parameters can be overriden using PARAM=value, for example, adding "MEM_CTL=FRFCFS" to the command line will override the value for MEM_CTL in the configuration file.

A various number of trace formats are supported, such as "ProtocolTrace" traces from gem5 or NVMain traces which contain the minimum amount of information needed to simulate a request. NVMain traces are recommended. Traces can be generated by running gem5 with the printtrace.config configuration file. The NVMain trace format prints the previous and new value of data being written to memory to allow for simulation of MLC NVMs and data encoding techniques which require knowing which data bits are changing.

For gem5, simulation is setup using python scripts. NVMain only patches gem5 to recognize command line options for NVMain. The example scripts provided with gem5 can be used:

configs/example/se.py - Run in SE mode configs/example/fs.py - Run in FS mode

When running gem5, the parameter --mem-type=NVMainMemory must be used to enable NVMain. The option --nvmain-config must be used to specify the NVMain configuration file. Below is an example command line:

$ gem5.fast config/example/se.py -c hello_world \ --mem-type=NVMainMemory --caches \ --l2cache --l1i_size 32kB \ --l1d_size 32kB --l2_size 2MB \ --cpu-type=detailed \ --nvmain-config=/path/to/nvmain.config
./nvmain.fast Config/PCM_ISSCC_2012_4GB.config Tests/Traces/hello_world.nvt 1000000

嗯,NVM砸门就算装好了,吃个午饭先下午还有数据库不然来不及了

相关标签: 内存