wuica-cli 0.1.7 → 0.1.10
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/README.md +233 -57
- 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 +145 -66
- package/dist/wuica_wasm.wasm.br +0 -0
- package/index.d.ts +205 -13
- package/lib/cli.js +467 -49
- package/lib/core.js +9 -1
- package/lib/details.js +4 -23
- package/lib/examples.js +27 -0
- package/lib/files.js +26 -3
- package/lib/index.js +228 -42
- package/lib/mcp.js +107 -84
- package/lib/objfile.js +218 -0
- package/lib/thread-worker.js +15 -9
- package/lib/threads.js +40 -23
- package/lib/wasm.js +42 -11
- package/lib/web/ab-diff.js +217 -0
- package/lib/web/accum.js +10 -2
- package/lib/web/asm-regions.js +24 -17
- package/lib/web/asm-tokens.js +357 -0
- package/lib/web/assembler.js +36 -6
- package/lib/web/block-diff.js +165 -0
- package/lib/web/bound-core.js +211 -0
- package/lib/web/branch-label.js +155 -0
- package/lib/web/caveats.js +115 -3
- package/lib/web/details.js +91 -0
- package/lib/web/examples.js +103 -0
- package/lib/web/loop-find.js +139 -16
- package/lib/web/markdown.js +437 -0
- package/lib/web/showcase.js +368 -0
- package/lib/web/whatif-core.js +339 -0
- package/package.json +3 -1
- package/dist/data/arch/ADL-P.json.br +0 -0
- package/dist/data/arch/BDW.json.br +0 -0
- package/dist/data/arch/CFL.json.br +0 -0
- package/dist/data/arch/CLX.json.br +0 -0
- package/dist/data/arch/HSW.json.br +0 -0
- package/dist/data/arch/ICL.json.br +0 -0
- package/dist/data/arch/ICX.json.br +0 -0
- package/dist/data/arch/IVB.json.br +0 -0
- package/dist/data/arch/KBL.json.br +0 -0
- package/dist/data/arch/RKL.json.br +0 -0
- package/dist/data/arch/SKL.json.br +0 -0
- package/dist/data/arch/SKX.json.br +0 -0
- package/dist/data/arch/SNB.json.br +0 -0
- package/dist/data/arch/TGL.json.br +0 -0
- package/dist/data/arch/ZEN3.json.br +0 -0
- package/lib/insights.js +0 -100
- package/lib/whatif.js +0 -136
package/dist/manifest.json
CHANGED
|
@@ -1,81 +1,160 @@
|
|
|
1
1
|
{
|
|
2
2
|
"uiCA": {
|
|
3
3
|
"repository": "https://github.com/jtl06/uiCA",
|
|
4
|
-
"commit": "
|
|
5
|
-
"branch": "improve-
|
|
4
|
+
"commit": "7301b04",
|
|
5
|
+
"branch": "improve-r10"
|
|
6
|
+
},
|
|
7
|
+
"tables": {
|
|
8
|
+
"format": "WUICATBL 1",
|
|
9
|
+
"sha256": "d1dce7edf3a6e0af263c94ed8712fb11ee8f4572c8685057201d2309e5e24631"
|
|
6
10
|
},
|
|
7
11
|
"files": {
|
|
8
12
|
"wuica_wasm.wasm": {
|
|
9
|
-
"size":
|
|
10
|
-
"sha256": "
|
|
13
|
+
"size": 3064326,
|
|
14
|
+
"sha256": "fe34e612cb5ec9ed7e8c409a63310e8fd4601b8fe95bc8bf23ff17ee3a377559"
|
|
11
15
|
},
|
|
12
16
|
"wuica_asm.wasm": {
|
|
13
17
|
"size": 3802001,
|
|
14
18
|
"sha256": "ee66811d0671cdea73176a3670f82816dcbb3cbb1fed13cd7dc2acbb69cb627d"
|
|
15
19
|
},
|
|
16
20
|
"data/uarch.json": {
|
|
17
|
-
"size":
|
|
18
|
-
"sha256": "
|
|
19
|
-
},
|
|
20
|
-
"data/arch/ADL-P.
|
|
21
|
-
"size":
|
|
22
|
-
"sha256": "
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
"
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
"
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
"
|
|
50
|
-
"
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
},
|
|
56
|
-
"data/arch/
|
|
57
|
-
"size":
|
|
58
|
-
"sha256": "
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
"
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
"
|
|
78
|
-
|
|
21
|
+
"size": 51885,
|
|
22
|
+
"sha256": "cce92ecddac13e6fa90902142a9e6cb03c4ef93d259039998488a31839426fd0"
|
|
23
|
+
},
|
|
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
|
}
|
package/dist/wuica_wasm.wasm.br
CHANGED
|
Binary file
|
package/index.d.ts
CHANGED
|
@@ -29,7 +29,9 @@ export type Syntax = 'auto' | 'intel' | 'att';
|
|
|
29
29
|
export type LoopChoice = 'auto' | 'whole' | number | string;
|
|
30
30
|
/** The named loop choices ('auto', 'whole'); a number is a loop's index (0-based), any other string its label. */
|
|
31
31
|
export declare const LOOP_CHOICES: readonly ['auto', 'whole'];
|
|
32
|
-
/** A loop of
|
|
32
|
+
/** A loop of the text that was not analyzed (analyze's `otherLoops`): listLoops' entry without `auto`. */
|
|
33
|
+
export type OtherLoop = Omit<LoopListing, 'auto'>;
|
|
34
|
+
/** A loop of assembly text (listLoops; the CLI's -loops; the MCP tool list_loops). */
|
|
33
35
|
export interface LoopListing {
|
|
34
36
|
/** Its index for `loop` (0-based): the deepest loops first, then in code order. */
|
|
35
37
|
index: number;
|
|
@@ -46,6 +48,27 @@ export interface LoopListing {
|
|
|
46
48
|
}
|
|
47
49
|
/** The loops of assembly text, as `loop` and `func` choose among them (no assembling). */
|
|
48
50
|
export function listLoops(source: string, options?: { func?: string | null }): LoopListing[] | { error: string };
|
|
51
|
+
/** A built-in example: the web page's set (the CLI's -examples / -example NAME). */
|
|
52
|
+
export interface Example {
|
|
53
|
+
/** "saxpy", "dot1", ... (findExample and the CLI take it in any case). */
|
|
54
|
+
name: string;
|
|
55
|
+
title: string;
|
|
56
|
+
group: 'basics' | 'classic' | 'showcase';
|
|
57
|
+
/** The CPU the page shows it on first. */
|
|
58
|
+
arch: string;
|
|
59
|
+
instructions: number;
|
|
60
|
+
/** Its machine code. */
|
|
61
|
+
hex: string;
|
|
62
|
+
/** Its assembly (a request's `source` with syntax 'intel' or 'att'); absent for the showcase (machine code only). */
|
|
63
|
+
intel?: string;
|
|
64
|
+
att?: string;
|
|
65
|
+
}
|
|
66
|
+
/** What a file is from its first bytes ('elf', 'macho', 'fat', 'macho32', 'coff', 'pe', 'archive'), or null. */
|
|
67
|
+
export function objectKind(bytes: Uint8Array): { kind: string } | null;
|
|
68
|
+
/** The built-in examples: basics, classic loops, the SHA-256 showcase. */
|
|
69
|
+
export function examples(): readonly Example[];
|
|
70
|
+
/** The example called `name` (case-insensitive), or null. */
|
|
71
|
+
export function findExample(name: string): Example | null;
|
|
49
72
|
/** 'att' or 'intel' from the text's signs, or null. */
|
|
50
73
|
export function detectSyntax(source: string): 'att' | 'intel' | null;
|
|
51
74
|
/** Per instruction details and the port set / issue slots of an analysis with options.details (the MCP summary's). */
|
|
@@ -84,7 +107,8 @@ export type CodeRequest =
|
|
|
84
107
|
export type AnalyzeRequest = CodeRequest & { options?: AnalysisOptions };
|
|
85
108
|
|
|
86
109
|
/** Body of POST /api/compare. */
|
|
87
|
-
|
|
110
|
+
/** `per`: elements per iteration (also cycles per element: `elementsPerIteration` and each row's `perElement`). */
|
|
111
|
+
export type CompareRequest = CodeRequest & { archs?: string[]; options?: AnalysisOptions; per?: number };
|
|
88
112
|
|
|
89
113
|
/** Result codes, like an exit status. */
|
|
90
114
|
export declare const CODES: Readonly<{ OK: 0; REQUEST: 1; ASSEMBLER: 2; ANALYSIS: 3 }>;
|
|
@@ -120,6 +144,14 @@ export interface Row {
|
|
|
120
144
|
notes: string;
|
|
121
145
|
/** values[i] belongs to columns[i]; averages per iteration. */
|
|
122
146
|
values: number[];
|
|
147
|
+
/** Assembly input: the instruction's 1-based line in the text, and its `.loc` source line ("file.c:12") when the text has .file/.loc directives. Absent for machine code. */
|
|
148
|
+
line?: number;
|
|
149
|
+
loc?: string;
|
|
150
|
+
/** objdump -S and perf annotate input: the interleaved source line in force ("s += a[i] * b[i];"). */
|
|
151
|
+
source?: string;
|
|
152
|
+
/** perf annotate input: the instruction's percent of all the samples of the output (each symbol's own percent weighted
|
|
153
|
+
* by its sample count). */
|
|
154
|
+
samples?: number;
|
|
123
155
|
}
|
|
124
156
|
|
|
125
157
|
/** A successful analysis: the response of docs/WASM-API.md plus code, hex and stderr. */
|
|
@@ -150,10 +182,19 @@ export interface AnalyzeResult {
|
|
|
150
182
|
hex?: string;
|
|
151
183
|
/** What of `source` was analyzed, when not the whole text as given (request.loop). */
|
|
152
184
|
loop?: LoopInfo;
|
|
185
|
+
/** The loops of the text that were not analyzed, when it has more than one (listLoops without `auto`). */
|
|
186
|
+
otherLoops?: OtherLoop[];
|
|
153
187
|
/** The syntax `source` was read in (detected unless the request said). */
|
|
154
188
|
syntax?: 'intel' | 'att';
|
|
155
189
|
/** Assembler warnings, notes (exits taken as not taken), and the decode warning. */
|
|
156
190
|
stderr: StderrLine[];
|
|
191
|
+
/** Only when this CPU cannot run the code (positions its decoder skipped, or an instruction of an extension it lacks,
|
|
192
|
+
* e.g. AVX-512 on ZEN3): why ("needs AVX-512", "12 undecodable"). `tp` is then the reference's number, which leaves
|
|
193
|
+
* that code out: not a result for this CPU. */
|
|
194
|
+
unsupported?: string;
|
|
195
|
+
/** Only when the CPU can run the code but some of its instructions are not in its instruction tables (rows with the
|
|
196
|
+
* note X: x87 tbyte loads, syscall, ...): their count. The result stands; their cost is left out. */
|
|
197
|
+
noData?: number;
|
|
157
198
|
}
|
|
158
199
|
|
|
159
200
|
/** The compact form of an analysis (summarize(); the MCP `analyze` JSON). */
|
|
@@ -169,11 +210,21 @@ export interface AnalyzeSummary {
|
|
|
169
210
|
bottlenecks: string[];
|
|
170
211
|
limits: Limit[];
|
|
171
212
|
decodeErrors: number;
|
|
213
|
+
/** As AnalyzeResult's: why this CPU cannot run the code, only then. */
|
|
214
|
+
unsupported?: string;
|
|
215
|
+
/** As AnalyzeResult's: the instructions without data of code it can run, only if any. */
|
|
216
|
+
noData?: number;
|
|
172
217
|
hex?: string;
|
|
173
218
|
loop?: LoopInfo;
|
|
219
|
+
/** The loops of the text that were not analyzed, when it has more than one (listLoops without `auto`). */
|
|
220
|
+
otherLoops?: OtherLoop[];
|
|
174
221
|
stderr: StderrLine[];
|
|
175
222
|
instructions: Array<{
|
|
176
223
|
instr: string;
|
|
224
|
+
line?: number;
|
|
225
|
+
loc?: string;
|
|
226
|
+
source?: string;
|
|
227
|
+
samples?: number;
|
|
177
228
|
bytes?: string;
|
|
178
229
|
kind?: 'regMerge' | 'stackSync';
|
|
179
230
|
issued?: number;
|
|
@@ -207,9 +258,9 @@ export interface Insights {
|
|
|
207
258
|
/** Cycles per iteration that no single limit explains. */
|
|
208
259
|
unexplained?: number;
|
|
209
260
|
/** The critical loop-carried dependency chain (index: into `instructions`). */
|
|
210
|
-
chain?: { index: number; instr: string; operand: string; latency: number; carried: boolean }[];
|
|
261
|
+
chain?: { index: number; instr: string; line?: number; loc?: string; operand: string; latency: number; carried: boolean }[];
|
|
211
262
|
/** The instructions with the largest share of the binding resource, or of the largest limit (top 5). */
|
|
212
|
-
hot?: { resource: string; ports?: string[]; instructions: { index: number; instr: string; share: number }[] };
|
|
263
|
+
hot?: { resource: string; ports?: string[]; instructions: { index: number; instr: string; line?: number; loc?: string; share: number }[] };
|
|
213
264
|
/** Known blind spots of the model the block meets (absent if none): rmw-index, paths, exit, split. */
|
|
214
265
|
caveats?: Caveat[];
|
|
215
266
|
/** With options.details: the ports behind the Ports limit (cycles = uops / ports) and the instructions that load them. */
|
|
@@ -243,7 +294,7 @@ export interface AssembleResult {
|
|
|
243
294
|
}
|
|
244
295
|
|
|
245
296
|
export type CompareRow =
|
|
246
|
-
| { arch: string; name: string; year: number | null; prototype: boolean; code: 0; tp: number; mode: 'loop' | 'unroll'; bottlenecks: string[]; limits: Limit[]; decodeErrors: number }
|
|
297
|
+
| { arch: string; name: string; year: number | null; prototype: boolean; code: 0; tp: number; mode: 'loop' | 'unroll'; bottlenecks: string[]; limits: Limit[]; decodeErrors: number; unsupported?: string; noData?: number; perElement?: number }
|
|
247
298
|
| { arch: string; name: string; year: number | null; prototype: boolean; code: 1 | 2 | 3; error: string };
|
|
248
299
|
|
|
249
300
|
export interface CompareResult {
|
|
@@ -251,9 +302,15 @@ export interface CompareResult {
|
|
|
251
302
|
/** The assembled machine code, when `source` was given. */
|
|
252
303
|
hex?: string;
|
|
253
304
|
loop?: LoopInfo;
|
|
305
|
+
/** The loops of the text that were not analyzed, when it has more than one (listLoops without `auto`). */
|
|
306
|
+
otherLoops?: OtherLoop[];
|
|
307
|
+
/** With the request's `per`. */
|
|
308
|
+
elementsPerIteration?: number;
|
|
254
309
|
stderr: StderrLine[];
|
|
255
310
|
results: CompareRow[];
|
|
256
311
|
}
|
|
312
|
+
/** A compare() result with cycles per element (`per` elements per iteration); unchanged without `per`. */
|
|
313
|
+
export function comparePerElement(result: CompareResult | Failure, per?: number): CompareResult | Failure;
|
|
257
314
|
|
|
258
315
|
export interface Wuica {
|
|
259
316
|
/** POST /api/analyze/<arch>. Failures resolve to a Failure (never throw for bad input). */
|
|
@@ -262,10 +319,21 @@ export interface Wuica {
|
|
|
262
319
|
analyze(request: AnalyzeRequest & { arch?: string }): Promise<AnalyzeResult | Failure>;
|
|
263
320
|
/** The machine code an analysis of assembly text gets (as the web page reads it: the loop of a whole function, objdump
|
|
264
321
|
* lines, exits as not taken, ';' comments, a marked region); `bytes` and `hex` of the analyzed code, `loop` what was picked. */
|
|
265
|
-
machineCode(source: string, syntax?: Syntax, loop?: LoopChoice): Promise<{ code: 0; hex: string; bytes: Uint8Array; stderr: StderrLine[]; loop: LoopInfo | null } | Failure>;
|
|
322
|
+
machineCode(source: string, syntax?: Syntax, loop?: LoopChoice, func?: string | null): Promise<{ code: 0; hex: string; bytes: Uint8Array; stderr: StderrLine[]; loop: LoopInfo | null } | Failure>;
|
|
266
323
|
/** POST /api/compare: one block on several microarchitectures (default: all of archs()); assembled once. The
|
|
267
324
|
* microarchitectures are analyzed on worker threads (CreateOptions.threads); the response is the same either way. */
|
|
268
325
|
compare(request: CompareRequest): Promise<CompareResult | Failure>;
|
|
326
|
+
/** Several blocks on one microarchitecture: each result exactly what analyze(arch, request) returns, in the same
|
|
327
|
+
* order. The code is assembled on the calling thread; the analyses run on worker threads when the work is worth it. */
|
|
328
|
+
analyzeMany(arch: string, requests: AnalyzeRequest[]): Promise<(AnalyzeResult | Failure)[]>;
|
|
329
|
+
/** Several blocks on several microarchitectures: each result exactly what compare() returns for that request (its
|
|
330
|
+
* `archs`, else options.archs, else all); every block x microarchitecture is one job for the threads. */
|
|
331
|
+
compareMany(requests: CompareRequest[], options?: { archs?: string[] }): Promise<(CompareResult | Failure)[]>;
|
|
332
|
+
/** An object file or executable (ELF or Mach-O, x86-64; a universal file's x86-64 slice) as llvm-objdump -d's text
|
|
333
|
+
* of its code sections, which analyze() and compare() read as `source` (the loop at its address, the alignment from
|
|
334
|
+
* it). Another architecture or format is a Failure that says what it is and how to get x86-64. `func` is resolved
|
|
335
|
+
* (exact, without Mach-O's "_", or a unique part of a name) and returned as `func`. */
|
|
336
|
+
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
337
|
/** GET /api/archs: in order of release (uiCA's ablation variants, ids with "_", are left out). */
|
|
270
338
|
archs(): ArchInfo[];
|
|
271
339
|
archs(fields: ArchField[] | string): Partial<ArchInfo>[];
|
|
@@ -277,6 +345,12 @@ export interface Wuica {
|
|
|
277
345
|
/** The derived diagnosis of a successful analyze() result with its microarchitecture's configuration (as in the REST
|
|
278
346
|
* response and summarize()); null for a failure. */
|
|
279
347
|
insights(result: AnalyzeResult | Failure): Insights | null;
|
|
348
|
+
/** The what-if experiments (the MCP tool what_if, POST /api/what-if/<arch>): analyze's request with `variants`
|
|
349
|
+
* (default all) and `per` (elements per iteration: also cycles per element). */
|
|
350
|
+
whatIf(arch: string, request: WhatIfRequest): Promise<WhatIfPerElement | Failure>;
|
|
351
|
+
/** Two blocks, A (before) and B (after), on one microarchitecture (wuica diff, the MCP tool diff_blocks,
|
|
352
|
+
* POST /api/diff/<arch>). A failure's error starts with "A: " or "B: ". */
|
|
353
|
+
diff(arch: string, request: DiffRequest): Promise<DiffResult | Failure>;
|
|
280
354
|
/** The id for a user-supplied name (case-insensitive, "-" optional), DEFAULT_ARCH for empty input, or null. */
|
|
281
355
|
resolveArch(arch?: string | null): string | null;
|
|
282
356
|
/** How many times the analyzer was restarted after a trap. */
|
|
@@ -294,9 +368,11 @@ export interface CreateOptions {
|
|
|
294
368
|
analyzerWasm?: string;
|
|
295
369
|
/** Path of wuica_asm.wasm (plain or .br). */
|
|
296
370
|
assemblerWasm?: string;
|
|
297
|
-
/** The most worker threads compare()
|
|
298
|
-
* thread). Default: the environment variable WUICA_THREADS, else
|
|
299
|
-
*
|
|
371
|
+
/** The most worker threads compare(), analyzeMany() and compareMany() use. A number: up to that many (one per job at
|
|
372
|
+
* most); 1: none (one after another on the calling thread). Default: the environment variable WUICA_THREADS, else
|
|
373
|
+
* "auto": by the amount of work (blocks x microarchitectures, their instructions, the tables to load): none when it
|
|
374
|
+
* 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
|
|
375
|
+
* thread). */
|
|
300
376
|
threads?: number | 'auto';
|
|
301
377
|
}
|
|
302
378
|
|
|
@@ -337,8 +413,11 @@ export interface Caveat {
|
|
|
337
413
|
instructions: number[];
|
|
338
414
|
}
|
|
339
415
|
|
|
340
|
-
export type WhatIfVariant = 'unroll2' | 'unroll4' | 'unroll8' | 'acc2' | 'acc3' | 'acc4' | 'acc8' | 'simpleFrontEnd' | 'noMacroFusion' | 'noMicroFusion' | 'nochain';
|
|
416
|
+
export type WhatIfVariant = 'unroll2' | 'unroll4' | 'unroll8' | 'acc2' | 'acc3' | 'acc4' | 'acc8' | 'simpleFrontEnd' | 'noMacroFusion' | 'noMicroFusion' | 'nochain' | 'align';
|
|
417
|
+
/** The default variants (not align). */
|
|
341
418
|
export const WHAT_IF_VARIANTS: readonly WhatIfVariant[];
|
|
419
|
+
/** The variants that run only when asked for: align (64 analyses). */
|
|
420
|
+
export const WHAT_IF_OPT_IN_VARIANTS: readonly WhatIfVariant[];
|
|
342
421
|
export interface WhatIfResult {
|
|
343
422
|
code: 0;
|
|
344
423
|
arch: string;
|
|
@@ -347,16 +426,79 @@ export interface WhatIfResult {
|
|
|
347
426
|
bottlenecks: string[];
|
|
348
427
|
unit: 'cycles per original iteration';
|
|
349
428
|
loop?: LoopInfo;
|
|
429
|
+
/** The base's decode errors and warnings (they hold for the variants too). */
|
|
430
|
+
decodeErrors?: number;
|
|
431
|
+
stderr?: StderrLine[];
|
|
432
|
+
/** Only when the CPU cannot run the base (as AnalyzeResult's): why. `variants` is then empty: no variant compares with
|
|
433
|
+
* a number that is not a result. */
|
|
434
|
+
unsupported?: string;
|
|
350
435
|
/** tp per original iteration, delta = tp − base tp, speedup = base tp / tp; estimate: no analysis (nochain);
|
|
351
|
-
* renamed (accN): the chain's registers and the ones of the copies after the first
|
|
352
|
-
|
|
436
|
+
* renamed (accN): the chain's registers and the ones of the copies after the first; approx: the simulation (tp) came
|
|
437
|
+
* out under the variant's own Ports or Issue limit by at most 1% (a short steady state): the text and the Markdown
|
|
438
|
+
* show `shown`, that limit per original iteration, marked ≈ (~ in text). */
|
|
439
|
+
variants: { id: WhatIfVariant; label: string; tp?: number; delta?: number; speedup?: number | null; estimate?: boolean; bottlenecks?: string[]; renamed?: { from: string; to: string[] }[]; error?: string;
|
|
440
|
+
approx?: { limit: 'Ports' | 'Issue'; shown: number };
|
|
441
|
+
/** align: the 64 alignment offsets (tp: the median); best and worst: the first offset with the minimum, the maximum; offset: this block's. */
|
|
442
|
+
alignment?: { min: number; median: number; max: number; best: number; worst: number; spread: number; offset: number } }[];
|
|
353
443
|
/** With accumulator variants: the best N (the smallest within 1% of the fastest; 1 = as it is) and its tp. */
|
|
354
444
|
accumulators?: { best: number; tp: number };
|
|
445
|
+
/** From the API server: its time limit for the whole request ("deadline") ran out, or it was busy, after the base:
|
|
446
|
+
* the variants without a result have error "not run: <notRun>" (align: with how many offsets were analyzed). */
|
|
447
|
+
notRun?: string;
|
|
355
448
|
}
|
|
356
449
|
|
|
357
450
|
/** The CLI's `-json -whatif`: one WhatIfResult per CPU, keyed by its id, with one CPU as with several. With `-per N`,
|
|
358
451
|
* each has elementsPerIteration (N) and perElement (tp / N), and each variant with a tp its perElement. */
|
|
359
|
-
export type CliWhatIf = Record<string,
|
|
452
|
+
export type CliWhatIf = Record<string, WhatIfPerElement | Failure>;
|
|
453
|
+
/** A what-if result; with `per`, elementsPerIteration and perElement (tp / per), and each variant with a tp its perElement. */
|
|
454
|
+
export type WhatIfPerElement = WhatIfResult & { elementsPerIteration?: number; perElement?: number; variants: (WhatIfResult['variants'][number] & { perElement?: number })[] };
|
|
455
|
+
/** The request of Wuica.diff: two blocks (each as analyze's request), `options` for both (unless a block has its own),
|
|
456
|
+
* `per` elements per iteration (N for both, or [A, B]). */
|
|
457
|
+
export interface DiffRequest { a: AnalyzeRequest; b: AnalyzeRequest; options?: AnalysisOptions; per?: number | [number, number] }
|
|
458
|
+
/** One side of a DiffResult: as analyze gives it; perElement = tp / per (unrounded, as compare's and what-if's). */
|
|
459
|
+
export interface DiffSide { tp: number; mode: 'loop' | 'unroll'; bottlenecks: string[]; decodeErrors: number; unsupported?: string; perElement?: number; loop?: LoopInfo; stderr?: StderrLine[] }
|
|
460
|
+
/** The result of Wuica.diff. tp and limits as analyze gives them; delta (B − A, 0 when the same within 0.25 %) and
|
|
461
|
+
* speedup (A / B) rounded to two decimals; perElement's a, b and delta unrounded; uop changes rounded to two decimals.
|
|
462
|
+
* Both blocks must be analyzed the same way (both loops, or both unrolled): else a Failure "not comparable". */
|
|
463
|
+
export interface DiffResult {
|
|
464
|
+
code: 0;
|
|
465
|
+
arch: string;
|
|
466
|
+
a: DiffSide;
|
|
467
|
+
b: DiffSide;
|
|
468
|
+
/** Not when a side's CPU cannot run its code (a side with `unsupported`): the verdict is then "not comparable". */
|
|
469
|
+
delta?: number;
|
|
470
|
+
speedup?: number | null;
|
|
471
|
+
verdict: 'better' | 'worse' | 'same' | 'not comparable';
|
|
472
|
+
perElement?: { a: number; b: number; delta?: number; speedup?: number | null; verdict: 'better' | 'worse' | 'same' | 'not comparable' };
|
|
473
|
+
/** The warnings of both sides (decode errors, assembler warnings), each starting with "A: " or "B: ". */
|
|
474
|
+
stderr?: StderrLine[];
|
|
475
|
+
bottlenecks: { a: string[]; b: string[]; gone: string[]; new: string[] };
|
|
476
|
+
limits: { name: string; a: number | null; b: number | null; delta: number | null }[];
|
|
477
|
+
/** uops per iteration of each execution port (both sides' ports; [] if they differ). */
|
|
478
|
+
ports: { port: string; a: number; b: number; delta: number }[];
|
|
479
|
+
/** The instructions aligned as a diff: changed (same instruction, other uops), modified (other operands), added (only
|
|
480
|
+
* in B), removed (only in A); `uops`: the change of the issued uops and of each port's, where not 0; `minor`: a change
|
|
481
|
+
* of uops under 0.05 per iteration in every column (left out of the Markdown and the text). */
|
|
482
|
+
instructions: { counts: Record<'same' | 'changed' | 'modified' | 'added' | 'removed', number>; changes: { status: 'changed' | 'modified' | 'added' | 'removed'; a: string | null; b: string | null; uops: Record<string, number>; minor?: true }[] };
|
|
483
|
+
}
|
|
484
|
+
/** Wuica.diff with any w that has analyze. */
|
|
485
|
+
export function diffRequest(w: Pick<Wuica, 'analyze'>, arch: string, request: DiffRequest): Promise<DiffResult | Failure>;
|
|
486
|
+
/** The two analyses and the result (for diffMarkdown), or the failure. */
|
|
487
|
+
export function diffAnalyses(w: Pick<Wuica, 'analyze'>, arch: string, request: DiffRequest): Promise<{ result: DiffResult; a: AnalyzeResult; b: AnalyzeResult; per: [number, number] | null; sourceA: string | null; sourceB: string | null } | { failure: Failure }>;
|
|
488
|
+
/** The result from two analyze() responses. */
|
|
489
|
+
export function diffResult(a: AnalyzeResult, b: AnalyzeResult, options?: { per?: [number, number] | null; sourceA?: string | null; sourceB?: string | null }): DiffResult | Failure;
|
|
490
|
+
/** Markdown of diffAnalyses' result (the page's A–B tables; markdown.compare), naming the microarchitecture (archTitle, else its id), with the warnings. */
|
|
491
|
+
export function diffMarkdown(x: Awaited<ReturnType<typeof diffAnalyses>>, options?: { archTitle?: string }): string;
|
|
492
|
+
/** The result as text (wuica diff; REST text/plain). */
|
|
493
|
+
export function diffText(result: DiffResult | Failure): string;
|
|
494
|
+
/** The request of Wuica.whatIf, the MCP tool what_if and POST /api/what-if/<arch>. */
|
|
495
|
+
export type WhatIfRequest = AnalyzeRequest & { variants?: readonly WhatIfVariant[]; per?: number };
|
|
496
|
+
/** whatIf with a request as the interfaces take it (`variants`, `per`), with w's analyze and assemble. */
|
|
497
|
+
export function whatIfRequest(w: Pick<Wuica, 'analyze' | 'assemble'>, arch: string, request: WhatIfRequest): Promise<WhatIfPerElement | Failure>;
|
|
498
|
+
/** A what-if result per element (`per` elements per iteration); unchanged without `per` or for a failure. */
|
|
499
|
+
export function whatIfPerElement(result: WhatIfResult | Failure, per?: number): WhatIfPerElement | Failure;
|
|
500
|
+
/** The what-if table as the CLI prints it (-whatif; REST text/plain). */
|
|
501
|
+
export function whatIfText(result: WhatIfPerElement | Failure): string;
|
|
360
502
|
/** The CLI's `-json` with one CPU: the analyze result with insights (caveats in insights.caveats), perElement (-per)
|
|
361
503
|
* and whatIf (-whatif). */
|
|
362
504
|
export type CliAnalyzeJson = AnalyzeResult & { insights?: Insights; perElement?: number; whatIf?: CliWhatIf };
|
|
@@ -365,8 +507,58 @@ export type CliAnalyzeJson = AnalyzeResult & { insights?: Insights; perElement?:
|
|
|
365
507
|
export type CliCompareJson = CompareResult & { results: (CompareResult['results'][number] & { perElement?: number; caveats?: Caveat[] })[]; whatIf?: CliWhatIf };
|
|
366
508
|
/** The CLI's `--version -json`: the package's version and the uiCA reference whose data and model it has (from the
|
|
367
509
|
* repository's ci/data-asset.txt at build time; null if the package was not built). */
|
|
510
|
+
/** The CLI's `-json` with several inputs (wuica a.s b.s ..., -files LIST): `code` is the largest of the files' codes
|
|
511
|
+
* (the exit status); each entry is what a single run prints for that file (CliAnalyzeJson, CliCompareJson, a Failure,
|
|
512
|
+
* or with -loops {code, loops}), with the file's name as given. */
|
|
513
|
+
export interface CliBatchJson { code: number; files: ({ file: string } & (CliAnalyzeJson | CliCompareJson | Failure | { code: 0; loops: LoopListing[] }))[] }
|
|
368
514
|
export interface CliVersionJson { wuica: string; uiCA: { repository: string; commit: string; branch?: string } | null; node: string }
|
|
369
515
|
/** The what-if experiments of the web page (the MCP tool `what_if`), with `analyze` (e.g. a Wuica's analyze, bound) and,
|
|
370
516
|
* for the accumulator variants, `assemble` (e.g. a Wuica's assemble, bound). */
|
|
371
517
|
export function whatIf(analyze: (arch: string, request: AnalyzeRequest) => Promise<AnalyzeResult | Failure>, arch: string, request: AnalyzeRequest, variants?: readonly WhatIfVariant[],
|
|
372
518
|
tools?: { assemble?: (text: string) => Promise<AssembleResult | Failure> }): Promise<WhatIfResult | Failure>;
|
|
519
|
+
/** Results as GitHub-flavoured Markdown (the page's copy controls and `wuica -md`; lib/web/markdown.js): deterministic
|
|
520
|
+
* text, columns padded for a monospace font, pipes and backticks escaped, numbers as the CLI prints them. Every
|
|
521
|
+
* generator returns text that ends with one newline. */
|
|
522
|
+
/** Where the Markdown's branch targets come from (branch-label.js): the labels per row as shown, the analyzed lines of
|
|
523
|
+
* the assembly ({text, from, to}), or the request's source text; else the offset in the block ("jnz 0x0"). */
|
|
524
|
+
export interface MarkdownLabels { shown?: (string | null)[] | null; src?: { text: string; from?: number; to?: number } | null; source?: string }
|
|
525
|
+
export namespace markdown {
|
|
526
|
+
/** The whole result: headline, limits, next limit, caveats ("not modelled"), critical chain, uop table, the code
|
|
527
|
+
* (meta.code) in a fenced block, a link (meta.link). A failure: its error and stderr lines. */
|
|
528
|
+
function report(result: AnalyzeResult | Failure, meta?: MarkdownLabels & { arch?: string; archTitle?: string; per?: number; insights?: Insights | null;
|
|
529
|
+
config?: { splitLoadCycles?: number } | null; code?: string; lang?: string; link?: string; title?: string }): string;
|
|
530
|
+
/** The headline alone (one line, no newline). */
|
|
531
|
+
function headline(result: AnalyzeResult, meta?: { arch?: string; archTitle?: string; per?: number }): string;
|
|
532
|
+
/** The uop table: every row, the used columns, the totals (no newline at the end). */
|
|
533
|
+
function uopTable(result: AnalyzeResult, meta?: MarkdownLabels): string;
|
|
534
|
+
/** Each row's instruction text with its branch target as a label. */
|
|
535
|
+
function shownLabels(result: AnalyzeResult, meta?: MarkdownLabels): string[];
|
|
536
|
+
/** Several CPUs, one row each (a compare result or its rows); or files x CPUs: [{file, result}]. */
|
|
537
|
+
function cpuTable(input: CompareResult | CliCompareJson | CompareResult['results'] | Failure | { file: string; result: CompareResult | AnalyzeResult | Failure }[],
|
|
538
|
+
options?: { per?: number }): string;
|
|
539
|
+
/** The what-if table of one CPU (per element with elementsPerIteration). */
|
|
540
|
+
function whatIf(result: (WhatIfResult & { elementsPerIteration?: number }) | (Failure & { arch?: string })): string;
|
|
541
|
+
/** whatIf's table, and the alignment line when the result has the variant align. */
|
|
542
|
+
function whatIfAlignment(result: (WhatIfResult & { elementsPerIteration?: number }) | (Failure & { arch?: string })): string;
|
|
543
|
+
/** The loops of assembly text (listLoops). */
|
|
544
|
+
function loops(list: LoopListing[]): string;
|
|
545
|
+
/** A against B (as the page's A–B view): summary, bottlenecks, limits, the aligned instructions with B − A per column;
|
|
546
|
+
* meta.cpus adds the A/B/Δ table per CPU. workA, workB: elements per iteration of each side (cycles per element). */
|
|
547
|
+
function compare(a: AnalyzeResult | Failure, b: AnalyzeResult | Failure, meta?: { workA?: number; workB?: number; archA?: string; archB?: string;
|
|
548
|
+
cpus?: { arch: string; a: number | null; b: number | null }[];
|
|
549
|
+
shownA?: (string | null)[]; srcA?: MarkdownLabels['src']; shownB?: (string | null)[]; srcB?: MarkdownLabels['src'] }): string;
|
|
550
|
+
/** The uop table as CSV (RFC 4180, CRLF). */
|
|
551
|
+
function toCSV(result: AnalyzeResult): string;
|
|
552
|
+
/** The request and the response as JSON (without trace and text). */
|
|
553
|
+
function toJSON(result: AnalyzeResult, request?: unknown): string;
|
|
554
|
+
/** Building blocks for further generators: a padded GFM table, a code span, escaped text, a fenced block. */
|
|
555
|
+
function table(head: string[], rows: string[][], align?: ('l' | 'r' | 'c')[]): string;
|
|
556
|
+
function code(text: string): string;
|
|
557
|
+
function text(s: unknown): string;
|
|
558
|
+
function fence(body: string, lang?: string): string;
|
|
559
|
+
/** A cycle count as the page shows it (two decimals; three significant digits below 0.1); with its sign. */
|
|
560
|
+
function cycles(v: number): string;
|
|
561
|
+
function signedCycles(v: number): string;
|
|
562
|
+
/** A uop-table value as uiCA prints it (up to two decimals, zero blank). */
|
|
563
|
+
function uopValue(v: number): string;
|
|
564
|
+
}
|