[ BENCHMARKS / v5.0 / TASKS / 195_riscv_insn_budget ]

RISC-V memcpy/strlen/CRC32 under an instruction budget in Python.

memcpy, strlen and CRC-32 in RV32IM assembly, each inside an exact instruction budget counted by a bundled interpreter.

Unit
195_riscv_insn_budget
Category
Performance & HW OptRISC-V assembly
Language
Python
Difficulty
Hard900 s wall clock (15 min)
Origin
New in v5
Ranked rows passed
1/7single seed each

The prompt

The agent receives exactly this text as its task, verbatim. The harness adds its own system prompt and, in some campaign arms, guidance of its own; the harness chapter describes those. The task’s setup also writes the files its working directory starts with (a worked sample, a repository or a service, where the prompt names them); they are not reproduced here.

Prompt · 195_riscv_insn_budget
Create /tmp/eval_rv195/lib.s: RV32IM assembly for three functions, memcpy, strlen and crc32, each fast enough to stay within an exact instruction budget. The validator runs your file on the bundled interpreter /tmp/eval_rv195/rvi.py, which counts every executed instruction. Read rvi.py first: its docstring is the complete machine and assembler reference (supported instructions, 12-bit immediate ranges, syntax, Python API). Anything outside it is an assembly error or a trap. The validator uses its own unmodified copy of rvi.py.

Machine and calling convention
- Memory is 65536 bytes, little-endian. lh/lhu/sh need 2-byte alignment and lw/sw 4-byte alignment; a misaligned access traps. Code is not in data memory.
- 0x0000-0xBFFF is the data area that holds the argument buffers. 0xC000-0xFFFF is scratch and stack: sp = 0x10000 at entry, you may read and write anything in [0xC000, 0x10000), and its contents at entry are arbitrary. You may read any address in memory.
- Each call runs on a fresh machine; nothing persists between calls. Arguments are in a0-a2. Every other register except zero, ra and sp holds an arbitrary value at entry. Return with `ret` (ra holds the return address), with the result in a0.
- At return, sp, gp, tp and s0-s11 must hold their entry values. Any other register may be changed.

Functions (labels memcpy, strlen, crc32; helpers of your own are fine)
1. memcpy(a0 = dst, a1 = src, a2 = n): copy the n bytes at src to dst and return dst. 0 <= n <= 4096. dst and src have any alignment, the two ranges do not overlap, and both lie in the data area. Every data-area byte outside [dst, dst+n) must hold its entry value at return.
2. strlen(a0 = s): return the number of bytes before the first zero byte at s. The length is 0..4096, s has any alignment, and the string's bytes take any value 1..255. Every data-area byte must hold its entry value at return.
3. crc32(a0 = buf, a1 = n): return the CRC-32 of the n bytes at buf (0 <= n <= 4096, any alignment): reflected polynomial 0xEDB88320, initial value 0xFFFFFFFF, final xor 0xFFFFFFFF, i.e. the value Python's zlib.crc32 returns. Every data-area byte must hold its entry value at return. Examples: the 9 bytes "123456789" give 0xCBF43926; n = 0 gives 0.

Instruction budget
The count runs from the first instruction at the entry label to the final ret, inclusive; every executed instruction costs 1, pseudo-instructions included (li costs 1). With n the byte count (the string length for strlen) and / meaning integer division, every single call must stay within:
- memcpy: 3*n/2 + 96
- strlen: 15*n/8 + 64
- crc32: 9*n + 1600
A call that exceeds its budget is stopped and fails.

Validation: hundreds of hidden, seeded calls per function: every size from 0 through the small sizes, every alignment combination, and sizes up to 4096, with arbitrary memory contents around the buffers. Each call is checked for the result, for data-area bytes that differ at return from their entry values (other than memcpy's [dst, dst+n)), for the preserved registers, and against its budget. Only the failing function and case index are reported. Test with rvi.py yourself.

What it tests and why it is in the suite

What it asks. memcpy, strlen and CRC-32 in RV32IM assembly, each inside an exact instruction budget counted by a bundled interpreter.

Why it is here. A new family in Performance & HW Opt.

In the suite README: evals/README.md:133

How it is graded

The validator holds its checks where the agent cannot read them, and runs them against what the agent left on disk once it stops. Its hidden cases are generated inside the validator from a seed; any worked sample the prompt names is only a sample, and no expected output for a hidden case is in the agent’s directory. Before any model ran it, the unit was proven: its reference solution passes, plausible wrong solutions fail for the reason declared in advance, an empty solution and a leak probe fail, and, where the unit is timed, a slow solution fails by the validator’s own limit. The family also went through up to three adversarial review rounds, in which an independent verifier tried to pass every unit without solving it.

Upstream: the prover’s controls · one unit’s life cycle · why v5 is built this way

How each ranked run did

One run per board row, the DGX Spark pair first, then the RTX 5090, then the gold standard. Each is a single seed: a pass or a fail on one unit is one draw, and a difference between two rows on one unit says little on its own. Claude Opus 5.5 is the unranked reference, in its own scaffold.

DGX Spark pair

One RTX 5090

Gold standard · unranked

  • Claude Opus 5.5Claude Code tools, no turn cap, 2× wallPassedPassed the validator.