Library Test
Reset
Run
HTML (editable)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
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
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>GEMMStore Library Test</title> <style> body { font-family: monospace; padding: 20px; } pre { background: #f5f5f5; padding: 15px; white-space: pre-wrap; } </style> <script type="importmap"> {"imports":{"gemmstore":"/api/generate-library?download=true"}} </script> </head> <body> <pre id="output">Running...</pre> <script type="module"> import gemmstore from 'gemmstore'; const output = document.getElementById('output'); const M = 1024, N = 1024, K = 1024; const warmups = 16; const performanceIterations = 128; try { const gsh = await gemmstore.gsInit(); if (!gsh.hasTimestampQuery) { output.textContent = "Error: GPU timestamp queries not supported"; throw new Error("No timestamp query"); } const tuning = gemmstore.gsGetTuning(gsh.device_id, M, N, K, "f32"); const tuningStr = tuning ? Object.entries(tuning).filter(([k]) => k !== "kernel").map(([k,v]) => k + ": " + v).join(", ") : "default"; const d_A = gemmstore.gsAlloc(gsh, M * K * 4); const d_B = gemmstore.gsAlloc(gsh, K * N * 4); const d_C = gemmstore.gsAlloc(gsh, M * N * 4, "output"); gemmstore.gsWrite(gsh, d_A, new Float32Array(M * K).fill(1.0)); gemmstore.gsWrite(gsh, d_B, new Float32Array(K * N).fill(1.0)); const result = await gemmstore.gsRunGEMM(gsh, performanceIterations, d_A, d_B, d_C, M, N, K, "f32"); let log = "Device: " + gsh.device_id + " (" + gsh.deviceName + ")\n"; log += "input size: " + M + "x" + N + "x" + K + "\n"; log += "tuning parameters: " + tuningStr + "\n"; log += "warmups: " + warmups + "\n"; log += "performance iterations: " + performanceIterations + "\n"; log += "average time (ms): " + result.avg.toFixed(3) + "\n"; log += "GFLOPs: " + result.gflops.toFixed(2) + "\n"; log += "\nDone!"; output.textContent = log; gemmstore.gsFree(d_A); gemmstore.gsFree(d_B); gemmstore.gsFree(d_C); gemmstore.gsDestroy(gsh); } catch (e) { output.textContent = "Error: " + (e && e.message ? e.message : String(e)); } </script> </body> </html>
Output