├── .gitignore
├── README.md
├── cal_GEM5_stats
├── README.md
├── cal_stats.py
├── data
│ ├── simpoint
│ │ └── graph500_s_14_e_14
│ │ │ ├── graph500_s_14_e_14_simpoint_file
│ │ │ └── graph500_s_14_e_14_weight_file
│ └── stats
│ │ ├── normal
│ │ ├── config.dot
│ │ ├── config.dot.pdf
│ │ ├── config.dot.svg
│ │ ├── config.ini
│ │ ├── config.json
│ │ ├── fs
│ │ │ ├── proc
│ │ │ │ ├── cpuinfo
│ │ │ │ └── stat
│ │ │ └── sys
│ │ │ │ └── devices
│ │ │ │ └── system
│ │ │ │ └── cpu
│ │ │ │ ├── online
│ │ │ │ └── possible
│ │ └── stats.txt
│ │ └── test
│ │ ├── 1
│ │ ├── config.dot
│ │ ├── config.dot.pdf
│ │ ├── config.dot.svg
│ │ ├── config.ini
│ │ ├── config.json
│ │ ├── fs
│ │ │ ├── proc
│ │ │ │ ├── cpuinfo
│ │ │ │ └── stat
│ │ │ └── sys
│ │ │ │ └── devices
│ │ │ │ └── system
│ │ │ │ └── cpu
│ │ │ │ ├── online
│ │ │ │ └── possible
│ │ └── stats.txt
│ │ ├── 2
│ │ ├── config.dot
│ │ ├── config.dot.pdf
│ │ ├── config.dot.svg
│ │ ├── config.ini
│ │ ├── config.json
│ │ ├── fs
│ │ │ ├── proc
│ │ │ │ ├── cpuinfo
│ │ │ │ └── stat
│ │ │ └── sys
│ │ │ │ └── devices
│ │ │ │ └── system
│ │ │ │ └── cpu
│ │ │ │ ├── online
│ │ │ │ └── possible
│ │ └── stats.txt
│ │ ├── 3
│ │ ├── config.dot
│ │ ├── config.dot.pdf
│ │ ├── config.dot.svg
│ │ ├── config.ini
│ │ ├── config.json
│ │ ├── fs
│ │ │ ├── proc
│ │ │ │ ├── cpuinfo
│ │ │ │ └── stat
│ │ │ └── sys
│ │ │ │ └── devices
│ │ │ │ └── system
│ │ │ │ └── cpu
│ │ │ │ ├── online
│ │ │ │ └── possible
│ │ └── stats.txt
│ │ ├── 4
│ │ ├── config.dot
│ │ ├── config.dot.pdf
│ │ ├── config.dot.svg
│ │ ├── config.ini
│ │ ├── config.json
│ │ ├── fs
│ │ │ ├── proc
│ │ │ │ ├── cpuinfo
│ │ │ │ └── stat
│ │ │ └── sys
│ │ │ │ └── devices
│ │ │ │ └── system
│ │ │ │ └── cpu
│ │ │ │ ├── online
│ │ │ │ └── possible
│ │ └── stats.txt
│ │ ├── 5
│ │ ├── config.dot
│ │ ├── config.dot.pdf
│ │ ├── config.dot.svg
│ │ ├── config.ini
│ │ ├── config.json
│ │ ├── fs
│ │ │ ├── proc
│ │ │ │ ├── cpuinfo
│ │ │ │ └── stat
│ │ │ └── sys
│ │ │ │ └── devices
│ │ │ │ └── system
│ │ │ │ └── cpu
│ │ │ │ ├── online
│ │ │ │ └── possible
│ │ └── stats.txt
│ │ ├── 6
│ │ ├── config.dot
│ │ ├── config.dot.pdf
│ │ ├── config.dot.svg
│ │ ├── config.ini
│ │ ├── config.json
│ │ ├── fs
│ │ │ ├── proc
│ │ │ │ ├── cpuinfo
│ │ │ │ └── stat
│ │ │ └── sys
│ │ │ │ └── devices
│ │ │ │ └── system
│ │ │ │ └── cpu
│ │ │ │ ├── online
│ │ │ │ └── possible
│ │ └── stats.txt
│ │ ├── 7
│ │ ├── config.dot
│ │ ├── config.dot.pdf
│ │ ├── config.dot.svg
│ │ ├── config.ini
│ │ ├── config.json
│ │ ├── fs
│ │ │ ├── proc
│ │ │ │ ├── cpuinfo
│ │ │ │ └── stat
│ │ │ └── sys
│ │ │ │ └── devices
│ │ │ │ └── system
│ │ │ │ └── cpu
│ │ │ │ ├── online
│ │ │ │ └── possible
│ │ └── stats.txt
│ │ ├── 8
│ │ ├── config.dot
│ │ ├── config.dot.pdf
│ │ ├── config.dot.svg
│ │ ├── config.ini
│ │ ├── config.json
│ │ ├── fs
│ │ │ ├── proc
│ │ │ │ ├── cpuinfo
│ │ │ │ └── stat
│ │ │ └── sys
│ │ │ │ └── devices
│ │ │ │ └── system
│ │ │ │ └── cpu
│ │ │ │ ├── online
│ │ │ │ └── possible
│ │ └── stats.txt
│ │ ├── 9
│ │ ├── config.dot
│ │ ├── config.dot.pdf
│ │ ├── config.dot.svg
│ │ ├── config.ini
│ │ ├── config.json
│ │ ├── fs
│ │ │ ├── proc
│ │ │ │ ├── cpuinfo
│ │ │ │ └── stat
│ │ │ └── sys
│ │ │ │ └── devices
│ │ │ │ └── system
│ │ │ │ └── cpu
│ │ │ │ ├── online
│ │ │ │ └── possible
│ │ └── stats.txt
│ │ ├── 10
│ │ ├── config.dot
│ │ ├── config.dot.pdf
│ │ ├── config.dot.svg
│ │ ├── config.ini
│ │ ├── config.json
│ │ ├── fs
│ │ │ ├── proc
│ │ │ │ ├── cpuinfo
│ │ │ │ └── stat
│ │ │ └── sys
│ │ │ │ └── devices
│ │ │ │ └── system
│ │ │ │ └── cpu
│ │ │ │ ├── online
│ │ │ │ └── possible
│ │ └── stats.txt
│ │ ├── 11
│ │ ├── config.dot
│ │ ├── config.dot.pdf
│ │ ├── config.dot.svg
│ │ ├── config.ini
│ │ ├── config.json
│ │ ├── fs
│ │ │ ├── proc
│ │ │ │ ├── cpuinfo
│ │ │ │ └── stat
│ │ │ └── sys
│ │ │ │ └── devices
│ │ │ │ └── system
│ │ │ │ └── cpu
│ │ │ │ ├── online
│ │ │ │ └── possible
│ │ └── stats.txt
│ │ ├── 12
│ │ ├── config.dot
│ │ ├── config.dot.pdf
│ │ ├── config.dot.svg
│ │ ├── config.ini
│ │ ├── config.json
│ │ ├── fs
│ │ │ ├── proc
│ │ │ │ ├── cpuinfo
│ │ │ │ └── stat
│ │ │ └── sys
│ │ │ │ └── devices
│ │ │ │ └── system
│ │ │ │ └── cpu
│ │ │ │ ├── online
│ │ │ │ └── possible
│ │ └── stats.txt
│ │ ├── 13
│ │ ├── config.dot
│ │ ├── config.dot.pdf
│ │ ├── config.dot.svg
│ │ ├── config.ini
│ │ ├── config.json
│ │ ├── fs
│ │ │ ├── proc
│ │ │ │ ├── cpuinfo
│ │ │ │ └── stat
│ │ │ └── sys
│ │ │ │ └── devices
│ │ │ │ └── system
│ │ │ │ └── cpu
│ │ │ │ ├── online
│ │ │ │ └── possible
│ │ └── stats.txt
│ │ ├── 14
│ │ ├── config.dot
│ │ ├── config.dot.pdf
│ │ ├── config.dot.svg
│ │ ├── config.ini
│ │ ├── config.json
│ │ ├── fs
│ │ │ ├── proc
│ │ │ │ ├── cpuinfo
│ │ │ │ └── stat
│ │ │ └── sys
│ │ │ │ └── devices
│ │ │ │ └── system
│ │ │ │ └── cpu
│ │ │ │ ├── online
│ │ │ │ └── possible
│ │ └── stats.txt
│ │ ├── 15
│ │ ├── config.dot
│ │ ├── config.dot.pdf
│ │ ├── config.dot.svg
│ │ ├── config.ini
│ │ ├── config.json
│ │ ├── fs
│ │ │ ├── proc
│ │ │ │ ├── cpuinfo
│ │ │ │ └── stat
│ │ │ └── sys
│ │ │ │ └── devices
│ │ │ │ └── system
│ │ │ │ └── cpu
│ │ │ │ ├── online
│ │ │ │ └── possible
│ │ └── stats.txt
│ │ ├── 16
│ │ ├── config.dot
│ │ ├── config.dot.pdf
│ │ ├── config.dot.svg
│ │ ├── config.ini
│ │ ├── config.json
│ │ ├── fs
│ │ │ ├── proc
│ │ │ │ ├── cpuinfo
│ │ │ │ └── stat
│ │ │ └── sys
│ │ │ │ └── devices
│ │ │ │ └── system
│ │ │ │ └── cpu
│ │ │ │ ├── online
│ │ │ │ └── possible
│ │ └── stats.txt
│ │ ├── 17
│ │ ├── config.dot
│ │ ├── config.dot.pdf
│ │ ├── config.dot.svg
│ │ ├── config.ini
│ │ ├── config.json
│ │ ├── fs
│ │ │ ├── proc
│ │ │ │ ├── cpuinfo
│ │ │ │ └── stat
│ │ │ └── sys
│ │ │ │ └── devices
│ │ │ │ └── system
│ │ │ │ └── cpu
│ │ │ │ ├── online
│ │ │ │ └── possible
│ │ └── stats.txt
│ │ ├── 18
│ │ ├── config.dot
│ │ ├── config.dot.pdf
│ │ ├── config.dot.svg
│ │ ├── config.ini
│ │ ├── config.json
│ │ ├── fs
│ │ │ ├── proc
│ │ │ │ ├── cpuinfo
│ │ │ │ └── stat
│ │ │ └── sys
│ │ │ │ └── devices
│ │ │ │ └── system
│ │ │ │ └── cpu
│ │ │ │ ├── online
│ │ │ │ └── possible
│ │ └── stats.txt
│ │ ├── 19
│ │ ├── config.dot
│ │ ├── config.dot.pdf
│ │ ├── config.dot.svg
│ │ ├── config.ini
│ │ ├── config.json
│ │ ├── fs
│ │ │ ├── proc
│ │ │ │ ├── cpuinfo
│ │ │ │ └── stat
│ │ │ └── sys
│ │ │ │ └── devices
│ │ │ │ └── system
│ │ │ │ └── cpu
│ │ │ │ ├── online
│ │ │ │ └── possible
│ │ └── stats.txt
│ │ ├── 20
│ │ ├── config.dot
│ │ ├── config.dot.pdf
│ │ ├── config.dot.svg
│ │ ├── config.ini
│ │ ├── config.json
│ │ ├── fs
│ │ │ ├── proc
│ │ │ │ ├── cpuinfo
│ │ │ │ └── stat
│ │ │ └── sys
│ │ │ │ └── devices
│ │ │ │ └── system
│ │ │ │ └── cpu
│ │ │ │ ├── online
│ │ │ │ └── possible
│ │ └── stats.txt
│ │ ├── 21
│ │ ├── config.dot
│ │ ├── config.dot.pdf
│ │ ├── config.dot.svg
│ │ ├── config.ini
│ │ ├── config.json
│ │ ├── fs
│ │ │ ├── proc
│ │ │ │ ├── cpuinfo
│ │ │ │ └── stat
│ │ │ └── sys
│ │ │ │ └── devices
│ │ │ │ └── system
│ │ │ │ └── cpu
│ │ │ │ ├── online
│ │ │ │ └── possible
│ │ └── stats.txt
│ │ ├── 22
│ │ ├── config.dot
│ │ ├── config.dot.pdf
│ │ ├── config.dot.svg
│ │ ├── config.ini
│ │ ├── config.json
│ │ ├── fs
│ │ │ ├── proc
│ │ │ │ ├── cpuinfo
│ │ │ │ └── stat
│ │ │ └── sys
│ │ │ │ └── devices
│ │ │ │ └── system
│ │ │ │ └── cpu
│ │ │ │ ├── online
│ │ │ │ └── possible
│ │ └── stats.txt
│ │ ├── 23
│ │ ├── config.dot
│ │ ├── config.dot.pdf
│ │ ├── config.dot.svg
│ │ ├── config.ini
│ │ ├── config.json
│ │ ├── fs
│ │ │ ├── proc
│ │ │ │ ├── cpuinfo
│ │ │ │ └── stat
│ │ │ └── sys
│ │ │ │ └── devices
│ │ │ │ └── system
│ │ │ │ └── cpu
│ │ │ │ ├── online
│ │ │ │ └── possible
│ │ └── stats.txt
│ │ ├── 24
│ │ ├── config.dot
│ │ ├── config.dot.pdf
│ │ ├── config.dot.svg
│ │ ├── config.ini
│ │ ├── config.json
│ │ ├── fs
│ │ │ ├── proc
│ │ │ │ ├── cpuinfo
│ │ │ │ └── stat
│ │ │ └── sys
│ │ │ │ └── devices
│ │ │ │ └── system
│ │ │ │ └── cpu
│ │ │ │ ├── online
│ │ │ │ └── possible
│ │ └── stats.txt
│ │ └── 25
│ │ ├── config.dot
│ │ ├── config.dot.pdf
│ │ ├── config.dot.svg
│ │ ├── config.ini
│ │ ├── config.json
│ │ ├── fs
│ │ ├── proc
│ │ │ ├── cpuinfo
│ │ │ └── stat
│ │ └── sys
│ │ │ └── devices
│ │ │ └── system
│ │ │ └── cpu
│ │ │ ├── online
│ │ │ └── possible
│ │ └── stats.txt
├── get_stats.sh
└── tools
│ ├── configs.py
│ └── utils.py
├── docs
├── README.md
├── makefile
│ └── makefile.md
└── python
│ └── python.md
├── paper
├── GEM5_tutorial
│ ├── ASPLOS2017_gem5_tutorial.pdf
│ ├── MB2020-HiPEAC_20201-gem5-sve-hands-on.pdf
│ └── gem5_tutorial.pdf
├── README.md
└── misc
│ ├── Continuous_Runahead.md
│ ├── Continus_Runahead_MICRO.pdf
│ └── The_Accelerator_Wall_HPCA.pdf
├── report
├── README.md
├── Simpoint
│ ├── Simpoint_record.md
│ └── Simpoint_record.pdf
├── Testbench
│ ├── GAP.md
│ ├── Graph500.md
│ └── SPEC17_and_Simpoint.md
└── gem5
│ ├── apl_test_report_spmv.md
│ ├── doc_zhanglucheng_Full_System实验记录.md
│ ├── gem5_FS_arm_linux.md
│ ├── gem5_arm_time_test.md
│ ├── gem5_checkpoint.md
│ └── gem5_checkpoint_test.md
└── simpoint_GEM5
├── README.md
├── configs
├── configs_example.sh
└── configs_graph500.sh
├── process
├── process_normal.sh
├── process_reload.sh
└── process_sim.sh
├── process_all_tests.py
└── sim
├── sim_O3.sh
├── sim_generate_checkpoint.sh
├── sim_generate_sim_weight.sh
├── sim_init.sh
└── sim_reload.sh
/.gitignore:
--------------------------------------------------------------------------------
1 | **/__pycache__
2 | .vscode
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | ## 介绍
2 | + 这个仓库存的是在学习计算机体系结构时的学习资料以及写的代码,目录结构如下:
3 |
4 | ```
5 | ├─cal_GEM5_stats
6 | │ ├─data
7 | │ └─tools
8 | ├─docs
9 | │ ├─makefile
10 | │ └─python
11 | ├─paper
12 | │ ├─GEM5_tutorial
13 | │ └─misc
14 | ├─report
15 | │ ├─gem5
16 | │ ├─Simpoint
17 | │ └─Testbench
18 | └─simpoint_GEM5
19 | ├─configs
20 | ├─process
21 | └─sim
22 | ```
23 |
24 | ### cal_GEM5_stats
25 | + 从 GEM5 的统计文件中自动读取并计算 IPC 等信息的自动化脚本.
26 |
27 | ### docs
28 | + 写代码时的技巧,让代码更加优雅.
29 |
30 | ### paper
31 | + 存有论文以及论文阅读笔记.
32 |
33 | ### report:
34 | + 做实验时留下的记录,方便未来复现.
35 |
36 | ### simpoint_GEM5
37 | + 便于在 GEM5 内使用 simpoint 的自动化脚本.
38 | + 可以加速 GEM5 的模拟,在测试中可以将十数小时的程序在 60s 左右完成.
--------------------------------------------------------------------------------
/cal_GEM5_stats/README.md:
--------------------------------------------------------------------------------
1 | ## 测试配置
2 | + Python 3.8.10
3 |
4 | ### 使用说明
5 | + 核心程序为 `cal_stats.py` ,该程序使用说明如下:
6 | ```
7 | usage: cal_stats.py [-h] [-c] [-r] [-n]
8 |
9 | A tool for calculate stats for GEM5
10 |
11 | optional arguments:
12 | -h, --help show this help message and exit
13 | -c, --compare use compare method to calculate error rate
14 | -r, --reload calculate reload stats
15 | -n, --normal calculate normal stats
16 | ```
17 | + normal 模式为抽取并计算正常情况(即无 checkpoint 的情况)下 GEM5 的部分参数信息.
18 | + reload 模式为抽取并计算采用 Simpoint 重载后 GEM5 的部分参数信息,建议配合 simpoint_GEM5 一起使用.
19 | + compare 模式为比较 normal 和 reload 的误差.
20 |
21 | ### 示例步骤
22 | 1. 更改 get_stats.sh 中的路径,将数据读入文件夹中,运行命令:
23 | ```bash
24 | bash get_stats.sh
25 | ```
26 | 注:这里的 get_stats.sh 是配套 simpoint_GEM5 里结果使用的,对于其他结果需要自己根据需求调整.
27 | 2. 修改 cal_stats.py 中的 sim_name,运行命令:
28 | ```bash
29 | python cal_stats.py -c
30 | ```
31 | 此命令是进行比较,不更新数据采用默认数据输出结果如下:
32 | ```
33 | Simpoint results are:
34 | IPC = 1.6477541695712086
35 | Dcache miss rate = 0.07962523778881567
36 | Predict incorrect rate = 0.016028486480200825
37 |
38 | Normal results are:
39 | IPC = 1.617784874066762
40 | Dcache miss rate = 0.07957689978578111
41 | Predict incorrect rate = 0.015927835343287462
42 |
43 | Errors are:
44 | IPC : 1.852489535837374 %
45 | Dcache miss : 0.06074376252992806 %
46 | Predict incorrect : 0.6319197476873759 %
47 | ```
48 | 发现使用 Simpoint 的结果(即文件夹中的样例)非常准确.
49 |
50 | ### 拓展
51 | + 程序可拓展性非常强,更改或增加 configs.py 以及 cal_stats.py 中的变量即可算出对应的不同参数.
--------------------------------------------------------------------------------
/cal_GEM5_stats/cal_stats.py:
--------------------------------------------------------------------------------
1 | import os
2 | import numpy as np
3 | import argparse
4 | import tools.configs
5 | import tools.utils
6 |
7 | # simpoint 文件对应的前缀,如不是使用 simpoint_GEM5 生成的则需要更改后面的 weight_route 与 sim_route
8 | sim_name='graph500_s_14_e_14'
9 |
10 | # 测试用的 CPU 是 2.5GHz 的,这个会被用来算 IPC. stats.txt 里的数据有问题,要自己手动设置
11 | freq=2.5e9
12 |
13 | normal_name='normal'
14 | checkpoint_name='test'
15 |
16 | route=f"./data/stats/{checkpoint_name}"
17 | route_normal=f"./data/stats/{normal_name}"
18 | weight_route=f"./data/simpoint/{sim_name}/{sim_name}_weight_file"
19 | sim_route=f"./data/simpoint/{sim_name}/{sim_name}_simpoint_file"
20 |
21 | IPC_nomral=IPC_sim=0
22 | Dcache_miss_normal=Dcache_miss_sim=0
23 | Pred_incorrect_normal=Pred_incorrect_sim=0
24 | ROB_stall_normal=ROB_stall_sim=0
25 |
26 | def cal_sim():
27 | dir=[]
28 | res=[]
29 | # stats_name = 'stats.txt'
30 | stats_name=tools.configs.stats_name
31 | # start_sym = '---------- Begin Simulation Statistics ----------'
32 | start_sym=tools.configs.start_sym
33 | # paras_sym 感兴趣的数据对应的关键词集合
34 | paras_sym=tools.configs.paras_sym
35 | # 用来记录那些数据的数组,大小为 len(paras_sym)
36 | paras=tools.configs.paras
37 | weight=tools.utils.read_weight_file(weight_route,sim_route)
38 |
39 | # 在并行执行reload时生成的文件夹可能不是顺序的,这个时候 os.walk 遍历就会出问题,解决方法是用 dir 记录每次访问的文件夹序号.
40 | for root,subdir,file in os.walk(route):
41 | if root == route:
42 | for i in subdir:
43 | dir.append(i)
44 | for subfile in file:
45 | #print(subfile)
46 | if subfile == stats_name:
47 | #print('yes')
48 | #print(root+'/'+subfile)
49 | fp=open(root+'/'+subfile)
50 | res.append(fp.readlines())
51 |
52 | num=0
53 |
54 | for stats in res:
55 | tot=-1
56 | for line in stats:
57 | if start_sym in line:
58 | tot+=1
59 | # 第一遍预热的数据不需要,所以等到tot==1(即第二遍访问到begin simulation的时候)才开始统计
60 | if tot == 1:
61 | for i in range(len(paras_sym)):
62 | flag,para=tools.utils.fin(paras_sym[i],line)
63 | if flag == True:
64 | # i == 0 对应 freq ,这个是不变的
65 | if i == 0:
66 | paras[i]=para
67 | else:
68 | # 下面更改使得可以适应不同的顺序
69 | paras[i]+=para*weight[int(dir[num])-1]
70 | num+=1
71 |
72 | # for i in range(len(paras_sym)):
73 | # print(paras_sym[i],paras[i])
74 |
75 | # 2.5GHz 的 IPC , GEM5 里统计的 freq 有问题
76 | IPC_sim=paras[1]/(freq*paras[2])
77 | Dcache_miss_sim=paras[4]/(paras[3]+paras[4])
78 | Pred_incorrect_sim=paras[6]/paras[5]
79 | ROB_stall_sim=paras[7]/paras[8]
80 | print()
81 | print("Simpoint results are:")
82 | print("IPC =",IPC_sim)
83 | print("Dcache miss rate =",Dcache_miss_sim)
84 | print("Predict incorrect rate =",Pred_incorrect_sim)
85 | #print("ROB stall rate =",ROB_stall_sim)
86 |
87 | return IPC_sim,Dcache_miss_sim,Pred_incorrect_sim,ROB_stall_sim
88 |
89 | def cal_normal():
90 | dir=[]
91 | res=[]
92 | stats_name=tools.configs.stats_name
93 | paras_sym=tools.configs.paras_sym_nor
94 | paras=tools.configs.paras_nor
95 | for root,subdir,file in os.walk(route_normal):
96 | #print(root,subdir,file)
97 | if root == route:
98 | for i in subdir:
99 | dir.append(i)
100 | for subfile in file:
101 | #print(subfile)
102 | if subfile == stats_name:
103 | #print('yes')
104 | fp=open(root+'/'+subfile)
105 | res.append(fp.readlines())
106 |
107 | for stats in res:
108 | for line in stats:
109 | for i in range(len(paras_sym)):
110 | flag,para=tools.utils.fin(paras_sym[i],line)
111 | if flag == True:
112 | paras[i]=para
113 |
114 | #for i in range(len(paras_sym)):
115 | #print(paras_sym[i],paras[i])
116 |
117 | IPC_nomral=paras[1]/(freq*paras[2])
118 | Dcache_miss_normal=paras[4]/(paras[3]+paras[4])
119 | Pred_incorrect_normal=paras[6]/paras[5]
120 | ROB_stall_normal=paras[7]/paras[8]
121 | print()
122 | print("Normal results are:")
123 | print("IPC =",IPC_nomral)
124 | print("Dcache miss rate =",Dcache_miss_normal)
125 | print("Predict incorrect rate =",Pred_incorrect_normal)
126 | #print("ROB stall rate =",ROB_stall_normal)
127 |
128 | return IPC_nomral,Dcache_miss_normal,Pred_incorrect_normal,ROB_stall_normal
129 |
130 | def disp_error():
131 | def cal_error(a,b):
132 | return abs(a-b)/b
133 |
134 | print()
135 | print("Errors are:")
136 | print("IPC :",cal_error(IPC_sim,IPC_nomral)*100,'%')
137 | print("Dcache miss :",cal_error(Dcache_miss_sim,Dcache_miss_normal)*100,'%')
138 | print("Predict incorrect :",cal_error(Pred_incorrect_sim,Pred_incorrect_normal)*100,'%')
139 | #print("ROB stall:",cal_error(ROB_stall_sim,ROB_stall_normal)*100,'%')
140 |
141 | parser=argparse.ArgumentParser(description="A tool for calculate stats for GEM5")
142 | parser.add_argument("-c","--compare",help="use compare method to calculate error rate",
143 | action="store_true")
144 | parser.add_argument("-r","--reload",help="calculate reload stats",
145 | action="store_true")
146 | parser.add_argument("-n","--normal",help="calculate normal stats",
147 | action="store_true")
148 | args=parser.parse_args()
149 |
150 | if __name__=="__main__":
151 | if args.compare:
152 | IPC_sim,Dcache_miss_sim,Pred_incorrect_sim,ROB_stall_sim=cal_sim()
153 | IPC_nomral,Dcache_miss_normal,Pred_incorrect_normal,ROB_stall_normal=cal_normal()
154 | disp_error()
155 | elif args.reload:
156 | cal_sim()
157 | elif args.normal:
158 | cal_normal()
159 | else:
160 | print("Please use -h to get help.")
161 |
--------------------------------------------------------------------------------
/cal_GEM5_stats/data/simpoint/graph500_s_14_e_14/graph500_s_14_e_14_simpoint_file:
--------------------------------------------------------------------------------
1 | 155 0
2 | 420 1
3 | 197 2
4 | 229 3
5 | 0 4
6 | 144 5
7 | 342 6
8 | 29 7
9 | 368 8
10 | 237 9
11 | 329 10
12 | 436 11
13 | 439 12
14 | 75 13
15 | 327 14
16 | 376 15
17 | 253 16
18 | 142 17
19 | 419 18
20 | 428 19
21 | 161 20
22 | 399 21
23 | 140 22
24 | 302 23
25 | 141 24
26 |
--------------------------------------------------------------------------------
/cal_GEM5_stats/data/simpoint/graph500_s_14_e_14/graph500_s_14_e_14_weight_file:
--------------------------------------------------------------------------------
1 | 0.0340136 0
2 | 0.0385488 1
3 | 0.031746 2
4 | 0.210884 3
5 | 0.00226757 4
6 | 0.00453515 5
7 | 0.015873 6
8 | 0.0793651 7
9 | 0.0272109 8
10 | 0.0249433 9
11 | 0.0181406 10
12 | 0.00907029 11
13 | 0.0839002 12
14 | 0.235828 13
15 | 0.0204082 14
16 | 0.0226757 15
17 | 0.0204082 16
18 | 0.00226757 17
19 | 0.0385488 18
20 | 0.0340136 19
21 | 0.00453515 20
22 | 0.0181406 21
23 | 0.00226757 22
24 | 0.0181406 23
25 | 0.00226757 24
26 |
--------------------------------------------------------------------------------
/cal_GEM5_stats/data/stats/normal/config.dot.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cry-daniel/Computer-Architecture-Learning/0c384ac88181333788920b76bab387b18136faa0/cal_GEM5_stats/data/stats/normal/config.dot.pdf
--------------------------------------------------------------------------------
/cal_GEM5_stats/data/stats/normal/fs/proc/cpuinfo:
--------------------------------------------------------------------------------
1 | processor : 0
2 | vendor_id : Generic
3 | cpu family : 0
4 | model : 0
5 | model name : Generic
6 | stepping : 0
7 | cpu MHz : 2500.000
8 | cache size: : 1024.0K
9 | physical id : 0
10 | siblings : 1
11 | core id : 0
12 | cpu cores : 1
13 | fpu : yes
14 | fpu exception : yes
15 | cpuid level : 1
16 | wp : yes
17 | flags : fpu
18 | cache alignment : 128
19 |
20 |
--------------------------------------------------------------------------------
/cal_GEM5_stats/data/stats/normal/fs/proc/stat:
--------------------------------------------------------------------------------
1 | cpu 0 0 0 0 0 0 0
2 | cpu0 0 0 0 0 0 0 0
3 |
--------------------------------------------------------------------------------
/cal_GEM5_stats/data/stats/normal/fs/sys/devices/system/cpu/online:
--------------------------------------------------------------------------------
1 | 0-0
--------------------------------------------------------------------------------
/cal_GEM5_stats/data/stats/normal/fs/sys/devices/system/cpu/possible:
--------------------------------------------------------------------------------
1 | 0-0
--------------------------------------------------------------------------------
/cal_GEM5_stats/data/stats/test/1/config.dot.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cry-daniel/Computer-Architecture-Learning/0c384ac88181333788920b76bab387b18136faa0/cal_GEM5_stats/data/stats/test/1/config.dot.pdf
--------------------------------------------------------------------------------
/cal_GEM5_stats/data/stats/test/1/config.dot.svg:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
341 |
--------------------------------------------------------------------------------
/cal_GEM5_stats/data/stats/test/1/fs/proc/cpuinfo:
--------------------------------------------------------------------------------
1 | processor : 0
2 | vendor_id : Generic
3 | cpu family : 0
4 | model : 0
5 | model name : Generic
6 | stepping : 0
7 | cpu MHz : 2500.000
8 | cache size: : 1024.0K
9 | physical id : 0
10 | siblings : 1
11 | core id : 0
12 | cpu cores : 1
13 | fpu : yes
14 | fpu exception : yes
15 | cpuid level : 1
16 | wp : yes
17 | flags : fpu
18 | cache alignment : 128
19 |
20 |
--------------------------------------------------------------------------------
/cal_GEM5_stats/data/stats/test/1/fs/proc/stat:
--------------------------------------------------------------------------------
1 | cpu 0 0 0 0 0 0 0
2 | cpu0 0 0 0 0 0 0 0
3 |
--------------------------------------------------------------------------------
/cal_GEM5_stats/data/stats/test/1/fs/sys/devices/system/cpu/online:
--------------------------------------------------------------------------------
1 | 0-0
--------------------------------------------------------------------------------
/cal_GEM5_stats/data/stats/test/1/fs/sys/devices/system/cpu/possible:
--------------------------------------------------------------------------------
1 | 0-0
--------------------------------------------------------------------------------
/cal_GEM5_stats/data/stats/test/10/config.dot.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cry-daniel/Computer-Architecture-Learning/0c384ac88181333788920b76bab387b18136faa0/cal_GEM5_stats/data/stats/test/10/config.dot.pdf
--------------------------------------------------------------------------------
/cal_GEM5_stats/data/stats/test/10/config.dot.svg:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
341 |
--------------------------------------------------------------------------------
/cal_GEM5_stats/data/stats/test/10/fs/proc/cpuinfo:
--------------------------------------------------------------------------------
1 | processor : 0
2 | vendor_id : Generic
3 | cpu family : 0
4 | model : 0
5 | model name : Generic
6 | stepping : 0
7 | cpu MHz : 2500.000
8 | cache size: : 1024.0K
9 | physical id : 0
10 | siblings : 1
11 | core id : 0
12 | cpu cores : 1
13 | fpu : yes
14 | fpu exception : yes
15 | cpuid level : 1
16 | wp : yes
17 | flags : fpu
18 | cache alignment : 128
19 |
20 |
--------------------------------------------------------------------------------
/cal_GEM5_stats/data/stats/test/10/fs/proc/stat:
--------------------------------------------------------------------------------
1 | cpu 0 0 0 0 0 0 0
2 | cpu0 0 0 0 0 0 0 0
3 |
--------------------------------------------------------------------------------
/cal_GEM5_stats/data/stats/test/10/fs/sys/devices/system/cpu/online:
--------------------------------------------------------------------------------
1 | 0-0
--------------------------------------------------------------------------------
/cal_GEM5_stats/data/stats/test/10/fs/sys/devices/system/cpu/possible:
--------------------------------------------------------------------------------
1 | 0-0
--------------------------------------------------------------------------------
/cal_GEM5_stats/data/stats/test/11/config.dot.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cry-daniel/Computer-Architecture-Learning/0c384ac88181333788920b76bab387b18136faa0/cal_GEM5_stats/data/stats/test/11/config.dot.pdf
--------------------------------------------------------------------------------
/cal_GEM5_stats/data/stats/test/11/fs/proc/cpuinfo:
--------------------------------------------------------------------------------
1 | processor : 0
2 | vendor_id : Generic
3 | cpu family : 0
4 | model : 0
5 | model name : Generic
6 | stepping : 0
7 | cpu MHz : 2500.000
8 | cache size: : 1024.0K
9 | physical id : 0
10 | siblings : 1
11 | core id : 0
12 | cpu cores : 1
13 | fpu : yes
14 | fpu exception : yes
15 | cpuid level : 1
16 | wp : yes
17 | flags : fpu
18 | cache alignment : 128
19 |
20 |
--------------------------------------------------------------------------------
/cal_GEM5_stats/data/stats/test/11/fs/proc/stat:
--------------------------------------------------------------------------------
1 | cpu 0 0 0 0 0 0 0
2 | cpu0 0 0 0 0 0 0 0
3 |
--------------------------------------------------------------------------------
/cal_GEM5_stats/data/stats/test/11/fs/sys/devices/system/cpu/online:
--------------------------------------------------------------------------------
1 | 0-0
--------------------------------------------------------------------------------
/cal_GEM5_stats/data/stats/test/11/fs/sys/devices/system/cpu/possible:
--------------------------------------------------------------------------------
1 | 0-0
--------------------------------------------------------------------------------
/cal_GEM5_stats/data/stats/test/12/config.dot.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cry-daniel/Computer-Architecture-Learning/0c384ac88181333788920b76bab387b18136faa0/cal_GEM5_stats/data/stats/test/12/config.dot.pdf
--------------------------------------------------------------------------------
/cal_GEM5_stats/data/stats/test/12/fs/proc/cpuinfo:
--------------------------------------------------------------------------------
1 | processor : 0
2 | vendor_id : Generic
3 | cpu family : 0
4 | model : 0
5 | model name : Generic
6 | stepping : 0
7 | cpu MHz : 2500.000
8 | cache size: : 1024.0K
9 | physical id : 0
10 | siblings : 1
11 | core id : 0
12 | cpu cores : 1
13 | fpu : yes
14 | fpu exception : yes
15 | cpuid level : 1
16 | wp : yes
17 | flags : fpu
18 | cache alignment : 128
19 |
20 |
--------------------------------------------------------------------------------
/cal_GEM5_stats/data/stats/test/12/fs/proc/stat:
--------------------------------------------------------------------------------
1 | cpu 0 0 0 0 0 0 0
2 | cpu0 0 0 0 0 0 0 0
3 |
--------------------------------------------------------------------------------
/cal_GEM5_stats/data/stats/test/12/fs/sys/devices/system/cpu/online:
--------------------------------------------------------------------------------
1 | 0-0
--------------------------------------------------------------------------------
/cal_GEM5_stats/data/stats/test/12/fs/sys/devices/system/cpu/possible:
--------------------------------------------------------------------------------
1 | 0-0
--------------------------------------------------------------------------------
/cal_GEM5_stats/data/stats/test/13/config.dot.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cry-daniel/Computer-Architecture-Learning/0c384ac88181333788920b76bab387b18136faa0/cal_GEM5_stats/data/stats/test/13/config.dot.pdf
--------------------------------------------------------------------------------
/cal_GEM5_stats/data/stats/test/13/fs/proc/cpuinfo:
--------------------------------------------------------------------------------
1 | processor : 0
2 | vendor_id : Generic
3 | cpu family : 0
4 | model : 0
5 | model name : Generic
6 | stepping : 0
7 | cpu MHz : 2500.000
8 | cache size: : 1024.0K
9 | physical id : 0
10 | siblings : 1
11 | core id : 0
12 | cpu cores : 1
13 | fpu : yes
14 | fpu exception : yes
15 | cpuid level : 1
16 | wp : yes
17 | flags : fpu
18 | cache alignment : 128
19 |
20 |
--------------------------------------------------------------------------------
/cal_GEM5_stats/data/stats/test/13/fs/proc/stat:
--------------------------------------------------------------------------------
1 | cpu 0 0 0 0 0 0 0
2 | cpu0 0 0 0 0 0 0 0
3 |
--------------------------------------------------------------------------------
/cal_GEM5_stats/data/stats/test/13/fs/sys/devices/system/cpu/online:
--------------------------------------------------------------------------------
1 | 0-0
--------------------------------------------------------------------------------
/cal_GEM5_stats/data/stats/test/13/fs/sys/devices/system/cpu/possible:
--------------------------------------------------------------------------------
1 | 0-0
--------------------------------------------------------------------------------
/cal_GEM5_stats/data/stats/test/14/config.dot.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cry-daniel/Computer-Architecture-Learning/0c384ac88181333788920b76bab387b18136faa0/cal_GEM5_stats/data/stats/test/14/config.dot.pdf
--------------------------------------------------------------------------------
/cal_GEM5_stats/data/stats/test/14/fs/proc/cpuinfo:
--------------------------------------------------------------------------------
1 | processor : 0
2 | vendor_id : Generic
3 | cpu family : 0
4 | model : 0
5 | model name : Generic
6 | stepping : 0
7 | cpu MHz : 2500.000
8 | cache size: : 1024.0K
9 | physical id : 0
10 | siblings : 1
11 | core id : 0
12 | cpu cores : 1
13 | fpu : yes
14 | fpu exception : yes
15 | cpuid level : 1
16 | wp : yes
17 | flags : fpu
18 | cache alignment : 128
19 |
20 |
--------------------------------------------------------------------------------
/cal_GEM5_stats/data/stats/test/14/fs/proc/stat:
--------------------------------------------------------------------------------
1 | cpu 0 0 0 0 0 0 0
2 | cpu0 0 0 0 0 0 0 0
3 |
--------------------------------------------------------------------------------
/cal_GEM5_stats/data/stats/test/14/fs/sys/devices/system/cpu/online:
--------------------------------------------------------------------------------
1 | 0-0
--------------------------------------------------------------------------------
/cal_GEM5_stats/data/stats/test/14/fs/sys/devices/system/cpu/possible:
--------------------------------------------------------------------------------
1 | 0-0
--------------------------------------------------------------------------------
/cal_GEM5_stats/data/stats/test/15/config.dot.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cry-daniel/Computer-Architecture-Learning/0c384ac88181333788920b76bab387b18136faa0/cal_GEM5_stats/data/stats/test/15/config.dot.pdf
--------------------------------------------------------------------------------
/cal_GEM5_stats/data/stats/test/15/fs/proc/cpuinfo:
--------------------------------------------------------------------------------
1 | processor : 0
2 | vendor_id : Generic
3 | cpu family : 0
4 | model : 0
5 | model name : Generic
6 | stepping : 0
7 | cpu MHz : 2500.000
8 | cache size: : 1024.0K
9 | physical id : 0
10 | siblings : 1
11 | core id : 0
12 | cpu cores : 1
13 | fpu : yes
14 | fpu exception : yes
15 | cpuid level : 1
16 | wp : yes
17 | flags : fpu
18 | cache alignment : 128
19 |
20 |
--------------------------------------------------------------------------------
/cal_GEM5_stats/data/stats/test/15/fs/proc/stat:
--------------------------------------------------------------------------------
1 | cpu 0 0 0 0 0 0 0
2 | cpu0 0 0 0 0 0 0 0
3 |
--------------------------------------------------------------------------------
/cal_GEM5_stats/data/stats/test/15/fs/sys/devices/system/cpu/online:
--------------------------------------------------------------------------------
1 | 0-0
--------------------------------------------------------------------------------
/cal_GEM5_stats/data/stats/test/15/fs/sys/devices/system/cpu/possible:
--------------------------------------------------------------------------------
1 | 0-0
--------------------------------------------------------------------------------
/cal_GEM5_stats/data/stats/test/16/config.dot.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cry-daniel/Computer-Architecture-Learning/0c384ac88181333788920b76bab387b18136faa0/cal_GEM5_stats/data/stats/test/16/config.dot.pdf
--------------------------------------------------------------------------------
/cal_GEM5_stats/data/stats/test/16/fs/proc/cpuinfo:
--------------------------------------------------------------------------------
1 | processor : 0
2 | vendor_id : Generic
3 | cpu family : 0
4 | model : 0
5 | model name : Generic
6 | stepping : 0
7 | cpu MHz : 2500.000
8 | cache size: : 1024.0K
9 | physical id : 0
10 | siblings : 1
11 | core id : 0
12 | cpu cores : 1
13 | fpu : yes
14 | fpu exception : yes
15 | cpuid level : 1
16 | wp : yes
17 | flags : fpu
18 | cache alignment : 128
19 |
20 |
--------------------------------------------------------------------------------
/cal_GEM5_stats/data/stats/test/16/fs/proc/stat:
--------------------------------------------------------------------------------
1 | cpu 0 0 0 0 0 0 0
2 | cpu0 0 0 0 0 0 0 0
3 |
--------------------------------------------------------------------------------
/cal_GEM5_stats/data/stats/test/16/fs/sys/devices/system/cpu/online:
--------------------------------------------------------------------------------
1 | 0-0
--------------------------------------------------------------------------------
/cal_GEM5_stats/data/stats/test/16/fs/sys/devices/system/cpu/possible:
--------------------------------------------------------------------------------
1 | 0-0
--------------------------------------------------------------------------------
/cal_GEM5_stats/data/stats/test/17/config.dot.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cry-daniel/Computer-Architecture-Learning/0c384ac88181333788920b76bab387b18136faa0/cal_GEM5_stats/data/stats/test/17/config.dot.pdf
--------------------------------------------------------------------------------
/cal_GEM5_stats/data/stats/test/17/fs/proc/cpuinfo:
--------------------------------------------------------------------------------
1 | processor : 0
2 | vendor_id : Generic
3 | cpu family : 0
4 | model : 0
5 | model name : Generic
6 | stepping : 0
7 | cpu MHz : 2500.000
8 | cache size: : 1024.0K
9 | physical id : 0
10 | siblings : 1
11 | core id : 0
12 | cpu cores : 1
13 | fpu : yes
14 | fpu exception : yes
15 | cpuid level : 1
16 | wp : yes
17 | flags : fpu
18 | cache alignment : 128
19 |
20 |
--------------------------------------------------------------------------------
/cal_GEM5_stats/data/stats/test/17/fs/proc/stat:
--------------------------------------------------------------------------------
1 | cpu 0 0 0 0 0 0 0
2 | cpu0 0 0 0 0 0 0 0
3 |
--------------------------------------------------------------------------------
/cal_GEM5_stats/data/stats/test/17/fs/sys/devices/system/cpu/online:
--------------------------------------------------------------------------------
1 | 0-0
--------------------------------------------------------------------------------
/cal_GEM5_stats/data/stats/test/17/fs/sys/devices/system/cpu/possible:
--------------------------------------------------------------------------------
1 | 0-0
--------------------------------------------------------------------------------
/cal_GEM5_stats/data/stats/test/18/config.dot.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cry-daniel/Computer-Architecture-Learning/0c384ac88181333788920b76bab387b18136faa0/cal_GEM5_stats/data/stats/test/18/config.dot.pdf
--------------------------------------------------------------------------------
/cal_GEM5_stats/data/stats/test/18/fs/proc/cpuinfo:
--------------------------------------------------------------------------------
1 | processor : 0
2 | vendor_id : Generic
3 | cpu family : 0
4 | model : 0
5 | model name : Generic
6 | stepping : 0
7 | cpu MHz : 2500.000
8 | cache size: : 1024.0K
9 | physical id : 0
10 | siblings : 1
11 | core id : 0
12 | cpu cores : 1
13 | fpu : yes
14 | fpu exception : yes
15 | cpuid level : 1
16 | wp : yes
17 | flags : fpu
18 | cache alignment : 128
19 |
20 |
--------------------------------------------------------------------------------
/cal_GEM5_stats/data/stats/test/18/fs/proc/stat:
--------------------------------------------------------------------------------
1 | cpu 0 0 0 0 0 0 0
2 | cpu0 0 0 0 0 0 0 0
3 |
--------------------------------------------------------------------------------
/cal_GEM5_stats/data/stats/test/18/fs/sys/devices/system/cpu/online:
--------------------------------------------------------------------------------
1 | 0-0
--------------------------------------------------------------------------------
/cal_GEM5_stats/data/stats/test/18/fs/sys/devices/system/cpu/possible:
--------------------------------------------------------------------------------
1 | 0-0
--------------------------------------------------------------------------------
/cal_GEM5_stats/data/stats/test/19/config.dot.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cry-daniel/Computer-Architecture-Learning/0c384ac88181333788920b76bab387b18136faa0/cal_GEM5_stats/data/stats/test/19/config.dot.pdf
--------------------------------------------------------------------------------
/cal_GEM5_stats/data/stats/test/19/fs/proc/cpuinfo:
--------------------------------------------------------------------------------
1 | processor : 0
2 | vendor_id : Generic
3 | cpu family : 0
4 | model : 0
5 | model name : Generic
6 | stepping : 0
7 | cpu MHz : 2500.000
8 | cache size: : 1024.0K
9 | physical id : 0
10 | siblings : 1
11 | core id : 0
12 | cpu cores : 1
13 | fpu : yes
14 | fpu exception : yes
15 | cpuid level : 1
16 | wp : yes
17 | flags : fpu
18 | cache alignment : 128
19 |
20 |
--------------------------------------------------------------------------------
/cal_GEM5_stats/data/stats/test/19/fs/proc/stat:
--------------------------------------------------------------------------------
1 | cpu 0 0 0 0 0 0 0
2 | cpu0 0 0 0 0 0 0 0
3 |
--------------------------------------------------------------------------------
/cal_GEM5_stats/data/stats/test/19/fs/sys/devices/system/cpu/online:
--------------------------------------------------------------------------------
1 | 0-0
--------------------------------------------------------------------------------
/cal_GEM5_stats/data/stats/test/19/fs/sys/devices/system/cpu/possible:
--------------------------------------------------------------------------------
1 | 0-0
--------------------------------------------------------------------------------
/cal_GEM5_stats/data/stats/test/2/config.dot.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cry-daniel/Computer-Architecture-Learning/0c384ac88181333788920b76bab387b18136faa0/cal_GEM5_stats/data/stats/test/2/config.dot.pdf
--------------------------------------------------------------------------------
/cal_GEM5_stats/data/stats/test/2/fs/proc/cpuinfo:
--------------------------------------------------------------------------------
1 | processor : 0
2 | vendor_id : Generic
3 | cpu family : 0
4 | model : 0
5 | model name : Generic
6 | stepping : 0
7 | cpu MHz : 2500.000
8 | cache size: : 1024.0K
9 | physical id : 0
10 | siblings : 1
11 | core id : 0
12 | cpu cores : 1
13 | fpu : yes
14 | fpu exception : yes
15 | cpuid level : 1
16 | wp : yes
17 | flags : fpu
18 | cache alignment : 128
19 |
20 |
--------------------------------------------------------------------------------
/cal_GEM5_stats/data/stats/test/2/fs/proc/stat:
--------------------------------------------------------------------------------
1 | cpu 0 0 0 0 0 0 0
2 | cpu0 0 0 0 0 0 0 0
3 |
--------------------------------------------------------------------------------
/cal_GEM5_stats/data/stats/test/2/fs/sys/devices/system/cpu/online:
--------------------------------------------------------------------------------
1 | 0-0
--------------------------------------------------------------------------------
/cal_GEM5_stats/data/stats/test/2/fs/sys/devices/system/cpu/possible:
--------------------------------------------------------------------------------
1 | 0-0
--------------------------------------------------------------------------------
/cal_GEM5_stats/data/stats/test/20/config.dot.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cry-daniel/Computer-Architecture-Learning/0c384ac88181333788920b76bab387b18136faa0/cal_GEM5_stats/data/stats/test/20/config.dot.pdf
--------------------------------------------------------------------------------
/cal_GEM5_stats/data/stats/test/20/fs/proc/cpuinfo:
--------------------------------------------------------------------------------
1 | processor : 0
2 | vendor_id : Generic
3 | cpu family : 0
4 | model : 0
5 | model name : Generic
6 | stepping : 0
7 | cpu MHz : 2500.000
8 | cache size: : 1024.0K
9 | physical id : 0
10 | siblings : 1
11 | core id : 0
12 | cpu cores : 1
13 | fpu : yes
14 | fpu exception : yes
15 | cpuid level : 1
16 | wp : yes
17 | flags : fpu
18 | cache alignment : 128
19 |
20 |
--------------------------------------------------------------------------------
/cal_GEM5_stats/data/stats/test/20/fs/proc/stat:
--------------------------------------------------------------------------------
1 | cpu 0 0 0 0 0 0 0
2 | cpu0 0 0 0 0 0 0 0
3 |
--------------------------------------------------------------------------------
/cal_GEM5_stats/data/stats/test/20/fs/sys/devices/system/cpu/online:
--------------------------------------------------------------------------------
1 | 0-0
--------------------------------------------------------------------------------
/cal_GEM5_stats/data/stats/test/20/fs/sys/devices/system/cpu/possible:
--------------------------------------------------------------------------------
1 | 0-0
--------------------------------------------------------------------------------
/cal_GEM5_stats/data/stats/test/21/config.dot.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cry-daniel/Computer-Architecture-Learning/0c384ac88181333788920b76bab387b18136faa0/cal_GEM5_stats/data/stats/test/21/config.dot.pdf
--------------------------------------------------------------------------------
/cal_GEM5_stats/data/stats/test/21/fs/proc/cpuinfo:
--------------------------------------------------------------------------------
1 | processor : 0
2 | vendor_id : Generic
3 | cpu family : 0
4 | model : 0
5 | model name : Generic
6 | stepping : 0
7 | cpu MHz : 2500.000
8 | cache size: : 1024.0K
9 | physical id : 0
10 | siblings : 1
11 | core id : 0
12 | cpu cores : 1
13 | fpu : yes
14 | fpu exception : yes
15 | cpuid level : 1
16 | wp : yes
17 | flags : fpu
18 | cache alignment : 128
19 |
20 |
--------------------------------------------------------------------------------
/cal_GEM5_stats/data/stats/test/21/fs/proc/stat:
--------------------------------------------------------------------------------
1 | cpu 0 0 0 0 0 0 0
2 | cpu0 0 0 0 0 0 0 0
3 |
--------------------------------------------------------------------------------
/cal_GEM5_stats/data/stats/test/21/fs/sys/devices/system/cpu/online:
--------------------------------------------------------------------------------
1 | 0-0
--------------------------------------------------------------------------------
/cal_GEM5_stats/data/stats/test/21/fs/sys/devices/system/cpu/possible:
--------------------------------------------------------------------------------
1 | 0-0
--------------------------------------------------------------------------------
/cal_GEM5_stats/data/stats/test/22/config.dot.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cry-daniel/Computer-Architecture-Learning/0c384ac88181333788920b76bab387b18136faa0/cal_GEM5_stats/data/stats/test/22/config.dot.pdf
--------------------------------------------------------------------------------
/cal_GEM5_stats/data/stats/test/22/fs/proc/cpuinfo:
--------------------------------------------------------------------------------
1 | processor : 0
2 | vendor_id : Generic
3 | cpu family : 0
4 | model : 0
5 | model name : Generic
6 | stepping : 0
7 | cpu MHz : 2500.000
8 | cache size: : 1024.0K
9 | physical id : 0
10 | siblings : 1
11 | core id : 0
12 | cpu cores : 1
13 | fpu : yes
14 | fpu exception : yes
15 | cpuid level : 1
16 | wp : yes
17 | flags : fpu
18 | cache alignment : 128
19 |
20 |
--------------------------------------------------------------------------------
/cal_GEM5_stats/data/stats/test/22/fs/proc/stat:
--------------------------------------------------------------------------------
1 | cpu 0 0 0 0 0 0 0
2 | cpu0 0 0 0 0 0 0 0
3 |
--------------------------------------------------------------------------------
/cal_GEM5_stats/data/stats/test/22/fs/sys/devices/system/cpu/online:
--------------------------------------------------------------------------------
1 | 0-0
--------------------------------------------------------------------------------
/cal_GEM5_stats/data/stats/test/22/fs/sys/devices/system/cpu/possible:
--------------------------------------------------------------------------------
1 | 0-0
--------------------------------------------------------------------------------
/cal_GEM5_stats/data/stats/test/23/config.dot.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cry-daniel/Computer-Architecture-Learning/0c384ac88181333788920b76bab387b18136faa0/cal_GEM5_stats/data/stats/test/23/config.dot.pdf
--------------------------------------------------------------------------------
/cal_GEM5_stats/data/stats/test/23/fs/proc/cpuinfo:
--------------------------------------------------------------------------------
1 | processor : 0
2 | vendor_id : Generic
3 | cpu family : 0
4 | model : 0
5 | model name : Generic
6 | stepping : 0
7 | cpu MHz : 2500.000
8 | cache size: : 1024.0K
9 | physical id : 0
10 | siblings : 1
11 | core id : 0
12 | cpu cores : 1
13 | fpu : yes
14 | fpu exception : yes
15 | cpuid level : 1
16 | wp : yes
17 | flags : fpu
18 | cache alignment : 128
19 |
20 |
--------------------------------------------------------------------------------
/cal_GEM5_stats/data/stats/test/23/fs/proc/stat:
--------------------------------------------------------------------------------
1 | cpu 0 0 0 0 0 0 0
2 | cpu0 0 0 0 0 0 0 0
3 |
--------------------------------------------------------------------------------
/cal_GEM5_stats/data/stats/test/23/fs/sys/devices/system/cpu/online:
--------------------------------------------------------------------------------
1 | 0-0
--------------------------------------------------------------------------------
/cal_GEM5_stats/data/stats/test/23/fs/sys/devices/system/cpu/possible:
--------------------------------------------------------------------------------
1 | 0-0
--------------------------------------------------------------------------------
/cal_GEM5_stats/data/stats/test/24/config.dot.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cry-daniel/Computer-Architecture-Learning/0c384ac88181333788920b76bab387b18136faa0/cal_GEM5_stats/data/stats/test/24/config.dot.pdf
--------------------------------------------------------------------------------
/cal_GEM5_stats/data/stats/test/24/fs/proc/cpuinfo:
--------------------------------------------------------------------------------
1 | processor : 0
2 | vendor_id : Generic
3 | cpu family : 0
4 | model : 0
5 | model name : Generic
6 | stepping : 0
7 | cpu MHz : 2500.000
8 | cache size: : 1024.0K
9 | physical id : 0
10 | siblings : 1
11 | core id : 0
12 | cpu cores : 1
13 | fpu : yes
14 | fpu exception : yes
15 | cpuid level : 1
16 | wp : yes
17 | flags : fpu
18 | cache alignment : 128
19 |
20 |
--------------------------------------------------------------------------------
/cal_GEM5_stats/data/stats/test/24/fs/proc/stat:
--------------------------------------------------------------------------------
1 | cpu 0 0 0 0 0 0 0
2 | cpu0 0 0 0 0 0 0 0
3 |
--------------------------------------------------------------------------------
/cal_GEM5_stats/data/stats/test/24/fs/sys/devices/system/cpu/online:
--------------------------------------------------------------------------------
1 | 0-0
--------------------------------------------------------------------------------
/cal_GEM5_stats/data/stats/test/24/fs/sys/devices/system/cpu/possible:
--------------------------------------------------------------------------------
1 | 0-0
--------------------------------------------------------------------------------
/cal_GEM5_stats/data/stats/test/25/config.dot.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cry-daniel/Computer-Architecture-Learning/0c384ac88181333788920b76bab387b18136faa0/cal_GEM5_stats/data/stats/test/25/config.dot.pdf
--------------------------------------------------------------------------------
/cal_GEM5_stats/data/stats/test/25/fs/proc/cpuinfo:
--------------------------------------------------------------------------------
1 | processor : 0
2 | vendor_id : Generic
3 | cpu family : 0
4 | model : 0
5 | model name : Generic
6 | stepping : 0
7 | cpu MHz : 2500.000
8 | cache size: : 1024.0K
9 | physical id : 0
10 | siblings : 1
11 | core id : 0
12 | cpu cores : 1
13 | fpu : yes
14 | fpu exception : yes
15 | cpuid level : 1
16 | wp : yes
17 | flags : fpu
18 | cache alignment : 128
19 |
20 |
--------------------------------------------------------------------------------
/cal_GEM5_stats/data/stats/test/25/fs/proc/stat:
--------------------------------------------------------------------------------
1 | cpu 0 0 0 0 0 0 0
2 | cpu0 0 0 0 0 0 0 0
3 |
--------------------------------------------------------------------------------
/cal_GEM5_stats/data/stats/test/25/fs/sys/devices/system/cpu/online:
--------------------------------------------------------------------------------
1 | 0-0
--------------------------------------------------------------------------------
/cal_GEM5_stats/data/stats/test/25/fs/sys/devices/system/cpu/possible:
--------------------------------------------------------------------------------
1 | 0-0
--------------------------------------------------------------------------------
/cal_GEM5_stats/data/stats/test/3/config.dot.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cry-daniel/Computer-Architecture-Learning/0c384ac88181333788920b76bab387b18136faa0/cal_GEM5_stats/data/stats/test/3/config.dot.pdf
--------------------------------------------------------------------------------
/cal_GEM5_stats/data/stats/test/3/fs/proc/cpuinfo:
--------------------------------------------------------------------------------
1 | processor : 0
2 | vendor_id : Generic
3 | cpu family : 0
4 | model : 0
5 | model name : Generic
6 | stepping : 0
7 | cpu MHz : 2500.000
8 | cache size: : 1024.0K
9 | physical id : 0
10 | siblings : 1
11 | core id : 0
12 | cpu cores : 1
13 | fpu : yes
14 | fpu exception : yes
15 | cpuid level : 1
16 | wp : yes
17 | flags : fpu
18 | cache alignment : 128
19 |
20 |
--------------------------------------------------------------------------------
/cal_GEM5_stats/data/stats/test/3/fs/proc/stat:
--------------------------------------------------------------------------------
1 | cpu 0 0 0 0 0 0 0
2 | cpu0 0 0 0 0 0 0 0
3 |
--------------------------------------------------------------------------------
/cal_GEM5_stats/data/stats/test/3/fs/sys/devices/system/cpu/online:
--------------------------------------------------------------------------------
1 | 0-0
--------------------------------------------------------------------------------
/cal_GEM5_stats/data/stats/test/3/fs/sys/devices/system/cpu/possible:
--------------------------------------------------------------------------------
1 | 0-0
--------------------------------------------------------------------------------
/cal_GEM5_stats/data/stats/test/4/config.dot.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cry-daniel/Computer-Architecture-Learning/0c384ac88181333788920b76bab387b18136faa0/cal_GEM5_stats/data/stats/test/4/config.dot.pdf
--------------------------------------------------------------------------------
/cal_GEM5_stats/data/stats/test/4/fs/proc/cpuinfo:
--------------------------------------------------------------------------------
1 | processor : 0
2 | vendor_id : Generic
3 | cpu family : 0
4 | model : 0
5 | model name : Generic
6 | stepping : 0
7 | cpu MHz : 2500.000
8 | cache size: : 1024.0K
9 | physical id : 0
10 | siblings : 1
11 | core id : 0
12 | cpu cores : 1
13 | fpu : yes
14 | fpu exception : yes
15 | cpuid level : 1
16 | wp : yes
17 | flags : fpu
18 | cache alignment : 128
19 |
20 |
--------------------------------------------------------------------------------
/cal_GEM5_stats/data/stats/test/4/fs/proc/stat:
--------------------------------------------------------------------------------
1 | cpu 0 0 0 0 0 0 0
2 | cpu0 0 0 0 0 0 0 0
3 |
--------------------------------------------------------------------------------
/cal_GEM5_stats/data/stats/test/4/fs/sys/devices/system/cpu/online:
--------------------------------------------------------------------------------
1 | 0-0
--------------------------------------------------------------------------------
/cal_GEM5_stats/data/stats/test/4/fs/sys/devices/system/cpu/possible:
--------------------------------------------------------------------------------
1 | 0-0
--------------------------------------------------------------------------------
/cal_GEM5_stats/data/stats/test/5/config.dot.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cry-daniel/Computer-Architecture-Learning/0c384ac88181333788920b76bab387b18136faa0/cal_GEM5_stats/data/stats/test/5/config.dot.pdf
--------------------------------------------------------------------------------
/cal_GEM5_stats/data/stats/test/5/fs/proc/cpuinfo:
--------------------------------------------------------------------------------
1 | processor : 0
2 | vendor_id : Generic
3 | cpu family : 0
4 | model : 0
5 | model name : Generic
6 | stepping : 0
7 | cpu MHz : 2500.000
8 | cache size: : 1024.0K
9 | physical id : 0
10 | siblings : 1
11 | core id : 0
12 | cpu cores : 1
13 | fpu : yes
14 | fpu exception : yes
15 | cpuid level : 1
16 | wp : yes
17 | flags : fpu
18 | cache alignment : 128
19 |
20 |
--------------------------------------------------------------------------------
/cal_GEM5_stats/data/stats/test/5/fs/proc/stat:
--------------------------------------------------------------------------------
1 | cpu 0 0 0 0 0 0 0
2 | cpu0 0 0 0 0 0 0 0
3 |
--------------------------------------------------------------------------------
/cal_GEM5_stats/data/stats/test/5/fs/sys/devices/system/cpu/online:
--------------------------------------------------------------------------------
1 | 0-0
--------------------------------------------------------------------------------
/cal_GEM5_stats/data/stats/test/5/fs/sys/devices/system/cpu/possible:
--------------------------------------------------------------------------------
1 | 0-0
--------------------------------------------------------------------------------
/cal_GEM5_stats/data/stats/test/6/config.dot.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cry-daniel/Computer-Architecture-Learning/0c384ac88181333788920b76bab387b18136faa0/cal_GEM5_stats/data/stats/test/6/config.dot.pdf
--------------------------------------------------------------------------------
/cal_GEM5_stats/data/stats/test/6/fs/proc/cpuinfo:
--------------------------------------------------------------------------------
1 | processor : 0
2 | vendor_id : Generic
3 | cpu family : 0
4 | model : 0
5 | model name : Generic
6 | stepping : 0
7 | cpu MHz : 2500.000
8 | cache size: : 1024.0K
9 | physical id : 0
10 | siblings : 1
11 | core id : 0
12 | cpu cores : 1
13 | fpu : yes
14 | fpu exception : yes
15 | cpuid level : 1
16 | wp : yes
17 | flags : fpu
18 | cache alignment : 128
19 |
20 |
--------------------------------------------------------------------------------
/cal_GEM5_stats/data/stats/test/6/fs/proc/stat:
--------------------------------------------------------------------------------
1 | cpu 0 0 0 0 0 0 0
2 | cpu0 0 0 0 0 0 0 0
3 |
--------------------------------------------------------------------------------
/cal_GEM5_stats/data/stats/test/6/fs/sys/devices/system/cpu/online:
--------------------------------------------------------------------------------
1 | 0-0
--------------------------------------------------------------------------------
/cal_GEM5_stats/data/stats/test/6/fs/sys/devices/system/cpu/possible:
--------------------------------------------------------------------------------
1 | 0-0
--------------------------------------------------------------------------------
/cal_GEM5_stats/data/stats/test/7/config.dot.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cry-daniel/Computer-Architecture-Learning/0c384ac88181333788920b76bab387b18136faa0/cal_GEM5_stats/data/stats/test/7/config.dot.pdf
--------------------------------------------------------------------------------
/cal_GEM5_stats/data/stats/test/7/fs/proc/cpuinfo:
--------------------------------------------------------------------------------
1 | processor : 0
2 | vendor_id : Generic
3 | cpu family : 0
4 | model : 0
5 | model name : Generic
6 | stepping : 0
7 | cpu MHz : 2500.000
8 | cache size: : 1024.0K
9 | physical id : 0
10 | siblings : 1
11 | core id : 0
12 | cpu cores : 1
13 | fpu : yes
14 | fpu exception : yes
15 | cpuid level : 1
16 | wp : yes
17 | flags : fpu
18 | cache alignment : 128
19 |
20 |
--------------------------------------------------------------------------------
/cal_GEM5_stats/data/stats/test/7/fs/proc/stat:
--------------------------------------------------------------------------------
1 | cpu 0 0 0 0 0 0 0
2 | cpu0 0 0 0 0 0 0 0
3 |
--------------------------------------------------------------------------------
/cal_GEM5_stats/data/stats/test/7/fs/sys/devices/system/cpu/online:
--------------------------------------------------------------------------------
1 | 0-0
--------------------------------------------------------------------------------
/cal_GEM5_stats/data/stats/test/7/fs/sys/devices/system/cpu/possible:
--------------------------------------------------------------------------------
1 | 0-0
--------------------------------------------------------------------------------
/cal_GEM5_stats/data/stats/test/8/config.dot.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cry-daniel/Computer-Architecture-Learning/0c384ac88181333788920b76bab387b18136faa0/cal_GEM5_stats/data/stats/test/8/config.dot.pdf
--------------------------------------------------------------------------------
/cal_GEM5_stats/data/stats/test/8/fs/proc/cpuinfo:
--------------------------------------------------------------------------------
1 | processor : 0
2 | vendor_id : Generic
3 | cpu family : 0
4 | model : 0
5 | model name : Generic
6 | stepping : 0
7 | cpu MHz : 2500.000
8 | cache size: : 1024.0K
9 | physical id : 0
10 | siblings : 1
11 | core id : 0
12 | cpu cores : 1
13 | fpu : yes
14 | fpu exception : yes
15 | cpuid level : 1
16 | wp : yes
17 | flags : fpu
18 | cache alignment : 128
19 |
20 |
--------------------------------------------------------------------------------
/cal_GEM5_stats/data/stats/test/8/fs/proc/stat:
--------------------------------------------------------------------------------
1 | cpu 0 0 0 0 0 0 0
2 | cpu0 0 0 0 0 0 0 0
3 |
--------------------------------------------------------------------------------
/cal_GEM5_stats/data/stats/test/8/fs/sys/devices/system/cpu/online:
--------------------------------------------------------------------------------
1 | 0-0
--------------------------------------------------------------------------------
/cal_GEM5_stats/data/stats/test/8/fs/sys/devices/system/cpu/possible:
--------------------------------------------------------------------------------
1 | 0-0
--------------------------------------------------------------------------------
/cal_GEM5_stats/data/stats/test/9/config.dot.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cry-daniel/Computer-Architecture-Learning/0c384ac88181333788920b76bab387b18136faa0/cal_GEM5_stats/data/stats/test/9/config.dot.pdf
--------------------------------------------------------------------------------
/cal_GEM5_stats/data/stats/test/9/fs/proc/cpuinfo:
--------------------------------------------------------------------------------
1 | processor : 0
2 | vendor_id : Generic
3 | cpu family : 0
4 | model : 0
5 | model name : Generic
6 | stepping : 0
7 | cpu MHz : 2500.000
8 | cache size: : 1024.0K
9 | physical id : 0
10 | siblings : 1
11 | core id : 0
12 | cpu cores : 1
13 | fpu : yes
14 | fpu exception : yes
15 | cpuid level : 1
16 | wp : yes
17 | flags : fpu
18 | cache alignment : 128
19 |
20 |
--------------------------------------------------------------------------------
/cal_GEM5_stats/data/stats/test/9/fs/proc/stat:
--------------------------------------------------------------------------------
1 | cpu 0 0 0 0 0 0 0
2 | cpu0 0 0 0 0 0 0 0
3 |
--------------------------------------------------------------------------------
/cal_GEM5_stats/data/stats/test/9/fs/sys/devices/system/cpu/online:
--------------------------------------------------------------------------------
1 | 0-0
--------------------------------------------------------------------------------
/cal_GEM5_stats/data/stats/test/9/fs/sys/devices/system/cpu/possible:
--------------------------------------------------------------------------------
1 | 0-0
--------------------------------------------------------------------------------
/cal_GEM5_stats/get_stats.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | # ssh连接的地址,本机跑 Simpoint 则忽略
4 | SSH_ROUTE=stu1@10.184.17.65:
5 |
6 | # 存放 Simpoint 结果的地址,改成自己的
7 | SIM_ROUTE=/home/data/ChenRuiyang/SimPoint.3.2/output/gem5/
8 |
9 | # 存放 Reload 结果的地址,改成自己的
10 | #RELOAD_ROUTE=/home/data/ChenRuiyang/gem5/m5out/RELOAD
11 | RELOAD_ROUTE=/home/data/ChenRuiyang/gem5/m5out/graph500_s_14_e_14/graph500_s_14_e_14_O3/
12 |
13 | # 存放 Normal 结果的地址,改成自己的
14 | NORMAL_ROUTE=/home/data/ChenRuiyang/gem5/m5out/graph500_s_14_e_14_normal/*
15 |
16 | rm -r ./data/simpoint/*
17 | rm -r ./data/stats/test/*
18 | rm -r ./data/stats/normal/*
19 | mkdir -p data;
20 | scp -r ${SSH_ROUTE}${SIM_ROUTE}/* ./data/simpoint/
21 | scp -r ${SSH_ROUTE}${RELOAD_ROUTE}/* ./data/stats/test/
22 | scp -r ${SSH_ROUTE}${NORMAL_ROUTE} ./data/stats/normal/
--------------------------------------------------------------------------------
/cal_GEM5_stats/tools/configs.py:
--------------------------------------------------------------------------------
1 | import numpy as np
2 |
3 | stats_name='stats.txt'
4 | start_sym='---------- Begin Simulation Statistics ----------'
5 | freq_sym='sim_freq'
6 | inst_sym='system.switch_cpus.committedInsts'
7 | seconds_sym='sim_seconds '
8 | dcache_hit_sym='system.cpu.dcache.overall_hits::.switch_cpus.data'
9 | dcache_miss_sym='system.cpu.dcache.overall_misses::.switch_cpus.data'
10 | branch_pred_sym='system.switch_cpus.branchPred.condPredicted'
11 | branch_miss_pred_sym='system.switch_cpus.branchPred.condIncorrect'
12 | ROB_stall_sym='system.switch_cpus.rename.ROBFullEvents'
13 | rename_inst_sym='system.switch_cpus.rename.renamedInsts'
14 | paras_sym=[freq_sym,inst_sym,seconds_sym,dcache_hit_sym,dcache_miss_sym,branch_pred_sym, \
15 | branch_miss_pred_sym,ROB_stall_sym,rename_inst_sym]
16 | paras=np.zeros(len(paras_sym))
17 | #freq=inst=ops=dcache_hit=dcache_miss=0
18 |
19 | # normal 的一般不用改
20 | freq_sym_nor='sim_freq'
21 | inst_sym_nor='system.cpu.committedInsts'
22 | seconds_sym_nor='sim_seconds '
23 | dcache_hit_sym_nor='system.cpu.dcache.overall_hits::.cpu.data'
24 | dcache_miss_sym_nor='system.cpu.dcache.overall_misses::.cpu.data'
25 | branch_pred_sym_nor='system.cpu.branchPred.condPredicted'
26 | branch_miss_pred_sym_nor='system.cpu.branchPred.condIncorrect'
27 | ROB_stall_sym_nor='system.cpu.rename.ROBFullEvents'
28 | rename_inst_sym_nor='system.cpu.rename.renamedInsts'
29 | IPC_nor='system.cpu.ipc'
30 | paras_sym_nor=[freq_sym_nor,inst_sym_nor,seconds_sym_nor,dcache_hit_sym_nor,dcache_miss_sym_nor,branch_pred_sym_nor, \
31 | branch_miss_pred_sym_nor,ROB_stall_sym_nor,rename_inst_sym_nor]
32 | paras_nor=np.zeros(len(paras_sym_nor))
--------------------------------------------------------------------------------
/cal_GEM5_stats/tools/utils.py:
--------------------------------------------------------------------------------
1 | from numpy.core.fromnumeric import sort
2 | import numpy as np
3 |
4 | num_list=['0','1','2','3','4','5','6','7','8','9','.']
5 |
6 | def isdig(a): #处理小数
7 | if a in num_list:
8 | return True
9 | return False
10 |
11 | def fin(para_sym,line):
12 | flag=False
13 | para=0
14 | if para_sym in line:
15 | line=line.split(para_sym)[1]
16 | temp=""
17 | for element in line:
18 | if isdig(element):
19 | temp+=element
20 | if element=="#":
21 | break
22 | para=float(temp)
23 | flag=True
24 | return flag,para
25 |
26 | def read_weight_file(weight_route,sim_route):
27 | f_w=open(weight_route)
28 | f_s=open(sim_route)
29 | weight=f_w.readlines()
30 | sim=f_s.readlines()
31 | length=len(weight)
32 | wei_sim=np.zeros((length,2))
33 | for i in range(length):
34 | temp=""
35 | for num in weight[i]:
36 | if isdig(num):
37 | temp+=num
38 | continue
39 | break
40 | wei_sim[i,0]=float(temp)
41 | temp=""
42 | for num in sim[i]:
43 | if isdig(num):
44 | temp+=num
45 | continue
46 | break
47 | wei_sim[i,1]=float(temp)
48 | sorted_wei_sim=sorted(wei_sim,key=lambda x:x[1])
49 | res=[]
50 | for item in sorted_wei_sim:
51 | res.append(item[0])
52 | return res
53 |
54 | def num_sort(a):
55 | if str.isdigit(a[0]):
56 | return int(a)
57 | else:
58 | return a
59 |
60 | # if __name__=="__main__":
61 | # print(read_weight_file())
--------------------------------------------------------------------------------
/docs/README.md:
--------------------------------------------------------------------------------
1 | ```
2 | ├─makefile
3 | │ makefile.md
4 | │
5 | └─python
6 | python.md
7 | ```
--------------------------------------------------------------------------------
/docs/makefile/makefile.md:
--------------------------------------------------------------------------------
1 | # Makefile skills
2 | ---
3 | 参考了 https://seisman.github.io/how-to-write-makefile/overview.html
4 | *Copy right by ChenRuiyang*
5 |
6 | ---
7 |
8 | makefile介绍
9 | ============
10 |
11 | make命令执行时,需要一个makefile文件,以告诉make命令需要怎么样的去编译和链接程序。
12 |
13 | 首先,我们用一个示例来说明makefile的书写规则,以便给大家一个感性认识。这个示例来源于gnu
14 | 的make使用手册,在这个示例中,我们的工程有8个c文件,和3个头文件,我们要写一个makefile来告
15 | 诉make命令如何编译和链接这几个文件。我们的规则是:
16 |
17 | #. 如果这个工程没有编译过,那么我们的所有c文件都要编译并被链接。
18 | #. 如果这个工程的某几个c文件被修改,那么我们只编译被修改的c文件,并链接目标程序。
19 | #. 如果这个工程的头文件被改变了,那么我们需要编译引用了这几个头文件的c文件,并链接目标程序。
20 |
21 | 只要我们的makefile写得够好,所有的这一切,我们只用一个make命令就可以完成,make命令会自动智能
22 | 地根据当前的文件修改的情况来确定哪些文件需要重编译,从而自动编译所需要的文件和链接目标程序。
23 |
24 | makefile的规则
25 | --------------
26 |
27 | 在讲述这个makefile之前,还是让我们先来粗略地看一看makefile的规则。
28 |
29 | .. code-block:: makefile
30 |
31 | target ... : prerequisites ...
32 | command
33 | ...
34 | ...
35 |
36 | target
37 | 可以是一个object file(目标文件),也可以是一个执行文件,还可以是一个标签(label)。对
38 | 于标签这种特性,在后续的“伪目标”章节中会有叙述。
39 | prerequisites
40 | 生成该target所依赖的文件和/或target
41 | command
42 | 该target要执行的命令(任意的shell命令)
43 |
44 | 这是一个文件的依赖关系,也就是说,target这一个或多个的目标文件依赖于prerequisites中的文件,
45 | 其生成规则定义在command中。说白一点就是说::
46 |
47 | prerequisites中如果有一个以上的文件比target文件要新的话,command所定义的命令就会被执行。
48 |
49 | 这就是makefile的规则,也就是makefile中最核心的内容。
50 |
51 | 说到底,makefile的东西就是这样一点,好像我的这篇文档也该结束了。呵呵。还不尽然,这是makefile
52 | 的主线和核心,但要写好一个makefile还不够,我会在后面一点一点地结合我的工作经验给你慢慢道来。内
53 | 容还多着呢。:)
54 |
55 | 一个示例
56 | --------
57 |
58 | 正如前面所说,如果一个工程有3个头文件和8个c文件,为了完成前面所述的那三个规则,我们的makefile
59 | 应该是下面的这个样子的。
60 |
61 | .. code-block:: makefile
62 |
63 | edit : main.o kbd.o command.o display.o \
64 | insert.o search.o files.o utils.o
65 | cc -o edit main.o kbd.o command.o display.o \
66 | insert.o search.o files.o utils.o
67 |
68 | main.o : main.c defs.h
69 | cc -c main.c
70 | kbd.o : kbd.c defs.h command.h
71 | cc -c kbd.c
72 | command.o : command.c defs.h command.h
73 | cc -c command.c
74 | display.o : display.c defs.h buffer.h
75 | cc -c display.c
76 | insert.o : insert.c defs.h buffer.h
77 | cc -c insert.c
78 | search.o : search.c defs.h buffer.h
79 | cc -c search.c
80 | files.o : files.c defs.h buffer.h command.h
81 | cc -c files.c
82 | utils.o : utils.c defs.h
83 | cc -c utils.c
84 | clean :
85 | rm edit main.o kbd.o command.o display.o \
86 | insert.o search.o files.o utils.o
87 |
88 | 反斜杠( ``\`` )是换行符的意思。这样比较便于makefile的阅读。我们可以把这个内容保存在名字
89 | 为“makefile”或“Makefile”的文件中,然后在该目录下直接输入命令 ``make`` 就可以生成执行文
90 | 件edit。如果要删除执行文件和所有的中间目标文件,那么,只要简单地执行一下 ``make clean`` 就
91 | 可以了。
92 |
93 | 在这个makefile中,目标文件(target)包含:执行文件edit和中间目标文件( ``*.o`` ),依赖文
94 | 件(prerequisites)就是冒号后面的那些 ``.c`` 文件和 ``.h`` 文件。每一个 ``.o`` 文件都有
95 | 一组依赖文件,而这些 ``.o`` 文件又是执行文件 ``edit`` 的依赖文件。依赖关系的实质就是说明了目
96 | 标文件是由哪些文件生成的,换言之,目标文件是哪些文件更新的。
97 |
98 | 在定义好依赖关系后,后续的那一行定义了如何生成目标文件的操作系统命令,一定要以一个 ``Tab`` 键
99 | 作为开头。记住,make并不管命令是怎么工作的,他只管执行所定义的命令。make会比较targets文件
100 | 和prerequisites文件的修改日期,如果prerequisites文件的日期要比targets文件的日期要新,或
101 | 者target不存在的话,那么,make就会执行后续定义的命令。
102 |
103 | 这里要说明一点的是, ``clean`` 不是一个文件,它只不过是一个动作名字,有点像c语言中的label一
104 | 样,其冒号后什么也没有,那么,make就不会自动去找它的依赖性,也就不会自动执行其后所定义的命令。
105 | 要执行其后的命令,就要在make命令后明显得指出这个label的名字。这样的方法非常有用,我们可以在一
106 | 个makefile中定义不用的编译或是和编译无关的命令,比如程序的打包,程序的备份,等等。
107 |
108 | make是如何工作的
109 | ----------------
110 |
111 | 在默认的方式下,也就是我们只输入 ``make`` 命令。那么,
112 |
113 | #. make会在当前目录下找名字叫“Makefile”或“makefile”的文件。
114 | #. 如果找到,它会找文件中的第一个目标文件(target),在上面的例子中,他会找到“edit”这个
115 | 文件,并把这个文件作为最终的目标文件。
116 | #. 如果edit文件不存在,或是edit所依赖的后面的 ``.o`` 文件的文件修改时间要比 ``edit`` 这个
117 | 文件新,那么,他就会执行后面所定义的命令来生成 ``edit`` 这个文件。
118 | #. 如果 ``edit`` 所依赖的 ``.o`` 文件也不存在,那么make会在当前文件中找目标为 ``.o`` 文件
119 | 的依赖性,如果找到则再根据那一个规则生成 ``.o`` 文件。(这有点像一个堆栈的过程)
120 | #. 当然,你的C文件和H文件是存在的啦,于是make会生成 ``.o`` 文件,然后再用 ``.o`` 文件生
121 | 成make的终极任务,也就是执行文件 ``edit`` 了。
122 |
123 | 这就是整个make的依赖性,make会一层又一层地去找文件的依赖关系,直到最终编译出第一个目标文件。在
124 | 找寻的过程中,如果出现错误,比如最后被依赖的文件找不到,那么make就会直接退出,并报错,而对于所
125 | 定义的命令的错误,或是编译不成功,make根本不理。make只管文件的依赖性,即,如果在我找了依赖关系
126 | 之后,冒号后面的文件还是不在,那么对不起,我就不工作啦。
127 |
128 | 通过上述分析,我们知道,像clean这种,没有被第一个目标文件直接或间接关联,那么它后面所定义的命
129 | 令将不会被自动执行,不过,我们可以显示要make执行。即命令—— ``make clean`` ,以此来清除所有
130 | 的目标文件,以便重编译。
131 |
132 | 于是在我们编程中,如果这个工程已被编译过了,当我们修改了其中一个源文件,比如 ``file.c`` ,
133 | 那么根据我们的依赖性,我们的目标 ``file.o`` 会被重编译(也就是在这个依性关系后面所定义的命令),
134 | 于是 ``file.o`` 的文件也是最新的啦,于是 ``file.o`` 的文件修改时间要比 ``edit`` 要新,所
135 | 以 ``edit`` 也会被重新链接了(详见 ``edit`` 目标文件后定义的命令)。
136 |
137 | 而如果我们改变了 ``command.h`` ,那么, ``kdb.o`` 、 ``command.o`` 和 ``files.o`` 都
138 | 会被重编译,并且, ``edit`` 会被重链接。
139 |
140 | makefile中使用变量
141 | ------------------
142 |
143 | 在上面的例子中,先让我们看看edit的规则:
144 |
145 | .. code-block:: makefile
146 |
147 | edit : main.o kbd.o command.o display.o \
148 | insert.o search.o files.o utils.o
149 | cc -o edit main.o kbd.o command.o display.o \
150 | insert.o search.o files.o utils.o
151 |
152 | 我们可以看到 ``.o`` 文件的字符串被重复了两次,如果我们的工程需要加入一个新的 ``.o`` 文件,
153 | 那么我们需要在两个地方加(应该是三个地方,还有一个地方在clean中)。当然,我们的makefile并不复
154 | 杂,所以在两个地方加也不累,但如果makefile变得复杂,那么我们就有可能会忘掉一个需要加入的地方,
155 | 而导致编译失败。所以,为了makefile的易维护,在makefile中我们可以使用变量。makefile的变量也
156 | 就是一个字符串,理解成C语言中的宏可能会更好。
157 |
158 | 比如,我们声明一个变量,叫 ``objects`` , ``OBJECTS`` , ``objs`` , ``OBJS`` ,
159 | ``obj`` 或是 ``OBJ`` ,反正不管什么啦,只要能够表示obj文件就行了。我们在makefile一开始就
160 | 这样定义:
161 |
162 | .. code-block:: makefile
163 |
164 | objects = main.o kbd.o command.o display.o \
165 | insert.o search.o files.o utils.o
166 |
167 | 于是,我们就可以很方便地在我们的makefile中以 ``$(objects)`` 的方式来使用这个变量了,于是
168 | 我们的改良版makefile就变成下面这个样子:
169 |
170 | .. code-block:: makefile
171 |
172 | objects = main.o kbd.o command.o display.o \
173 | insert.o search.o files.o utils.o
174 |
175 | edit : $(objects)
176 | cc -o edit $(objects)
177 | main.o : main.c defs.h
178 | cc -c main.c
179 | kbd.o : kbd.c defs.h command.h
180 | cc -c kbd.c
181 | command.o : command.c defs.h command.h
182 | cc -c command.c
183 | display.o : display.c defs.h buffer.h
184 | cc -c display.c
185 | insert.o : insert.c defs.h buffer.h
186 | cc -c insert.c
187 | search.o : search.c defs.h buffer.h
188 | cc -c search.c
189 | files.o : files.c defs.h buffer.h command.h
190 | cc -c files.c
191 | utils.o : utils.c defs.h
192 | cc -c utils.c
193 | clean :
194 | rm edit $(objects)
195 |
196 | 于是如果有新的 ``.o`` 文件加入,我们只需简单地修改一下 ``objects`` 变量就可以了。
197 |
198 | 关于变量更多的话题,我会在后续给你一一道来。
199 |
200 | 让make自动推导
201 | --------------
202 |
203 | GNU的make很强大,它可以自动推导文件以及文件依赖关系后面的命令,于是我们就没必要去在每一个
204 | ``.o`` 文件后都写上类似的命令,因为,我们的make会自动识别,并自己推导命令。
205 |
206 | 只要make看到一个 ``.o`` 文件,它就会自动的把 ``.c`` 文件加在依赖关系中,如果make找到一个
207 | ``whatever.o`` ,那么 ``whatever.c`` 就会是 ``whatever.o`` 的依赖文件。并且
208 | ``cc -c whatever.c`` 也会被推导出来,于是,我们的makefile再也不用写得这么复杂。我们的
209 | 新makefile又出炉了。
210 |
211 | .. code-block:: makefile
212 |
213 | objects = main.o kbd.o command.o display.o \
214 | insert.o search.o files.o utils.o
215 |
216 | edit : $(objects)
217 | cc -o edit $(objects)
218 |
219 | main.o : defs.h
220 | kbd.o : defs.h command.h
221 | command.o : defs.h command.h
222 | display.o : defs.h buffer.h
223 | insert.o : defs.h buffer.h
224 | search.o : defs.h buffer.h
225 | files.o : defs.h buffer.h command.h
226 | utils.o : defs.h
227 |
228 | .PHONY : clean
229 | clean :
230 | rm edit $(objects)
231 |
232 | 这种方法,也就是make的“隐晦规则”。上面文件内容中, ``.PHONY`` 表示 ``clean`` 是个伪目标
233 | 文件。
234 |
235 | 关于更为详细的“隐晦规则”和“伪目标文件”,我会在后续给你一一道来。
236 |
237 | 另类风格的makefiles
238 | -------------------
239 |
240 | 既然我们的make可以自动推导命令,那么我看到那堆 ``.o`` 和 ``.h`` 的依赖就有点不爽,那么多的
241 | 重复的 ``.h`` ,能不能把其收拢起来,好吧,没有问题,这个对于make来说很容易,谁叫它提供了自动
242 | 推导命令和文件的功能呢?来看看最新风格的makefile吧。
243 |
244 | .. code-block:: makefile
245 |
246 | objects = main.o kbd.o command.o display.o \
247 | insert.o search.o files.o utils.o
248 |
249 | edit : $(objects)
250 | cc -o edit $(objects)
251 |
252 | $(objects) : defs.h
253 | kbd.o command.o files.o : command.h
254 | display.o insert.o search.o files.o : buffer.h
255 |
256 | .PHONY : clean
257 | clean :
258 | rm edit $(objects)
259 |
260 | 这种风格,让我们的makefile变得很简单,但我们的文件依赖关系就显得有点凌乱了。鱼和熊掌不可兼得。
261 | 还看你的喜好了。我是不喜欢这种风格的,一是文件的依赖关系看不清楚,二是如果文件一多,要加入几个
262 | 新的 ``.o`` 文件,那就理不清楚了。
263 |
264 | 清空目标文件的规则
265 | ------------------
266 |
267 | 每个Makefile中都应该写一个清空目标文件( ``.o`` 和执行文件)的规则,这不仅便于重编译,也很
268 | 利于保持文件的清洁。这是一个“修养”(呵呵,还记得我的《编程修养》吗)。一般的风格都是:
269 |
270 | .. code-block:: makefile
271 |
272 | clean:
273 | rm edit $(objects)
274 |
275 | 更为稳健的做法是:
276 |
277 | .. code-block:: makefile
278 |
279 | .PHONY : clean
280 | clean :
281 | -rm edit $(objects)
282 |
283 | 前面说过, ``.PHONY`` 表示 ``clean`` 是一个“伪目标”。而在 ``rm`` 命令前面加了一个小减号的
284 | 意思就是,也许某些文件出现问题,但不要管,继续做后面的事。当然, ``clean`` 的规则不要放在文件
285 | 的开头,不然,这就会变成make的默认目标,相信谁也不愿意这样。不成文的规矩是——“clean从来都是放
286 | 在文件的最后”。
287 |
288 | 上面就是一个makefile的概貌,也是makefile的基础,下面还有很多makefile的相关细节,准备好了
289 | 吗?准备好了就来。
290 |
291 | Makefile里有什么?
292 | ------------------
293 |
294 | Makefile里主要包含了五个东西:显式规则、隐晦规则、变量定义、文件指示和注释。
295 |
296 | #. 显式规则。显式规则说明了如何生成一个或多个目标文件。这是由Makefile的书写者明显指出要生成的
297 | 文件、文件的依赖文件和生成的命令。
298 | #. 隐晦规则。由于我们的make有自动推导的功能,所以隐晦的规则可以让我们比较简略地书写
299 | Makefile,这是由make所支持的。
300 | #. 变量的定义。在Makefile中我们要定义一系列的变量,变量一般都是字符串,这个有点像你C语言中的
301 | 宏,当Makefile被执行时,其中的变量都会被扩展到相应的引用位置上。
302 | #. 文件指示。其包括了三个部分,一个是在一个Makefile中引用另一个Makefile,就像C语言中
303 | 的include一样;另一个是指根据某些情况指定Makefile中的有效部分,就像C语言中的预编译#if一
304 | 样;还有就是定义一个多行的命令。有关这一部分的内容,我会在后续的部分中讲述。
305 | #. 注释。Makefile中只有行注释,和UNIX的Shell脚本一样,其注释是用 ``#`` 字符,这个就
306 | 像C/C++中的 ``//`` 一样。如果你要在你的Makefile中使用 ``#`` 字符,可以用反斜杠进行
307 | 转义,如: ``\#`` 。
308 |
309 | 最后,还值得一提的是,在Makefile中的命令,必须要以 ``Tab`` 键开始。
310 |
311 | Makefile的文件名
312 | ----------------
313 |
314 | 默认的情况下,make命令会在当前目录下按顺序找寻文件名为“GNUmakefile”、
315 | “makefile”、“Makefile”的文件,找到了解释这个文件。在这三个文件名中,最好使用“Makefile”
316 | 这个文件名,因为,这个文件名第一个字符为大写,这样有一种显目的感觉。最好不要用“GNUmakefile”,
317 | 这个文件是GNU的make识别的。有另外一些make只对全小写的“makefile”文件名敏感,但是基本上来说,
318 | 大多数的make都支持“makefile”和“Makefile”这两种默认文件名。
319 |
320 | 当然,你可以使用别的文件名来书写Makefile,比如:“Make.Linux”,“Make.Solaris”
321 | ,“Make.AIX”等,如果要指定特定的Makefile,你可以使用make的 ``-f`` 和 ``--file`` 参数,
322 | 如: ``make -f Make.Linux`` 或 ``make --file Make.AIX`` 。
323 |
324 | 引用其它的Makefile
325 | ------------------
326 |
327 | 在Makefile使用 ``include`` 关键字可以把别的Makefile包含进来,这很像C语言的
328 | ``#include`` ,被包含的文件会原模原样的放在当前文件的包含位置。 ``include`` 的语法是:
329 |
330 | .. code-block:: makefile
331 |
332 | include
333 |
334 | ``filename`` 可以是当前操作系统Shell的文件模式(可以包含路径和通配符)。
335 |
336 | 在 ``include`` 前面可以有一些空字符,但是绝不能是 ``Tab`` 键开始。 ``include`` 和
337 | ```` 可以用一个或多个空格隔开。举个例子,你有这样几个Makefile: ``a.mk`` 、
338 | ``b.mk`` 、 ``c.mk`` ,还有一个文件叫 ``foo.make`` ,以及一个变量 ``$(bar)`` ,其包含
339 | 了 ``e.mk`` 和 ``f.mk`` ,那么,下面的语句:
340 |
341 | .. code-block:: makefile
342 |
343 | include foo.make *.mk $(bar)
344 |
345 | 等价于:
346 |
347 | .. code-block:: makefile
348 |
349 | include foo.make a.mk b.mk c.mk e.mk f.mk
350 |
351 | make命令开始时,会找寻 ``include`` 所指出的其它Makefile,并把其内容安置在当前的位置。就好
352 | 像C/C++的 ``#include`` 指令一样。如果文件都没有指定绝对路径或是相对路径的话,make会在当前目
353 | 录下首先寻找,如果当前目录下没有找到,那么,make还会在下面的几个目录下找:
354 |
355 | #. 如果make执行时,有 ``-I`` 或 ``--include-dir`` 参数,那么make就会在这个参数所指定的目
356 | 录下去寻找。
357 | #. 如果目录 ``/include`` (一般是: ``/usr/local/bin`` 或
358 | ``/usr/include`` )存在的话,make也会去找。
359 |
360 | 如果有文件没有找到的话,make会生成一条警告信息,但不会马上出现致命错误。它会继续载入其它的
361 | 文件,一旦完成makefile的读取,make会再重试这些没有找到,或是不能读取的文件,如果还是
362 | 不行,make才会出现一条致命信息。如果你想让make不理那些无法读取的文件,而继续执行,你可以
363 | 在include前加一个减号“-”。如:
364 |
365 | .. code-block:: makefile
366 |
367 | -include
368 |
369 | 其表示,无论include过程中出现什么错误,都不要报错继续执行。和其它版本make兼容的相关命令
370 | 是sinclude,其作用和这一个是一样的。
371 |
372 | 环境变量MAKEFILES
373 | -----------------
374 |
375 | 如果你的当前环境中定义了环境变量 ``MAKEFILES`` ,那么,make会把这个变量中的值做一个类似于
376 | ``include`` 的动作。这个变量中的值是其它的Makefile,用空格分隔。只是,它和 ``include`` 不
377 | 同的是,从这个环境变量中引入的Makefile的“目标”不会起作用,如果环境变量中定义的文件发现
378 | 错误,make也会不理。
379 |
380 | 但是在这里我还是建议不要使用这个环境变量,因为只要这个变量一被定义,那么当你使用make时,
381 | 所有的Makefile都会受到它的影响,这绝不是你想看到的。在这里提这个事,只是为了告诉大家,也许
382 | 有时候你的Makefile出现了怪事,那么你可以看看当前环境中有没有定义这个变量。
383 |
384 | make的工作方式
385 | --------------
386 |
387 | GNU的make工作时的执行步骤如下:(想来其它的make也是类似)
388 |
389 | #. 读入所有的Makefile。
390 | #. 读入被include的其它Makefile。
391 | #. 初始化文件中的变量。
392 | #. 推导隐晦规则,并分析所有规则。
393 | #. 为所有的目标文件创建依赖关系链。
394 | #. 根据依赖关系,决定哪些目标要重新生成。
395 | #. 执行生成命令。
396 |
397 | 1-5步为第一个阶段,6-7为第二个阶段。第一个阶段中,如果定义的变量被使用了,那么,make会把其展
398 | 开在使用的位置。但make并不会完全马上展开,make使用的是拖延战术,如果变量出现在依赖关系的规则
399 | 中,那么仅当这条依赖被决定要使用了,变量才会在其内部展开。
400 |
401 | 当然,这个工作方式你不一定要清楚,但是知道这个方式你也会对make更为熟悉。有了这个基础,后续部分
402 | 也就容易看懂了。
--------------------------------------------------------------------------------
/docs/python/python.md:
--------------------------------------------------------------------------------
1 | #Python Tricks
2 | ---
3 |
4 | *Copy right by ChenRuiyang*
5 |
6 | ---
7 |
8 | ##一些优雅的写法
9 | + 添加 utils.py, config.py,其中 utils.py 写一些功能性的函数,configs.py 写一些常用参数. 需要里面的函数就 import utils,config. 如果引用 utils.py 或者 config.py 的 python 文件和他们在同一文件夹下,就不需要任何操作,否则需要加如下语句:
10 | ```python
11 | import sys
12 | sys.path.append('path_to_utils_or_config')
13 | ```
14 | 举个例子,如果他们在上一级文件夹中,则可以这么写
15 | ```python
16 | import sys
17 | sys.path.append('..')
18 | ```
19 | + `if __name__ == "__main__":`
20 | 上面的语句可以做到只有在运行自己时才执行if语句,如果是被其他 python 文件调用,则 if 语句将被忽略.
21 | 这是因为__name__是文件的一个属性,如果是被其他 python 文件调用,__name__将会变成其他,可以 print 一下看看是什么.
22 | + ```python
23 | from tqdm import tqdm
24 | for i in tqdm(range(1,10005))
25 | ```
26 | tqdm 可以给循环加进度条,很好用.
27 | + ```python
28 | dataPath=config.dataPath
29 | for root, dirs, files in os.walk(dataPath):
30 | for file in tqdm(files):
31 | filePath=os.path.join(root, file)
32 | ```
33 | 遍历文件的写法,注意第二个 for 循环的 root 并不是第一个 for 循环的 root,而是对应 file in files 中每一个 file 的 root.
34 | + numpy保存读取的格式,举几个例子
35 | ```python
36 | import numpy as np
37 | np.savetxt(r'../data/x1.txt',x[1],fmt='%s',newline='\n')
38 | np.save(r'../data/x1.npy',x[1])
39 | x1=np.load('../data/x1.npy')
40 | x2=np.load('../data/x1.txt')
41 | ```
42 | + 对矩阵的行列哪个在前哪个在后傻傻分不清,对np.size不会用,看看下面的输出结果就懂了:
43 | ```python
44 | test=[[1,3,4,2],
45 | [2,1,4,3],
46 | [3,2,4,4],
47 | [4,1,1,2]]
48 |
49 | print(test[0][2])
50 | print(np.size(test),np.size(test,1),np.size(test,0))
51 | ```
--------------------------------------------------------------------------------
/paper/GEM5_tutorial/ASPLOS2017_gem5_tutorial.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cry-daniel/Computer-Architecture-Learning/0c384ac88181333788920b76bab387b18136faa0/paper/GEM5_tutorial/ASPLOS2017_gem5_tutorial.pdf
--------------------------------------------------------------------------------
/paper/GEM5_tutorial/MB2020-HiPEAC_20201-gem5-sve-hands-on.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cry-daniel/Computer-Architecture-Learning/0c384ac88181333788920b76bab387b18136faa0/paper/GEM5_tutorial/MB2020-HiPEAC_20201-gem5-sve-hands-on.pdf
--------------------------------------------------------------------------------
/paper/GEM5_tutorial/gem5_tutorial.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cry-daniel/Computer-Architecture-Learning/0c384ac88181333788920b76bab387b18136faa0/paper/GEM5_tutorial/gem5_tutorial.pdf
--------------------------------------------------------------------------------
/paper/README.md:
--------------------------------------------------------------------------------
1 | ```
2 | ├─GEM5_tutorial
3 | │ ASPLOS2017_gem5_tutorial.pdf
4 | │ gem5_tutorial.pdf
5 | │ MB2020-HiPEAC_20201-gem5-sve-hands-on.pdf
6 | │
7 | └─misc
8 | Continuous_Runahead.md
9 | Continus_Runahead_MICRO.pdf
10 | The_Accelerator_Wall_HPCA.pdf
11 | ```
12 |
13 |
--------------------------------------------------------------------------------
/paper/misc/Continuous_Runahead.md:
--------------------------------------------------------------------------------
1 | # Continus Runahead: Transparent Hardware Acceleration for Memory Intensive Workloads
2 |
3 | ## 为什么写这篇文章(背景)
4 | + 即使采用 Runahead ,程序执行时间仍有一半是从主存中取数据.
5 | + 发现 Runahead 的准确性很高,但覆盖率不太行(13%)
6 | + 于是作者研究了为什么覆盖率不高,发现:
7 | + Run ahead intervals are short
8 | + Limit by the duration of each full-window stall
9 | + 作者基于此提出了目标:要做到更好的 Runahead prefetch data ,增加覆盖率,以此减少 stall ,进而提升程序执行效率.
10 |
11 | ## 本文的创新点
12 | + 提出了 interval length 限制了 performance.
13 | + 提出了一种 low-cost , high-efficiency 的实现方案(即 Continuous Runahead),该实现方案基于两个关键的 ideal:
14 | + most critical dependence chain can be dynamically identified with low cost as ***run time***
15 | + critical dependence chain can be repeatedly executed with CRE(Continuous Runahead Engine)
16 | + CRE 在 memory controller 并且只占用 2% 的空间 (4核)
17 |
18 | ## Runahead 的思路
19 | $$
20 | Continuous \ Runahead \ Instruction \ Supply \\
21 | \downarrow \\
22 | Continuous \ Runahead \ Hardware \\
23 | \downarrow \\
24 | Continuous \ Runahead \ Control
25 | $$
26 | ### Continuous Runahead Instruction Supply
27 | + 原理本质上就是一句话:在 runahead 中,最应该被预取的数据是导致 pipeline stall 最频繁的数据.
28 | + 基于上述原理,为了实现数据预取,这里引入了 dependence chain ,也就是将数据依赖写成链的形式,这样是为了方便后面 continuously execute.
29 | + 现在问题变成了怎么找 dependence chain 以及找几个 dependence chain.
30 | + 怎么找 dependence chain 作者提出了3个可能的策略:
31 | 1. PC-based Policy
32 | 2. Maximum-Misses Policy
33 | 3. Stall Policy
34 | 这三个策略本质上是递进的,结果见 Figure 5,最后的结论是 Stall Policy 最好.
35 | 此外还有一个结论是不一定要存下所有的 PCs ,90%的 full-window stall 是由20%的 operations 造成的(数据见 Figure 6),只存下那20%可以在几乎不影响性能的情况下节省存储的开销.
36 | + 作者在实验后发现1个 dependence chain 在大多数情况就够用了,甚至有的情况比多的性能还好,详见 Figure 7.
37 |
38 | ### Continuous Runahead Engine
39 | + 在有了 dependence chain 之后,还需要 continuously execute ,即需要执行的硬件.
40 | + 硬件一开始挑的是 SMT thread contexts 或 idle core(空闲的),但发现太浪费了,一是不怎么需要 register file,二是只有整型操作,用不到浮点和向量单元.
41 | + 于是就在 memory controller 设计了 CRE(Continuous Runahead Engine)
42 | + CRE 的流程:
43 | + track 32 PCs that have caused the most full-window stall
44 | + if processor is in a memory-intensive phase, begin a dependence chain generation
45 |
46 | ### Continuous Runahead Control
47 | + 不能无期限执行或执行一个 interval 过久,也就意味着要经常替换
48 | + CRE update interval: the time between dependence chain updates from the core
49 | + 发现选 100k 是个较为合适的策略
50 |
51 | ### 其他
52 | + 仿真器:Multi2Sim
53 | + 配置
54 | + 实验结果
55 | + 多核扩展
56 |
57 | ### 总结
58 | + Continuous Runahead 本质上是通过 CRE 不间断的执行 dependence chain, dependence chain 每过一定的 CRE update interval 就要进行更换,这是因为要适应不同的程序片段.
59 | + 低能耗、高效率、可在 run time 发掘(最重要的) dependence chain.
60 | + dependence chain 可被重复执行并通过 CRE 控制,性能较之前有极大的提升.
--------------------------------------------------------------------------------
/paper/misc/Continus_Runahead_MICRO.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cry-daniel/Computer-Architecture-Learning/0c384ac88181333788920b76bab387b18136faa0/paper/misc/Continus_Runahead_MICRO.pdf
--------------------------------------------------------------------------------
/paper/misc/The_Accelerator_Wall_HPCA.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cry-daniel/Computer-Architecture-Learning/0c384ac88181333788920b76bab387b18136faa0/paper/misc/The_Accelerator_Wall_HPCA.pdf
--------------------------------------------------------------------------------
/report/README.md:
--------------------------------------------------------------------------------
1 | ```
2 | ├─gem5
3 | │ apl_test_report_spmv.md
4 | │ doc_zhanglucheng_Full_System实验记录.md
5 | │ gem5_arm_time_test.md
6 | │ gem5_checkpoint.md
7 | │ gem5_checkpoint_test.md
8 | │ gem5_FS_arm_linux.md
9 | │
10 | ├─Simpoint
11 | │ Simpoint_record.md
12 | │ Simpoint_record.pdf
13 | │
14 | └─Testbench
15 | GAP.md
16 | Graph500.md
17 | SPEC17_and_Simpoint.md
18 | ```
19 |
20 |
--------------------------------------------------------------------------------
/report/Simpoint/Simpoint_record.md:
--------------------------------------------------------------------------------
1 | # Simpoint 实验记录
2 |
3 | ## 采用不同聚类数对结果的影响
4 |
5 | ### 聚类数为4 (MAX=5)
6 | + 实验配置如下:
7 | ```
8 | # 这里normal的配置和使用O3重载checkpoint时的配置一样
9 | build/ARM/gem5.fast --outdir=${SE_OUT_DIR_NORMAL} \
10 | configs/example/se.py \
11 | --cpu-type O3_ARM_v7a_3 \
12 | --cpu-clock 2.5GHz \
13 | --num-cpu 1 \
14 | --caches --l2cache --l1i_size 64kB --l1d_size 32kB --l2_size 1MB \
15 | --l1i_assoc 8 --l1d_assoc 8 --l2_assoc 16 --cacheline_size 128 \
16 | --mem-type DDR3_2133_8x8 --mem-size 16GB
17 | ```
18 | + 此时的权重为:
19 | |聚类簇序号 |权重(已归一化) |
20 | |- |- |
21 | |0 |0.345946 |
22 | |1 |0.0378378 |
23 | |2 |0.318919 |
24 | |3 |0.297297 |
25 | 可以发现,此时存在三个权重较大的聚类簇,而剩下一个聚类簇的权重相比可以忽略不计.
26 | + 对此分类结果进行模拟,结果如下:
27 | |参数 |正常运行的结果 |Simpoint的结果 |误差(%) |
28 | |- |- |- |- |
29 | |IPC |1.676 |1.336 |20.24 |
30 | |Dcache miss rate (%) |6.462 |5.881 |9.00 |
31 | |Mispredict rate (%) |1.664 |3.266 |96.27 |
32 | |ROB stall rate (%) |0.0029|0.0019 |34.36 |
33 | 发现当聚类簇总数过小时会存在相当大的误差,可能的原因如下:
34 | + 设置的 interval length 不够长,之前设置的 `interval length = 1e7` 可能无法较好的模拟一个较长的代码段
35 | + 可能有不止三个主要的代码段,设置聚类数过少就较为片面
36 |
37 | ### 聚类数为28 (MAX=30)
38 | + 实验配置如下:
39 | ```
40 | # 这里normal的配置和使用O3重载checkpoint时的配置一样
41 | build/ARM/gem5.fast --outdir=${SE_OUT_DIR_NORMAL} \
42 | configs/example/se.py \
43 | --cpu-type O3_ARM_v7a_3 \
44 | --cpu-clock 2.5GHz \
45 | --num-cpu 1 \
46 | --caches --l2cache --l1i_size 64kB --l1d_size 32kB --l2_size 1MB \
47 | --l1i_assoc 8 --l1d_assoc 8 --l2_assoc 16 --cacheline_size 128 \
48 | --mem-type DDR3_2133_8x8 --mem-size 16GB
49 | ```
50 | + 此时的权重为(只标出了权重大于0.05的项):
51 |
52 | |聚类簇序号 |权重(已归一化) |
53 | |- |- |
54 | |...|... |
55 | |3 |0.108106 |
56 | |4 |0.0972973 |
57 | |...|... |
58 | |11 |0.145946 |
59 | |...|... |
60 | |17 |0.0648649 |
61 | |...|... |
62 | |24 |0.0594595 |
63 | |...|... |
64 | 可以发现,此时不存在权重特别大的聚类簇,但相比而言较大的有三个聚类簇(近似大于等于0.1),其他结果都比较平均.
65 | + 对此分类结果进行模拟,结果如下:
66 | |参数 |正常运行的结果 |Simpoint的结果 |误差(%) |
67 | |- |- |- |- |
68 | |IPC |1.676 |1.687 |0.71 |
69 | |Dcache miss rate (%) |6.462 |6.452 |0.16 |
70 | |Mispredict rate (%) |1.664 |1.694 |1.80 |
71 | |ROB stall rate (%) |0.0029|0.0030 |4.52 |
72 | 发现当聚类簇较多时,误差被控制在一个合理的范围内.
73 | + 接下来考虑**只算权重大于0.05的聚类簇(共五个)**,结果如下:
74 | |参数 |正常运行的结果 |Simpoint的结果 |误差(%) |
75 | |- |- |- |- |
76 | |IPC |1.676 |1.712 |2.17 |
77 | |Dcache miss rate (%) |6.462 |6.405 |0.88 |
78 | |Mispredict rate (%) |1.664 |1.436 |13.69 |
79 | |ROB stall rate (%) |0.0029|0.0042 |43.58 |
80 | 发现结果相较于之前全部都算的误差变大,部分误差甚至超过 10% ,所以还是要全部 checkpoint 都算为好.
81 | ### 结论
82 | + 综上所述,在 GEM5 里使用 Simpoint 是具有相当合理性的,但是如果要取典型的片段进行模拟,合理的措施还是尝试减小聚类个数以及增大 interval length.
83 | + 后来又尝试了减少聚类总数但增加 interval length 的策略,但是准确率依然不够,详见下表:
84 | ```
85 | Simpoint results are:
86 | IPC = 1.6541297322928858
87 | Dcache miss rate = 0.05404827342566031
88 | Predict incorrect rate = 0.020100357727433814
89 | ROB stall rate = 2.463187811511429e-05
90 |
91 | Normal results are:
92 | IPC = 1.667545945165815
93 | Dcache miss rate = 0.06463431515940303
94 | Predict incorrect rate = 0.01663909859660678
95 | ROB stall rate = 2.86616936490782e-05
96 |
97 | Errors are:
98 | IPC : 0.8045483191526154 %
99 | Dcache miss : 16.37836141318294 %
100 | Predict incorrect : 20.801962983336676 %
101 | ROB stall: 14.059935129107476 %
102 | ```
103 |
104 | ## 在重载checkpoint时更改参数对实验结果的影响
105 | ### 更改CPU类型以及主频
106 | + 将CPU类型从 O3_ARM_v7a_3 更改为 DerivO3CPU,将主频从 2.5GHz 调整为 1GHz.
107 | + 实验结果如下:
108 | |参数 |正常运行的结果 |Simpoint的结果 |误差(%) |
109 | |- |- |- |- |
110 | |IPC |1.906 |1.924 |0.94 |
111 | |Dcache miss rate (%) |7.170 |7.192 |0.32 |
112 | |Mispredict rate (%) |1.844 |1.798 |2.51 |
113 | |ROB stall rate (%) |0.0007|0.0005 |20.27 |
114 |
115 | ### 更改cache参数
116 | + 将 cache 参数从
117 | `-caches --l2cache --l1i_size 64kB --l1d_size 32kB --l2_size 1MB --l1i_assoc 8 --l1d_assoc 8 --l2_assoc 16 --cacheline_size 128`
118 | 调整到
119 | `--caches --l2cache --l1i_size 32kB --l1d_size 16kB --l2_size 512kB --l1i_assoc 1 --l1d_assoc 1 --l2_assoc 1 --cacheline_size 128`
120 | + 实验结果如下:
121 | |参数 |正常运行的结果 |Simpoint的结果 |误差(%) |
122 | |- |- |- |- |
123 | |IPC |1.535 |1.493 |2.74 |
124 | |Dcache miss rate (%) |9.759 |9.790 |0.31 |
125 | |Mispredict rate (%) |1.685 |1.717 |1.89 |
126 | |ROB stall rate (%) |0.0057|0.0061 |8.07 |
127 |
128 | ### 更改mem类型
129 | + 将 mem 参数从 DDR3_2133_8x8 调整为 DDR4_2400_16x4
130 | + 实验结果如下:
131 | |参数 |正常运行的结果 |Simpoint的结果 |误差(%) |
132 | |- |- |- |- |
133 | |IPC |1.668 |1.677 |0.58 |
134 | |Dcache miss rate (%) |6.463 |6.453 |0.16 |
135 | |Mispredict rate (%) |1.664 |1.694 |1.78 |
136 | |ROB stall rate (%) |0.0028|0.0031 |9.67 |
137 |
138 | ### 结论
139 |
140 | + 在重载时更改 CPU,cache 以及 mem 的参数对除了 ROB stall 外的实验结果都没有特别大的影响,ROB stall 受影响大主要是因为 Stall 次数太少了,所以较少的浮动在误差上会体现的比较大,但是从总的 ROB stall rate 来看绝对误差都在 0.001% 内,还是可以接受的.
--------------------------------------------------------------------------------
/report/Simpoint/Simpoint_record.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cry-daniel/Computer-Architecture-Learning/0c384ac88181333788920b76bab387b18136faa0/report/Simpoint/Simpoint_record.pdf
--------------------------------------------------------------------------------
/report/Testbench/GAP.md:
--------------------------------------------------------------------------------
1 | # GAP
2 |
3 | ## 简介
4 | + GAP 基准套件旨在通过标准化评估来帮助图形处理研究。图形处理评估之间的差异越小,就越容易比较不同的研究工作和量化改进。该基准测试不仅指定了图内核、输入图和评估方法,而且还提供了优化的基线实现(此 repo)。这些基线实现代表了最先进的性能,因此新的贡献应该优于它们以证明改进。
5 |
6 | ## Kernels Included
7 | + Breadth-First Search (BFS) - direction optimizing
8 | + Single-Source Shortest Paths (SSSP) - delta stepping
9 | + PageRank (PR) - iterative method in pull direction
10 | + Connected Components (CC) - Afforest & Shiloach-Vishkin
11 | 求一个图的联通分支
12 | + Betweenness Centrality (BC) - Brandes
13 | 如果最短路中的很多条都经过某个节点,那么这个节点的 BC 就高,计算是用经过它的除以总的
14 | + Triangle Counting (TC) - Order invariant with possible relabelling
15 | 找图里的三角形
16 |
17 | ## 参数
18 | ```
19 | All of the binaries use the same command-line options for loading graphs:
20 |
21 | -g 20 generates a Kronecker graph with 2^20 vertices (Graph500 specifications)
22 | -u 20 generates a uniform random graph with 2^20 vertices (degree 16)
23 | -f graph.el loads graph from file graph.el
24 | -sf graph.el symmetrizes graph loaded from file graph.el
25 |
26 | The graph loading infrastructure understands the following formats:
27 |
28 | .el plain-text edge-list with an edge per line as node1 node2
29 | .wel plain-text weighted edge-list with an edge per line as node1 node2 weight
30 | .gr 9th DIMACS Implementation Challenge format
31 | .graph Metis format (used in 10th DIMACS Implementation Challenge)
32 | .mtx Matrix Market format
33 | .sg serialized pre-built graph (use converter to make)
34 | .wsg weighted serialized pre-built graph (use converter to make)
35 | ```
36 |
37 | ## GAP 编译流程
38 | + 正常情况:
39 | + 修改 gap/Makefile 中的 CXX ,在服务器上 CXX=g++ (X86) 或 CXX=aarch64-none-linux-gnu-g++ (ARM64)
40 | + 在 gap 路径下输入 `make` 即可编译.
41 | + 加入 m5ops 的情况:
42 | + 首先修改 gap/src/benchmark.h ,在 kernel 的部分做如下修改:
43 | ```cpp
44 | #include "/home/data/ChenRuiyang/gem5/include/gem5/m5ops.h" //new add
45 |
46 | ...
47 |
48 | m5_checkpoint(0,0); // new add
49 | m5_reset_stats(0,0); // new add
50 | auto result = kernel(g);
51 | m5_exit(0); // new add
52 |
53 | ...
54 |
55 | ```
56 | 目的是为了能够使 gem5 只记录 kernel 核心部分运行的情况,统计信息不再包含数据的载入以及结果的输出.
57 | + 修改 Makefile 中的 CXX_FLAGS 以及编译命令,将其修改如下:
58 | ```makefile
59 | # old CXX_FLAGS
60 | # CXX_FLAGS += -std=c++11 -O3 -Wall -static
61 |
62 | # new CXX_FLAGS
63 | CXX_FLAGS += -std=c++11 -O3 -I /home/data/ChenRuiyang/gem5/include/ \
64 | -L /home/data/ChenRuiyang/gem5/util/m5/build/aarch64/out -lm5 -static
65 |
66 | # old command
67 | # % : src/%.cc src/*.h
68 | # $(CXX) $(CXX_FLAGS) $< -o $@
69 |
70 | # new command
71 | % : src/%.cc src/*.h
72 | $(CXX) $< -o $@ $(CXX_FLAGS)
73 | ```
74 | + 输入 `make` 即可编译.
75 |
76 | ## GAP 运行流程
77 | + 正常情况
78 | + 在 gap 路径下输入如下命令:
79 | ```bash
80 | # example
81 | ./bc -g 10 -n 1
82 | ```
83 | `./bc` 是运行的测试程序的名称,`-g 10` 是生成大小为 $2^{10}$ 的 kronecker graph , `-n 1` 是代表执行1遍 kernel ,如果 `-n 10` 将执行10遍 kernel ,每次执行都会采用不同的参数.
84 | + 如果需要指定输入文件,则需要在后面加上 `-f my_input_file` ,例如:
85 | ```bash
86 | # example
87 | ./bc -f input/ks2010.mtx -n 1
88 | ```
89 | `input/ks2010.mtx` 是我们给定的输入矩阵,除了 `.mtx` 也支持其他常见矩阵格式的输入,例如以下的情形:
90 | ```
91 | .el plain-text edge-list with an edge per line as node1 node2
92 | .wel plain-text weighted edge-list with an edge per line as node1 node2 weight
93 | .gr 9th DIMACS Implementation Challenge format
94 | .graph Metis format (used in 10th DIMACS Implementation Challenge)
95 | .mtx Matrix Market format
96 | .sg serialized pre-built graph (use converter to make)
97 | .wsg weighted serialized pre-built graph (use converter to make)
98 | ```
99 | + 常用的 kernel 有 6 个,分别是:
100 | + Breadth-First Search (BFS) - direction optimizing
101 | + Single-Source Shortest Paths (SSSP) - delta stepping
102 | + PageRank (PR) - iterative method in pull direction
103 | + Connected Components (CC) - Afforest & Shiloach-Vishkin
104 | 求一个图的联通分支
105 | + Betweenness Centrality (BC) - Brandes
106 | 如果最短路中的很多条都经过某个节点,那么这个节点的 BC 就高,计算是用经过它的除以总的
107 | + Triangle Counting (TC) - Order invariant with possible relabelling
108 | 找图里的三角形
109 | + 加入 m5ops 的情况:
110 | + 加入 m5ops 之后就无法正常在服务器上运行了(很奇特,X86 架构的服务器能运行 ARM 架构的程序,但是本机用 X86 的 CPU 就没法运行),则需要在 gem5 里运行,命令行如下:
111 | ```bash
112 | # 以 ARM 为例,X86 类似
113 | build/ARM/gem5.fast --outdir=m5out/GAP_bc_m5ops_normal \
114 | configs/example/se.py --cpu-type O3_ARM_v7a_3 --cpu-clock 3.1GHz \
115 | --num-cpu 1 --caches --l2cache --l1i_size 64kB --l1d_size 64kB \
116 | --l2_size 1MB --l1i_assoc 4 --l1d_assoc 4 --l2_assoc 4 \
117 | --cacheline_size 128 --mem-type DDR3_2133_8x8 --mem-size 16GB \
118 | --l2-hwp-type StridePrefetcher \
119 | -c /home/data/ChenRuiyang/gap_GEM5_version/bc \
120 | -o ' -f /home/data/ChenRuiyang/gap_GEM5_version/input/ks2010.mtx'
121 | ```
122 | 其中 `-c` 是 gem5 中需要被执行的程序,`-o` 是传给命令行的参数,等待执行完成之后读 `/m5out` 中的统计信息即可
--------------------------------------------------------------------------------
/report/Testbench/Graph500.md:
--------------------------------------------------------------------------------
1 | # Graph 500
2 |
3 | ## 简介
4 | + 数据密集型超级计算机应用程序是越来越重要的工作负载,但不适合为 3D 物理模拟设计的平台。没有有意义的基准测试就无法提高应用程序性能。图是大多数分析工作负载的核心部分。在由来自学术界、工业界和国家实验室的 30 多位国际 HPC 专家组成的指导委员会的支持下,该规范为这些应用建立了大规模基准。它将为社区提供一个论坛,并为数据密集型超级计算问题提供一个集结点。
5 | + 基准测试问题(“搜索”和“最短路径”)的目的是开发一个紧凑的应用程序,该应用程序具有多种分析技术(多个内核),可以访问表示加权无向图的单个数据结构。除了从输入元组列表构建图的内核之外,还有两个额外的计算内核可以对图进行操作。
6 | + 该基准测试包括一个可扩展的数据生成器,它生成包含每个边的起始顶点和结束顶点的边元组。第一个内核以所有后续内核都可用的格式构造一个无向图。不允许进行后续修改以使特定内核受益。第二个内核对图执行广度优先搜索。第三个内核在图上执行多个单源最短路径计算。所有三个内核都是定时的(包含在性能里)。
7 |
8 | ## 步骤
9 | 1. Generate the edge list.
10 | 2. Construct a graph from the edge list (timed, kernel 1).
11 | 3. Randomly sample 64 unique search keys with degree at least one, not counting self-loops.
12 | 4. For each search key:
13 | 1. Compute the parent array (timed, kernel 2).
14 | 2. Validate that the parent array is a correct BFS search tree for the given search tree.
15 | 5. For each search key:
16 | 1. Compute the parent array and the distance array (timed, kernel 3).
17 | 2. Validate that the parent array/distance vector is a correct SSSP search tree with shortest paths for the given search tree.
18 | 6. Compute and output performance information.
19 |
20 | ## Generate the edge list (还没到 kernel)
21 | + 可扩展数据生成器将构造一个包含顶点标识符的边元组列表。每条边都是无向的,其端点在元组中指定为 StartVertex、EndVertex 和 Weight。如果边元组仅用于运行内核 2,则允许不生成边权重。这允许 BFS 运行不受存储边缘权重导致的不必要内存使用的影响。
22 | + 下面第一个内核的目的是将没有局部性的列表转换为更优化的形式。生成的输入元组列表不得表现出任何可被计算内核利用的局部性。因此,顶点编号必须随机化,并且元组的随机排序必须呈现给内核 1。数据生成器可以并行化,但顶点名称必须全局一致,并且必须注意尽量减少处理器中数据局部性的影响等级。
23 |
24 | ### 参数
25 | + scale: 规模参数,总顶点数为 $2^{scale}$
26 | + edgefactor: 图的边数与其顶点数的比率(即图中顶点平均度数的一半)
27 | + 由此推出总边数为: $N=edgefactor*2^{scale}$
28 | + 采用了 Kronecker generator 的算法,算法有四个参数:a,b,c,d,它们对应邻接矩阵的四个大小相等的分区,含义为邻接矩阵添加边时选择该分区的概率.
29 |
30 | ## Kernel 1 : Constrct a graph
31 | + 第一个内核可以将边列表转换为用于其余内核的任何数据结构(保存在内部或外部存储器中)。例如,内核 1 可以从元组列表构造一个(稀疏)图;每个元组包含一条边的端点标识符,以及一个表示分配给边的数据的权重。
32 | + 该图可以以任何方式表示,但不能被后续内核修改或在后续内核之间进行修改。可以在数据结构中保留空间用于标记或锁定。一次只能运行一个内核副本;该内核对任何此类标记或锁定空间具有独占访问权,并且被允许(仅)修改该空间。
33 | + 稀疏图有多种内部存储器表示,包括(但不限于)稀疏矩阵和(多级)链表。出于本应用的目的,内核仅提供边列表和边列表的大小。必须在此内核中计算更多信息,例如顶点数。
34 | + ```
35 | function G = kernel_1 (ij)
36 | %% Compute a sparse adjacency matrix representation
37 | %% of the graph with edges from ij.
38 |
39 | %% Remove self-edges.
40 | ij(:, ij(1,:) == ij(2,:)) = [];
41 | %% Adjust away from zero labels.
42 | ij = ij + 1;
43 | %% Find the maximum label for sizing.
44 | N = max (max (ij));
45 | %% Create the matrix, ensuring it is square.
46 | G = sparse (ij(1,:), ij(2,:), ones (1, size (ij, 2)), N, N);
47 | %% Symmetrize to model an undirected graph.
48 | G = spones (G + G.');
49 | ```
50 |
51 | ## Kernel 2 : Breadth-First Search
52 | + 图的广度优先搜索 (BFS) 从单个源顶点开始,然后分阶段查找并标记其邻居,然后是其邻居的邻居等。这是许多图算法所基于的基本方法. BFS 的正式描述可以在 Cormen、Leiserson 和 Rivest 中找到。下面,我们为 BFS 基准指定输入和输出,并对计算施加一些限制。但是,我们不限制 BFS 算法本身的选择,只要它产生正确的 BFS 树作为输出即可。
53 | + 该基准测试的内存访问模式(内部或外部)依赖于数据,平均预取深度较小。就像在简单的并发链表遍历基准测试中一样,性能反映了架构在执行并发线程时的吞吐量,每个线程都具有低内存并发性和高内存引用密度。与此类基准测试不同的是,当许多内存引用指向同一位置时,该基准测试还测量了对热点的恢复能力;当每个线程的执行路径依赖于其他线程的异步副作用时的效率;以及动态负载平衡不可预测大小的工作单元的能力。测量同步性能不是这里的主要目标。
54 | + 您不能同时从多个搜索键进行搜索。在此内核的不同调用之间不能传递任何信息。内核可能会返回一个用于验证的深度数组。
55 | + 算法说明当 BFS 级别 k 的顶点发现级别 k+1 的顶点时,我们允许良性竞争条件。具体来说,我们不需要同步来确保第一个访问者必须成为父访问者,同时锁定后续访问者。只要最后发现的 BFS 树是正确的,就认为算法是正确的。
56 | + ```
57 | function parent = kernel_2 (G, root)
58 | %% Compute a sparse adjacency matrix representation
59 | %% of the graph with edges from ij.
60 |
61 | N = size (G, 1);
62 | %% Adjust from zero labels.
63 | root = root + 1;
64 | parent = zeros (N, 1);
65 | parent (root) = root;
66 |
67 | vlist = zeros (N, 1);
68 | vlist(1) = root;
69 | lastk = 1;
70 | for k = 1:N,
71 | v = vlist(k);
72 | if v == 0, break; end
73 | [I,J,V] = find (G(:, v));
74 | nxt = I(parent(I) == 0);
75 | parent(nxt) = v;
76 | vlist(lastk + (1:length (nxt))) = nxt;
77 | lastk = lastk + length (nxt);
78 | end
79 |
80 | %% Adjust to zero labels.
81 | parent = parent - 1;
82 | ```
83 |
84 | ## Kernel 3 : Single Source Shortest Paths
85 | + 单源最短路径 (SSSP) 计算找到从给定起始顶点到图中每个其他顶点的最短距离。也可以在 Cormen、Leiserson 和 Rivest 中找到对非负权重图上 SSSP 的正式描述。我们为 SSSP 基准指定了输入和输出,并对计算施加了一些限制。但是,我们不限制 SSSP 算法本身的选择,只要实现产生正确的 SSSP 距离向量和父树作为输出即可。这是一个单独的内核,不能使用内核 2 (BFS)计算的数据。
86 | + 该内核通过额外的测试和每个顶点的数据访问扩展了整体基准。许多但并非所有的 SSSP 算法都与 BFS 相似,并且存在类似的热点和重复内存引用问题。
87 | + 您不能同时从多个初始顶点进行搜索。在此内核的不同调用之间不能传递任何信息。
88 | + 算法说明我们也允许 SSSP 中的良性竞争条件。我们不要求第一个访问者必须阻止后续访问者占用父位置。只要最后SSSP距离和父树是正确的,算法就被认为是正确的。
89 | + ```
90 | function [parent, d] = kernel_3 (G, root)
91 | %% Compute the shortest path lengths and parent
92 | %% tree starting from vertex root on the graph
93 | %% represented by the sparse matrix G. Every
94 | %% vertex in G can be reached from root.
95 |
96 | N = size (G, 1);
97 | %% Adjust from zero labels.
98 | root = root + 1;
99 | d = inf * ones (N, 1);
100 | parent = zeros (N, 1);
101 | d (root) = 0;
102 | parent (root) = root;
103 |
104 | Q = 1:N;
105 | while length (Q) > 0
106 | [dist, idx] = min (d(Q));
107 | v = Q(idx);
108 | Q = setdiff (Q, v);
109 | [I, J, V] = find (G (:, v));
110 | for idx = 1:length(I),
111 | u = I(idx);
112 | dist_tmp = d(v) + V(idx);
113 | if dist_tmp < d(u),
114 | d(u) = dist_tmp;
115 | parent(u) = v;
116 | end
117 | end
118 | end
119 |
120 | %% Adjust back to zero labels.
121 | parent = parent - 1;
122 | ```
123 |
124 | ## 其他
125 | ### 验证
126 | + 因为采用了随机数(伪),所以没有确定的结果可以比对,需要验证
127 | + 具体验证方法没细看,但是验证的时间是不记在总时间里的.
128 | + ```
129 | function out = validate (parent, ijw, search_key, d, is_sssp)
130 | %% Validate the results of BFS or SSSP.
131 |
132 | %% Default: no error.
133 | out = 1;
134 |
135 | %% Adjust from zero labels.
136 | parent = parent + 1;
137 | search_key = search_key + 1;
138 | ijw = ijw + 1;
139 |
140 | %% Remove self-loops.
141 | ijw(:,(ijw(1, :) == ijw(2, :))') = [];
142 |
143 | %% root must be the parent of itself.
144 | if parent (search_key) != search_key,
145 | out = 0;
146 | return;
147 | end
148 |
149 | N = max (max (ijw(1:2,:)));
150 | slice = find (parent > 0);
151 |
152 | %% Compute levels and check for cycles.
153 | level = zeros (size (parent));
154 | level (slice) = 1;
155 | P = parent (slice);
156 | mask = P != search_key;
157 | k = 0;
158 | while any (mask),
159 | level(slice(mask)) = level(slice(mask)) + 1;
160 | P = parent (P);
161 | mask = P != search_key;
162 | k = k + 1;
163 | if k > N,
164 | %% There must be a cycle in the tree.
165 | out = -3;
166 | return;
167 | end
168 | end
169 |
170 | %% Check that there are no edges with only one end in the tree.
171 | %% This also checks the component condition.
172 | lij = level (ijw(1:2,:));
173 | neither_in = lij(1,:) == 0 & lij(2,:) == 0;
174 | both_in = lij(1,:) > 0 & lij(2,:) > 0;
175 | if any (not (neither_in | both_in)),
176 | out = -4;
177 | return
178 | end
179 |
180 | %% Validate the distances/levels.
181 | respects_tree_level = true(1,size(ijw, 2));
182 | if !is_sssp
183 | respects_tree_level = abs (lij(1,:) - lij(2,:)) <= 1;
184 | else
185 | respects_tree_level = abs (d(ijw(1,:)) - d(ijw(2,:)))' <= ijw(3,:);
186 | end
187 | if any (not (neither_in | respects_tree_level))
188 | out = -5;
189 | return
190 | end
191 | ```
192 | ### 输出结果
193 | + ```
194 | SCALE
195 | Graph generation parameter
196 | edgefactor
197 | Graph generation parameter
198 | NBFS
199 | Number of BFS searches run, 64 for non-trivial graphs
200 | construction_time
201 | The single kernel 1 time
202 | bfs_min_time, bfs_firstquartile_time, bfs_median_time, bfs_thirdquartile_time, bfs_max_time
203 | Quartiles for the kernel 2 times
204 | bfs_mean_time, bfs_stddev_time
205 | Mean and standard deviation of the kernel 2 times
206 | bfs_min_nedge, bfs_firstquartile_nedge, bfs_median_nedge, bfs_thirdquartile_nedge, bfs_max_nedge
207 | Quartiles for the number of input edges visited by kernel 2, see TEPS section above.
208 | bfs_mean_nedge, bfs_stddev_nedge
209 | Mean and standard deviation of the number of input edges visited by kernel 2, see TEPS section above.
210 | bfs_min_TEPS, bfs_firstquartile_TEPS, bfs_median_TEPS, bfs_thirdquartile_TEPS, bfs_max_TEPS
211 | Quartiles for the kernel 2 TEPS
212 | bfs_harmonic_mean_TEPS, bfs_harmonic_stddev_TEPS
213 | Mean and standard deviation of the kernel 2 TEPS.
214 | sssp_min_time, sssp_firstquartile_time, sssp_median_time, sssp_thirdquartile_time, sssp_max_time
215 | Quartiles for the kernel 3 times
216 | sssp_mean_time, sssp_stddev_time
217 | Mean and standard deviation of the kernel 3 times
218 | sssp_min_nedge, sssp_firstquartile_nedge, sssp_median_nedge, sssp_thirdquartile_nedge, sssp_max_nedge
219 | Quartiles for the number of input edges visited by kernel 3, see TEPS section above.
220 | sssp_mean_nedge, sssp_stddev_nedge
221 | Mean and standard deviation of the number of input edges visited by kernel 3, see TEPS section above.
222 | sssp_min_TEPS, sssp_firstquartile_TEPS, sssp_median_TEPS, sssp_thirdquartile_TEPS, sssp_max_TEPS
223 | Quartiles for the kernel 3 TEPS
224 | sssp_harmonic_mean_TEPS, sssp_harmonic_stddev_TEPS
225 | Mean and standard deviation of the kernel 3 TEPS.
226 | ```
--------------------------------------------------------------------------------
/report/Testbench/SPEC17_and_Simpoint.md:
--------------------------------------------------------------------------------
1 | # SPEC17 & Simpoint 安装教程
2 | ---
3 | 参考了 `https://www.spec.org/cpu2017/`
4 |
5 | *Copy right by ChenRuiyang*
6 |
7 | ---
8 | ## SPEC17准备工作
9 | + 准备好 SPEC17 的iso文件,因为版权问题网上下载不了,但在 stu1 服务器上 /home/data/ChenRuiyang/SPEC_ISO 目录里有 cpu2017-1.0.2.iso ,用那个即可,详细安装过程参考 CSDN 这篇博文,在此不多赘述:
10 | `https://blog.csdn.net/weixin_30648963/article/details/102273129` .
11 |
12 | 注:挂载参考下面的命令
13 | ```bash
14 | sudo mount -t iso9660 -o ro,exec cpu2006.iso /mnt
15 | ```
16 | + SPEC 编译时需要改配置文件,这里直接在 Example 上小改:
17 | ```bash
18 | cd spec17/config
19 | scp Example-gcc-linux64-aarch64.cfg ARM.cfg
20 | ```
21 | 因为我们是在 arm 下测试程序,并且 Gem5 要求静态链接,所以要改一下 ARM.cfg,把参数改成下面的即可:
22 | ```
23 | ...
24 | CC = aarch64-linux-gnu-gcc -std=c99
25 | CXX = aarch64-linux-gnu-g++
26 | ...
27 | default=base: # flags for all base
28 | OPTIMIZE = -O2 -static
29 | ...
30 | ```
31 | + 在 config 目录下运行下命令:
32 | `runspec --config=ARM.cfg --action=build --tune=base --size=test gcc_r`
33 | 此处 `--size=test` 意味着采用最小测试集,bzip2为我们举例的测试集,可选取的测试集详见 `spec17/benchspec/CPU` .
34 | 注意:若此时出现 runspec 未定义的警告,需要运行下列命令
35 | ```bash
36 | cd spec17
37 | source shrc
38 | ```
39 | + build 完成之后在`spec17/benchspec/CPU/502.gcc_r`下会出现 data 以及 exe 文件夹,代表成功.
40 | 但是不是所有的测试程序都能用 runspec build 成功,部分程序可能因为与 aarch64-linux-gnu 不兼容而失败(或者因为 gFortran).
41 | + 对所有程序进行编译:
42 | `runspec --config=ARM.cfg --action=build --tune=base all`
43 | all代表所有测试程序.
44 |
45 |
46 | ## 安装Simpoint.3.2
47 | + 第一步是下载Simpoint的源码,链接为:
48 | `https://cseweb.ucsd.edu/~calder/simpoint/releases/SimPoint.3.2.tar.gz`
49 | 下载完成后解压缩
50 | + 打开解压好的文件夹,这里要改部分文件
51 | `/config`文件夹中需要更改的内容如下,前面为需要更改的文件,后面为文件需要添加的内容:
52 | ```cpp
53 | cmdlineparser.cpp #include
54 | utilities.h #include #include
55 | datapoint.h #include
56 | FVParser.cpp #include
57 | ```
58 | + 执行命令:
59 | `make CXXFLAGS='-std=c++03 -O1'`
60 | 注意此处要加后缀,因为Simpoint是06年的,部分标准和现在不同,不加会导致出现编译错误.
61 | + 编译完成后应能看到./simpoint文件
--------------------------------------------------------------------------------
/report/gem5/apl_test_report_spmv.md:
--------------------------------------------------------------------------------
1 | # Arm Performance Library Test Report
2 | ---
3 | 参考了 https://developer.arm.com/
4 | *Copy right by ChenRuiyang*
5 |
6 | ---
7 |
8 | ## 测试参数:
9 | + 架构:ARM指令集
10 | + 处理器类型:DerivO3CPU
11 | + 单核单线程
12 | + Cache:2级Cache
13 | + L1_icache 64KB 4assoc
14 | + L1_dcache 64KB 4assoc
15 | + L2_cache 1MB 4assoc
16 | + Cacheline_size 128
17 | + Mem:无指定mem(加入Mem参数后长时间无输出)
18 | + SVE:vector length = 4 ( * 128 )
19 |
20 | ## 测试程序:
21 | + 矩阵乘法运算: dgemm
22 | $ C := \alpha * A * B + \beta * C$
23 | 上式中 $\alpha , \beta $为双精度浮点数,$A,B,C$为矩阵,且满足矩阵乘法与加法的要求.
24 | + 奇异值分解: dgesdd
25 | $A = U * \Sigma * V^T $
26 | 上式中 $ A , U , \Sigma , V $均为矩阵.
27 | + LU分解: dgetrf
28 | $A = P * L * U$
29 | 上式中 $A , P , L , U$均为矩阵.
30 | + 稀疏矩阵线性运算: spadd
31 | $ C := \alpha * A + \beta * B $
32 | 上式中$ \alpha , \beta $为单精度浮点数, $A , B , C$为稀疏矩阵,且满足矩阵加法的要求.
33 | + 稀疏矩阵乘法运算: spmm
34 | $ C := \alpha * A * B + \beta * C$
35 | 上式中 $\alpha , \beta $为单精度浮点数,$A,B,C$为稀疏矩阵,且满足矩阵乘法与加法的要求.
36 | + 稀疏矩阵和向量的乘法运算: spmv
37 | $ C := \alpha * A * x + \beta * y$
38 | 上式中 $\alpha , \beta $为单精度浮点数,$A$为稀疏矩阵,$ x , y $为向量.
39 |
40 | ## 测试环境:
41 | + GEM5 + FS
42 | + 初始化脚本(GEM5 script)
43 | ```
44 | m5 checkpoint
45 | m5 resetstats
46 | m5 readfile > /tmp/gem5.sh && sh /tmp/gem5.sh
47 | m5 exit
48 | ```
49 | + 运行脚本(GEM5 script)
50 | ```
51 | ./filename
52 | m5 exit
53 | ```
54 |
55 | ## 测试结果:
56 | | param | dgemm | dgesdd | dgetrf | spadd | spmm | smpv |
57 | |:----:|:----:|:----:|:----:|:----:|:----:|:----:|
58 | |Time /s |0.026537|0.011012|0.004807|0.004175|0.006348|0.005961|
59 | |IPC|0.948067|1.322738|0.659510|0.554336|1.080294|1.283651|
60 | |Dcache hit|26297684|14971421|3069195|2376856|8161132|7587199|
61 | |Dcache miss|6613428|105773|100281|99434|101700|99455|
62 | |Dcache miss rate|20.09%|7.02%|3.16%|4.02%|1.23%|1.29%|
63 | |Branch prediction|4840430|5238655|1640061|1223354|3236808|3074956|
64 | |Incorrect prediction|202956|204771|106523|100506|146004|102016|
65 | |Branch mispredict rate|4.19%|3.91%|6.50%|8.22%|4.51%|3.22%|
66 | |ROB stall|11286|14313|4048|3081|2183|2557|
67 | |Renamed insts|9545255|10606040|9735275|9081936|25965997|9531122|
68 | |Stall rate|0.0124%|0.0274%|0.0341%|0.0339%|0.0084%|0.0095%|
69 |
70 | ## 结果分析:
71 | + 通过分析上表可以得出的最显然的结论是通过优化 cache miss , branch predict 以及 ROB stall 可以显著提高 IPC.
72 | + 对于矩阵乘法运算来说, Cache miss 是限制 IPC 的瓶颈,通过优化Cache读取可以提升性能.
73 | + 在LU分解以及稀疏矩阵加法中,瓶颈为分支预测的准确率以及ROB stall的概率.
74 | + 得到的这些数据从某种意义上来说并不能直观的给出瓶颈所在,和预想的不同, cache miss 等参数在不同应用场景下并没有特别直观的差距,很难得到有说服力的结论.
--------------------------------------------------------------------------------
/report/gem5/doc_zhanglucheng_Full_System实验记录.md:
--------------------------------------------------------------------------------
1 | # Full System实验记录
2 |
3 |
4 |
5 | ## 如何使用gem5 FS模式
6 |
7 | 0. Prerequisite
8 |
9 | ```bash
10 | sudo apt install build-essential git m4 scons zlib1g zlib1g-dev libprotobuf-dev \
11 | protobuf-compiler libprotoc-dev libgoogle-perftools-dev \
12 | python3-dev python3-six python-is-python3 libboost-all-dev \
13 | pkg-config
14 |
15 | # 需要注意不同Ubuntu版本下的aarch64-gcc版本
16 | sudo apt install gcc-aarch64-linux-gnu g++-aarch64-linux-gnu binutils-aarch64-linux-gnu
17 | ```
18 |
19 | 1. build gem5
20 |
21 | ```bash
22 | git clone https://github.com/gem5/gem5.git
23 | cd gem5/
24 | scons build/ARM/gem5.opt -j9
25 |
26 | # make bootloader
27 | make -C system/arm/bootloader/arm
28 | make -C system/arm/bootloader/arm64
29 | # make device trees
30 | make -C system/arm/dt
31 |
32 | # build m5ops library
33 | cd util/m5
34 | scons build/aarch64/out/m5
35 | cd util/term; make
36 | ```
37 |
38 | 2. 下载pre-built ARM Linux kernel
39 |
40 | [Latest Linux Kernel Image / Bootloader](http://dist.gem5.org/dist/v21-0/arm/aarch-system-201901106.tar.bz2)(最新版不知为何服务器上跑不了,这里换成了201901106版)
41 |
42 | [Latest Linux Disk Images](http://dist.gem5.org/dist/current/arm/disks/ubuntu-18.04-arm64-docker.img.bz2)
43 |
44 | 3. 解压,**千万别用GUI解压工具**
45 |
46 | `bzip2 -d aarch-system-20210904.tar.bz2` `tar xvf aarch-system-20210904.tar`
47 |
48 | `bzip2 -d ubuntu-18.04-arm64-docker.img.bz2`
49 |
50 | 4. 设置环境变量M5_PATH为`aarch-system-20210904`解压路径
51 |
52 | `echo "export M5_PATH=\"~\\aarch-system-20210904\"" >> ~/.bashrc; source ~/.bashrc`
53 |
54 | 5. 扩容和添加内容(如Compiler, Library, Benchmark)到磁盘映像
55 |
56 | [arm-compiler-for-linux_21.0_Ubuntu-18.04_aarch64](https://developer.arm.com/-/media/Files/downloads/hpc/arm-allinea-studio/21-0/ACfL/arm-compiler-for-linux_21.0_Ubuntu-18.04_aarch64.tar?revision=31400f62-c9e6-4d20-a2b7-4ed597a53c5e)
57 |
58 | ```bash
59 | mkdir ~/mnt
60 | # 需要sudo,可以在自己虚拟机上整好再传到服务器上
61 | $GEM5_PATH/util/gem5img.py mount XXX.img ~/mnt
62 | cp XXX mnt/root/XXX
63 | $GEM5_PATH/util/gem5img.py umount mnt
64 | ```
65 |
66 | disk image 2G空间不够,用dd和gparted扩容
67 |
68 | ```bash
69 | # 扩容
70 | $ dd if=/dev/zero bs=1M count=10240 >> ./ubuntu-18.04-arm64-docker.img
71 | # 挂载
72 | $ sudo udisksctl loop-setup -f ./ubuntu-18.04-arm64-docker.img
73 | Mapped file linux-x86.img as /dev/loop0.
74 |
75 | # 用gparted把空闲空间加到image的sda1上
76 | $ sudo gparted /dev/loop0
77 | # 卸载
78 | $ sudo udisksctl loop-delete -b /dev/loop0
79 | ```
80 |
81 | 6. 启动
82 |
83 | ```bash
84 | $ ./build/ARM/gem5.opt ./configs/example/fs.py \
85 | > --kernel $M5_PATH/binaries/vmlinux.arm64 \
86 | > --disk-image $M5_PATH/disks/ubuntu-18.04-arm64-docker.img \
87 | > --bootloader $M5_PATH/binaries/boot.arm64 \
88 | > --param "system.highest_el_is_64 = True"
89 | ```
90 |
91 | 或者
92 |
93 | ```bash
94 | ./build/ARM/gem5.opt ./configs/example/arm/starter_fs.py \
95 | --kernel /home/zhanglucheng/aarch-system-201901106/binaries/vmlinux.arm64 \
96 | --disk-image /home/zhanglucheng/ubuntu-18.04-arm64-docker.img
97 | ```
98 |
99 | 从输出信息中看终端端口号
100 |
101 | ```bash
102 | system.terminal: Listening for connections on port 3456
103 | ```
104 |
105 | 则使用m5term连接3456即可使用终端
106 |
107 | ```
108 | ./util/term/m5term 3456
109 | ```
110 |
111 | 一般在gem5里启动aarch64 linux要5分钟左右
112 |
113 | 7. 虚拟机内安装arm-compiler-for-linux(内含performance library)
114 |
115 | ```bash
116 | cd
117 | ./.sh -a
118 | # -a表示自动接受EULA协议,不然要在超高输入延迟下一行一行回车看完
119 | ```
120 |
121 |
122 |
123 | ## 试验
124 |
125 | 1. fs + 64 或 starter_fs + 32/64 都不行;
126 |
127 | 用fs + 32位可跑,但最后会有kernel panic
128 |
129 | ```bash
130 | ./build/ARM/gem5.opt ./configs/example/fs.py \
131 | --kernel /home/zhanglucheng/aarch-system-20210904/binaries/vmlinux.arm \
132 | --disk-image /home/zhanglucheng/ubuntu-18.04-arm64-docker.img
133 | ```
134 |
135 | ```bash
136 | [ 0.444805] Kernel panic - not syncing: No working init found. Try passing init= option to kernel. See Linux Documentation/admin-guide/init.rst for guidance.
137 | [ 0.444879] ---[ end Kernel panic - not syncing: No working init found. Try passing init= option to kernel. See Linux Documentation/admin-guide/init.rst for guidance. ]---
138 | ```
139 |
140 | 2. *Mail Archive*类似状况解决办法:
141 |
142 | - 不能用GUI解压,要`bzip2 -d aarch-system-201901106.tar.bz2` `tar xvf aarch-system-201901106.tar`
143 |
144 | - `--root /dev/vda1` 加上似乎有别的问题
145 |
146 | - > Unrelated, could you use vmlinux.vexpress_gem5_v1_64 instead?
147 |
148 | - > there are some incompatibilities between the prebuilt kernel and
149 | > your binutils
150 |
151 | 换到自己的虚拟机ubuntu20.04 + gem5 21.0.1.0 也是
152 |
153 | ```bash
154 | warn: Kernel panic in simulated kernel
155 | ```
156 |
157 | ```bash
158 | [ 0.444806] Kernel panic - not syncing: No working init found. Try passing init= option to kernel. See Linux Documentation/admin-guide/init.rst for guidance.
159 | [ 0.444880] ---[ end Kernel panic - not syncing: No working init found. Try passing init= option to kernel. See Linux Documentation/admin-guide/init.rst for guidance. ]---
160 | ```
161 |
162 | 4. 尝试2019版另一个64位kernel,记得要修改M5_PATH
163 |
164 | ```bash
165 | ./build/ARM/gem5.opt ./configs/example/fs.py --kernel /home/zhanglucheng/aarch-system-201901106/binaries/vmlinux.arm64 --disk-image /home/zhanglucheng/ubuntu-18.04-arm64-docker.img --bootloader /home/zhanglucheng/aarch-system-201901106/binaries/boot.arm64 --param 'system.highest_el_is_64 = True'
166 | ```
167 |
168 |
169 |
170 | ## 总结
171 |
172 | 1. GUI解压工具Archive Manager就是辣鸡,应该用`bzip2 -d aarch-system-201901106.tar.bz2` `tar xvf aarch-system-201901106.tar`
173 |
174 | 如果用Archive Manager解压,运行时会卡在最开始
175 |
176 | 2. 用不同版本的pre-built kernel 需要修改M5_PATH `export $M5_PATH=\path\to\aarch-system-XXXX`
177 |
178 | 3. fs.py 需要参数 `kernel` `disk-image` `bootloader` 以及设置最高exception level = 64。不加bootloader会导致上述kernel panic
179 |
180 | starter_fs.py 不用加`bootloader`和`param`,但需要提前make bootloader `make -C $GEM5_PATH/system/arm/bootloader/arm64`
181 |
182 |
183 |
184 |
--------------------------------------------------------------------------------
/report/gem5/gem5_FS_arm_linux.md:
--------------------------------------------------------------------------------
1 | #Full system 模式运行 linux(arm) 实验记录
2 | ---
3 | 参考了 gem5.org 以及 doc_zhanglucheng_Full_System.md
4 |
5 | *Copy right by ChenRuiyang*
6 |
7 | ---
8 | ##前期准备工作
9 | + 安装依赖(Ubuntu 20.XX):
10 | ```
11 | sudo apt install build-essential git m4 scons zlib1g zlib1g-dev \
12 | libprotobuf-dev protobuf-compiler libprotoc-dev libgoogle-perftools-dev \
13 | python3-dev python3-six python-is-python3 libboost-all-dev pkg-config
14 | ```
15 | + 下载 gem5 源代码:
16 | 推荐使用 gitee搜索gem5下载,官方的`git clone https://gem5.googlesource.com/public/gem5`命令需要科学上网(VPN).
17 | + 解压缩文件至 ~/gem5.
18 | 注:gitee下载压缩包需要解压,解压缩命令百度自查;直接clone的则跳过这一步.
19 | + 对arm架构使用scons命令进行build.
20 | ```bash
21 | cd ~/gem5
22 | scons build/ARM/gem5.opt -j9
23 | ```
24 | 注:gem5里本来是没有build文件夹的,scons之后才有;-j9是为了加快编译速度,-j后的数字一般为你的CPU核心数+1,例如我的CPU是8核的,后面的数字就是8+1=9.
25 | + 上一步的编译时间一般较长,在等待时间可以提前下载arm_linux的kernel和image.
26 | `https://www.gem5.org/documentation/general_docs/fullsystem/guest_binaries`
27 | 一般选择推荐的即可,下载完成后解压到 ~/gem5/full_system_images, 其中full_system_image是自己创建的存kernel和image的文件夹, XXX.img存在~/gem5/full_system_images/disk内.
28 | 进入页面后可能出现点击链接无法下载的情况,复制链接新开一个页面粘贴链接即可下载,网速慢的话科学上网或者找找有没有国内的镜像.
29 |
30 | ##完善 Full System 依赖功能
31 | + 编译bootloader
32 | ```bash
33 | cd gem5
34 | make -C system/arm/bootloader/arm
35 | make -C system/arm/bootloader/arm64
36 | ```
37 | 此时打开~/gem5/system/arm/bootloader/arm64会看到boot.arm64文件,后面我们会用它做bootloader.
38 | + 编译m5term
39 | ```bash
40 | cd ~/gem5/util/term
41 | make
42 | ```
43 | 完成后会在对应文件夹内看到m5term. m5term将用来建立localhost与port间的联系,简单来说,就是建立full system模拟的linux与本机的联系.
44 | + 添加M5_PATH
45 | 出于方便起见,避免每次使用都要export,将M5_PATH写到.bashrc里面.
46 | ```bash
47 | cd ~
48 | gedit .bashrc
49 | ```
50 | 在.bashrc中添加
51 | ```bash
52 | export M5_PATH=$M5_PATH:~/gem5/full_system_images
53 | ```
54 | 应用更改
55 | ```bash
56 | source .bashrc
57 | ```
58 | 此时可以使用下述命令检查是否更改成功:
59 | ```bash
60 | echo $M5_PATH
61 | ```
62 | 如若之前曾经设置过M5_PATH,即echo显示的M5_PATH有多个路径,采用下述命令即可:
63 | ```bash
64 | unset M5_PATH
65 | source .bashrc
66 | echo $M5_PATH
67 | ```
68 | + 更改 SysPaths.py 中的路径
69 | ```bash
70 | cd ~/configs/common
71 | gedit SysPaths.py
72 | ```
73 | 将第51行(expect KeyError: 后的那条语句)改成:
74 | ```bash
75 | paths = [ '~/gem5/full_system_images', '/n/poolfs/z/dist/m5/system' ]
76 | ```
77 | 主要改的是前面那个地址,目的是给FS做检索.
78 | + 试运行FS
79 | 首先打开一个终端(叫它终端1)
80 | ```bash
81 | cd ~/gem5
82 | build/ARM/gem5.opt configs/example/fs.py --kernel vmlinux.arm64 --disk-image ubuntu-18.04-arm64-docker.img --bootloader ~/gem5/system/arm/bootloader/arm64/boot.arm64 --param "system.highest_el_is_64 = True"
83 | ```
84 | 另起一个终端(叫它终端2)
85 | ```bash
86 | cd ~/gem5/util/term
87 | sudo ./m5term localhost 3456
88 | ```
89 | 等待几分钟后加载完成,即可在终端2运行FS模拟的linux,输入help即可查看可用命令.
90 | 注:
91 | 1. 'localhost'后的'3456'是第一个默认端口,若再起终端3则可用'3457',详见终端1有关输出.
92 | 2. 在终端2中执行'ls'命令可能会出现没有文件的情况,此时不要慌张,检查当前的目录是~还是/, 如果是~,执行 `cd / ` 切换到根目录再ls即可.
93 |
94 | ##向linux内部添加文件
95 | + 首先需要建立img与本机之间的关系,本文采用的是linux的mount命令.
96 | ```bash
97 | cd ~/gem5
98 | sudo util/gem5img.py mount full_system_images/disks/ubuntu-18.04-arm64-docker.img ~/mnt
99 | ```
100 | mount指令执行之后即建立了aarch64-ubuntu-trusty-headless.img和~/mnt之间的联系,对img的所有操作(例如删除或添加文件都可以cd到 ~/mnt进行).
101 | + 添加文件
102 | ```bash
103 | cd ~/gem5
104 | sudo scp -r mountfile ~/mnt
105 | ```
106 | scp是linux中的复制命令,-r代表将整个文件夹全部复制;mountflie是我存放已编译好的程序的文件夹,位置是~/gem5/mountfile,有关mountfile内的源文件以及编译后文件请见附录.
107 | + 在文件复制完成后img里实际就已经同步了我们所复制的文件,此时输入
108 | ```bash
109 | cd ~/gem5
110 | sudo util/gem5img.py umount ~/mnt
111 | ```
112 | img和我们~/mnt文件夹的联系到此就解除啦.
113 | + 在FS中尝试运行我们同步的文件
114 | 首先启动系统
115 | ```bash
116 | cd ~/gem5
117 | build/ARM/gem5.opt configs/example/fs.py --kernel vmlinux.arm64 --disk-image ubuntu-18.04-arm64-docker.img --bootloader ~/gem5/system/arm/bootloader/arm64/boot.arm64 --param "system.highest_el_is_64 = True"
118 | ```
119 | ```bash
120 | cd ~/gem5/util/term
121 | sudo ./m5term localhost 3456
122 | ```
123 | 等待系统加载完成后
124 | ```bash
125 | cd /mountfile
126 | ./hello_par_static
127 | ```
128 | 系统输出
129 | ```bash
130 | root@aarch64-gem5:/mountfile# ./test_par_static
131 | 0123456789
132 | ```
133 | 成功输出结果,但程序似乎是被串行执行的,因为按照附录hello_par.cpp的程序,多线程执行下输出应该是乱序的.在下面的拓展部分中,将会证明按照之前那么做程序只是单线程执行的,并给出了多线程执行的方法.
134 |
135 | ##拓展
136 | + 之前在FS下执行多线程程序最多只能有一个线程,采用测试程序输出如下所示:
137 | ```bash
138 | root@aarch64-gem5:/mountfile# ./hello_par_static
139 | Hello World from thread = 0
140 | Number of threads = 1
141 | ```
142 | + 解决这个问题的方法是编译device tree文件,即给gem5指定硬件(例如即将用到的多核CPU)
143 | ```bash
144 | cd ~/gem5/system/arm
145 | make -C dt
146 | ```
147 | 等待编译完成后,文件夹出现很多以.dtb为后缀的文件,其含义是device tree binaries,即device tree的二进制文件。此处注意,原来有的以.dts为后缀的文件是编译前的源文件,计算机没有办法直接读,要将其编译为.dtb的二进制文件后才能读取。
148 | + 有了device tree后原命令变成
149 | ```bash
150 | cd ~/gem5
151 | build/ARM/gem5.opt configs/example/fs.py --kernel vmlinux.arm64 --disk-image ubuntu-18.04-arm64-docker.img --bootloader ~/gem5/system/arm/bootloader/arm64/boot.arm64 --param "system.highest_el_is_64 = True" --dtb-filename ~/gem5/system/arm/dt/armv8_gem5_v1_2cpu.dtb --cpu-type AtomicSimpleCPU -n 2
152 | ```
153 | 需要注意到这个命令与原命令不同的是加了两个后缀:
154 | ```bash
155 | --dtb-filename ~/gem5/system/arm/dt/armv8_gem5_v1_2cpu.dtb
156 | --cpu-type AtomicSimpleCPU -n 2
157 | ```
158 | dtb-filename顾名思义,就是制定了.dtb文件的路径;cpu-type是指定CPU类型,后面的-n 2 是CPU的核数(这里是2核).
159 | + 采用更新后的指令启动FS下的linux
160 | ```bash
161 | cd ~/gem5
162 | build/ARM/gem5.opt configs/example/fs.py --kernel vmlinux.arm64 --disk-image ubuntu-18.04-arm64-docker.img --bootloader ~/gem5/system/arm/bootloader/arm64/boot.arm64 --param "system.highest_el_is_64 = True" --dtb-filename ~/gem5/system/arm/dt/armv8_gem5_v1_2cpu.dtb --cpu-type AtomicSimpleCPU -n 2
163 | ```
164 | ```bash
165 | cd ~/gem5/util/term
166 | sudo ./m5term localhost 3456
167 | ```
168 | 启动后首先采用测试程序./hello_par_static测试是否是多线程
169 | ```bash
170 | root@aarch64-gem5:/mountfile# ./hello_par_static
171 | Hello World from thread = 0
172 | Number of threads = 2
173 | Hello World from thread = 1
174 | ```
175 | 显示为2个线程,与2核CPU相符.
176 | 再运行之前顺序输出的./test_par_static
177 | ```bash
178 | root@aarch64-gem5:/mountfile# ./test_par_static
179 | 0125367489
180 | ```
181 | 输出是乱序,符合预期.
182 | 最后测试多线程是否带来了性能的提升,分别运行未进行openmp优化的./test2_un_static和./test2_static,观察执行时间的改变:
183 | ```bash
184 | root@aarch64-gem5:/mountfile# ./test2_un_static
185 | 10000
186 | 0
187 | 1000
188 | 2000
189 | 3000
190 | 4000
191 | 5000
192 | 6000
193 | 7000
194 | 8000
195 | 9000
196 | Total time:0.001567
197 | Total time:1.567ms
198 | ```
199 | ```bash
200 | root@aarch64-gem5:/mountfile# ./test2_static
201 | 10000
202 | 0
203 | 5000
204 | 1000
205 | 6000
206 | 2000
207 | 7000
208 | 3000
209 | 8000
210 | 4000
211 | 9000
212 | Total time:0.000836
213 | Total time:0.836ms
214 | ```
215 | openmp优化后相较于优化前带来了执行速度接近一倍的提升,与多线程理论上带来的优化相符. 至此,FS运行linux(arm)的实验画上了完美的句号.
216 |
217 | ##小结
218 | + 这次实验花费了将近一周的时间,可能看起来实验记录很顺利,但实际做起来各种各样的问题解决起来还是很费功夫的. 说到这里,我认为这次实验让我收获最大的是我为了解决程序运行中,而不得不深入了解gem5的代码结构,加深了对FS的理解,从而从只会按教程跑样例变成了可以根据实际需要进行调整.
219 | + FS下的ARM和X86对静态编译文件的支持度不同。在X86架构下,编译时静态链接的程序无法运行,显示错误为segfault,在google上也查询不到有关的解决方法,这就导致了FS的X86下很难跑openmp的程序。为什么说很难呢,因为FS下的linux实测编译速度巨慢,简单的hello world程序十分钟都没编译好(也不排除根本就不能编译),非静态链接的程序又会导致库以及glibc版本的不兼容,总之FS下的X86对openmp的支持不太好. 反观FS下的ARM,可以完美运行静态链接的程序(但不能运行非静态链接的程序,与X86恰好相反),进行模拟的结果也很符合理论,我认为是优秀的硬件仿真方式.
220 | + Openmp能带来很高的执行效率优化. 我一开始想FS下的能做到这么高程度的优化是因为CPU太理想化了,实际多核CPU还要考虑缓存一致性等因素优化达不到这么多,于是我又在本机的linux上运行了之前的测时程序,惊奇的发现几乎多线程并行的执行时间都能达到非多线程运行的${\frac{1}{n}}$. 不过后来又思考了一下,好像是因为我写的程序设置并行的代码段都是没有依赖关系的,也就不需要考虑data hazard;如果遇到依赖关系强的语句,就正常的顺序执行,等到遇到大规模的独立运算,再调用omp语句多线程执行.
221 |
222 |
223 | ##附录
224 | 1. ~/gem5/mountfile中的文件及其编译指令
225 | + hello.cpp
226 | ```cpp
227 | #include
228 | using namespace std;
229 |
230 | int main(){
231 | cout<<"Hello!"<
242 |
243 | using namespace std;
244 | int main()
245 | {
246 | #pragma omp parallel for
247 | for (int i=0; i<10; i++)
248 | {
249 | cout << i;
250 | }
251 |
252 | return 0;
253 | }
254 | ```
255 | 编译命令
256 | ```bash
257 | arm-linux-gnueabi-g++ test_par.cpp -o test_par_static -static -fopenmp
258 | ```
259 | + hello_par.cpp
260 | ```cpp
261 | #include
262 | #include
263 | #include
264 |
265 | int main()
266 | {
267 | int nthreads, tid;
268 |
269 | /* Fork a team of threads giving them their own copies of variables */
270 | #pragma omp parallel private(nthreads, tid)
271 | {
272 |
273 | /* Obtain thread number */
274 | tid = omp_get_thread_num();
275 | printf("Hello World from thread = %d\n", tid);
276 |
277 | /* Only master thread does this */
278 | if (tid == 0)
279 | {
280 | nthreads = omp_get_num_threads();
281 | printf("Number of threads = %d\n", nthreads);
282 | }
283 |
284 | } /* All threads join master thread and disband */
285 | return 0;
286 | }
287 | ```
288 | 编译命令
289 | ```bash
290 | arm-linux-gnueabi-g++ hello_par.cpp -o hello_par_static -static -fopenmp
291 | ```
292 | + test2.cpp
293 | ```bash
294 | #include
295 | #include
296 | #include
297 |
298 | using namespace std;
299 |
300 | long long N;
301 |
302 | clock_t start,End;
303 |
304 | int main()
305 | {
306 | cin >> N;
307 | start=clock();
308 |
309 | #pragma omp parallel for
310 | for (int i=0; i
330 | #include
331 | #include
332 |
333 | using namespace std;
334 |
335 | long long N;
336 |
337 | clock_t start,End;
338 |
339 | int main()
340 | {
341 | cin >> N;
342 | start=clock();
343 |
344 | //#pragma omp parallel for
345 | for (int i=0; i
40 | #include
41 |
42 | using namespace std;
43 |
44 | long long N = 1e5;
45 |
46 | int main()
47 | {
48 |
49 | for (int i=0; i
73 | #include
74 | #include "gem5/m5ops.h" //add
75 |
76 | using namespace std;
77 |
78 | long long N = 1e5;
79 |
80 | int main()
81 | {
82 |
83 | m5_reset_stats(0,0); //add
84 |
85 | for (int i=0; i
129 | #include
130 | #include
131 |
132 | using namespace std;
133 |
134 | long long N = 1e5;
135 |
136 | clock_t start,End;
137 |
138 | int main()
139 | {
140 | start = clock();
141 |
142 | for (int i=0; i
93 | #include
94 | #include "gem5/m5ops.h"
95 |
96 | using namespace std;
97 |
98 | long long N = 1e4;
99 |
100 | int main()
101 | {
102 |
103 | for (int i=0; i<2*N; i++)
104 | {
105 | if(!(i%(N/10))) cout << i+1 <1) holders of the requested data. (Count)
61 | system.voltage_domain.voltage 1 # Voltage in Volts (Volt)
62 | system.workload.inst.arm 0 # number of arm instructions executed (Count)
63 | system.workload.inst.quiesce 0 # number of quiesce instructions executed (Count)
64 |
65 | ---------- End Simulation Statistics ----------
66 |
67 | ---------- Begin Simulation Statistics ----------
68 | ……
69 | ---------- End Simulation Statistics ----------
70 |
71 | ---------- Begin Simulation Statistics ----------
72 | ……
73 | ---------- End Simulation Statistics ----------
74 | ```
75 | 在stats.txt中有多个Begin Simultaion与End Simulation,这是因为 "m5_dump_stats(0,0);" 会对stats.txt进行写入,每个写入会增加一组Begin - End,除了 "m5_dump_stats(0,0);" 会写入之外,程序运行完成(即 return 0; )之后会自动再写入一组Begin - End.
76 | 与此同时,stats.txt中还有程序运行数据(时间,tick等)、CPU的各项数据以及MEM的各项数据.
77 | + 有了前面的铺垫,接下来就要讨论一下各种情况下的测试.
78 |
79 | ##得到一个程序中的某个代码段的debug数据
80 | + 这个讨论需要分两种情况:
81 | 1. 代码段不需要切换不同的CPU.
82 | 2. 代码段需要切换不同的CPU.
83 | + 不需要切换CPU的情况最为简单,**只需要在程序内部关注的代码段前后增加reset与dump指令即可,如果有多个代码段,就增加多组reset与dump**,其中reset是清空之前的数据,dump则是数据的写入.
84 | + 下面举一个容易理解的例子:
85 | ```cpp
86 | m5_reset_stats(0,0); //add
87 |
88 | for (int i=0; i
164 |
165 | int main(){
166 | m5_reset_stats(0,0);
167 | ……
168 | m5_dump_stats(0,0);
169 | }
170 | ```
171 | 在编译时按gem5_checkpoint.md中的过程做即可.
172 |
173 | ##得到多个完整程序的debug数据
174 | + 这个的方法只有写运行脚本了,举个例子:
175 | ```
176 | configs/test.rcS:
177 | #!/bin/sh
178 | # Wait for system to calm down
179 | sleep 10
180 | # Take a checkpoint in 100000 ticks
181 | m5 checkpoint 100000
182 | # Reset the stats
183 | m5 resetstats
184 | # Run hello
185 | /mountfile/hello
186 | /mountfile/hello2
187 | # Exit the simulation
188 | m5 exit
189 | ```
190 | 在执行的时候加后缀--script=./configs/test.rcS
191 | + 这个暂时没想到更好的办法,如果有好的想法欢迎讨论,不过一般来说需要测多个程序的情况不多,遇到要测多个的都是把单个的数据相加,似乎也可以,但是会麻烦很多.
192 |
193 | ##小结
194 | + 这篇报告对讨论以下几种类型的debug打印进行了讨论:
195 | 1. 运行一个程序中的某个代码段,例如一个for循环,或者从语句A到语句B.
196 | 2. 运行一个完整程序的debug打印.
197 | 3. 运行多个完整程序的debug打印.
198 | + 其实如果只是单纯统计数据并不是很需要checkpoint,需要的是reset和dump,不过可能checkpoint是为了后续调试方便,所以在debug方式的讨论中我都加了checkpoint.
199 | + reset和dump并不是需要严格的一一对应,上文那么写是为了测试方便,实际情况下可以灵活调整的.
200 | + 测试的结果是FS模式下通过上述方法得到的数据和SE模式下误差在5%以内,故认为是合理的.
201 |
202 | ---
203 |
204 | ##附录
205 | + test.cpp
206 | ```cpp
207 | #include
208 | #include
209 | #include "gem5/m5ops.h"
210 |
211 | using namespace std;
212 |
213 | long long N = 1e4;
214 |
215 | int main()
216 | {
217 |
218 | for (int i=0; i<2*N; i++)
219 | {
220 | if(!(i%(N/10))) cout << i <
243 | #include
244 | #include "gem5/m5ops.h"
245 |
246 | using namespace std;
247 |
248 | long long N = 1e4;
249 |
250 | int main()
251 | {
252 | for (int i=0; i
281 | #include
282 | #include "gem5/m5ops.h"
283 |
284 | using namespace std;
285 |
286 | long long N = 1e4;
287 |
288 | int main()
289 | {
290 |
291 | for (int i=0; i<2*N; i++)
292 | {
293 | if(!(i%(N/10))) cout << i+1 < ${REC_ROUTE}/${SE_NAME}/${SE_NAME}_${SE_SUFFIX}/$i.txt &
18 | done
19 |
20 | else
21 | echo SE_OR_FS should be SE
22 | fi
23 |
24 | # 将完成的结果写到文件里面
25 | echo ${SE_NAME}_${SE_SUFFIX} has been done! >> /home/data/ChenRuiyang/time_rec/done_tests.txt
--------------------------------------------------------------------------------
/simpoint_GEM5/process/process_sim.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | NAME=$1
4 |
5 | # 注:这里是 ./configs 而不是 ../configs 是因为调用它的文件在上一级
6 | . ./configs/configs_${NAME}.sh
7 |
8 | if [ ${SE_OR_FS} == SE ];then
9 | # 下面两行是清空记录的数据的文件夹
10 | rm -r ${REC_ROUTE}/${SE_NAME};
11 | mkdir ${REC_ROUTE}/${SE_NAME};
12 | # 下面三行依次是初始化、使用simpoint计算切分点和权重、依据算出来的结果写checkpoint
13 | cd ${SH_ROUTE};nohup time bash sim_init.sh ${NAME} > ${REC_ROUTE}/${SE_NAME}/${SE_NAME}_init.txt
14 | cd ${SH_ROUTE};nohup time bash sim_generate_sim_weight.sh ${NAME} > ${REC_ROUTE}/${SE_NAME}/${SE_NAME}_sim_weight.txt
15 | cd ${SH_ROUTE};nohup time bash sim_generate_checkpoint.sh ${NAME} > ${REC_ROUTE}/${SE_NAME}/${SE_NAME}_checkpoint.txt
16 | # times 是读写了多少个 checkpoint
17 | times=$(ls ${GEM5_PATH}/${SE_OUT_DIR_CHECKPOINT} | grep simpoint | wc -l)
18 | mkdir ${REC_ROUTE}/${SE_NAME}/${SE_NAME}_O3
19 | for ((i=1;i<=times;i++))
20 | # 对每一个 checkpoint 做 O3 重载
21 | do cd ${SH_ROUTE};nohup time bash sim_O3.sh $i ${NAME} > ${REC_ROUTE}/${SE_NAME}/${SE_NAME}_O3/$i.txt &
22 | done
23 |
24 | else
25 | echo SE_OR_FS should be SE
26 | fi
27 |
28 | # 将完成的结果写到文件里面
29 | echo ${NAME} has been done! >> /home/data/ChenRuiyang/time_rec/done_tests.txt
--------------------------------------------------------------------------------
/simpoint_GEM5/process_all_tests.py:
--------------------------------------------------------------------------------
1 | import os
2 | import argparse
3 |
4 | # tests 里的是 configs_XXX.sh 后面的 XXX
5 | # 例: configs_example.sh 中的 XXX 为 example
6 | # 如果要同时做多组就写成 tests=['example1','example2','example3',...]
7 | sim_tests=['example']
8 | reload_tests=['example']
9 |
10 | parser=argparse.ArgumentParser(description='A tool for simpoint and reload checkpoints')
11 | parser.add_argument("-n","--name",help="use NAME to replace the original test.")
12 | parser.add_argument("-s","--simpoint",help="use simpoint to generate checkpoint",
13 | action="store_true")
14 | parser.add_argument("-r","--reload",help="use new parms to reload checkpoint",
15 | action="store_true")
16 | args=parser.parse_args()
17 | #print(args)
18 |
19 | def simpoint(tests):
20 | for item in tests:
21 | # 第一个是进行 Simpoint 模拟的,第二个是正常跑的,是验证 Simpoint 结果准确性的,
22 | # 理论上生成 Simpoint 就可以了,第二行命令可以注释掉
23 | # ">" 后面的是将运行的输出重定向的地址,改成自己的即可
24 | os.system('nohup time bash process/process_sim.sh '+item+' > \
25 | /home/data/ChenRuiyang/time_rec/'+item+'_process.txt &')
26 | #os.system('nohup time bash process/process_normal.sh '+item+' > \
27 | # /home/data/ChenRuiyang/time_rec/'+item+'_normal.txt &')
28 |
29 | def reload(tests):
30 | for item in tests:
31 | # 同上,只改了.sh文件的名字,执行重载操作
32 | # ">" 后面的是将运行的输出重定向的地址,改成自己的即可
33 | os.system('nohup time bash process/process_reload.sh '+item+' > \
34 | /home/data/ChenRuiyang/time_rec/'+item+'_reload.txt &')
35 |
36 | if args.name:
37 | sim_tests=reload_tests=[args.name]
38 | print("Using [",args.name,"] as the new test suffix.")
39 | print()
40 |
41 | # 这里不能 simpoint 和 reload 同时做,
42 | # 因为 reload 需要 simpoint 的结果.
43 | if args.simpoint:
44 | print("Starting simpoint!")
45 | print()
46 | simpoint(sim_tests)
47 | elif args.reload:
48 | print("Starting Reload!")
49 | print()
50 | reload(reload_tests)
51 | else:
52 | print("Please give operations.")
53 | print("Use -h to get help")
54 | print()
--------------------------------------------------------------------------------
/simpoint_GEM5/sim/sim_O3.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | . ../configs/configs_$2.sh
4 |
5 | cd ${GEM5_PATH}
6 |
7 | if [ ${SE_OR_FS} == SE ];then
8 |
9 | build/${ARCH}/gem5.${METHOD} --outdir=${SE_OUT_DIR_O3}/$1 \
10 | configs/example/se.py \
11 | ${CPU_PARM} \
12 | ${CACHE_PRAM} \
13 | ${MEM_PRAM} \
14 | -c ${SE_ELF_ROUTE} \
15 | -o "${SE_INPUT_ROUTE}${OPTIONS}" \
16 | --restore-simpoint-checkpoint -r $1 --checkpoint-dir ${SE_OUT_DIR_CHECKPOINT}
17 |
18 | else
19 | echo SE_OR_FS should be SE or FS
20 | fi
21 |
22 |
--------------------------------------------------------------------------------
/simpoint_GEM5/sim/sim_generate_checkpoint.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | . ../configs/configs_$1.sh
4 |
5 | cd ${GEM5_PATH}
6 |
7 | if [ ${SE_OR_FS} == SE ];then
8 |
9 | build/${ARCH}/gem5.${METHOD} --outdir=${SE_OUT_DIR_CHECKPOINT} \
10 | configs/example/se.py \
11 | --take-simpoint-checkpoint=\
12 | ${SE_simpoint_file_path},${SE_weight_file_path},\
13 | ${interval_length},${warmup_length} \
14 | --cpu-type=AtomicSimpleCPU \
15 | ${CACHE_PRAM} \
16 | ${MEM_PRAM} \
17 | -c ${SE_ELF_ROUTE} \
18 | -o "${SE_INPUT_ROUTE}${OPTIONS}"
19 |
20 |
21 | else
22 | echo SE_OR_FS should be SE
23 | fi
24 |
25 |
--------------------------------------------------------------------------------
/simpoint_GEM5/sim/sim_generate_sim_weight.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | . ../configs/configs_$1.sh
4 |
5 | cd ${SIMPOINT_PATH}/bin
6 |
7 | if [ ${SE_OR_FS} == SE ];then
8 |
9 | rm -r ${SIMPOINT_PATH}/output/gem5/${SE_NAME}
10 | mkdir ${SIMPOINT_PATH}/output/gem5/${SE_NAME}
11 |
12 | ./simpoint -loadFVFile ${GEM5_PATH}/${SE_OUT_DIR_INIT}/simpoint.bb.gz \
13 | -maxK 30 -saveSimpoints ${SE_simpoint_file_path} \
14 | -saveSimpointWeights ${SE_weight_file_path} \
15 | -inputVectorsGzipped
16 |
17 | else
18 | echo SE_OR_FS should be SE
19 | fi
20 |
21 |
--------------------------------------------------------------------------------
/simpoint_GEM5/sim/sim_init.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | . ../configs/configs_$1.sh
4 |
5 | cd ${GEM5_PATH}
6 |
7 | if [ ${SE_OR_FS} == SE ];then
8 |
9 | rm -r m5out/${SE_NAME};
10 |
11 | build/${ARCH}/gem5.${METHOD} --outdir=${SE_OUT_DIR_INIT} \
12 | configs/example/se.py \
13 | --simpoint-profile \
14 | --simpoint-interval ${interval_length} \
15 | --cpu-type=NonCachingSimpleCPU \
16 | -c ${SE_ELF_ROUTE} \
17 | -o "${SE_INPUT_ROUTE}${OPTIONS}"
18 |
19 | else
20 | echo SE_OR_FS should be SE
21 | fi
22 |
23 |
--------------------------------------------------------------------------------
/simpoint_GEM5/sim/sim_reload.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | . ../configs/configs_$2.sh
4 |
5 | cd ${GEM5_PATH}
6 |
7 | if [ ${SE_OR_FS} == SE ];then
8 |
9 | build/${ARCH}/gem5.${METHOD} --outdir=${SE_OUT_DIR_RELOAD}/$1 \
10 | configs/example/se.py \
11 | ${CPU_PARM} \
12 | ${CACHE_PRAM} \
13 | ${MEM_PRAM} \
14 | -c ${SE_ELF_ROUTE} \
15 | -o "${SE_INPUT_ROUTE}${OPTIONS}" \
16 | --restore-simpoint-checkpoint -r $1 --checkpoint-dir ${SE_OUT_DIR_CHECKPOINT}
17 |
18 | else
19 | echo SE_OR_FS should be SE or FS
20 | fi
21 |
22 |
--------------------------------------------------------------------------------