wuica-cli 0.0.0-stage → 0.1.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +661 -0
- package/README.md +546 -2
- package/bin/wuica-mcp.js +16 -0
- package/bin/wuica.js +25 -0
- package/dist/data/arch/ADL-P.bin.br +0 -0
- package/dist/data/arch/BDW.bin.br +0 -0
- package/dist/data/arch/CFL.bin.br +0 -0
- package/dist/data/arch/CLX.bin.br +0 -0
- package/dist/data/arch/HSW.bin.br +0 -0
- package/dist/data/arch/ICL.bin.br +0 -0
- package/dist/data/arch/ICX.bin.br +0 -0
- package/dist/data/arch/IVB.bin.br +0 -0
- package/dist/data/arch/KBL.bin.br +0 -0
- package/dist/data/arch/RKL.bin.br +0 -0
- package/dist/data/arch/SKL.bin.br +0 -0
- package/dist/data/arch/SKX.bin.br +0 -0
- package/dist/data/arch/SNB.bin.br +0 -0
- package/dist/data/arch/TGL.bin.br +0 -0
- package/dist/data/arch/ZEN3.bin.br +0 -0
- package/dist/data/uarch.json.br +0 -0
- package/dist/manifest.json +160 -0
- package/dist/wuica_asm.wasm.br +0 -0
- package/dist/wuica_wasm.wasm.br +0 -0
- package/index.d.ts +410 -0
- package/lib/archs.js +44 -0
- package/lib/cli.js +693 -0
- package/lib/core.js +36 -0
- package/lib/details.js +60 -0
- package/lib/examples.js +26 -0
- package/lib/files.js +40 -0
- package/lib/index.js +577 -0
- package/lib/insights.js +100 -0
- package/lib/mcp.js +366 -0
- package/lib/objfile.js +216 -0
- package/lib/thread-worker.js +49 -0
- package/lib/threads.js +235 -0
- package/lib/wasm.js +246 -0
- package/lib/web/accum.js +202 -0
- package/lib/web/asm-regions.js +415 -0
- package/lib/web/assembler.js +188 -0
- package/lib/web/caveats.js +214 -0
- package/lib/web/examples.js +99 -0
- package/lib/web/loop-find.js +492 -0
- package/lib/web/showcase.js +368 -0
- package/lib/whatif.js +136 -0
- package/licenses/LICENSE-LLVM.txt +279 -0
- package/licenses/LICENSE-XED.txt +178 -0
- package/package.json +58 -4
package/README.md
CHANGED
|
@@ -1,3 +1,547 @@
|
|
|
1
|
-
#
|
|
1
|
+
# wuica
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Throughput prediction for x86-64 basic blocks, running locally in Node. **wuica** (WebAssembly uiCA) is an independent
|
|
4
|
+
Rust/WebAssembly port of [uiCA](https://github.com/andreas-abel/uiCA). Its reports are bit-identical to the Python uiCA on the
|
|
5
|
+
port's test corpus. The package contains:
|
|
6
|
+
|
|
7
|
+
- a **library**: `import { createWuica } from 'wuica-cli'`
|
|
8
|
+
- a **command-line tool**: `npx wuica-cli loop.s -arch SKL`
|
|
9
|
+
- a local **MCP server** (stdio) for AI agents: `npx wuica-cli mcp`
|
|
10
|
+
|
|
11
|
+
This is **not the official uiCA** (that is [uiCA.uops.info](https://uiCA.uops.info) and the
|
|
12
|
+
[uiCA repository](https://github.com/andreas-abel/uiCA)). The instruction data (latencies, throughputs, port usage) comes
|
|
13
|
+
from [uops.info](https://www.uops.info). Besides uiCA's Intel models (Sandy Bridge to Rocket Lake), wuica includes the
|
|
14
|
+
experimental models of the fork [jtl06/uiCA](https://github.com/jtl06/uiCA): **AMD Zen 3 (ZEN3), Alder Lake P-core
|
|
15
|
+
(ADL-P) and Ice Lake server (ICX)**. They are marked `prototype` and are less validated than the Intel models.
|
|
16
|
+
|
|
17
|
+
Everything runs offline. The two WebAssembly modules (the analyzer, and LLVM's x86 assembler for assembly input) and the
|
|
18
|
+
instruction tables are shipped brotli-compressed. A table is loaded the first time its microarchitecture is used.
|
|
19
|
+
Requirements: Node.js 20 or later. **No dependencies**: `npm install wuica-cli` (or `npx wuica-cli`) adds this one
|
|
20
|
+
package, 2.3 MB unpacked; the MCP server is part of it.
|
|
21
|
+
|
|
22
|
+
The commands are `wuica` and `wuica-mcp`. Install them with `npm install -g wuica-cli`, or run without installing
|
|
23
|
+
with `npx wuica-cli ...`. The examples below write `wuica`.
|
|
24
|
+
|
|
25
|
+
## The CLI in five minutes
|
|
26
|
+
|
|
27
|
+
```
|
|
28
|
+
wuica -example saxpy -arch SKL,ZEN3,ADL-P # a built-in loop, no file needed (-examples lists them)
|
|
29
|
+
clang -O3 -march=haswell -S dot.c -o dot.s # AT&T, as clang and gcc write it: detected, no flag needed
|
|
30
|
+
wuica dot.s # uiCA's report for SKL, of the loop wuica picked
|
|
31
|
+
wuica dot.s -arch SKL,ZEN3,ADL-P # one table for several CPUs ("all": every one)
|
|
32
|
+
wuica dot.s -per 8 # the loop does 8 elements per iteration: cycles per element too
|
|
33
|
+
wuica dot.s -loops # the loops in the file; -loop N or -loop .LBB0_12 picks one
|
|
34
|
+
wuica dot.s -whatif # unrolled, N accumulators, front end and fusion variants
|
|
35
|
+
clang -O3 -c dot.c && wuica dot.o -func dot # an object file (ELF or Mach-O, x86-64): no objdump needed
|
|
36
|
+
wuica *.s -arch SKL,ZEN3 # several files in one run: one table (-files LIST for long lists)
|
|
37
|
+
objdump -d dot.o | wuica # objdump output: the loop's real alignment from its address
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
- **Syntax.** Intel (noprefix) or AT&T is detected from the text (`%rdx`, `$8`, `(%rdi,%rcx,4)` are AT&T);
|
|
41
|
+
stderr says which (`analyzed: loop .LBB0_9 (lines 28-47, in dot), AT&T syntax (detected)`). `-att` or `-intel`
|
|
42
|
+
force one.
|
|
43
|
+
- **Per iteration.** `tp` is cycles per iteration of the loop as the compiler wrote it. Compilers unroll and vectorize
|
|
44
|
+
(×8, ×16, ×32 elements per iteration), so compare per element: `-per N` prints `Per element: … cycles` (JSON
|
|
45
|
+
`perElement`; under 0.1 with 3 significant digits, `0.0625`); without it, stderr shows the loop's step when it can,
|
|
46
|
+
in the register's units: `rcx += 8 per iteration (index; ×4 bytes in [rdi+rcx*4])` is 8 elements of 4 bytes,
|
|
47
|
+
`r13 += 64 per iteration (bytes; the base of [r13+0x20])` is 64 bytes (16 floats: `-per 16`), `(register step)` a
|
|
48
|
+
counter no address uses.
|
|
49
|
+
- **Which loop.** A whole function or file is analyzed at one loop: the deepest one (clang's
|
|
50
|
+
`# =>This Inner Loop Header` notes count), among equals the first in the code. That can be a remainder loop: clang
|
|
51
|
+
often emits it before the main loop, gcc after it. Stderr says what was picked and how many others there are;
|
|
52
|
+
`-loops` lists them (index, label, function, lines, instructions, depth, auto), `-loop N` (0-based) or
|
|
53
|
+
`-loop LABEL` picks one, `-func NAME` keeps one function's loops, `-loop whole` analyzes the whole text. A label
|
|
54
|
+
that names loops in several functions (`1:` … `jnz 1b`) is an error that lists them; `-func` or the index picks one.
|
|
55
|
+
- **Branches inside the loop.** uiCA runs the analyzed code straight through: in a loop with an if/else (or two back
|
|
56
|
+
edges, as clang's remainder loops often have), both sides of the branch are simulated, one after the other, while a
|
|
57
|
+
real iteration takes one. A `Not modelled: both paths: both sides of the branch at line N …` line (table note
|
|
58
|
+
`both paths`; JSON caveat `paths`) says so. To analyze one side, put `# wuica-begin` and `# wuica-end` around it.
|
|
59
|
+
- **Inputs**: a file (assembly, objdump output, or an object file), `-` or nothing for stdin, a hex argument, `-hex` or
|
|
60
|
+
`-raw FILE` (bare machine code).
|
|
61
|
+
- **Object files.** An ELF or Mach-O x86-64 object, executable or shared object is read directly: its code as
|
|
62
|
+
`llvm-objdump -d` prints it (decoded by the analyzer), so `wuica dot.o` and `objdump -d dot.o | wuica` pick the same
|
|
63
|
+
loop and give the same numbers. `-func NAME` takes the symbol, without Mach-O's `_`, or a unique part of it; `-funcs`
|
|
64
|
+
lists the functions; `-loops` gives the loops' addresses; `-ffunction-sections` objects work. An arm64 object (what a
|
|
65
|
+
Mac compiles by default) says so and how to compile for x86-64 (`clang -arch x86_64 -c`, or
|
|
66
|
+
`--target=x86_64-linux-gnu`); COFF is not supported yet (`llvm-objdump -d f.obj | wuica`).
|
|
67
|
+
- **Several inputs** (`wuica a.s b.s c.o`, a glob, or `-files LIST` with one name per line, `-files -` from stdin):
|
|
68
|
+
one process for all of them, the analyses spread over the threads. One CPU: a row per file (file, loop, TP,
|
|
69
|
+
bottlenecks, notes); several: a row per file and CPU (grouped by file, a CPU column: any number of CPUs fits in 80
|
|
70
|
+
columns). `-TPonly`: `file<TAB>[CPU<TAB>]cycles` lines; `-report` adds uiCA's report of each file, `-whatif` the
|
|
71
|
+
what-if tables, after a `==> FILE <==` line. A file that fails does not stop the others: its row says why, and the
|
|
72
|
+
exit status is the largest of the files' statuses. One input prints exactly what it printed before.
|
|
73
|
+
- **Tables.** `-arch A,B,C` prints one row per CPU; `-` means unknown (uiCA names no single bottleneck; the notes
|
|
74
|
+
give the nearest limit), `5.00*` that the CPU could not decode some instructions (they are left out), and the notes
|
|
75
|
+
column the caveats (what the model does not simulate, such as store forwarding through an indexed address).
|
|
76
|
+
- **After the report** come what uiCA's text leaves out: the nearest limit when the bottleneck is unknown, the next
|
|
77
|
+
limit, and `Not modelled:` lines.
|
|
78
|
+
- **Exit status**: 0 ok, 1 bad request or usage, 2 assembler error, 3 the analysis failed; with several CPUs, the
|
|
79
|
+
largest of their codes, which is also the JSON's `code`. A reader that closes the pipe (`| head`) does not change it.
|
|
80
|
+
- **What if** (`-whatif`): a table per CPU, in cycles per original iteration, or per element with `-per N`. With
|
|
81
|
+
`-TPonly`, one `variant cycles` line per variant after the throughput (`acc2 16.00`; with `-per`, `acc2 16.00
|
|
82
|
+
2.00`; with several CPUs, each line starts with the CPU). Estimates (`>=` in the table) are printed as plain numbers.
|
|
83
|
+
- **JSON** (`-json`): one CPU gives the analyze response (`tp`, `bottlenecks`, `limits`, `rows`, `criticalPath`,
|
|
84
|
+
`insights`, `loop`, `syntax`, and `perElement` / `whatIf` when asked); several give `{code, hex, loop, stderr,
|
|
85
|
+
results: [{arch, tp, bottlenecks, limits, decodeErrors, perElement?, caveats?}]}`. The shapes are the same for one
|
|
86
|
+
CPU and several: `whatIf` is keyed by CPU (`{SKL: {tp, variants: [{id, tp, …, perElement?}], perElement?}}`), and a
|
|
87
|
+
caveat is `{id, text, title, instructions}` (in `insights.caveats` with one CPU, `results[].caveats` with several).
|
|
88
|
+
Types: `CliAnalyzeJson`, `CliCompareJson`, `CliWhatIf` in index.d.ts. Several inputs give `{code, files: [{file,
|
|
89
|
+
...}]}`: each entry is what a single run prints for that file, with its name (`CliBatchJson`). `--version -json` gives `{wuica, uiCA:
|
|
90
|
+
{repository, commit, branch}, node}`: the uiCA commit whose data and model the package has.
|
|
91
|
+
- **Syntax mistakes.** When the assembler fails, a `hint:` line names a line with the other syntax's operands (mixed
|
|
92
|
+
AT&T and Intel lines, a `.intel_syntax` directive over AT&T code, `mov rdx, $8` in Intel code) and the flag to try.
|
|
93
|
+
- No colours and no links, on a terminal or not.
|
|
94
|
+
|
|
95
|
+
## What the numbers mean
|
|
96
|
+
|
|
97
|
+
`tp` is the predicted steady-state throughput in **core cycles per iteration** of the block (lower is faster). How the
|
|
98
|
+
block is simulated depends on how it ends:
|
|
99
|
+
|
|
100
|
+
- A block that ends with a branch is simulated as a loop body (`mode: "loop"`).
|
|
101
|
+
- Any other block is simulated as if it were unrolled, i.e. repeated back to back (`mode: "unroll"`).
|
|
102
|
+
|
|
103
|
+
The model assumes that all data is in the L1 cache, that no branches are mispredicted, and that nothing else is running
|
|
104
|
+
on the core. `bottlenecks` names what limits the throughput, such as Dependencies (a loop-carried chain), Ports, Issue,
|
|
105
|
+
Decoder or DSB. `limits` gives the throughput each component alone would allow. `text` is uiCA's complete report.
|
|
106
|
+
|
|
107
|
+
## Library
|
|
108
|
+
|
|
109
|
+
```js
|
|
110
|
+
import { createWuica } from 'wuica-cli';
|
|
111
|
+
|
|
112
|
+
const w = await createWuica();
|
|
113
|
+
const r = await w.analyze('SKL', { source: 'loop:\n add rax, [rsi]\n add rsi, 8\n dec rcx\n jnz loop\n' });
|
|
114
|
+
if (r.code === 0) {
|
|
115
|
+
console.log(r.tp, r.mode, r.bottlenecks); // cycles per iteration, "loop", [...]
|
|
116
|
+
console.log(r.text); // uiCA's report
|
|
117
|
+
console.log(r.hex); // the assembled bytes
|
|
118
|
+
} else {
|
|
119
|
+
console.error(r.error, r.stderr); // e.g. assembler diagnostics with line/column
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
await w.analyze('ZEN3', { hex: '4801d84801c349ffcf75f5', options: { noMacroFusion: true } });
|
|
123
|
+
await w.analyze({ arch: 'ADL-P', source: 'addq %rbx, %rax', syntax: 'att' }); // single-object form
|
|
124
|
+
await w.compare({ source: 'imul rax, rbx' }); // every microarchitecture
|
|
125
|
+
w.archs(); // [{id, name, year, prototype, table, xedChip}, ...]
|
|
126
|
+
await w.assemble('vaddps zmm0, zmm1, zmm2'); // {code: 0, hex, length, bytes, stderr}
|
|
127
|
+
w.summarize(r); // compact form (the MCP analyze result)
|
|
128
|
+
w.insights(r); // the diagnosis alone (REST's insights)
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
Methods never throw for bad input: they resolve to a failure `{code, error, stderr}` (see the contract below).
|
|
132
|
+
`createWuica({ dataDir })` reads the tables from another directory (`uarch.json` and `arch/<NAME>.json` or the binary
|
|
133
|
+
`arch/<NAME>.bin`, plain or `.br`). `w.disassemble(bytes)` turns an object file into the text `analyze` reads. TypeScript declarations are included (`index.d.ts`).
|
|
134
|
+
|
|
135
|
+
`compare`, `analyzeMany(arch, requests)` and `compareMany(requests, {archs})` analyze on worker threads when the work
|
|
136
|
+
is worth it: by default the number of threads comes from the work (the tables to load, the analyses and their
|
|
137
|
+
instructions): none when it would take less than about 0.3 s on one thread (a thread's start, its table and its first,
|
|
138
|
+
not yet optimized analysis cost more than they save; `-arch all` on a small block stays on one thread), else one per
|
|
139
|
+
0.15 s of work, from 2 to 8, at most the cores but one. `createWuica({ threads: N })` or the environment variable
|
|
140
|
+
`WUICA_THREADS=N` uses up to N threads (one per job at most); 1 runs everything on the calling thread. The response is
|
|
141
|
+
the same either way. The threads share one compiled module and take jobs from one queue; each loads the tables of the
|
|
142
|
+
jobs it takes and keeps them for the next call; idle threads do not keep the process alive and stop after 30 s
|
|
143
|
+
(`w.close()` stops them at once). A thread's WebAssembly memory has a lower limit (a quarter
|
|
144
|
+
of the RAM shared by the threads, 256 MB to 1 GB each); an analysis that exceeds it is done again on the calling thread.
|
|
145
|
+
|
|
146
|
+
Inputs on which the original uiCA fails can make the WebAssembly module trap. In that case the call resolves to
|
|
147
|
+
`{code: 3, error, trapped: true}`. The module is then re-instantiated and its tables are reloaded, so the next call works.
|
|
148
|
+
|
|
149
|
+
## Command line
|
|
150
|
+
|
|
151
|
+
```
|
|
152
|
+
wuica loop.s # assembly file (syntax detected), uiCA's report for SKL
|
|
153
|
+
wuica loop.s -arch ICL -TPonly # only the throughput
|
|
154
|
+
cat loop.s | wuica -arch ZEN3 # stdin (or "-")
|
|
155
|
+
wuica -att loop_att.s # AT&T syntax, forced (-intel forces Intel)
|
|
156
|
+
wuica 4801d84801c349ffcf75f5 # a hex argument (as in the Rust CLI)
|
|
157
|
+
wuica -hex code.txt # hex from a file or stdin ("48 01 d8", "0x48,0x01" are fine)
|
|
158
|
+
wuica -raw code.bin # raw machine code
|
|
159
|
+
wuica loop.s -arch all # throughput table for every microarchitecture (in parallel)
|
|
160
|
+
wuica loop.s -arch SKL,ICL,ZEN3 # throughput table for these
|
|
161
|
+
wuica -list # the microarchitectures
|
|
162
|
+
wuica loop.s -json # the JSON result (the contract's analyze response)
|
|
163
|
+
wuica psum.s -loop whole # the whole text, not the loop found in it (-loop auto, the default, or -loop N)
|
|
164
|
+
wuica psum.s -loops # list the loops; -loop .LBB0_12 or -func psum to choose
|
|
165
|
+
wuica psum.s -whatif -per 8 # what-if variants; cycles per element (8 elements per iteration)
|
|
166
|
+
wuica dot.o -func dot # an object file (ELF or Mach-O x86-64); -funcs lists its functions
|
|
167
|
+
wuica a.s b.s c.o -arch SKL,ZEN3 # several inputs: one table, a row per file and CPU
|
|
168
|
+
wuica -files list.txt -TPonly # the names from a file (- for stdin): file<TAB>cycles lines
|
|
169
|
+
wuica *.s -json # {code, files: [{file, ...}]}, each entry as a single run's JSON
|
|
170
|
+
wuica -examples # the built-in examples (the web page's set)
|
|
171
|
+
wuica -example dot1 -whatif # one of them, as if it were the input file (every option applies)
|
|
172
|
+
wuica -example dot1 -show > dot.s # its assembly, to save and edit
|
|
173
|
+
wuica --version
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
The simulation options are uiCA's: `-alignmentOffset N`, `-initPolicy diff|same|stack`, `-simpleFrontEnd`,
|
|
177
|
+
`-noMicroFusion`, `-noMacroFusion`, `-minIterations N`, `-minCycles N`, and `-trace` (with `-json`). Every flag also
|
|
178
|
+
takes `--flag` and `--flag=value`, in any case (`--tponly`, `--arch=zen3`). With several microarchitectures or files,
|
|
179
|
+
the threads are chosen by the amount of work (see Library); `-threads N` uses at most N threads (`-threads 1`: one
|
|
180
|
+
after another).
|
|
181
|
+
Diagnostics go to stderr. The exit status is the result code: 0 ok, 1 bad request or usage, 2 assembler error, 3 analysis failed.
|
|
182
|
+
`wuica -h` lists everything.
|
|
183
|
+
|
|
184
|
+
## MCP server
|
|
185
|
+
|
|
186
|
+
`wuica mcp` (or the `wuica-mcp` binary) is a Model Context Protocol server on stdio, written without an MCP library:
|
|
187
|
+
newline-delimited JSON-RPC 2.0 with the `initialize` handshake of the protocol revisions 2025-11-25, 2025-06-18,
|
|
188
|
+
2025-03-26 and 2024-11-05 (the client's revision if it is one of these, else 2025-11-25; batches only under 2025-03-26),
|
|
189
|
+
`ping`, `tools/list` and `tools/call`. Arguments are checked against the tools' JSON Schemas; a mismatch is a tool error
|
|
190
|
+
(`isError`) that says what is wrong, an unknown tool a JSON-RPC error. The server ends with its stdin, and writes only
|
|
191
|
+
protocol messages to stdout. `wuica mcp --help` prints the usage. The tool table itself (names, descriptions, JSON
|
|
192
|
+
Schemas, handlers) is exported as `mcpTools(w)` from `wuica-cli/mcp`, with `callTool` and `validate`; the remote server
|
|
193
|
+
(`server/`) serves the same table over HTTP. It has five tools:
|
|
194
|
+
|
|
195
|
+
| Tool | What it does |
|
|
196
|
+
|---|---|
|
|
197
|
+
| `analyze` | one block on one microarchitecture: `tp`, bottlenecks, limits, a compact per-instruction table (ports, uop sources, fusion notes) and uiCA's text report (`format`: `json`, `text`, `both`) |
|
|
198
|
+
| `what_if` | one block re-analyzed with one change each (the web page's "try" row): `unroll2`/`unroll4`/`unroll8` (per original iteration), `acc2`/`acc3`/`acc4`/`acc8` (N accumulators: unrolled ×N with the loop-carried register renamed in each copy; `renamed` lists the registers, `accumulators.best` is the best N, 1 = as it is), `simpleFrontEnd`, `noMacroFusion`, `noMicroFusion`, and `nochain` (an estimate without the loop-carried chain); per variant `tp`, `delta`, `speedup` |
|
|
199
|
+
| `compare_archs` | one block on several or all microarchitectures: `tp` and bottlenecks per microarchitecture |
|
|
200
|
+
| `list_archs` | ids, names, years, prototype flags |
|
|
201
|
+
| `assemble` | assembly → hex bytes, or diagnostics with line/column |
|
|
202
|
+
|
|
203
|
+
### Set it up in your agent
|
|
204
|
+
|
|
205
|
+
The command is `npx -y wuica-cli mcp` (stdio) in every client. **Claude Code**, **OpenAI Codex CLI**, **opencode**
|
|
206
|
+
and **Amp** add it with one command:
|
|
207
|
+
|
|
208
|
+
```sh
|
|
209
|
+
claude mcp add wuica -- npx -y wuica-cli mcp
|
|
210
|
+
codex mcp add wuica -- npx -y wuica-cli mcp
|
|
211
|
+
opencode mcp add wuica -- npx -y wuica-cli mcp
|
|
212
|
+
amp mcp add wuica -- npx -y wuica-cli mcp
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
Most other clients read a JSON file with an `mcpServers` object: **Claude Desktop** (Settings → Developer → Edit Config:
|
|
216
|
+
`claude_desktop_config.json`), **Cursor** (`~/.cursor/mcp.json`, or `.cursor/mcp.json` in a project), **Gemini CLI**
|
|
217
|
+
(`~/.gemini/settings.json`, or `.gemini/settings.json` in a project), **Cline** (MCP Servers → Configure → Configure MCP
|
|
218
|
+
Servers: `cline_mcp_settings.json`) and **Continue** (a file in `.continue/mcpServers/`):
|
|
219
|
+
|
|
220
|
+
```json
|
|
221
|
+
{
|
|
222
|
+
"mcpServers": {
|
|
223
|
+
"wuica": { "command": "npx", "args": ["-y", "wuica-cli", "mcp"] }
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
Where the format differs:
|
|
229
|
+
|
|
230
|
+
- **Codex** (`~/.codex/config.toml`, or `.codex/config.toml` in a trusted project; what `codex mcp add` writes):
|
|
231
|
+
|
|
232
|
+
```toml
|
|
233
|
+
[mcp_servers.wuica]
|
|
234
|
+
command = "npx"
|
|
235
|
+
args = ["-y", "wuica-cli", "mcp"]
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
- **opencode** 2.x (`opencode.jsonc` in the project, or the global configuration):
|
|
239
|
+
|
|
240
|
+
```json
|
|
241
|
+
{
|
|
242
|
+
"$schema": "https://opencode.ai/config.json",
|
|
243
|
+
"mcp": { "servers": { "wuica": { "type": "local", "command": ["npx", "-y", "wuica-cli", "mcp"] } } }
|
|
244
|
+
}
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
- **VS Code** with GitHub Copilot (`~/.copilot/mcp-config.json`; `.mcp.json` at the workspace root is behind an
|
|
248
|
+
experimental setting):
|
|
249
|
+
|
|
250
|
+
```json
|
|
251
|
+
{
|
|
252
|
+
"mcpServers": {
|
|
253
|
+
"wuica": { "type": "stdio", "command": "npx", "args": ["-y", "wuica-cli", "mcp"], "tools": ["*"] }
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
- **Zed** (`settings.json`):
|
|
259
|
+
|
|
260
|
+
```json
|
|
261
|
+
{
|
|
262
|
+
"context_servers": {
|
|
263
|
+
"wuica": { "command": "npx", "args": ["-y", "wuica-cli", "mcp"], "env": {} }
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
```
|
|
267
|
+
|
|
268
|
+
- **Amp** (`~/.config/amp/settings.json`, or `.amp/settings.json` in a project):
|
|
269
|
+
|
|
270
|
+
```json
|
|
271
|
+
{
|
|
272
|
+
"amp.mcpServers": {
|
|
273
|
+
"wuica": { "command": "npx", "args": ["-y", "wuica-cli", "mcp"] }
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
```
|
|
277
|
+
|
|
278
|
+
- **goose** (`~/.config/goose/config.yaml`):
|
|
279
|
+
|
|
280
|
+
```yaml
|
|
281
|
+
extensions:
|
|
282
|
+
wuica:
|
|
283
|
+
type: stdio
|
|
284
|
+
name: wuica
|
|
285
|
+
enabled: true
|
|
286
|
+
cmd: npx
|
|
287
|
+
args: ["-y", "wuica-cli", "mcp"]
|
|
288
|
+
timeout: 300
|
|
289
|
+
```
|
|
290
|
+
|
|
291
|
+
The hosted server (`server/`, the REST API's host) speaks MCP over Streamable HTTP at
|
|
292
|
+
`https://api.wuica.jacen.li/mcp`, with nothing to install: `claude mcp add --transport http wuica
|
|
293
|
+
https://api.wuica.jacen.li/mcp`. Clients with a JSON or TOML file give the URL instead of the command: `"url"` in
|
|
294
|
+
Cursor and Zed, `"type": "http", "url"` in VS Code, `"httpUrl"` in Gemini CLI, `"type": "remote", "url"` in opencode,
|
|
295
|
+
`url = "…"` in Codex.
|
|
296
|
+
|
|
297
|
+
To develop wuica, point a client at a checkout instead (after `packages/wuica/build.sh` and `npm install`):
|
|
298
|
+
`claude mcp add wuica -- node /absolute/path/to/packages/wuica/bin/wuica.js mcp`.
|
|
299
|
+
|
|
300
|
+
Example prompt: *"Use wuica to compare this loop on Skylake, Ice Lake and Zen 3 and explain the bottleneck."*
|
|
301
|
+
|
|
302
|
+
**Without MCP.** An agent that can run shell commands can use the CLI directly: `npx -y wuica-cli FILE -arch SKL,ZEN3
|
|
303
|
+
-json` (one JSON object; the shapes are under "JSON" in [The CLI in five minutes](#the-cli-in-five-minutes)), `-whatif`
|
|
304
|
+
for the variants, `-loops` and `-loop N` to choose the loop, and `-example saxpy` to try it without a file.
|
|
305
|
+
|
|
306
|
+
## API contract
|
|
307
|
+
|
|
308
|
+
The library, the MCP tools and the REST API (https://api.wuica.jacen.li, server/) share these shapes. They follow
|
|
309
|
+
[Compiler Explorer's API](https://github.com/compiler-explorer/compiler-explorer/blob/main/docs/API.md): a list
|
|
310
|
+
endpoint like `/api/compilers`, a call keyed by id like `/api/compiler/<id>/compile`, results as JSON or plain
|
|
311
|
+
text, and errors with structured stderr.
|
|
312
|
+
|
|
313
|
+
| REST | Library | MCP tool |
|
|
314
|
+
|---|---|---|
|
|
315
|
+
| `GET /api/archs[?fields=id,name]` | `w.archs(fields?)` | `list_archs {fields?}` |
|
|
316
|
+
| `POST /api/analyze/<arch>` | `w.analyze(arch, request)` | `analyze {arch, ...request, format?}` |
|
|
317
|
+
| `POST /api/compare` | `w.compare(request)` | `compare_archs {...request}` |
|
|
318
|
+
| — | `whatIf((a, r) => w.analyze(a, r), arch, request, variants?, {assemble: (t) => w.assemble(t)})` | `what_if {arch, ...request, variants?}` |
|
|
319
|
+
| `POST /api/assemble` | `w.assemble(source, syntax)` | `assemble {source, syntax?}` |
|
|
320
|
+
|
|
321
|
+
### Microarchitectures: `GET /api/archs`
|
|
322
|
+
|
|
323
|
+
```json
|
|
324
|
+
[{"id": "SKL", "name": "Skylake", "year": 2015, "prototype": false, "table": "SKL", "xedChip": "SKYLAKE"}, ...]
|
|
325
|
+
```
|
|
326
|
+
|
|
327
|
+
The list is in order of release. `prototype` is true for ZEN3, ADL-P and ICX. `fields` (comma-separated, or an
|
|
328
|
+
array in the library) selects fields; the default is all fields (`list_archs` defaults to `id,name,year,prototype`).
|
|
329
|
+
uiCA's ablation variants (ids containing `_`) are not listed, but `analyze` accepts them. Ids are matched exactly,
|
|
330
|
+
or failing that case-insensitively with `-` optional (`adlp` → `ADL-P`). The default arch is `SKL`.
|
|
331
|
+
|
|
332
|
+
### Analysis: `POST /api/analyze/<arch>`
|
|
333
|
+
|
|
334
|
+
Request:
|
|
335
|
+
|
|
336
|
+
```json
|
|
337
|
+
{
|
|
338
|
+
"source": "loop: add rax, rbx\n dec rcx\n jnz loop",
|
|
339
|
+
"hex": "4801d8...",
|
|
340
|
+
"syntax": "intel",
|
|
341
|
+
"options": {
|
|
342
|
+
"alignmentOffset": 0, "initPolicy": "diff", "simpleFrontEnd": false, "noMicroFusion": false,
|
|
343
|
+
"noMacroFusion": false, "minIterations": 10, "minCycles": 500, "includeTrace": false, "details": false
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
```
|
|
347
|
+
|
|
348
|
+
- Give exactly one of `source` (assembly; the library also accepts `asm`) and `hex` (machine code; spaces, commas and
|
|
349
|
+
`0x` are allowed).
|
|
350
|
+
- `source` is read as the web page reads pasted assembly. `loop` (optional) says what of it is analyzed:
|
|
351
|
+
- `"auto"` (the default): a whole function (`gcc -S`, `clang -S`, `objdump -d` lines with addresses, with or
|
|
352
|
+
without the bytes, Intel or AT&T) is analyzed at its deepest loop (clang's `Inner Loop Header` notes count;
|
|
353
|
+
among equals the first in the code, which may be a remainder loop: clang often emits it first). A span that holds a `ret` or another function's label is not a loop (a tail
|
|
354
|
+
call jumping back). A compiler's function without a loop (it has a function label, directives or a
|
|
355
|
+
prologue/epilogue, and ends in `ret`) is analyzed at its body, without prologue, epilogue and `ret`; a bare snippet
|
|
356
|
+
such as `add rax, 1` / `ret` is analyzed as typed. A text that is one loop already, or has region markers, is
|
|
357
|
+
analyzed as it is.
|
|
358
|
+
- `"whole"`: the whole text, never a pick; a number: that loop (0-based: deepest first, then in code order); any
|
|
359
|
+
other string: the loop with that label (`".LBB0_12"`, `"0x10"`). `func` (optional) keeps one function's loops.
|
|
360
|
+
- `syntax` is `"auto"` (the default: detected from the text), `"intel"` or `"att"`; the response's `syntax` says
|
|
361
|
+
which was used.
|
|
362
|
+
|
|
363
|
+
objdump text is recognised by a header line (`0000… <f>:`), a byte column or `<sym+off>` branch targets; without
|
|
364
|
+
those, only when every line is address-prefixed, there are at least three, and the steps between the addresses fit
|
|
365
|
+
the instructions (so `a: add rax, 1` / `b: dec rcx` / `jnz a` stays assembly). In objdump text a branch target is
|
|
366
|
+
always an address (`jne 1b <psum+0x1b>`); GNU numeric labels (`1:` … `jnz 1b`) keep working in assembly. Code in
|
|
367
|
+
`.text.*` sections (gcc's `main` in `.text.startup`, `-ffunction-sections`) is analyzed as `.text`. CRLF and lone CR
|
|
368
|
+
line ends are line feeds (REST, MCP, the library, the CLI).
|
|
369
|
+
|
|
370
|
+
Conditional branches to a symbol the text does not define (a loop's exits, `jae .Lout`, `.L` or not) are taken as
|
|
371
|
+
not taken: the symbol is defined right after the analyzed code, so they assemble as short jumps; a note says so in
|
|
372
|
+
`stderr`. An undefined target of a `jmp` gives a warning (it is encoded as a 32-bit jump to an external symbol).
|
|
373
|
+
objdump lines with their bytes are assembled as those bytes. With addresses, the alignment offset is the analyzed
|
|
374
|
+
code's address modulo 64, unless `options.alignmentOffset` is given. When something other than the whole text was
|
|
375
|
+
analyzed, the response has `loop`: `{index, count, name, line, endLine, lines?, address?, alignmentOffset?}` (`name`:
|
|
376
|
+
`"loop .L3"`, `"loop 0x10"`, `"body"`; `lines`: the source line of each instruction).
|
|
377
|
+
Region markers (`# LLVM-MCA-BEGIN` … `# LLVM-MCA-END`, `# wuica-begin` … `# wuica-end`, IACA's byte markers) select
|
|
378
|
+
the first marked region. A `;` that starts a line is a comment. After a statement, LLVM reads `;` as a separator. If
|
|
379
|
+
what follows assembles, it is assembled, with a note in `stderr` naming it (`';' separates statements: 'call helper'
|
|
380
|
+
was assembled (use # for a comment)`), unless the `;` follows the statement without a space, as GNU as code chains
|
|
381
|
+
statements (`dec rcx; jnz 1b`). If it does not assemble, for any reason, it is a comment: nothing after a `;` makes a
|
|
382
|
+
valid line an error; a note says so when it starts with a mnemonic (`add the next element`), and nothing when it does
|
|
383
|
+
not (`sum += a[i]`). A line the assembler rejects inside the analyzed code is an error with its line number (objdump
|
|
384
|
+
lines outside the picked loop that the assembler rejects, such as padding, are left out).
|
|
385
|
+
- `syntax` is `auto` (the default), `intel` (noprefix) or `att`. The source may also switch syntax itself with
|
|
386
|
+
`.intel_syntax noprefix` / `.att_syntax`.
|
|
387
|
+
- Every field of `options` is optional; the defaults are shown. Unknown options and unknown request fields are an
|
|
388
|
+
error (code 1), not ignored. The library also accepts the options at the top level of the request
|
|
389
|
+
(`{hex, arch, minIterations}`); `options` takes precedence. The MCP tools accept only the nested form.
|
|
390
|
+
- The source must be 64-bit code: `.code16`, `.code16gcc` and `.code32` are an error (code 1), since the analyzer
|
|
391
|
+
only models 64-bit mode. `assemble` alone accepts them.
|
|
392
|
+
- `loop` exists in the library, REST (`/api/analyze`, `/api/compare`), the MCP tools `analyze`, `what_if` and
|
|
393
|
+
`compare_archs`, and the package's CLI (`wuica -loop auto|whole|N`). The native CLI (`crates/wuica-cli`) reads
|
|
394
|
+
machine code only (hex or `-raw`), so it has no `-loop`.
|
|
395
|
+
|
|
396
|
+
### Option ranges per interface
|
|
397
|
+
|
|
398
|
+
All interfaces run the same analyzer, but they accept different ranges for the numeric options. A value outside the
|
|
399
|
+
range is refused (code 1, REST 400; the MCP tools' schema rejects it as invalid arguments), except in the web page,
|
|
400
|
+
which clamps it into its range.
|
|
401
|
+
|
|
402
|
+
| Interface | `alignmentOffset` | `minIterations` | `minCycles` | Other limits |
|
|
403
|
+
|---|---|---|---|---|
|
|
404
|
+
| library, `wuica` CLI, native CLI (`crates/wuica-cli`) | any integer (negative values and values above 63 are simulated as given) | any integer | any integer | none; very large values run out of memory (library: code 3) |
|
|
405
|
+
| MCP tools of `wuica mcp` (stdio) | 0–63 | 1–100000 | 1–1000000 | |
|
|
406
|
+
| REST API (`server/`) | any integer | at most 1000 | at most 20000 | `source` at most 64 KB, `hex` at most 65536 characters, at most 10,000 instructions |
|
|
407
|
+
| remote MCP (`server/`, `/mcp`) | 0–63 | 1–1000 | 1–20000 | as REST |
|
|
408
|
+
| web page | 0–63 | 1–10000 | 1–100000 | at most 1 MiB of machine code (assembled or as hex) |
|
|
409
|
+
|
|
410
|
+
Microarchitecture ids are accepted the same way everywhere: exactly, or case-insensitively with `-` optional (`adlp`,
|
|
411
|
+
`adl-p` → `ADL-P`). Hex may contain spaces, commas and `0x` / `\x` prefixes everywhere.
|
|
412
|
+
|
|
413
|
+
Response (JSON), on success:
|
|
414
|
+
|
|
415
|
+
```json
|
|
416
|
+
{
|
|
417
|
+
"code": 0,
|
|
418
|
+
"arch": "SKL", "tp": 1.25, "mode": "loop", "decodeErrors": 0,
|
|
419
|
+
"bottlenecks": ["Dependencies"],
|
|
420
|
+
"limits": [{"name": "Issue", "tp": 0.75}, {"name": "Dependencies", "tp": 1.0}],
|
|
421
|
+
"columns": ["MITE", "MS", "DSB", "LSD", "Issued", "Exec.", "Port 0", "..."],
|
|
422
|
+
"rows": [{"kind": "instr", "label": "add rax, rbx", "opcode": "4801D8", "instrStr": "ADD (R64, R64)",
|
|
423
|
+
"url": "https://www.uops.info/html-instr/ADD_01_R64_R64.html", "notes": "", "values": [0, 0, 1.0, "..."]}],
|
|
424
|
+
"text": "Throughput (in cycles per iteration): 1.25\n...",
|
|
425
|
+
"trace": null,
|
|
426
|
+
"hex": "4801d8...",
|
|
427
|
+
"stderr": [],
|
|
428
|
+
"insights": {"utilization": {"Issue": 0.6, "Dependencies": 0.8, "Port 0": 0.25}, "binding": ["Dependencies"], "...": "..."}
|
|
429
|
+
}
|
|
430
|
+
```
|
|
431
|
+
|
|
432
|
+
The fields from `arch` to `trace` are the analysis response of the WebAssembly module (`docs/WASM-API.md` in the wuica
|
|
433
|
+
repository: `rows[].values[i]` belongs to `columns[i]`, and `notes` is `M` macro-fused, `J` JCC erratum or `X`
|
|
434
|
+
unsupported). `hex` is present when `source` was given and holds the assembled bytes. `stderr` holds the assembler's
|
|
435
|
+
warnings, the notes on exits taken as not taken, and the warning "N position(s) could not be decoded". `insights` (REST only; the library's `analyze()` result
|
|
436
|
+
does not have it, `w.insights(r)` computes it) is the diagnosis described under the compact form below, with `portSet`
|
|
437
|
+
and `issueSlots` when `options.details` is true.
|
|
438
|
+
|
|
439
|
+
**Plain text** (CE's `Accept: text/plain`): the response is `text` (uiCA's report), or the `stderr` lines on failure.
|
|
440
|
+
In the library this is `r.text`; the MCP tool takes `format: "text"`.
|
|
441
|
+
|
|
442
|
+
**Compact form** (the MCP `analyze` JSON, `w.summarize(r)`): `{code, arch, name, year, prototype, tp, unit, mode,
|
|
443
|
+
bottlenecks, limits, decodeErrors, hex?, loop?, stderr, instructions, insights}`. Each entry of `instructions` is
|
|
444
|
+
`{instr, bytes, issued, executed, uopSource: {MITE|DSB|LSD|MS: n}, ports: {"Port 0": n, ...}, notes, uopsInfo}`
|
|
445
|
+
(zero values omitted, numbers rounded to 2 decimals). `insights` is a diagnosis derived from the analysis (as the web
|
|
446
|
+
page's "bound" view): `utilization` (each limit and port: cycles / tp), `binding` (the bottlenecks uiCA names: always
|
|
447
|
+
the same as `bottlenecks`, `[]` when it names none), `largest` (only when `binding` is `[]`: the largest limit, the
|
|
448
|
+
nearest bound, which alone does not reach tp; the web page shows "unknown · nearest Ports"), `next` (`{limit, tp,
|
|
449
|
+
maxSpeedup}`: the next limit, and the speedup at most if the binding one went away), `unexplained` (cycles no single
|
|
450
|
+
limit explains),
|
|
451
|
+
`chain` (the critical loop-carried chain: `{index, instr, operand, latency, carried}`) and `hot` (`{resource, ports?,
|
|
452
|
+
instructions: [{index, instr, share}]}`: the largest shares of the binding resource, or of the largest limit), and
|
|
453
|
+
`caveats` (only if any: `[{id, text, title, instructions}]`, known blind spots of the model that the block meets:
|
|
454
|
+
`rmw-index` a read-modify-write to an indexed address, whose store forwarding between iterations depends on the data;
|
|
455
|
+
`paths` a conditional branch inside the block (an if/else, a second back edge), both of whose sides are simulated one
|
|
456
|
+
after the other while a real iteration takes one (named by its source line); `exit` an exit before the loop's branch,
|
|
457
|
+
whose mispredict is not modelled; `split` loads at an offset that is not a
|
|
458
|
+
multiple of their width, which may cross a cache line: on the CPUs whose model charges line crossings (ZEN3, ADL-P,
|
|
459
|
+
ICX: `splitLoadCycles` in uarch.json) only the loads whose address the model cannot follow (an address register written
|
|
460
|
+
other than by adding an immediate); the web page shows them in one line under the throughput). With `options.details` (MCP:
|
|
461
|
+
`details: true`), each instruction also has `allowedPorts` (`1*p0156+1*p23`), `uops`, `fusedUops`, `latencies`
|
|
462
|
+
(`"RAX->RAX:1"`) and `frontEnd` (`length`, `offset`, `crosses`, `lcp`, `microcoded`, fusion), and `insights` has `portSet`
|
|
463
|
+
(the ports behind the Ports limit, `cycles` = uops / ports, and the instructions that load them) and `issueSlots` (per
|
|
464
|
+
iteration: issued, and lost to the front end, a full ROB or RS, or other).
|
|
465
|
+
|
|
466
|
+
### Failures
|
|
467
|
+
|
|
468
|
+
Every call can fail like a compiler run in Compiler Explorer, with a non-zero `code` and stderr lines:
|
|
469
|
+
|
|
470
|
+
```json
|
|
471
|
+
{
|
|
472
|
+
"code": 2,
|
|
473
|
+
"error": "assembly failed: line 2: invalid instruction mnemonic 'frobnicate'",
|
|
474
|
+
"stderr": [
|
|
475
|
+
{"text": "<input>:2:1: error: invalid instruction mnemonic 'frobnicate'",
|
|
476
|
+
"tag": {"line": 2, "column": 1, "severity": "error", "text": "invalid instruction mnemonic 'frobnicate'"}},
|
|
477
|
+
{"text": "frobnicate rax"},
|
|
478
|
+
{"text": "^~~~~~~~~~"}
|
|
479
|
+
]
|
|
480
|
+
}
|
|
481
|
+
```
|
|
482
|
+
|
|
483
|
+
| code | meaning | REST status |
|
|
484
|
+
|---|---|---|
|
|
485
|
+
| 0 | success | 200 |
|
|
486
|
+
| 1 | bad request: neither or both of source/hex, bad hex, unknown arch, unknown option, bad option value or syntax | 400 (unknown arch: 404) |
|
|
487
|
+
| 2 | assembler error (stderr as `llvm-mc` prints it; positioned lines carry `tag`) | 200, like a failed compile in CE |
|
|
488
|
+
| 3 | the analysis failed for this input (as the Python uiCA would); `trapped: true` if the module trapped | 200 |
|
|
489
|
+
|
|
490
|
+
### Compare: `POST /api/compare`
|
|
491
|
+
|
|
492
|
+
The request is the same as for analyze, plus an optional `archs` (ids; missing or empty: all listed ones; a repeated id counts once). The response:
|
|
493
|
+
|
|
494
|
+
```json
|
|
495
|
+
{
|
|
496
|
+
"code": 0, "hex": "...", "stderr": [],
|
|
497
|
+
"results": [
|
|
498
|
+
{"arch": "SKL", "name": "Skylake", "year": 2015, "prototype": false, "code": 0, "tp": 2.0, "mode": "loop",
|
|
499
|
+
"bottlenecks": ["Dependencies"], "decodeErrors": 0},
|
|
500
|
+
{"arch": "K8", "name": "K8", "year": null, "prototype": false, "code": 1, "error": "unknown microarchitecture: K8 ..."}
|
|
501
|
+
]
|
|
502
|
+
}
|
|
503
|
+
```
|
|
504
|
+
|
|
505
|
+
The top-level `code` is non-zero only if the request or the assembly fails. A failure on one microarchitecture is
|
|
506
|
+
reported in its row.
|
|
507
|
+
|
|
508
|
+
### Assemble: `POST /api/assemble`
|
|
509
|
+
|
|
510
|
+
Request: `{"source": "...", "syntax": "intel"}`. The whole text is assembled as it is (no loop finding, no region
|
|
511
|
+
markers; `;` comments as above). Response: `{"code": 0, "hex": "4801d8", "length": 3, "stderr": []}`;
|
|
512
|
+
the library also returns `bytes` (a `Uint8Array`). On failure: `{code: 2, error, stderr}` as above. The assembler is
|
|
513
|
+
LLVM 22.1.2's (the same bytes as `llvm-mc`). Only `.text` is returned. `.include`/`.incbin` always fail. GNU as's
|
|
514
|
+
`{load}`/`{store}` hints, which LLVM rejects, are removed at the start of a line.
|
|
515
|
+
|
|
516
|
+
## Building from the repository
|
|
517
|
+
|
|
518
|
+
```
|
|
519
|
+
packages/wuica/build.sh # copies and compresses the wasm modules and tables into dist/, copies the licenses
|
|
520
|
+
cd packages/wuica && npm install && npm test
|
|
521
|
+
npm pack # wuica-cli-<version>.tgz
|
|
522
|
+
```
|
|
523
|
+
|
|
524
|
+
`build.sh` uses `target/wasm32-unknown-unknown/release/wuica_wasm.wasm` (it runs `./build-wasm.sh` if the file is
|
|
525
|
+
missing), `assembler/dist/wuica_asm.wasm` and `data/`. The instruction tables are shipped in a binary form
|
|
526
|
+
(`dist/data/arch/<NAME>.bin.br`, written from `data/arch/*.json` by `tools/encode-tables.sh`; 6.4 MB instead of
|
|
527
|
+
14.6 MB, and loaded about 40% faster); `createWuica({ dataDir })` also reads JSON tables. `dist/manifest.json` records
|
|
528
|
+
the size and SHA-256 of each
|
|
529
|
+
uncompressed file.
|
|
530
|
+
|
|
531
|
+
## Licenses
|
|
532
|
+
|
|
533
|
+
- wuica is a derivative work of uiCA and, like uiCA, is licensed under the **GNU Affero General Public License v3.0
|
|
534
|
+
only** (`LICENSE`).
|
|
535
|
+
- The analyzer contains a subset of [Intel XED](https://github.com/intelxed/xed) (Apache License 2.0,
|
|
536
|
+
`licenses/LICENSE-XED.txt`).
|
|
537
|
+
- The assembler module is a modified build of [LLVM](https://llvm.org) 22.1.2 (Apache License 2.0 with LLVM
|
|
538
|
+
Exceptions, `licenses/LICENSE-LLVM.txt`). The changes are in `assembler/llvm-22.1.2-wasi.patch` in the wuica
|
|
539
|
+
repository. It also contains wasi-libc and libc++ from wasi-sdk (Apache-2.0 WITH LLVM-exception, MIT and other
|
|
540
|
+
permissive licenses).
|
|
541
|
+
- The instruction data comes from [uops.info](https://www.uops.info) by Andreas Abel and Jan Reineke.
|
|
542
|
+
- The package has no dependencies. Its tests use the [MCP TypeScript SDK](https://github.com/modelcontextprotocol/typescript-sdk)
|
|
543
|
+
(MIT) and [zod](https://zod.dev) (MIT) as development dependencies; the remote server (`server/`) uses them at run time.
|
|
544
|
+
|
|
545
|
+
uiCA is described in: Andreas Abel and Jan Reineke, *uiCA: Accurate Throughput Prediction of Basic Blocks on Recent
|
|
546
|
+
Intel Microarchitectures*, ICS 2022. The Intel models are uiCA's; the ZEN3, ADL-P and ICX models are prototypes of the
|
|
547
|
+
fork [jtl06/uiCA](https://github.com/jtl06/uiCA) and are not part of that work.
|
package/bin/wuica-mcp.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// The wuica MCP server on stdio (same as `wuica mcp`). --help, --version: print and exit.
|
|
3
|
+
const args = process.argv.slice(2);
|
|
4
|
+
if (args.some((a) => /^(?:-h|-help|--help)$/i.test(a))) {
|
|
5
|
+
const { MCP_USAGE } = await import('../lib/cli.js');
|
|
6
|
+
process.stdout.write(MCP_USAGE);
|
|
7
|
+
} else if (args.some((a) => /^(?:-v|-V|-version|--version)$/i.test(a))) {
|
|
8
|
+
const { VERSION } = await import('../lib/cli.js');
|
|
9
|
+
process.stdout.write(`wuica-mcp ${VERSION}\n`);
|
|
10
|
+
} else if (args.length) {
|
|
11
|
+
process.stderr.write(`wuica-mcp: unknown argument ${args[0]} (--help for usage)\n`);
|
|
12
|
+
process.exitCode = 1;
|
|
13
|
+
} else {
|
|
14
|
+
const { runServer } = await import('../lib/mcp.js');
|
|
15
|
+
await runServer();
|
|
16
|
+
}
|
package/bin/wuica.js
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// wuica [options] [FILE | - | HEX] or wuica mcp [--help | --version]
|
|
3
|
+
const args = process.argv.slice(2);
|
|
4
|
+
if (args[0] === 'mcp') {
|
|
5
|
+
const rest = args.slice(1);
|
|
6
|
+
if (rest.some((a) => /^(?:-h|-help|--help)$/i.test(a))) {
|
|
7
|
+
const { MCP_USAGE } = await import('../lib/cli.js');
|
|
8
|
+
process.stdout.write(MCP_USAGE);
|
|
9
|
+
} else if (rest.some((a) => /^(?:-v|-V|-version|--version)$/i.test(a))) {
|
|
10
|
+
const { VERSION } = await import('../lib/cli.js');
|
|
11
|
+
process.stdout.write(`wuica-mcp ${VERSION}\n`);
|
|
12
|
+
} else if (rest.length) {
|
|
13
|
+
process.stderr.write(`wuica mcp: unknown argument ${rest[0]} (--help for usage)\n`);
|
|
14
|
+
process.exitCode = 1;
|
|
15
|
+
} else {
|
|
16
|
+
const { runServer } = await import('../lib/mcp.js');
|
|
17
|
+
await runServer();
|
|
18
|
+
}
|
|
19
|
+
} else {
|
|
20
|
+
// a reader that closes the pipe early (wuica ... | head): the rest of the output is dropped quietly, and the exit
|
|
21
|
+
// status stays the result's code
|
|
22
|
+
for (const s of [process.stdout, process.stderr]) s.on('error', (e) => { if (e?.code !== 'EPIPE') throw e; });
|
|
23
|
+
const { main } = await import('../lib/cli.js');
|
|
24
|
+
process.exitCode = await main(args);
|
|
25
|
+
}
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|