您的位置:首页 > 其它

GemFI的安装及实验

2016-03-22 09:19 330 查看

一、GemFI的安装

1、预装软件

sudo apt-get install build-essential
sudo apt-get install build-essential
sudo apt-get install flex
sudo apt-get install bison
sudo apt-get install libncurses5-dev
sudo apt-get install python-docutils
sudo apt-get install scons
sudo apt-get install swig
sudo apt-get install m4
sudo apt-get install python-dev
sudo apt-get install zlib1g
sudo apt-get install zlib1g-dev
sudo apt-get install protobuf-compiler
sudo apt-get install libprotobuf-dev


2、安装dmtcp-2.2.1和protobuf-2.5.0

在网上下载dmtcp-2.2.1和protobuf-2.5.0两个安装包,并将其放到自己的目录下,例如:/home/cyh/cyh/gemfi,然后根据一般软件的安装方法安装即可。(在这里我使用的是Ubuntu 12.04)

3、安装GemFI

1、修改文件gemfi-x86/configs/common/SysPaths.py第53行,修改为自己路径。例如:

path = [ ‘/dist/m5/system’, ‘/home/cyh/cyh/gemfi/gemfi-x86/dist’ ]

2、修改后在终端进入gemfi-x86文件夹,运行如下指令:

scons build/X86/gem5.opt


第一次安装需要等待20-30分钟左右,安装成功后会显示:

scons: done building targets.

3、编译m5term用于连接进入模拟系统。进入gemfi-x86文件夹下util子目录term,运行如下指令:

make


sudo make install


4、运行例子程序。

从终端进入到gemfi-x86目录:

cd /home/cyh/cyh/gemfi/gemfi-x86


执行下面的指令:

dmtcp_checkpoint build/X86/gem5.opt configs/example/fs.py --kernel=x86_64-vmlinux-2.6.28.4-smp -b mybench_hello


当看到“hello world”的输出时证明GemFI的安装成功了。

二、使用GemFI进行故障注入实验

1、修改hello.c文件

添加故障注入的库文件和语句

hello.c所在的目录下:

/home/cyh/cyh/gemfi/gemfi-x86/tests/test-progs/hello/src

hello.c原内容如下:

#include <stdio.h>

int main()
{
printf("hello world!\n");
return 0;
}


将hello.c修改为如下内容:

#include <m5op.h>
#include <stdio.h>

int main()
{
unsigned int id=0;
fi_activate_inst(id, START);

printf("hello world!\n");

fi_activate_inst(id, STOP);
return 0;
}


fi_activate_inst(id, START)
是用于启动故障注入,
fi_activate_inst(id, STOP)
是用于关闭故障注入。编译所需的头文件以及库文件在gemfi-x86/util/fi目录下。

2、使用gcc编译hello.c文件

在/home/cyh/cyh/gemfi/gemfi-x86/tests/test-progs/hello/src的目录下,执行下列命令:

gcc -static -o2 -L/home/cyh/cyh/gemfi/gemfi-x86/util/fi -lm5 -I/home/cyh/cyh/gemfi/gemfi-x86/util/fi -o hello hello.c /home/cyh/cyh/gemfi/gemfi-x86/util/fi/m5op_x86.S


执行结束后在该目录下可以产生hello的可执行文件

注意:

-I:显示指定头文件的所在地,告诉gcc去哪里找头文件。

-L:告诉gcc去哪里找库文件。

通常情况下,gcc默认会在程序当前目录、/lib、/usr/lib和/usr/local/lib下找对应的库。

3、将hello文件mount进磁盘中

执行下列指令:

cd /home/cyh/cyh/gemfi/gemfi-x86
sudo mount -o,loop,offset=32256 ./dist/disk /x86root.img /mnt
cd /mnt
sudo cp /home/cyh/cyh/gemfi/gemfi-x86/tests/test-progs/hello/src/hello ./


4、修改configs内的一些文件

这里主要修改/home/cyh/cyh/gemfi/gemfi-x86/configs/common这个目录下的SysPaths.py和Benchmarks.py两个文件。

将SysPaths.py文件的第53行修改为:

path = [ ‘/dist/m5/system’, ‘/home/cyh/cyh/gemfi/gemfi-x86/dist’ ]

在Benchmarks.py文件中添加benchmark,例如:

‘test_hello’: [SysConfig(‘test_hello.rcS’)],

在这里需要写自己的xxx.rcS文件,下面是我的test_hello.rcS的具体内容

# !/bin/sh/home/cyh/cyh/gemfi/gemfi-x86/configs/boot
cd test
/sbin/m5 dumpresetstats

echo ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"
echo "Running test now ..."
./hello
echo "Finish test :D"
echo ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"

/sbin/m5 exit


注意:这里的hello文件就是本文中上面所述通过gcc编译生成的可执行文件,并且该文件已经mount进磁盘中。

注意:这里我们写的xxx.rcS需要放到/home/cyh/cyh/gemfi/gemfi-x86/configs/boot这个目录下。

5、重新编译。

scons -c
scons build/X86/gem5.opt


6、运行。

dmtcp_checkpoint build/X86/gem5.opt -r -d ./fi_output/hello --debug-flags=FaultInjection configs/example/fs.py --kernel=x86_64-vmlinux-2.6.28.4-smp --caches -b test_hello


注意:

-r -d,指定文件的输出目录。

–debug-flags=FaultInjection,指定故障注入。

configs/example/fs.py,指定全系统模式。

7、查看输出文件。

程序运行结束后,查看/home/cyh/cyh/gemfi/gemfi-x86/fi_output该目录下的输出文件。

system.pc.com_1.terminal文件的部分内容:

mounting filesystems...
loading script...
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Running test now ...
hello world!
Finish test :D
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>


simout文件的部分内容:

CORE:system.cpu
Pipeline Stage   NonProtected    Protected   NOP     Other object file
Fetch    1396    0   0   0
Decode   2467    0   0   0
IEW      1820    0   0   0
MEM      505     0   0   0
Ticks : 13825453785113500
4962489605500: system.fi_system: ~===Fault Injection Deactivation Instruction===
Exiting @ tick 4963195465500 because m5_exit instruction encountered


8、生成故障注入文件。

执行下列命令:

cd /home/cyh/cyh/gemfi/gemfi-x86/util/create_exp
./generator -f 1396 -d 2467
ba04
-e 1820 -l 505


注意:这里的“-f 1396 -d 2467 -e 1820 -l 505”指的是上面我们得到的取指、译码、执行、访存的指令条数。通过上面的命令,我们可以得到四个txt文件。

上述命令的输出内容:

Fetch Instructions: 1396
Decode Instructions 2467
Execute Instructions 1820
LoadStore Instructions 505

Probability for Fetch PC fault:     0.225598
Probability for Decode fault:       0.398675
Probability for Execute fault:      0.294118
Probability for Load/Store fault:   0.081610

Total Number Of Experiments :   1780

Total Number Of Upper Bounded Experiments :     1782
Fetch faults:       402
Reg faults:         0
PC faults:      0
Decode faults:      710
Execute faults:     524
Load/Store faults:  146


在create_exp目录下将会生成Fetch.txt,Decode.txt,IEW.txt,LDS.txt四个文件。

9、单点故障注入。

这里我们用Decode作为示例。

在/home/cyh/cyh/gemfi/gemfi-x86/fi_input/hello该目录下创建input文件:

touch input


将上面生成的Decode.txt文件的最后一行拷贝到input文件中。

执行下列命令:

echo -n "RegisterDecodingInjectedFault Inst:7 Flip:30 all all 1 0 Src0:0" > input


接下来执行下列命令:

dmtcp_checkpoint build/X86/gem5.opt -r -d ./fi_output/hello1/ --debug-flags=FaultInjection configs/example/fs.py --kernel=x86_64-vmlinux-2.6.28.4-smp --caches --switch-on-fault=1 --repeat-switch=1 --checkpoint-on-fault 1 -b test_hello --fi-in fi_input/hello/input


执行结束后我们就可以通过fi_output/hello1该目录下的system.pc.com_1.terminal和simout文件来观察执行的结果。

注意:在执行结束后,/home/cyh/cyh/gemfi/gemfi-x86目录下会产生下列的这样一些文件:“ckpt_gem5.opt_2da1a61fd716c21e-40000-56efc871_files”,“decode_ckpt.dmtcp”,“dmtcp_restart_script.sh”,“dmtcp_restart_script_2da1a61fd716c21e-40000-56efc870.sh”。当我们做完实验可以将这些文件删除,因为它们占的空间比较大。

Good Luck Fern!
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: