Skip to content

Commit ebcb2ee

Browse files
authored
Merge pull request #23 from VectorCamp/feature/endpoint_asm_syntax
asm, asm syntax view
2 parents f909ce3 + 56983ee commit ebcb2ee

7 files changed

Lines changed: 299 additions & 159 deletions

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,4 +60,7 @@ All notable changes to the "code.simd.ai" extension will be documented in this f
6060

6161
## 1.0.15
6262
- Simd.info endpoints
63+
64+
## 1.0.16
65+
- Added asm, asm syntax and example in the performance view
6366
---

code-simd-ai-1.0.15.vsix

-459 KB
Binary file not shown.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "code-simd-ai",
33
"displayName": "code.simd",
44
"description": "VScode plugin for porting of code between different cpu architectures",
5-
"version": "1.0.15",
5+
"version": "1.0.16",
66
"publisher": "VectorCamp",
77
"engines": {
88
"vscode": "^1.100.0"

src/api/tooltipFetcher.ts

Lines changed: 60 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,29 @@
1515
*/
1616

1717
import fetch from 'node-fetch';
18-
(globalThis as any).fetch = fetch;
18+
if (!(globalThis as any).fetch) {
19+
(globalThis as any).fetch = fetch;
20+
}
21+
1922

2023
import * as vscode from 'vscode';
2124
import { fetchIntrinsicInfo } from './simdAi';
2225
// process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0'; // Dev only — allow self-signed certs
26+
import { simdFullData } from '../intrinsicsCache';
27+
2328

2429
const tooltipCache: Record<string, vscode.MarkdownString> = {};
2530

31+
function normalizeProto(proto: any, archOrData: any) {
32+
return {
33+
...proto,
34+
asm: proto.asm || archOrData.asm || 'N/A',
35+
syntax: proto.syntax || archOrData.syntax || 'N/A',
36+
example: proto.example || archOrData.example || 'N/A',
37+
llvm_mca: proto.llvm_mca || proto.llvm_mca_neon || {},
38+
};
39+
}
40+
2641
export async function fetchTooltip(word: string): Promise<vscode.MarkdownString> {
2742
if (tooltipCache[word]) {return tooltipCache[word];}
2843

@@ -57,7 +72,8 @@ export async function fetchTooltip(word: string): Promise<vscode.MarkdownString>
5772
const line = `${proto.output || 'void'} result = ${proto.key}(${inputList});`;
5873
md.appendMarkdown('```c\n' + line + '\n```\n');
5974

60-
addViewPerformanceData(md, proto, simd);
75+
const normalizedProto = normalizeProto(proto, arch);
76+
addViewPerformanceData(md, normalizedProto, simd);
6177
}
6278
}
6379
}
@@ -83,10 +99,13 @@ export async function fetchTooltip(word: string): Promise<vscode.MarkdownString>
8399
const line = `${proto.output || 'void'} result = ${proto.key}(${inputList});`;
84100
md.appendMarkdown('```c\n' + line + '\n```\n');
85101

86-
addViewPerformanceData(md, proto, data.simd || data.engine);
102+
const normalizedProto = normalizeProto(proto, data);
103+
addViewPerformanceData(md, normalizedProto, data.simd || data.engine);
87104
}
88105
}
89106
}
107+
108+
90109

91110
tooltipCache[word] = md;
92111
return md;
@@ -138,7 +157,6 @@ export async function fetchDatatypeTooltip(name: string): Promise<string> {
138157
return '';
139158
}
140159
}
141-
142160
function addViewPerformanceData(
143161
md: vscode.MarkdownString,
144162
proto: any,
@@ -153,15 +171,46 @@ function addViewPerformanceData(
153171
typeof proto.syntax === 'string' && proto.syntax.trim().toLowerCase() === 'sequence';
154172

155173
if (hasGraphData) {
156-
const args = {
174+
const existing = simdFullData[proto.key];
175+
176+
const protoData = {
157177
key: proto.key,
158-
simd,
159-
llvm_mca: proto.llvm_mca,
160-
llvm_mca_neon: proto.llvm_mca_neon
178+
inputs: proto.inputs,
179+
output: proto.output,
180+
asm: proto.asm,
181+
syntax: proto.syntax,
182+
example: proto.example,
183+
llvm_mca: proto.llvm_mca || proto.llvm_mca_neon || {},
161184
};
162-
const encodedArgs = encodeURIComponent(JSON.stringify(args));
185+
186+
if (existing) {
187+
const sig = `${protoData.output}|${protoData.key}|${(protoData.inputs || []).join(',')}`;
188+
const exists = existing.prototypes.some(p =>
189+
`${p.output}|${p.key}|${(p.inputs || []).join(',')}` === sig
190+
);
191+
if (!exists) {
192+
existing.prototypes.push(protoData);
193+
}
194+
} else {
195+
const cleanTooltip = md.value.replace(
196+
/\* \[Show Latency\/Throughput\][^\n]*\n?/g,
197+
''
198+
);
199+
200+
simdFullData[proto.key] = {
201+
key: proto.key,
202+
simd,
203+
llvm_mca: proto.llvm_mca,
204+
llvm_mca_neon: proto.llvm_mca_neon,
205+
tooltip: cleanTooltip,
206+
prototypes: [protoData],
207+
};
208+
}
209+
210+
const commandUri = `command:code.simd.ai.showPerformanceGraph?${encodeURIComponent(JSON.stringify([proto.key]))}`;
211+
163212
md.appendMarkdown(
164-
`\n*→ [Show Latency/Throughput](command:code.simd.ai.showPerformanceGraph?${encodedArgs})*\n`
213+
`\n*→ [Show Latency/Throughput](${commandUri})*\n`
165214
);
166215
} else if (isSequence) {
167216
md.appendMarkdown(
@@ -172,4 +221,4 @@ function addViewPerformanceData(
172221
`\n*Latency/Throughput data unavailable for this intrinsic.*\n`
173222
);
174223
}
175-
}
224+
}

src/intrinsicsCache.ts

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,25 @@ export async function getIntrinsics(): Promise<string[]> {
1212
}
1313
}
1414
return intrinsics;
15-
}
15+
}
16+
17+
export interface SimdPrototype {
18+
key: string;
19+
inputs?: string[];
20+
output?: string;
21+
asm?: string;
22+
syntax?: string;
23+
example?: string;
24+
llvm_mca?: any;
25+
}
26+
27+
export interface SimdFullEntry {
28+
key: string;
29+
simd?: string;
30+
llvm_mca?: any;
31+
llvm_mca_neon?: any;
32+
tooltip: string;
33+
prototypes: SimdPrototype[];
34+
}
35+
36+
export const simdFullData: Record<string, SimdFullEntry> = {};

0 commit comments

Comments
 (0)