diff --git a/README.adoc b/README.adoc index d2f3c0f..19d8276 100644 --- a/README.adoc +++ b/README.adoc @@ -11578,7 +11578,10 @@ gem5 allocates some magic instructions on unused instruction encodings for conve Those instructions are exposed through the <> in tree executable. -To make things simpler to understand, you can play around with our own minimized educational `m5` subset link:userland/c/m5ops.c[]. +To make things simpler to understand, you can play around with our own minimized educational `m5` subset: + +* link:userland/c/m5ops.c[] +* link:userland/cpp/m5ops.cpp[] The instructions used by `./c/m5ops.out` are present in link:lkmc/m5ops.h[] in a very simple to understand and reuse inline assembly form. @@ -19433,10 +19436,10 @@ Summary of manually collected results on <> at LKMC a18f28e263c91362519ef55 .Busy loop MIPS for different simulator setups [options="header"] |=== -|LKMC |Benchmark |Emulator |Loops |Time (s) |Instruction count |Approximate MIPS +|LKMC |Benchmark build |Emulator command |Loops |Time (s) |Instruction count |Approximate MIPS |a18f28e263c91362519ef550150b5c9d75fa3679 + 1 -|userland/gcc/busy_loop.c -O0 +|link:userland/gcc/busy_loop.c[] `-O0` |`qemu --arch aarch64` |10^10 |68 @@ -19444,7 +19447,7 @@ Summary of manually collected results on <> at LKMC a18f28e263c91362519ef55 |2000 |a18f28e263c91362519ef550150b5c9d75fa3679 + 1 -|userland/gcc/busy_loop.c -O0 +|link:userland/gcc/busy_loop.c[] `-O0` |`gem5 --arch aarch64` |10^7 |100 @@ -19452,7 +19455,7 @@ Summary of manually collected results on <> at LKMC a18f28e263c91362519ef55 |1 |a18f28e263c91362519ef550150b5c9d75fa3679 + 1 -|userland/gcc/busy_loop.c -O0 +|link:userland/gcc/busy_loop.c[] `-O0` |`+gem5 --arch aarch64 -- --cpu-type MinorCPU --caches+` |10^6 |31 @@ -19460,7 +19463,7 @@ Summary of manually collected results on <> at LKMC a18f28e263c91362519ef55 |0.4 |a18f28e263c91362519ef550150b5c9d75fa3679 + 1 -|userland/gcc/busy_loop.c -O0 +|link:userland/gcc/busy_loop.c[] `-O0` |`+gem5 --arch aarch64 -- --cpu-type DerivO3CPU --caches+` |10^6 |52 @@ -19468,7 +19471,7 @@ Summary of manually collected results on <> at LKMC a18f28e263c91362519ef55 |0.2 |a18f28e263c91362519ef550150b5c9d75fa3679 + 1 -|userland/gcc/busy_loop.c -O0 +|link:userland/gcc/busy_loop.c[] `-O0` |`+gem5 --arch aarch64 --gem5-build-id MOESI_CMP_directory -- --cpu-type DerivO3CPU --caches --ruby+` |1 * 1000000 = 10^6 |63 @@ -19476,7 +19479,7 @@ Summary of manually collected results on <> at LKMC a18f28e263c91362519ef55 |0.2 |605448f07e6380634b1aa7e9732d111759f69fd -|<> -O3 +|<> `-O3` |`gem5 --arch aarch64` |4 * 10^5 |68 @@ -19484,13 +19487,29 @@ Summary of manually collected results on <> at LKMC a18f28e263c91362519ef55 |1.6 |5d233f2664a78789f9907d27e2a40e86cefad595 -|<> -O3 +|<> `-O3` |`gem5 --arch aarch64 --userland-args 300000 2` |3 * 10^5 * 2 |64 |9.9674773 * 10^7 |1.6 +|ab6f7331406b22f8ab6e2df5f8b8e464fb35b611 +|link:userland/c/m5ops.c[] `-O0` +|`gem5 --arch aarch64 --userland-args e` +|1 +|2 +|1.26479 * 10^5 +|0.05 + +|ab6f7331406b22f8ab6e2df5f8b8e464fb35b611 +|link:userland/cpp/m5ops.cpp[] `-O0` +|`gem5 --arch aarch64 --userland-args e` +|1 +|2 +|2.385012 * 10^6 +|1 + |=== The first step is to determine a number of loops that will run long enough to have meaningful results, but not too long that we will get bored, so about 1 minute. diff --git a/userland/cpp/m5ops.cpp b/userland/cpp/m5ops.cpp new file mode 100644 index 0000000..b9b1c8b --- /dev/null +++ b/userland/cpp/m5ops.cpp @@ -0,0 +1,29 @@ +/* https://cirosantilli.com/linux-kernel-module-cheat#m5ops-instructions */ + +#include + +int main(int argc, char **argv) { + char action; + if (argc > 1) { + action = argv[1][0]; + } else { + action = 'e'; + } + switch (action) { + case 'c': + LKMC_M5OPS_CHECKPOINT; + break; + case 'd': + LKMC_M5OPS_DUMPSTATS; + break; + case 'e': + LKMC_M5OPS_EXIT; + break; + case 'f': + LKMC_M5OPS_FAIL_1; + break; + case 'r': + LKMC_M5OPS_RESETSTATS; + break; + } +}