Nezha C906 on gem5¶
Template hfim-template-nezha-c906-gem5. The same XuanTie C906 as Nezha C906, on gem5 instead of QEMU: the core is gem5's in-order MinorCPU with the C906's L1 caches and no L2, and the benchmark runs as a static Linux program in syscall emulation. It reaches what QEMU cannot: the L1 data, instruction and tag arrays, the Ruby coherence protocol between two harts, and a non-volatile main memory. The fibonacci program and its observables are those of the QEMU template, so a campaign here and its twin there compare.
hfim init nezha-c906-gem5 my-campaigns
cd my-campaigns
hfim run campaigns/fibonacci/register.yaml
Board¶
| Property | Value |
|---|---|
| Core | XuanTie C906, RV64, 5-stage in-order, single issue, as gem5 MinorCPU |
| Clock | 1 GHz |
| L1 instruction cache | 32 kB, 2-way, 64-byte lines |
| L1 data cache | 32 kB, 4-way, 64-byte lines |
| L2 cache | none on the classic memory system; Ruby's protocol has its own |
| Memory | 256 MB, gem5's DDR3, or NVMain with campaigns/nvmain.yaml |
board.yaml sets each of these on gem5; a campaign that states cpu_model, cpu_clock, cache_config or memory_size wins over it. The memory is 256 MB, as the QEMU template gives QEMU. What a board sets and how: gem5 backend, What the board sets.
hfim run prints the machine before it starts, each part followed by who set it:
machine: cpu MinorCPU at 1GHz, L1I 32kB 2-way, L1D 32kB 4-way, no L2, 64 B lines, 256MB memory (board.yaml)
Requirements¶
| Package | Version | Install |
|---|---|---|
| hfim | >=1.15,<2 |
hfim update |
hfim-sim-gem5 |
23.2.0 |
hfim init or hfim run |
hfim-sdk |
>=1.5,<2 |
hfim init or hfim run |
The hfim-sim-gem5 image compiles gem5 twice, once for the classic memory system and once for Ruby, the first time it is installed on a machine. It also carries the compiler the benchmarks need, riscv64-linux-gnu-gcc, so the build runs inside it on any host.
Contents¶
| Path | Contents |
|---|---|
hfim.yaml |
template name, version pins, board |
board.yaml |
the C906 as gem5 models it: CPU, clock, caches, memory |
nvmain/PCM_ISSCC_2012_4GB.config |
the phase-change memory NVMain models for nvm_tags |
benchmarks/fibonacci/, benchmarks/mmult/, benchmarks/pingpong/ |
main.c of each benchmark |
campaigns/<benchmark>/<benchmark>.yaml |
what every campaign of a benchmark includes: the benchmark and its observables |
campaigns/nvmain.yaml |
NVMain as main memory, included by pingpong/nvm_tags.yaml |
There is no startup/ directory and no modules/: a gem5 benchmark is built for the SDK target gem5-se, a static Linux program with no boot code and no UART. What a campaign compares is its variables.
Benchmarks¶
| Benchmark | What it computes | Observables |
|---|---|---|
fibonacci |
the first 64 Fibonacci numbers, the QEMU template's program | result |
mmult |
a 16x16 integer matrix product | result |
pingpong |
two harts hand one variable back and forth, then hart 0 writes and reads back 512 kB | pingpong_var, checksum |
pingpong needs two harts. gem5 starts the second only when the program calls clone(), so pingpong starts it itself with a raw clone system call; with one hart it exits at once with code 2. Its final pingpong_var and checksum have a closed form, written in its main.c.
Campaigns¶
| Campaign file | Target | Backend | timeout |
|---|---|---|---|
fibonacci/register.yaml, mmult/register.yaml |
integer registers | gem5 |
120 |
fibonacci/memory.yaml |
the variable result |
gem5 |
120 |
mmult/memory.yaml |
the input matrix A |
gem5 |
120 |
<benchmark>/cache_l1d.yaml, cache_l1i.yaml |
L1 data and instruction arrays | gem5 |
120 |
<benchmark>/cache_tag.yaml |
L1D tags | gem5 |
120 |
pingpong/ruby_mshr.yaml, ruby_tbe.yaml, ruby_directory.yaml |
Ruby coherence state of pingpong_var's line |
gem5-ruby, two harts |
300 |
pingpong/nvm_tags.yaml |
NVMain's tag store | gem5-ruby with NVMain |
600 |
Each has 10 injections and seed 7. A memory campaign names its window by a variable (target_variable), never by an address or a section: on a static glibc program .bss holds the C library's variables as well as the benchmark's. No campaign states injection_mode: gem5 counts the instructions it commits and fires at the drawn count.
# campaigns/pingpong/ruby_tbe.yaml
include: pingpong.yaml # the benchmark, two harts, the target variable
campaign_name: pingpong-ruby_tbe
simulator_backend: gem5-ruby
seed: 7
num_injections: 10
num_workers: 1
target_types: [ruby_tbe]
fault_model: single_bit_flip
timeout: 300
output_dir: results
Add a benchmark¶
- Copy
benchmarks/fibonaccitobenchmarks/<name>. - In
main.c, callfim_init()where the measured work starts andfim_exit(0)where it ends. Declare every value to compare as a file-scopevolatilevariable. The program may use the C library. - Copy
campaigns/fibonacci/tocampaigns/<name>/and renamefibonacci.yamlto<name>.yaml. In it, setbenchmark: <name>and name those variables underobservable_outputs. - In the copied campaigns, set a new
campaign_name.
Details: Writing a benchmark.