-
Notifications
You must be signed in to change notification settings - Fork 10
/
GARDENIA-on-gem5.txt
147 lines (115 loc) · 5.12 KB
/
GARDENIA-on-gem5.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
Running GARDENIA Benchmarks on gem5
Xuhao Chen
Department of Computer Science
National University of Defense Technology
Abstract: This technical report describes the steps that we took to compile GARDENIA 1.0 [1] for the x86/ARM architecture to run on gem5 [2]. gem5 is a full system multiprocessor simulator that is capable of booting a full Linux system. This report covers installing gem5 on Ubuntu 14.04, adding gem5 intrinsics to the GARDENIA infrastructure, compiling the benchmarks, and the creation of gem5 execution scripts. Along with this technical report we are distributing a disk image containing pre-compiled statically linked x86 binaries for all of GARDENIA benchmarks that can be used with gem5. Using the disk image removes the need to compile the benchmarks.
1. Install gem5 on Ubuntu 14.04
First, we need to install gem5 dependencies:
$ sudo apt-get install scons swig python-dev m4 libprotobuf-dev python-protobuf protobuf-compiler libgoogle-perftools-dev
Then build gem5 using the scons tool:
$ scons build/ARM/gem5.opt -j4
Run the test (hello world) program to check if installed successfully:
$ build/ARM/gem5.opt configs/example/se.py -c tests/test-progs/hello/bin/arm/linux/hello
2. Adding gem5 intrinsics
Since we are interested in measuring the performance of just the parallel portion of the benchmark, Region of Interest (ROI), we added support to the hooks package to make M5 pseudo calls to dump the statistics at the entry and exit of the ROI. Additionally, we have added support to take a checkpoint at the beginning of the ROI. This checkpoint can later be used to simulate just the ROI in detailed mode.
Take "cc" as a example.
$ vim ~/gardenia_code/src/cc/omp_base.cc
Include the header file:
#ifdef SIM
#include "sim.h"
#endif
Add the following function call to the beginning of solver function:
#ifdef SIM
omp_set_num_threads(4);
map_m5_mem();
#endif
Add the following function call to the beginning of ROI:
#ifdef SIM
m5_checkpoint(0,0);
#endif
Add the following function call to the end of ROI:
#ifdef SIM
m5_dumpreset_stats(0,0);
#endif
3. Compiling the benchmarks
When compiling benchmarks, make sure you add the following compiler options:
-static
Set options:
$ vim ~/gardenia_code/src/common.mk
Modify like this:
from
HOST=X86
to
HOST=ARM
Set LONG_TYPE:
$ vim include/common.h
Uncomment this line:
//#define LONG_TYPES
Install ARM cross-compiler:
sudo apt-get install g++-aarch64-linux-gnu
Then build the benchmark (take "cc" as a example):
$ make cc_omp_base_sim
You will find the binary in:
~/gardenia_code/bin/cc_omp_base_sim
4. Creating gem5 execution scripts
vim /home/cxh/gem5-configs/run_cc_google.rcS
1 #!/bin/sh
2 echo "Starting ..."
3 cd /gardenia
4 #/sbin/m5 dumpstats
5 #/sbin/m5 resetstats
6 ./bin/cc_omp_base_sim datasets/web-Google.mtx
7 echo "Done :D"
8 /sbin/m5 exit
5. Preparing disk image
Download the image file
$ wget http://www.cs.utexas.edu/~parsec_m5/x86root-parsec.img.bz2
Put the disk image in ~/m5-dist/x86-system/disks/ and mount the disk image to modify it:
$ sudo mount -o loop,offset=32256 ~/m5-dist/x86-system/disks/x86root-parsec.img ~/m5-dist/x86-system/disks/tmp
Transfer files to the disk:
$ sudo cp ~/gardenia_code/bin/cc_omp_base_sim /gardenia/bin
$ sudo cp ~/datasets/web-Google.mtx /gardenia/datasets
Unmount the disk:
$ sudo umount ~/m5-dist/x86-system/disks/tmp
6. Running benchmarks on gem5
Download linux kernel binary:
X86
$ wget http://www.cs.utexas.edu/~parsec_m5/x86_64-vmlinux-2.6.28.4-smp
# wget http://www.m5sim.org/dist/current/m5_system_2.0b3.tar.bz2
ARM
$ wget http://www.gem5.org/dist/current/arm/aarch-system-2014-10.tar.xz
Modify $GEM5_HOME/configs/common/SysPath.py, set system path
X86
path = [ '/dist/m5/system', '~/m5-dist/x86-system' ]
ARM
path = [ '/dist/m5/system', '~/m5-dist/aarch-system' ]
Modify configs/common/Benchmarks.py
X86
return env.get('LINUX_IMAGE', disk('x86root-parsec.img'))
ARM
return env.get('LINUX_IMAGE', disk('aarch64-ubuntu-trusty-headless.img'))
Modify configs/common/FSConfig.py
X86
self.kernel = binary('x86_64-vmlinux-2.6.28.4-smp')
ARM
self.kernel = binary('vmlinux.aarch64.20140821')
For X86, modify gem5/src/arch/X86/cpuid.cc to fix a "kernel panic" bug:
from
result = CpuidResult(0x00020f51, 0x00000805, 0xe7dbfbff, 0x04000209);
to
result = CpuidResult(0x00020f51, 0x00000805, 0xe7dbfbff, 0x00000209);
src/mem/packet_queue.cc to fix "Packet queue %s has grown beyond 100 packets" problem
if (transmitList.size() > 10000)
Find the script files in ~/gardenia_code.
Copy them to gem5 directory.
Run for a first time to create a checkpoint:
$ ./run-ckpt.sh
Open another terminal to see the progress
$ ./util/term/m5term 3456
The checkpoint is kept in /home/cxh/gem5-ckpt
Run for the second time to restore from the checkpoint:
$ ./run-detail.sh
The statistics are in /home/cxh/out
References
[1] Z. Xu, Y. Zhang, J. Shen, and X. Chen. The GARDENIA benchmark suite: Characterization and architectural implications. Computer Architecture Letters, pages 72–81, 2018.
[2] N. L. Binkert, R. G. Dreslinski, L. R. Hsu, K. T. Lim, A. G. Saidi, and S. K. Reinhardt. The M5 Simulator: Modeling Networked Systems. In IEEE Micro, pages 52–60, July/August 2006.