/odin-native:cpu-pipelines-and-hazardsfrom ODIN Native
Explains CPU pipeline stages, data/control hazards, forwarding, and stalls. Interprets perf counters and proposes loop restructuring to break dependency chains.
Ships in ODIN Native. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
| Field | Bound contract |
|---|---|
| Trigger | A stall counter needs interpreting, instruction order changes throughput in a hot loop, or assembly scheduling needs relating to hardware behavior. |
| Authority | Read-only. The skill runs perf stat on a user-named binary and answers in chat. Nothing on disk changes, so there is nothing to roll back. No remote mutation. |
| Side effect | Chat output only. |
| Done | The hazard class in the loop is named, the counter that shows it is quoted where a binary exists, and one restructuring is proposed with its condition. |
| Hazard | Example | Hardware answer |
|---|---|---|
| Read after write (true dependency) | add r1, r2, r3 then sub r4, r1, r5 | Forwarding from the execute or memory stage; a stall when the producer is a load |
| Write after read or write after write | Rare in an in-order core; matters under out-of-order rename | Register renaming |
| Control | A branch whose target is unknown until execute | Prediction, then a flush on mispredict; cost scales with pipeline depth |
| Structural | One memory port shared by two loads | Stall with no dependency at all |
/* Serial: each iteration waits on acc. */
acc = 0;
for (int i = 0; i < n; i++)
acc = acc + data[i];
/* Two chains: the core overlaps them. */
acc0 = acc1 = 0;
for (int i = 0; i + 1 < n; i += 2) {
acc0 += data[i];
acc1 += data[i + 1];
}
if (n & 1) /* odd tail: one element left */
acc0 += data[n - 1];
acc = acc0 + acc1;
perf stat -e instructions,cycles,stalled-cycles-frontend,stalled-cycles-backend ./app
Read instructions per cycle against the core's issue width, not against a fixed number: a four-wide core running a dependent chain sits near one, and that is the chain's floor, not a defect. A high front-end stall share points at instruction cache misses or mispredicts; a high back-end share points at load latency or a saturated port. Memory latency dominates most loops, so pair this with cpu-cache-opt before scheduling instructions by hand.
| Failure class | Behavior |
|---|---|
| No binary or workload | Deliver the hazard classification and the restructuring as a hypothesis. |
perf stat denied | Report the perf_event_paranoid value the tool prints. Do not change the sysctl. |
| High front-end stalls | Look at instruction cache footprint and mispredicts; use branch-prediction-and-speculation. |
| Unrolling gives no gain | The loop is memory-bound. Profile loads and consider prefetch; use cpu-cache-opt. |
| Cycle model does not match | The target is out-of-order and the in-order count was applied. Use the counters, not a hand count. |
A nop fixes a device timing bug | That is memory-mapped I/O ordering, not a pipeline hazard. Use the proper barrier or delay primitive; never tune device delays with nop. |
A chat answer naming the hazard class for each dependency, the front-end versus back-end stall split when measured, and one restructuring with the condition under which it helps.
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
cpu-pipelines, hazards, perf-stat, assembly-optimization, loop-unrolling
npx claudepluginhub outlinedriven/odin-claude-plugin --plugin odin-native138 skills in this plugin
/abi-and-calling-conventionsUse when explaining System V AMD64, ARM AAPCS, RISC-V psABI, stack frames, variadic calls, or FFI register rules. Not for the Rust FFI binding layer: use rust-ffi./adc-dac-baremetalUse when configuring ADC sampling time, DMA-driven ADC, calibration, or DAC channel setup on bare-metal MCUs. Not for the DMA stream itself: use dma-baremetal./af-xdpUse when creating AF_XDP sockets, configuring UMEM and XSK rings, writing an XDP redirect program, or choosing copy versus zero-copy mode. Not for full kernel bypass: use dpdk./apple-siliconUse when tuning or profiling native code on Apple M-series Macs: unified memory, 16 KiB pages, Accelerate and Metal for matrix work, xctrace and leaks, Rosetta 2, or sysctl hardware queries./arm-sveUse when writing or porting AArch64 SIMD to SVE or SVE2: arm_sve.h intrinsics, predicates, vector-length-agnostic loops, auto-vectorization, or SVE registers in GDB. Not for NEON: use simd-intrinsics./assembly-armUse when reading or writing AArch64 or AArch32 Thumb assembly, inline asm in C, AAPCS64 register roles, or NEON and SVE vector code. Not for ABI detail across ISAs: use abi-and-calling-conventions.Other plugins' skills for the same job