跳到正文
cccskills
免费在 GitHub 公开

cpu-pipelines-and-hazards

Use when explaining pipeline stages, data or control hazards, forwarding, stalls, or superscalar basics behind a counter reading. Not for mispredict cost: use branch-prediction-and-speculation.

中文简介正在准备中。当前显示原文说明。

查看安装方法

包含的文件(2)

  • SKILL.md4.4 KB
  • agents/openai.yaml208 B

SKILL.md(原文)

安装前可以查看交给 AI 代理的指令内容。

CPU pipelines and hazards

Contract

FieldBound contract
TriggerA stall counter needs interpreting, instruction order changes throughput in a hot loop, or assembly scheduling needs relating to hardware behavior.
AuthorityRead-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 effectChat output only.
DoneThe 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.

Inputs

  • Hot loop (required): source or assembly.
  • Binary and workload (optional): needed for counter evidence.
  • Target microarchitecture (optional): in-order embedded core or out-of-order desktop or server core. The answer differs.

Procedure

  1. Set the model. The five-stage in-order pipeline (fetch, decode, execute, memory, writeback) overlaps instruction N in execute with N+1 in decode. Out-of-order cores rename registers, issue to several ports, and retire in order; the five-stage picture still explains where a dependency costs. Done when: the user knows which model applies to the target.
  2. Classify the hazard. Done when: each dependency in the loop has a class.
HazardExampleHardware answer
Read after write (true dependency)add r1, r2, r3 then sub r4, r1, r5Forwarding from the execute or memory stage; a stall when the producer is a load
Write after read or write after writeRare in an in-order core; matters under out-of-order renameRegister renaming
ControlA branch whose target is unknown until executePrediction, then a flush on mispredict; cost scales with pipeline depth
StructuralOne memory port shared by two loadsStall with no dependency at all
  1. Break the dependency chain where the loop is latency-bound. A single accumulator serializes every iteration on the add latency. Two or more accumulators expose independent chains and let the core issue them in parallel. Done when: the loop is restructured or the user confirms the loop is memory-bound and the change would not help.
/* 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;
  1. Measure the stall split. Done when: front-end and back-end stall counts for the real workload are recorded, or the answer is marked unmeasured.
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 and recovery

Failure classBehavior
No binary or workloadDeliver the hazard classification and the restructuring as a hypothesis.
perf stat deniedReport the perf_event_paranoid value the tool prints. Do not change the sysctl.
High front-end stallsLook at instruction cache footprint and mispredicts; use branch-prediction-and-speculation.
Unrolling gives no gainThe loop is memory-bound. Profile loads and consider prefetch; use cpu-cache-opt.
Cycle model does not matchThe 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 bugThat is memory-mapped I/O ordering, not a pipeline hazard. Use the proper barrier or delay primitive; never tune device delays with nop.

Output

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.

评价

还没有评价。欢迎分享你的使用感受。

评论

无需登录即可发表。欢迎分享使用感受、提问,或说明在哪些环境下无法运行。

还没有评论。来写第一条吧。

提交后会立即公开。请勿填写邮箱、电话等个人信息。URL 最多 2 个。

0 / 1000 字

此表单受 reCAPTCHA 保护,适用 Google 的隐私权政策和服务条款。

同一仓库的技能

Use 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.

中文简介正在准备中。当前显示原文说明。

OutlineDriven/odin-claude-plugin382026年9月29日 更新

Use 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.

中文简介正在准备中。当前显示原文说明。

OutlineDriven/odin-claude-plugin382026年9月29日 更新

af-xdp

免费

Use 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.

中文简介正在准备中。当前显示原文说明。

OutlineDriven/odin-claude-plugin382026年9月29日 更新

Use when a completed session needs an agent-environment retrospective. Not for an engineering retrospective from telemetry: use engineering-retrospective.

中文简介正在准备中。当前显示原文说明。

OutlineDriven/odin-claude-plugin382026年9月29日 更新

Use when a redacted, trimmed agent transcript must be appended to a GitHub PR or issue body, with human approval and preview. Not for automated or model-initiated insertion.

中文简介正在准备中。当前显示原文说明。

OutlineDriven/odin-claude-plugin382026年9月29日 更新

agents-md

免费

Use when a repo needs agent setup, AGENTS.md added or made lean, CLAUDE.md audited, or agent instructions scored or pruned. Not for remote, credential, publish, deploy, or irreversible changes.

中文简介正在准备中。当前显示原文说明。

OutlineDriven/odin-claude-plugin382026年9月29日 更新

查看 OutlineDriven 的全部技能

报告此技能的问题