Skip to content

Multicore

A multicore campaign runs the benchmark on several harts and injects each fault into one of them.

Keys

num_cores: 4             # more than 1 starts an SMP machine
target_cluster: 0        # the cluster the harts below belong to
target_core: random      # the hart a fault lands on
injection_mode: breakpoint
inject_at_symbol: work_step
Key Values Default
num_cores number of harts 1
target_cluster cluster number, on a board with several clusters 0
target_core a hart (2), a list of harts ([0, 2]), or random random when num_cores is above 1
memory_per_core true: split a memory target into one slice per hart false

Harts are numbered within their cluster, from 0. On a single-cluster machine (QEMU virt) the harts are 0 to num_cores - 1. A target_core outside that range, a hart listed twice, or an empty list is rejected at load.

Important

On QEMU, num_cores above 1 requires injection_mode: breakpoint. Under SMP the instruction count is one budget shared by all harts, so it cannot name an instant on one hart's timeline; icount is rejected at load.

Choosing the hart

target_core Hart of each injection
2 hart 2, always
[0, 2] hart 0 or hart 2, drawn with the campaign seed
random or unset any hart of target_cluster, drawn with the seed

The drawn hart is part of the faultlist, like the instant and the bit. The same seed draws the same harts in the same order, and faultlist.json lists them. Over many injections each hart gets about the same share.

target_core chooses whose registers take the fault. It does not choose where the machine stops. In breakpoint mode the injection point is an address drawn from the golden run, and the machine stops when any hart reaches it. The fault then goes into the registers of the chosen hart, whatever that hart is executing. The target_pc column records where the chosen hart was; actual_pc records where the machine stopped.

A memory fault does not depend on the hart: memory is shared, and a flipped bit is the same for every hart that reads it. Memory campaigns draw no hart, and their rows record the first hart of the selection. The exception is memory per core.

Clusters

A heterogeneous SoC exposes each cluster as its own GDB inferior. The board's board.yaml, in the template, declares which hart belongs to which cluster. The Microchip PolarFire SoC has two clusters: cluster 0 is the E51 monitor core, cluster 1 the four U54 application cores.

# board.yaml
cpu:
  clusters: 2
  harts:
    - {hart: 0, core: "E51",   cluster: 0}
    - {hart: 1, core: "U54_1", cluster: 1}
    - {hart: 2, core: "U54_2", cluster: 1}
    - {hart: 3, core: "U54_3", cluster: 1}
    - {hart: 4, core: "U54_4", cluster: 1}

A campaign that spreads register faults over the four U54 cores, never the E51:

num_cores: 5
target_cluster: 1        # the U54 cluster
target_core: random      # U54_1..U54_4 are target_core 0..3
injection_mode: breakpoint
target_core Harts injected
random U54_1, U54_2, U54_3, U54_4
[0, 2] U54_1, U54_3
0 U54_1

Rules:

  • random draws among the harts of target_cluster. A multi-cluster board whose board.yaml lacks cpu.harts[].cluster stops the campaign before it runs, asking for it or for an explicit target_core.
  • target_cluster above 0 needs num_cores above 1 and must be below the board's cpu.clusters in board.yaml. A board that declares no clusters (QEMU virt) has one.
  • With several clusters, HFIM attaches the targeted cluster's inferior before the first continue and resumes every cluster on each continue. The harts that are not targeted keep running.
  • A breakpoint on a multi-cluster board stops slowly, because GDB polls for it. The QEMU icount plugin counts every hit after the first, and GDB takes only the hit chosen for the injection.

The hfim-template-polarfire-zephyr-qemu template contains one campaign of each target_core form. Board details: PolarFire SoC with Zephyr.

Memory per core

An operating system keeps some memory per CPU, such as interrupt stacks, laid out as an array with one equal slice per CPU. memory_per_core: true targets one slice per injection:

num_cores: 5
target_cluster: 1
target_core: random
fault: memory
target_symbol: z_interrupt_stacks    # Zephyr: one interrupt stack per CPU
memory_per_core: true
  1. The target symbol is split into one slice per hart of target_cluster. The slice count is every hart of the cluster, also when target_core lists only some of them.
  2. Each injection draws its hart by the target_core rules.
  3. The fault lands in the slice of the CPU that runs the drawn hart.

The target must split into equal slices of whole accesses, or the campaign stops before it runs. memory_per_core needs num_cores above 1 and fault: memory. With it, memory rows count in the per-hart table of results.txt.

The slices are in the operating system's CPU order, which can differ from hart order. In Zephyr, CPU 0 is the hart it booted on (CONFIG_RV_BOOT_HART), and the other CPUs follow the devicetree. A benchmark publishes the mapping in a 32-bit array named fim_cpu_hart, where entry i is the hart CPU i runs on:

volatile uint32_t fim_cpu_hart[CONFIG_MP_MAX_NUM_CPUS];   /* Zephyr */

static int fim_record_cpu_harts(void)
{
    for (int i = 0; i < CONFIG_MP_MAX_NUM_CPUS; i++)
        fim_cpu_hart[i] = _kernel.cpus[i].arch.hartid;
    return 0;
}
SYS_INIT(fim_record_cpu_harts, APPLICATION, 0);   /* before main() */

The golden run reads the array and stores it in trace.json as cpu_harts. The campaign maps it to the hart ids of cpu.harts in board.yaml. A drawn hart on which no CPU runs stops the campaign. Without the array, CPU i is taken to be target_core i, with a warning. The PolarFire template's benchmarks publish the array; Zephyr boots on U54_1 there, so the map is [1, 2, 3, 4].

Results

File Multicore content
injections.csv target_core and target_cluster: the hart that took the fault; target_pc: where that hart was; actual_pc: where the machine stopped
report.tsv target_core, target_cluster and target_pc as the last three columns
results.txt a per-hart table of outcomes, with the names from board.yaml
faultlist.json the hart drawn for each injection
  PER-HART BREAKDOWN (target_core)
  Hart                MASKED   SDC   DET  CRASH   T/O  Total
  U54_1 (1/0)              6     1     0      1     0      8
  U54_2 (1/1)              1     0     0      2     0      3

The per-hart table counts register faults, and memory faults when memory_per_core is set. A single-core campaign's report.tsv has the same columns, empty, and its results.txt has no per-hart table. Column definitions: Output files.

A faultlist CSV can carry a target_core column, so a previous run's injections.csv replays on the same harts. A row with the column blank takes the first hart of the campaign's target_core.

One result directory per hart Run a [batch](running-campaigns.md#batches) with one entry per hart:
defaults:
  num_cores: 4
  # ... the rest of the campaign
campaigns:
  - {campaign_name: core0, target_core: 0, output_dir: results/core0}
  - {campaign_name: core1, target_core: 1, output_dir: results/core1}
  - {campaign_name: core2, target_core: 2, output_dir: results/core2}
  - {campaign_name: core3, target_core: 3, output_dir: results/core3}

Backends

QEMU gem5 (classic) gem5-ruby Hardware
num_cores above 1 yes rejected at load yes yes, the harts of target_cluster
injection_mode breakpoint only committed-instruction count breakpoint or timer
Fault on the drawn hart yes no: faults go to CPU 0; ruby_* targets select a line, not a hart yes
Bit-exact replay of a seed no unverified no
Fault targets register, memory ruby_*, register, memory, caches register, memory

QEMU. QEMU runs the harts as parallel host threads (MTTCG). How their instructions interleave depends on the host, so the same seed draws the same faults but the run around them can differ. The campaign warns and runs. A board can declare emulation.timing: icount in board.yaml: QEMU then derives the guest clock from instructions, which keeps timed firmware handshakes from failing on a loaded host. It does not make an SMP run reproducible: QEMU then runs the harts one at a time and switches between them on a host timer, which also changes how an operating system spreads work across harts.

gem5. The classic backend rejects num_cores above 1: it has no multicore coherence model. simulator_backend: gem5-ruby runs num_cores CPUs under the MESI_Two_Level protocol and models coherence explicitly. Cache ECC (cache_ecc_enabled) is single-core only. Coherence targets: Ruby controllers and, for classic caches on one core, Coherence state. Backend setup: gem5 backend.

Hardware. The harts of target_cluster run on the board's own cores. At the injection point every one of them halts, and the fault goes to the hart target_core names; harts outside the cluster keep running. A seed draws the same faults, but the board's timing around them varies from run to run. Backend setup: Hardware backend.