Skip to content

Commit 33f9862

Browse files
committed
gem5: benchmark hdf5 stats
1 parent 91d6315 commit 33f9862

File tree

5 files changed

+49
-20
lines changed

5 files changed

+49
-20
lines changed

README.adoc

+18-2
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,8 @@ The link:build[] script is just a lightweight wrapper that calls the smaller bui
202202
./build --dry-run
203203
....
204204

205+
see also: <<dry-run>>.
206+
205207
When you reach difficulties, QEMU makes it possible to easily GDB step debug the Linux kernel source code, see: xref:gdb[xrefstyle=full].
206208

207209
===== Your first kernel module hack
@@ -254,6 +256,8 @@ You can see that `./build` does that as well, by running:
254256
./build --dry-run
255257
....
256258

259+
See also: <<dry-run>>.
260+
257261
`--eval-after` is optional: you could just type `insmod hello.ko` in the terminal, but this makes it run automatically at the end of boot, and then drops you into a shell.
258262

259263
If the guest and host are the same arch, typically x86_64, you can speed up boot further with <<kvm>>:
@@ -531,6 +535,7 @@ Read the following sections for further introductory material:
531535
* <<introduction-to-qemu>>
532536
* <<introduction-to-buildroot>>
533537

538+
[[dry-run]]
534539
=== Dry run to get commands for your project
535540

536541
One of the major features of this repository is that we try to support the `--dry-run` option really well for all scripts.
@@ -11879,7 +11884,6 @@ To use that file, first rebuild `m5ops.out` with the m5ops instructions enabled
1187911884
....
1188011885
./build-userland \
1188111886
--arch aarch64 \
11882-
--ccflags='-DLKMC_M5OPS_ENABLE=1' \
1188311887
--force-rebuild \
1188411888
userland/c/m5ops.c \
1188511889
;
@@ -12180,7 +12184,19 @@ as explained in:
1218012184
gem5.opt --stats-help
1218112185
....
1218212186

12183-
TODO what is the advantage? The generated file for `--stats-file h5://stats.h5?desc=False` in LKMC f42c525d7973d70f4c836d2169cc2bd2893b4197 gem5 5af26353b532d7b5988cf0f6f3d0fbc5087dd1df was 946K, so much larger than the text version!
12187+
This is not exposed in LKMC f42c525d7973d70f4c836d2169cc2bd2893b4197 however, you just have to <<dry-run,hack the gem5 CLI for now>>.
12188+
12189+
TODO what is the advantage? The generated file for `--stats-file h5://stats.h5?desc=False` in LKMC f42c525d7973d70f4c836d2169cc2bd2893b4197 gem5 5af26353b532d7b5988cf0f6f3d0fbc5087dd1df for a single dump was 946K, so much larger than the text version seen at <<gem5-m5out-stats-txt-file>> which was only 59KB max!
12190+
12191+
We then try to see if it is any better when you have a bunch of dump events:
12192+
12193+
....
12194+
./run --arch aarch64 --emulator gem5 --userland userland/c/m5ops.c --userland-args 'd 1000'
12195+
....
12196+
12197+
and there yes, we see that the file size fell from 39MB on `stats.txt` to 3.2MB on `stats.m5`, so the increase observed previously was just due to some initial size overhead.
12198+
12199+
We also note however that the stat dump made the such a simulation that just loops and dumps considerably slower, from 3s to 15s on <<p51>>. Fascinating, we are definitely not disk bound there.
1218412200

1218512201
===== gem5 only dump selected stats
1218612202

common.py

+2
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,8 @@ def __init__(
239239
Bash equivalents even for actions taken directly in Python without shelling out.
240240
241241
mkdir are generally omitted since those are obvious
242+
243+
See also: https://cirosantilli.com/linux-kernel-module-cheat#dry-run
242244
'''
243245
)
244246
self.add_argument(

path_properties.py

+2
Original file line numberDiff line numberDiff line change
@@ -649,6 +649,7 @@ def get(path):
649649
'file_write_read.c': {'baremetal': False},
650650
'getchar.c': {'interactive': True},
651651
'malloc_max.c': {'disrupts_system': True},
652+
'm5ops.c': {'allowed_emulators': {'gem5'}},
652653
'return1.c': {'exit_status': 1},
653654
'return2.c': {'exit_status': 2},
654655
}
@@ -669,6 +670,7 @@ def get(path):
669670
},
670671
),
671672
'count.cpp': {'more_than_1s': True},
673+
'm5ops.cpp': {'allowed_emulators': {'gem5'}},
672674
'parallel_sort.cpp': {'minimum_gcc_version': (9, 0, 0)},
673675
'sleep_for.cpp': {
674676
'more_than_1s': True,

userland/c/m5ops.c

+26-18
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,42 @@
11
/* https://cirosantilli.com/linux-kernel-module-cheat#m5ops-instructions */
22

3-
#include <stdint.h>
4-
#include <stdio.h>
53
#include <stdlib.h>
64

5+
#define LKMC_M5OPS_ENABLE 1
76
#include <lkmc/m5ops.h>
87

98
int main(int argc, char **argv) {
109
char action;
10+
unsigned long long loops;
11+
1112
if (argc > 1) {
1213
action = argv[1][0];
1314
} else {
1415
action = 'e';
1516
}
16-
switch (action) {
17-
case 'c':
18-
LKMC_M5OPS_CHECKPOINT;
19-
break;
20-
case 'd':
21-
LKMC_M5OPS_DUMPSTATS;
22-
break;
23-
case 'e':
24-
LKMC_M5OPS_EXIT;
25-
break;
26-
case 'f':
27-
LKMC_M5OPS_FAIL_1;
28-
break;
29-
case 'r':
30-
LKMC_M5OPS_RESETSTATS;
31-
break;
17+
if (argc > 2) {
18+
loops = strtoull(argv[2], NULL, 0);
19+
} else {
20+
loops = 1;
21+
}
22+
for (unsigned long long i = 0; i < loops; i++) {
23+
switch (action) {
24+
case 'c':
25+
LKMC_M5OPS_CHECKPOINT;
26+
break;
27+
case 'd':
28+
LKMC_M5OPS_DUMPSTATS;
29+
break;
30+
case 'e':
31+
LKMC_M5OPS_EXIT;
32+
break;
33+
case 'f':
34+
LKMC_M5OPS_FAIL_1;
35+
break;
36+
case 'r':
37+
LKMC_M5OPS_RESETSTATS;
38+
break;
39+
}
3240
}
3341
return EXIT_SUCCESS;
3442
}

userland/cpp/m5ops.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/* https://cirosantilli.com/linux-kernel-module-cheat#m5ops-instructions */
22

3+
#define LKMC_M5OPS_ENABLE 1
34
#include <lkmc/m5ops.h>
45

56
int main(int argc, char **argv) {

0 commit comments

Comments
 (0)