wuica-cli 0.1.7 → 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.
Files changed (46) hide show
  1. package/README.md +140 -30
  2. package/dist/data/arch/ADL-P.bin.br +0 -0
  3. package/dist/data/arch/BDW.bin.br +0 -0
  4. package/dist/data/arch/CFL.bin.br +0 -0
  5. package/dist/data/arch/CLX.bin.br +0 -0
  6. package/dist/data/arch/HSW.bin.br +0 -0
  7. package/dist/data/arch/ICL.bin.br +0 -0
  8. package/dist/data/arch/ICX.bin.br +0 -0
  9. package/dist/data/arch/IVB.bin.br +0 -0
  10. package/dist/data/arch/KBL.bin.br +0 -0
  11. package/dist/data/arch/RKL.bin.br +0 -0
  12. package/dist/data/arch/SKL.bin.br +0 -0
  13. package/dist/data/arch/SKX.bin.br +0 -0
  14. package/dist/data/arch/SNB.bin.br +0 -0
  15. package/dist/data/arch/TGL.bin.br +0 -0
  16. package/dist/data/arch/ZEN3.bin.br +0 -0
  17. package/dist/manifest.json +140 -61
  18. package/dist/wuica_wasm.wasm.br +0 -0
  19. package/index.d.ts +41 -3
  20. package/lib/cli.js +280 -17
  21. package/lib/examples.js +26 -0
  22. package/lib/files.js +25 -3
  23. package/lib/index.js +131 -28
  24. package/lib/objfile.js +216 -0
  25. package/lib/thread-worker.js +8 -5
  26. package/lib/threads.js +32 -21
  27. package/lib/wasm.js +30 -5
  28. package/lib/web/caveats.js +8 -0
  29. package/lib/web/examples.js +99 -0
  30. package/lib/web/showcase.js +368 -0
  31. package/package.json +1 -1
  32. package/dist/data/arch/ADL-P.json.br +0 -0
  33. package/dist/data/arch/BDW.json.br +0 -0
  34. package/dist/data/arch/CFL.json.br +0 -0
  35. package/dist/data/arch/CLX.json.br +0 -0
  36. package/dist/data/arch/HSW.json.br +0 -0
  37. package/dist/data/arch/ICL.json.br +0 -0
  38. package/dist/data/arch/ICX.json.br +0 -0
  39. package/dist/data/arch/IVB.json.br +0 -0
  40. package/dist/data/arch/KBL.json.br +0 -0
  41. package/dist/data/arch/RKL.json.br +0 -0
  42. package/dist/data/arch/SKL.json.br +0 -0
  43. package/dist/data/arch/SKX.json.br +0 -0
  44. package/dist/data/arch/SNB.json.br +0 -0
  45. package/dist/data/arch/TGL.json.br +0 -0
  46. package/dist/data/arch/ZEN3.json.br +0 -0
package/README.md CHANGED
@@ -25,12 +25,15 @@ with `npx wuica-cli ...`. The examples below write `wuica`.
25
25
  ## The CLI in five minutes
26
26
 
27
27
  ```
28
+ wuica -example saxpy -arch SKL,ZEN3,ADL-P # a built-in loop, no file needed (-examples lists them)
28
29
  clang -O3 -march=haswell -S dot.c -o dot.s # AT&T, as clang and gcc write it: detected, no flag needed
29
30
  wuica dot.s # uiCA's report for SKL, of the loop wuica picked
30
31
  wuica dot.s -arch SKL,ZEN3,ADL-P # one table for several CPUs ("all": every one)
31
32
  wuica dot.s -per 8 # the loop does 8 elements per iteration: cycles per element too
32
33
  wuica dot.s -loops # the loops in the file; -loop N or -loop .LBB0_12 picks one
33
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)
34
37
  objdump -d dot.o | wuica # objdump output: the loop's real alignment from its address
35
38
  ```
36
39
 
@@ -53,8 +56,20 @@ objdump -d dot.o | wuica # objdump output: the loop's real
53
56
  edges, as clang's remainder loops often have), both sides of the branch are simulated, one after the other, while a
54
57
  real iteration takes one. A `Not modelled: both paths: both sides of the branch at line N …` line (table note
55
58
  `both paths`; JSON caveat `paths`) says so. To analyze one side, put `# wuica-begin` and `# wuica-end` around it.
56
- - **One input per run**: a file, `-` or nothing for stdin, a hex argument, `-hex` or `-raw FILE` (bare machine code:
57
- for an object file, `objdump -d file.o | wuica`).
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.
58
73
  - **Tables.** `-arch A,B,C` prints one row per CPU; `-` means unknown (uiCA names no single bottleneck; the notes
59
74
  give the nearest limit), `5.00*` that the CPU could not decode some instructions (they are left out), and the notes
60
75
  column the caveats (what the model does not simulate, such as store forwarding through an indexed address).
@@ -70,7 +85,8 @@ objdump -d dot.o | wuica # objdump output: the loop's real
70
85
  results: [{arch, tp, bottlenecks, limits, decodeErrors, perElement?, caveats?}]}`. The shapes are the same for one
71
86
  CPU and several: `whatIf` is keyed by CPU (`{SKL: {tp, variants: [{id, tp, …, perElement?}], perElement?}}`), and a
72
87
  caveat is `{id, text, title, instructions}` (in `insights.caveats` with one CPU, `results[].caveats` with several).
73
- Types: `CliAnalyzeJson`, `CliCompareJson`, `CliWhatIf` in index.d.ts. `--version -json` gives `{wuica, uiCA:
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:
74
90
  {repository, commit, branch}, node}`: the uiCA commit whose data and model the package has.
75
91
  - **Syntax mistakes.** When the assembler fails, a `hint:` line names a line with the other syntax's operands (mixed
76
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.
@@ -113,15 +129,18 @@ w.insights(r); // the diagnosis alone
113
129
  ```
114
130
 
115
131
  Methods never throw for bad input: they resolve to a failure `{code, error, stderr}` (see the contract below).
116
- `createWuica({ dataDir })` reads the tables from another directory (`uarch.json` and `arch/<NAME>.json`, plain or
117
- `.br`). TypeScript declarations are included (`index.d.ts`).
118
-
119
- `compare` analyzes the microarchitectures in parallel on worker threads: by default one thread per two
120
- microarchitectures (a thread's start costs about one analysis), at most `os.availableParallelism()`.
121
- `createWuica({ threads: N })` or the environment variable `WUICA_THREADS=N` uses up to N threads, one per
122
- microarchitecture; 1 runs them one after another on the calling thread. The response is the same either way. Each thread loads only the
123
- tables of the microarchitectures it analyzes and keeps them for the next `compare`; idle threads do not keep the process
124
- alive and stop after 30 s (`w.close()` stops them at once). A thread's WebAssembly memory has a lower limit (a quarter
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
125
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.
126
145
 
127
146
  Inputs on which the original uiCA fails can make the WebAssembly module trap. In that case the call resolves to
@@ -144,13 +163,21 @@ wuica loop.s -json # the JSON result (the contract's analyze r
144
163
  wuica psum.s -loop whole # the whole text, not the loop found in it (-loop auto, the default, or -loop N)
145
164
  wuica psum.s -loops # list the loops; -loop .LBB0_12 or -func psum to choose
146
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
147
173
  wuica --version
148
174
  ```
149
175
 
150
176
  The simulation options are uiCA's: `-alignmentOffset N`, `-initPolicy diff|same|stack`, `-simpleFrontEnd`,
151
177
  `-noMicroFusion`, `-noMacroFusion`, `-minIterations N`, `-minCycles N`, and `-trace` (with `-json`). Every flag also
152
- takes `--flag` and `--flag=value`, in any case (`--tponly`, `--arch=zen3`). With several
153
- microarchitectures, `-threads N` analyzes them on at most N threads at a time (`-threads 1`: one after another).
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).
154
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.
155
182
  `wuica -h` lists everything.
156
183
 
@@ -162,7 +189,7 @@ newline-delimited JSON-RPC 2.0 with the `initialize` handshake of the protocol r
162
189
  `ping`, `tools/list` and `tools/call`. Arguments are checked against the tools' JSON Schemas; a mismatch is a tool error
163
190
  (`isError`) that says what is wrong, an unknown tool a JSON-RPC error. The server ends with its stdin, and writes only
164
191
  protocol messages to stdout. `wuica mcp --help` prints the usage. The tool table itself (names, descriptions, JSON
165
- Schemas, handlers) is exported as `mcpTools(w)` from `wuica/mcp`, with `callTool` and `validate`; the remote server
192
+ Schemas, handlers) is exported as `mcpTools(w)` from `wuica-cli/mcp`, with `callTool` and `validate`; the remote server
166
193
  (`server/`) serves the same table over HTTP. It has five tools:
167
194
 
168
195
  | Tool | What it does |
@@ -173,30 +200,109 @@ Schemas, handlers) is exported as `mcpTools(w)` from `wuica/mcp`, with `callTool
173
200
  | `list_archs` | ids, names, years, prototype flags |
174
201
  | `assemble` | assembly → hex bytes, or diagnostics with line/column |
175
202
 
176
- Add it to **Claude Code** from a local checkout (after `build.sh` and `npm install`) or an installed tarball:
203
+ ### Set it up in your agent
177
204
 
178
- ```
179
- claude mcp add wuica -- node /absolute/path/to/packages/wuica/bin/wuica.js mcp
180
- ```
181
-
182
- Once the package is published on npm:
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:
183
207
 
184
- ```
208
+ ```sh
185
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
186
213
  ```
187
214
 
188
- Other MCP clients (Claude Desktop, Cursor, VS Code, ...) use the same command in their JSON configuration:
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/`):
189
219
 
190
220
  ```json
191
221
  {
192
222
  "mcpServers": {
193
- "wuica": { "command": "npx", "args": ["-y", "wuica", "mcp"] }
223
+ "wuica": { "command": "npx", "args": ["-y", "wuica-cli", "mcp"] }
194
224
  }
195
225
  }
196
226
  ```
197
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
+
198
300
  Example prompt: *"Use wuica to compare this loop on Skylake, Ice Lake and Zen 3 and explain the bottleneck."*
199
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
+
200
306
  ## API contract
201
307
 
202
308
  The library, the MCP tools and the REST API (https://api.wuica.jacen.li, server/) share these shapes. They follow
@@ -412,11 +518,14 @@ LLVM 22.1.2's (the same bytes as `llvm-mc`). Only `.text` is returned. `.include
412
518
  ```
413
519
  packages/wuica/build.sh # copies and compresses the wasm modules and tables into dist/, copies the licenses
414
520
  cd packages/wuica && npm install && npm test
415
- npm pack # wuica-<version>.tgz
521
+ npm pack # wuica-cli-<version>.tgz
416
522
  ```
417
523
 
418
524
  `build.sh` uses `target/wasm32-unknown-unknown/release/wuica_wasm.wasm` (it runs `./build-wasm.sh` if the file is
419
- missing), `assembler/dist/wuica_asm.wasm` and `data/`. `dist/manifest.json` records the size and SHA-256 of each
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
420
529
  uncompressed file.
421
530
 
422
531
  ## Licenses
@@ -430,8 +539,9 @@ uncompressed file.
430
539
  repository. It also contains wasi-libc and libc++ from wasi-sdk (Apache-2.0 WITH LLVM-exception, MIT and other
431
540
  permissive licenses).
432
541
  - The instruction data comes from [uops.info](https://www.uops.info) by Andreas Abel and Jan Reineke.
433
- - The MCP server uses the [MCP TypeScript SDK](https://github.com/modelcontextprotocol/typescript-sdk) (MIT) and
434
- [zod](https://zod.dev) (MIT), installed as npm dependencies.
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.
435
544
 
436
- If you use uiCA's models in research, cite the uiCA paper: Andreas Abel and Jan Reineke, *uiCA: Accurate Throughput
437
- Prediction of Basic Blocks on Recent Intel Microarchitectures*, ICS 2022.
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.
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
@@ -4,10 +4,14 @@
4
4
  "commit": "640e40e",
5
5
  "branch": "improve-r9"
6
6
  },
7
+ "tables": {
8
+ "format": "WUICATBL 1",
9
+ "sha256": "d1dce7edf3a6e0af263c94ed8712fb11ee8f4572c8685057201d2309e5e24631"
10
+ },
7
11
  "files": {
8
12
  "wuica_wasm.wasm": {
9
- "size": 4307652,
10
- "sha256": "6af065d98b90c2d945903fafccd0b6b749bdfe7dbc2d364adc98f50dfa310773"
13
+ "size": 3111653,
14
+ "sha256": "1a004180a1c1a79a02b039a4737c9c457ceacf507d735c6955046b071f28e818"
11
15
  },
12
16
  "wuica_asm.wasm": {
13
17
  "size": 3802001,
@@ -17,65 +21,140 @@
17
21
  "size": 51318,
18
22
  "sha256": "f543714ba2927986671f1de045a6162296ce860c5d34a086cc4c72d6c828e7a1"
19
23
  },
20
- "data/arch/ADL-P.json": {
21
- "size": 1771348,
22
- "sha256": "1632dd7f57d26efa6e465c25c72e38523302c906f8db403af6ba1c432b1e1ccb"
23
- },
24
- "data/arch/BDW.json": {
25
- "size": 526864,
26
- "sha256": "48e3e00ba260d97abcdae17a330c1e426b09b8e55b35c6d65932cc226237be0e"
27
- },
28
- "data/arch/CFL.json": {
29
- "size": 535543,
30
- "sha256": "26806383a9a25e1fdd327ad3140c32f2b0a2b919c23d72cbd017e268177bfb7a"
31
- },
32
- "data/arch/CLX.json": {
33
- "size": 1397578,
34
- "sha256": "368c51d6fb60c91480346dd592239f09b5dce8e523034e27da439f19f97673d7"
35
- },
36
- "data/arch/HSW.json": {
37
- "size": 537696,
38
- "sha256": "52ca060485b45c73e7c4229bb77f3637cacb5544349789cf0913fd329d6f18c9"
39
- },
40
- "data/arch/ICL.json": {
41
- "size": 1465390,
42
- "sha256": "3315a5d3463e3b2453943e9984d28c8135b8b20168c283a4d4d4c610a99e94de"
43
- },
44
- "data/arch/ICX.json": {
45
- "size": 1495406,
46
- "sha256": "dd45538e22584305d5186d78673b3d4f8bc83fd2d0c0e600ec98540a6d0f2eff"
47
- },
48
- "data/arch/IVB.json": {
49
- "size": 464357,
50
- "sha256": "53c297d60bba360223c44c1403c820555a2c01c2dc680f229c44036f8c89bda8"
51
- },
52
- "data/arch/KBL.json": {
53
- "size": 541457,
54
- "sha256": "a5381d040f4c38e2c67a740d28e522b6918650044bb4cbd3e92e45c749a2a607"
55
- },
56
- "data/arch/RKL.json": {
57
- "size": 1487905,
58
- "sha256": "8b2fee3a39a5632e845add182f1f1f0a5ab6158b6c2141952accb37b85ecc2a6"
59
- },
60
- "data/arch/SKL.json": {
61
- "size": 532918,
62
- "sha256": "c4c216edb3af2bf19847a9398dbc3c2cc46e5ad1fe609b2dd2db07203d2d191f"
63
- },
64
- "data/arch/SKX.json": {
65
- "size": 1379117,
66
- "sha256": "5dea6ecf323367fe217fafe624c92a5e6085ed3112fb3a173ab081353fd11480"
67
- },
68
- "data/arch/SNB.json": {
69
- "size": 460620,
70
- "sha256": "3ba130e0858faa73bd16677e740b9fda75329df87eae339326a74a4a27e16e69"
71
- },
72
- "data/arch/TGL.json": {
73
- "size": 1461441,
74
- "sha256": "6f799ff308e1f9e62c0b5118921dcca3253644b7a028e50d0737cc4d731f2780"
75
- },
76
- "data/arch/ZEN3.json": {
77
- "size": 527963,
78
- "sha256": "72097d0e154b17ef71c12547946c2750f388cdae479b9af99ed5633959c9059a"
24
+ "data/arch/ADL-P.bin": {
25
+ "size": 819776,
26
+ "sha256": "3a6623b7086ada2689d068745929537046655b444641885e09154221b5edac87",
27
+ "source": {
28
+ "file": "data/arch/ADL-P.json",
29
+ "size": 1771348,
30
+ "sha256": "1632dd7f57d26efa6e465c25c72e38523302c906f8db403af6ba1c432b1e1ccb"
31
+ }
32
+ },
33
+ "data/arch/BDW.bin": {
34
+ "size": 197075,
35
+ "sha256": "7c9f3af2afaaebb8ec49f9d02e5e85cd5be606b75d19c498bbc7159a3a0c7d2d",
36
+ "source": {
37
+ "file": "data/arch/BDW.json",
38
+ "size": 526864,
39
+ "sha256": "48e3e00ba260d97abcdae17a330c1e426b09b8e55b35c6d65932cc226237be0e"
40
+ }
41
+ },
42
+ "data/arch/CFL.bin": {
43
+ "size": 199949,
44
+ "sha256": "91616eec3eeaabb032e42e3e87c25945121513036041e200bea5dc109f2d7bb2",
45
+ "source": {
46
+ "file": "data/arch/CFL.json",
47
+ "size": 535543,
48
+ "sha256": "26806383a9a25e1fdd327ad3140c32f2b0a2b919c23d72cbd017e268177bfb7a"
49
+ }
50
+ },
51
+ "data/arch/CLX.bin": {
52
+ "size": 654383,
53
+ "sha256": "5fb768f2d4aab8c876183640b1fc5425f357f958356052172c3be00970a01c5a",
54
+ "source": {
55
+ "file": "data/arch/CLX.json",
56
+ "size": 1397578,
57
+ "sha256": "368c51d6fb60c91480346dd592239f09b5dce8e523034e27da439f19f97673d7"
58
+ }
59
+ },
60
+ "data/arch/HSW.bin": {
61
+ "size": 201318,
62
+ "sha256": "7ee63a4845a64c96948ee343148ce9db770d5c3347edb1414a35a6a305bd3cd7",
63
+ "source": {
64
+ "file": "data/arch/HSW.json",
65
+ "size": 537696,
66
+ "sha256": "52ca060485b45c73e7c4229bb77f3637cacb5544349789cf0913fd329d6f18c9"
67
+ }
68
+ },
69
+ "data/arch/ICL.bin": {
70
+ "size": 691859,
71
+ "sha256": "92d27cfb556b46617a1cfe433d5956f455192459888447e6276bdfdb9255eec2",
72
+ "source": {
73
+ "file": "data/arch/ICL.json",
74
+ "size": 1465390,
75
+ "sha256": "3315a5d3463e3b2453943e9984d28c8135b8b20168c283a4d4d4c610a99e94de"
76
+ }
77
+ },
78
+ "data/arch/ICX.bin": {
79
+ "size": 698165,
80
+ "sha256": "b01057f584a837604ad9c08c4eeae45e09161dce826234d5f010e807a0a18b21",
81
+ "source": {
82
+ "file": "data/arch/ICX.json",
83
+ "size": 1495406,
84
+ "sha256": "dd45538e22584305d5186d78673b3d4f8bc83fd2d0c0e600ec98540a6d0f2eff"
85
+ }
86
+ },
87
+ "data/arch/IVB.bin": {
88
+ "size": 163769,
89
+ "sha256": "484f4e7d1552a44084a7d1298eec1d94c4229b24c385a474a3b56a915933e4b9",
90
+ "source": {
91
+ "file": "data/arch/IVB.json",
92
+ "size": 464357,
93
+ "sha256": "53c297d60bba360223c44c1403c820555a2c01c2dc680f229c44036f8c89bda8"
94
+ }
95
+ },
96
+ "data/arch/KBL.bin": {
97
+ "size": 201120,
98
+ "sha256": "26ab42345e8de863ae825f278143bf4ba234635d532268cf5e5f18d165528435",
99
+ "source": {
100
+ "file": "data/arch/KBL.json",
101
+ "size": 541457,
102
+ "sha256": "a5381d040f4c38e2c67a740d28e522b6918650044bb4cbd3e92e45c749a2a607"
103
+ }
104
+ },
105
+ "data/arch/RKL.bin": {
106
+ "size": 696724,
107
+ "sha256": "c839f40ac2aaed5c10d6f122edcffe6e1a5eecfcfcd21be8fc75e1f68098dc36",
108
+ "source": {
109
+ "file": "data/arch/RKL.json",
110
+ "size": 1487905,
111
+ "sha256": "8b2fee3a39a5632e845add182f1f1f0a5ab6158b6c2141952accb37b85ecc2a6"
112
+ }
113
+ },
114
+ "data/arch/SKL.bin": {
115
+ "size": 199362,
116
+ "sha256": "690d24c0478ed18e4280491dde5cbbcd5c739664cd87be5f1f22aa3236b95267",
117
+ "source": {
118
+ "file": "data/arch/SKL.json",
119
+ "size": 532918,
120
+ "sha256": "c4c216edb3af2bf19847a9398dbc3c2cc46e5ad1fe609b2dd2db07203d2d191f"
121
+ }
122
+ },
123
+ "data/arch/SKX.bin": {
124
+ "size": 647385,
125
+ "sha256": "50b8496690e3cb8b7bad0f2ecb36ad61c7a110193ce798838902257ea92a1bf6",
126
+ "source": {
127
+ "file": "data/arch/SKX.json",
128
+ "size": 1379117,
129
+ "sha256": "5dea6ecf323367fe217fafe624c92a5e6085ed3112fb3a173ab081353fd11480"
130
+ }
131
+ },
132
+ "data/arch/SNB.bin": {
133
+ "size": 162979,
134
+ "sha256": "a14e6a77ec41fe14db1745acbfb6a4df4d360b58068b391f0df9a6804c247589",
135
+ "source": {
136
+ "file": "data/arch/SNB.json",
137
+ "size": 460620,
138
+ "sha256": "3ba130e0858faa73bd16677e740b9fda75329df87eae339326a74a4a27e16e69"
139
+ }
140
+ },
141
+ "data/arch/TGL.bin": {
142
+ "size": 692074,
143
+ "sha256": "abaeb3cb2f10a3e68c4f1f5374007b574982f09ae5832fcd9f5ed1d3f60ff3cd",
144
+ "source": {
145
+ "file": "data/arch/TGL.json",
146
+ "size": 1461441,
147
+ "sha256": "6f799ff308e1f9e62c0b5118921dcca3253644b7a028e50d0737cc4d731f2780"
148
+ }
149
+ },
150
+ "data/arch/ZEN3.bin": {
151
+ "size": 198979,
152
+ "sha256": "525e66430a3ddc9f0c88d914f32083fbdc0c32f17233dd972548286b4d43b7c7",
153
+ "source": {
154
+ "file": "data/arch/ZEN3.json",
155
+ "size": 527963,
156
+ "sha256": "72097d0e154b17ef71c12547946c2750f388cdae479b9af99ed5633959c9059a"
157
+ }
79
158
  }
80
159
  }
81
160
  }
Binary file
package/index.d.ts CHANGED
@@ -46,6 +46,27 @@ export interface LoopListing {
46
46
  }
47
47
  /** The loops of assembly text, as `loop` and `func` choose among them (no assembling). */
48
48
  export function listLoops(source: string, options?: { func?: string | null }): LoopListing[] | { error: string };
49
+ /** A built-in example: the web page's set (the CLI's -examples / -example NAME). */
50
+ export interface Example {
51
+ /** "saxpy", "dot1", ... (findExample and the CLI take it in any case). */
52
+ name: string;
53
+ title: string;
54
+ group: 'basics' | 'classic' | 'showcase';
55
+ /** The CPU the page shows it on first. */
56
+ arch: string;
57
+ instructions: number;
58
+ /** Its machine code. */
59
+ hex: string;
60
+ /** Its assembly (a request's `source` with syntax 'intel' or 'att'); absent for the showcase (machine code only). */
61
+ intel?: string;
62
+ att?: string;
63
+ }
64
+ /** What a file is from its first bytes ('elf', 'macho', 'fat', 'macho32', 'coff', 'pe', 'archive'), or null. */
65
+ export function objectKind(bytes: Uint8Array): { kind: string } | null;
66
+ /** The built-in examples: basics, classic loops, the SHA-256 showcase. */
67
+ export function examples(): readonly Example[];
68
+ /** The example called `name` (case-insensitive), or null. */
69
+ export function findExample(name: string): Example | null;
49
70
  /** 'att' or 'intel' from the text's signs, or null. */
50
71
  export function detectSyntax(source: string): 'att' | 'intel' | null;
51
72
  /** Per instruction details and the port set / issue slots of an analysis with options.details (the MCP summary's). */
@@ -266,6 +287,17 @@ export interface Wuica {
266
287
  /** POST /api/compare: one block on several microarchitectures (default: all of archs()); assembled once. The
267
288
  * microarchitectures are analyzed on worker threads (CreateOptions.threads); the response is the same either way. */
268
289
  compare(request: CompareRequest): Promise<CompareResult | Failure>;
290
+ /** Several blocks on one microarchitecture: each result exactly what analyze(arch, request) returns, in the same
291
+ * order. The code is assembled on the calling thread; the analyses run on worker threads when the work is worth it. */
292
+ analyzeMany(arch: string, requests: AnalyzeRequest[]): Promise<(AnalyzeResult | Failure)[]>;
293
+ /** Several blocks on several microarchitectures: each result exactly what compare() returns for that request (its
294
+ * `archs`, else options.archs, else all); every block x microarchitecture is one job for the threads. */
295
+ compareMany(requests: CompareRequest[], options?: { archs?: string[] }): Promise<(CompareResult | Failure)[]>;
296
+ /** An object file or executable (ELF or Mach-O, x86-64; a universal file's x86-64 slice) as llvm-objdump -d's text
297
+ * of its code sections, which analyze() and compare() read as `source` (the loop at its address, the alignment from
298
+ * it). Another architecture or format is a Failure that says what it is and how to get x86-64. `func` is resolved
299
+ * (exact, without Mach-O's "_", or a unique part of a name) and returned as `func`. */
300
+ disassemble(bytes: Uint8Array, options?: { name?: string; func?: string | null }): { code: 0; text: string; format: string; functions: { name: string; section: string; address: number; size: number }[]; func?: string } | Failure;
269
301
  /** GET /api/archs: in order of release (uiCA's ablation variants, ids with "_", are left out). */
270
302
  archs(): ArchInfo[];
271
303
  archs(fields: ArchField[] | string): Partial<ArchInfo>[];
@@ -294,9 +326,11 @@ export interface CreateOptions {
294
326
  analyzerWasm?: string;
295
327
  /** Path of wuica_asm.wasm (plain or .br). */
296
328
  assemblerWasm?: string;
297
- /** The most worker threads compare() uses, one per microarchitecture. 1: none (one after another on the calling
298
- * thread). Default: the environment variable WUICA_THREADS, else "auto": one thread per two microarchitectures, at
299
- * most os.availableParallelism() (none inside a worker thread). */
329
+ /** The most worker threads compare(), analyzeMany() and compareMany() use. A number: up to that many (one per job at
330
+ * most); 1: none (one after another on the calling thread). Default: the environment variable WUICA_THREADS, else
331
+ * "auto": by the amount of work (blocks x microarchitectures, their instructions, the tables to load): none when it
332
+ * would take less than about 0.3 s on one thread, else 2 to 8, at most the cores but one (none inside a worker
333
+ * thread). */
300
334
  threads?: number | 'auto';
301
335
  }
302
336
 
@@ -365,6 +399,10 @@ export type CliAnalyzeJson = AnalyzeResult & { insights?: Insights; perElement?:
365
399
  export type CliCompareJson = CompareResult & { results: (CompareResult['results'][number] & { perElement?: number; caveats?: Caveat[] })[]; whatIf?: CliWhatIf };
366
400
  /** The CLI's `--version -json`: the package's version and the uiCA reference whose data and model it has (from the
367
401
  * repository's ci/data-asset.txt at build time; null if the package was not built). */
402
+ /** The CLI's `-json` with several inputs (wuica a.s b.s ..., -files LIST): `code` is the largest of the files' codes
403
+ * (the exit status); each entry is what a single run prints for that file (CliAnalyzeJson, CliCompareJson, a Failure,
404
+ * or with -loops {code, loops}), with the file's name as given. */
405
+ export interface CliBatchJson { code: number; files: ({ file: string } & (CliAnalyzeJson | CliCompareJson | Failure | { code: 0; loops: LoopListing[] }))[] }
368
406
  export interface CliVersionJson { wuica: string; uiCA: { repository: string; commit: string; branch?: string } | null; node: string }
369
407
  /** The what-if experiments of the web page (the MCP tool `what_if`), with `analyze` (e.g. a Wuica's analyze, bound) and,
370
408
  * for the accumulator variants, `assemble` (e.g. a Wuica's assemble, bound). */