webgpu-bench 0.1.0

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 (183) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +120 -0
  3. package/dist/benchmarks/common.d.ts +71 -0
  4. package/dist/benchmarks/common.d.ts.map +1 -0
  5. package/dist/benchmarks/common.js +104 -0
  6. package/dist/benchmarks/common.js.map +1 -0
  7. package/dist/benchmarks/flopsCommon.d.ts +52 -0
  8. package/dist/benchmarks/flopsCommon.d.ts.map +1 -0
  9. package/dist/benchmarks/flopsCommon.js +78 -0
  10. package/dist/benchmarks/flopsCommon.js.map +1 -0
  11. package/dist/benchmarks/flopsConvert.d.ts +18 -0
  12. package/dist/benchmarks/flopsConvert.d.ts.map +1 -0
  13. package/dist/benchmarks/flopsConvert.js +61 -0
  14. package/dist/benchmarks/flopsConvert.js.map +1 -0
  15. package/dist/benchmarks/flopsF16.d.ts +12 -0
  16. package/dist/benchmarks/flopsF16.d.ts.map +1 -0
  17. package/dist/benchmarks/flopsF16.js +54 -0
  18. package/dist/benchmarks/flopsF16.js.map +1 -0
  19. package/dist/benchmarks/flopsF32.d.ts +12 -0
  20. package/dist/benchmarks/flopsF32.d.ts.map +1 -0
  21. package/dist/benchmarks/flopsF32.js +50 -0
  22. package/dist/benchmarks/flopsF32.js.map +1 -0
  23. package/dist/benchmarks/flopsI8.d.ts +16 -0
  24. package/dist/benchmarks/flopsI8.d.ts.map +1 -0
  25. package/dist/benchmarks/flopsI8.js +83 -0
  26. package/dist/benchmarks/flopsI8.js.map +1 -0
  27. package/dist/benchmarks/flopsMath.d.ts +28 -0
  28. package/dist/benchmarks/flopsMath.d.ts.map +1 -0
  29. package/dist/benchmarks/flopsMath.js +98 -0
  30. package/dist/benchmarks/flopsMath.js.map +1 -0
  31. package/dist/benchmarks/streamBandwidth.d.ts +17 -0
  32. package/dist/benchmarks/streamBandwidth.d.ts.map +1 -0
  33. package/dist/benchmarks/streamBandwidth.js +78 -0
  34. package/dist/benchmarks/streamBandwidth.js.map +1 -0
  35. package/dist/data/generate.d.ts +23 -0
  36. package/dist/data/generate.d.ts.map +1 -0
  37. package/dist/data/generate.js +41 -0
  38. package/dist/data/generate.js.map +1 -0
  39. package/dist/gpu/benchmarkRunner.d.ts +98 -0
  40. package/dist/gpu/benchmarkRunner.d.ts.map +1 -0
  41. package/dist/gpu/benchmarkRunner.js +178 -0
  42. package/dist/gpu/benchmarkRunner.js.map +1 -0
  43. package/dist/gpu/buffers.d.ts +8 -0
  44. package/dist/gpu/buffers.d.ts.map +1 -0
  45. package/dist/gpu/buffers.js +41 -0
  46. package/dist/gpu/buffers.js.map +1 -0
  47. package/dist/gpu/context.d.ts +16 -0
  48. package/dist/gpu/context.d.ts.map +1 -0
  49. package/dist/gpu/context.js +71 -0
  50. package/dist/gpu/context.js.map +1 -0
  51. package/dist/gpu/timing.d.ts +20 -0
  52. package/dist/gpu/timing.d.ts.map +1 -0
  53. package/dist/gpu/timing.js +55 -0
  54. package/dist/gpu/timing.js.map +1 -0
  55. package/dist/index.d.ts +12 -0
  56. package/dist/index.d.ts.map +1 -0
  57. package/dist/index.js +7 -0
  58. package/dist/index.js.map +1 -0
  59. package/dist/sampling.d.ts +96 -0
  60. package/dist/sampling.d.ts.map +1 -0
  61. package/dist/sampling.js +239 -0
  62. package/dist/sampling.js.map +1 -0
  63. package/dist/shaders/flopsF16Mat4.d.ts +7 -0
  64. package/dist/shaders/flopsF16Mat4.d.ts.map +1 -0
  65. package/dist/shaders/flopsF16Mat4.js +40 -0
  66. package/dist/shaders/flopsF16Mat4.js.map +1 -0
  67. package/dist/shaders/flopsF16Matvec.d.ts +14 -0
  68. package/dist/shaders/flopsF16Matvec.d.ts.map +1 -0
  69. package/dist/shaders/flopsF16Matvec.js +58 -0
  70. package/dist/shaders/flopsF16Matvec.js.map +1 -0
  71. package/dist/shaders/flopsF16Scalar.d.ts +8 -0
  72. package/dist/shaders/flopsF16Scalar.d.ts.map +1 -0
  73. package/dist/shaders/flopsF16Scalar.js +71 -0
  74. package/dist/shaders/flopsF16Scalar.js.map +1 -0
  75. package/dist/shaders/flopsF16Vec4.d.ts +7 -0
  76. package/dist/shaders/flopsF16Vec4.d.ts.map +1 -0
  77. package/dist/shaders/flopsF16Vec4.js +35 -0
  78. package/dist/shaders/flopsF16Vec4.js.map +1 -0
  79. package/dist/shaders/flopsF32Div.d.ts +10 -0
  80. package/dist/shaders/flopsF32Div.d.ts.map +1 -0
  81. package/dist/shaders/flopsF32Div.js +71 -0
  82. package/dist/shaders/flopsF32Div.js.map +1 -0
  83. package/dist/shaders/flopsF32F16Convert.d.ts +11 -0
  84. package/dist/shaders/flopsF32F16Convert.d.ts.map +1 -0
  85. package/dist/shaders/flopsF32F16Convert.js +73 -0
  86. package/dist/shaders/flopsF32F16Convert.js.map +1 -0
  87. package/dist/shaders/flopsF32Log.d.ts +11 -0
  88. package/dist/shaders/flopsF32Log.d.ts.map +1 -0
  89. package/dist/shaders/flopsF32Log.js +71 -0
  90. package/dist/shaders/flopsF32Log.js.map +1 -0
  91. package/dist/shaders/flopsF32Mat4.d.ts +9 -0
  92. package/dist/shaders/flopsF32Mat4.d.ts.map +1 -0
  93. package/dist/shaders/flopsF32Mat4.js +38 -0
  94. package/dist/shaders/flopsF32Mat4.js.map +1 -0
  95. package/dist/shaders/flopsF32Matvec.d.ts +14 -0
  96. package/dist/shaders/flopsF32Matvec.d.ts.map +1 -0
  97. package/dist/shaders/flopsF32Matvec.js +58 -0
  98. package/dist/shaders/flopsF32Matvec.js.map +1 -0
  99. package/dist/shaders/flopsF32Pow.d.ts +10 -0
  100. package/dist/shaders/flopsF32Pow.d.ts.map +1 -0
  101. package/dist/shaders/flopsF32Pow.js +71 -0
  102. package/dist/shaders/flopsF32Pow.js.map +1 -0
  103. package/dist/shaders/flopsF32Rsqrt.d.ts +12 -0
  104. package/dist/shaders/flopsF32Rsqrt.d.ts.map +1 -0
  105. package/dist/shaders/flopsF32Rsqrt.js +72 -0
  106. package/dist/shaders/flopsF32Rsqrt.js.map +1 -0
  107. package/dist/shaders/flopsF32Scalar.d.ts +11 -0
  108. package/dist/shaders/flopsF32Scalar.d.ts.map +1 -0
  109. package/dist/shaders/flopsF32Scalar.js +72 -0
  110. package/dist/shaders/flopsF32Scalar.js.map +1 -0
  111. package/dist/shaders/flopsF32Sincos.d.ts +9 -0
  112. package/dist/shaders/flopsF32Sincos.d.ts.map +1 -0
  113. package/dist/shaders/flopsF32Sincos.js +68 -0
  114. package/dist/shaders/flopsF32Sincos.js.map +1 -0
  115. package/dist/shaders/flopsF32Sqrt.d.ts +9 -0
  116. package/dist/shaders/flopsF32Sqrt.d.ts.map +1 -0
  117. package/dist/shaders/flopsF32Sqrt.js +69 -0
  118. package/dist/shaders/flopsF32Sqrt.js.map +1 -0
  119. package/dist/shaders/flopsF32Vec4.d.ts +9 -0
  120. package/dist/shaders/flopsF32Vec4.d.ts.map +1 -0
  121. package/dist/shaders/flopsF32Vec4.js +33 -0
  122. package/dist/shaders/flopsF32Vec4.js.map +1 -0
  123. package/dist/shaders/flopsI32Div.d.ts +10 -0
  124. package/dist/shaders/flopsI32Div.d.ts.map +1 -0
  125. package/dist/shaders/flopsI32Div.js +71 -0
  126. package/dist/shaders/flopsI32Div.js.map +1 -0
  127. package/dist/shaders/flopsI32F16Convert.d.ts +10 -0
  128. package/dist/shaders/flopsI32F16Convert.d.ts.map +1 -0
  129. package/dist/shaders/flopsI32F16Convert.js +71 -0
  130. package/dist/shaders/flopsI32F16Convert.js.map +1 -0
  131. package/dist/shaders/flopsI32F32Convert.d.ts +10 -0
  132. package/dist/shaders/flopsI32F32Convert.d.ts.map +1 -0
  133. package/dist/shaders/flopsI32F32Convert.js +71 -0
  134. package/dist/shaders/flopsI32F32Convert.js.map +1 -0
  135. package/dist/shaders/flopsI8Dp4a.d.ts +23 -0
  136. package/dist/shaders/flopsI8Dp4a.d.ts.map +1 -0
  137. package/dist/shaders/flopsI8Dp4a.js +49 -0
  138. package/dist/shaders/flopsI8Dp4a.js.map +1 -0
  139. package/dist/shaders/flopsI8Mat4.d.ts +9 -0
  140. package/dist/shaders/flopsI8Mat4.d.ts.map +1 -0
  141. package/dist/shaders/flopsI8Mat4.js +41 -0
  142. package/dist/shaders/flopsI8Mat4.js.map +1 -0
  143. package/dist/shaders/flopsI8Matvec.d.ts +16 -0
  144. package/dist/shaders/flopsI8Matvec.d.ts.map +1 -0
  145. package/dist/shaders/flopsI8Matvec.js +57 -0
  146. package/dist/shaders/flopsI8Matvec.js.map +1 -0
  147. package/dist/shaders/flopsI8MatvecDp4a.d.ts +17 -0
  148. package/dist/shaders/flopsI8MatvecDp4a.d.ts.map +1 -0
  149. package/dist/shaders/flopsI8MatvecDp4a.js +60 -0
  150. package/dist/shaders/flopsI8MatvecDp4a.js.map +1 -0
  151. package/dist/shaders/flopsI8Scalar.d.ts +9 -0
  152. package/dist/shaders/flopsI8Scalar.d.ts.map +1 -0
  153. package/dist/shaders/flopsI8Scalar.js +70 -0
  154. package/dist/shaders/flopsI8Scalar.js.map +1 -0
  155. package/dist/shaders/flopsI8Vec4.d.ts +7 -0
  156. package/dist/shaders/flopsI8Vec4.d.ts.map +1 -0
  157. package/dist/shaders/flopsI8Vec4.js +31 -0
  158. package/dist/shaders/flopsI8Vec4.js.map +1 -0
  159. package/dist/shaders/flopsU32PackUnpack.d.ts +11 -0
  160. package/dist/shaders/flopsU32PackUnpack.d.ts.map +1 -0
  161. package/dist/shaders/flopsU32PackUnpack.js +55 -0
  162. package/dist/shaders/flopsU32PackUnpack.js.map +1 -0
  163. package/dist/shaders/streamRead.d.ts +10 -0
  164. package/dist/shaders/streamRead.d.ts.map +1 -0
  165. package/dist/shaders/streamRead.js +33 -0
  166. package/dist/shaders/streamRead.js.map +1 -0
  167. package/dist/shaders/streamWrite.d.ts +8 -0
  168. package/dist/shaders/streamWrite.d.ts.map +1 -0
  169. package/dist/shaders/streamWrite.js +29 -0
  170. package/dist/shaders/streamWrite.js.map +1 -0
  171. package/dist/stats.d.ts +31 -0
  172. package/dist/stats.d.ts.map +1 -0
  173. package/dist/stats.js +67 -0
  174. package/dist/stats.js.map +1 -0
  175. package/dist/suite.d.ts +25 -0
  176. package/dist/suite.d.ts.map +1 -0
  177. package/dist/suite.js +196 -0
  178. package/dist/suite.js.map +1 -0
  179. package/dist/types.d.ts +171 -0
  180. package/dist/types.d.ts.map +1 -0
  181. package/dist/types.js +2 -0
  182. package/dist/types.js.map +1 -0
  183. package/package.json +45 -0
@@ -0,0 +1,72 @@
1
+ /**
2
+ * Raw fp32 FLOPS probe. Eight *independent* scalar FMA chains per thread,
3
+ * with the loop body unrolled 4x, so the ALU always has work in flight:
4
+ * a single dependent chain would measure FMA latency (plus loop overhead)
5
+ * rather than throughput. `a`/`b`/the trip count are runtime values, and
6
+ * every chain starts from a different value so the compiler can't merge
7
+ * them. One tiny write per thread at the end; everything else is pure ALU.
8
+ * 8 chains x 4 unrolled steps = 32 FMAs (64 FLOPs) per loop iteration.
9
+ */
10
+ export const flopsF32ScalarWgsl = /* wgsl */ `
11
+ struct Params {
12
+ threads: u32,
13
+ iterations: u32,
14
+ };
15
+
16
+ @group(0) @binding(0) var<uniform> params: Params;
17
+ @group(0) @binding(1) var<storage, read_write> out: array<f32>;
18
+
19
+ @compute @workgroup_size(64)
20
+ fn main(@builtin(global_invocation_id) gid: vec3<u32>) {
21
+ let idx = gid.x;
22
+ if (idx >= params.threads) {
23
+ return;
24
+ }
25
+ let a: f32 = 1.0 - f32(idx & 15u) * 0.001;
26
+ let b: f32 = 0.5 + f32(idx & 7u) * 0.001;
27
+ var x0: f32 = f32(idx & 255u) * 0.0001 + 0.01;
28
+ var x1: f32 = f32(idx & 255u) * 0.0001 + 0.02;
29
+ var x2: f32 = f32(idx & 255u) * 0.0001 + 0.03;
30
+ var x3: f32 = f32(idx & 255u) * 0.0001 + 0.04;
31
+ var x4: f32 = f32(idx & 255u) * 0.0001 + 0.05;
32
+ var x5: f32 = f32(idx & 255u) * 0.0001 + 0.06;
33
+ var x6: f32 = f32(idx & 255u) * 0.0001 + 0.07;
34
+ var x7: f32 = f32(idx & 255u) * 0.0001 + 0.08;
35
+ for (var i: u32 = 0u; i < params.iterations; i = i + 1u) {
36
+ x0 = x0 * a + b;
37
+ x1 = x1 * a + b;
38
+ x2 = x2 * a + b;
39
+ x3 = x3 * a + b;
40
+ x4 = x4 * a + b;
41
+ x5 = x5 * a + b;
42
+ x6 = x6 * a + b;
43
+ x7 = x7 * a + b;
44
+ x0 = x0 * a + b;
45
+ x1 = x1 * a + b;
46
+ x2 = x2 * a + b;
47
+ x3 = x3 * a + b;
48
+ x4 = x4 * a + b;
49
+ x5 = x5 * a + b;
50
+ x6 = x6 * a + b;
51
+ x7 = x7 * a + b;
52
+ x0 = x0 * a + b;
53
+ x1 = x1 * a + b;
54
+ x2 = x2 * a + b;
55
+ x3 = x3 * a + b;
56
+ x4 = x4 * a + b;
57
+ x5 = x5 * a + b;
58
+ x6 = x6 * a + b;
59
+ x7 = x7 * a + b;
60
+ x0 = x0 * a + b;
61
+ x1 = x1 * a + b;
62
+ x2 = x2 * a + b;
63
+ x3 = x3 * a + b;
64
+ x4 = x4 * a + b;
65
+ x5 = x5 * a + b;
66
+ x6 = x6 * a + b;
67
+ x7 = x7 * a + b;
68
+ }
69
+ out[idx] = x0 + x1 + x2 + x3 + x4 + x5 + x6 + x7;
70
+ }
71
+ `;
72
+ //# sourceMappingURL=flopsF32Scalar.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"flopsF32Scalar.js","sourceRoot":"","sources":["../../src/shaders/flopsF32Scalar.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,UAAU,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA6D5C,CAAC"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * fp32 sin/cos FLOPS probe. Same shape as {@link flopsF32ScalarWgsl} but
3
+ * `x = cos(sin(x))` in place of the FMA: sin then cos, both naturally
4
+ * bounded to [-1, 1] so the chain needs no extra stabilization. 64 ops (32
5
+ * sins + 32 coss) per loop iteration, same MAC-as-2 convention as the
6
+ * multiply version.
7
+ */
8
+ export declare const flopsF32SincosWgsl = "\nstruct Params {\n threads: u32,\n iterations: u32,\n};\n\n@group(0) @binding(0) var<uniform> params: Params;\n@group(0) @binding(1) var<storage, read_write> out: array<f32>;\n\n@compute @workgroup_size(64)\nfn main(@builtin(global_invocation_id) gid: vec3<u32>) {\n let idx = gid.x;\n if (idx >= params.threads) {\n return;\n }\n var x0: f32 = f32(idx & 255u) * 0.01 + 0.1;\n var x1: f32 = f32(idx & 255u) * 0.01 + 0.2;\n var x2: f32 = f32(idx & 255u) * 0.01 + 0.3;\n var x3: f32 = f32(idx & 255u) * 0.01 + 0.4;\n var x4: f32 = f32(idx & 255u) * 0.01 + 0.5;\n var x5: f32 = f32(idx & 255u) * 0.01 + 0.6;\n var x6: f32 = f32(idx & 255u) * 0.01 + 0.7;\n var x7: f32 = f32(idx & 255u) * 0.01 + 0.8;\n for (var i: u32 = 0u; i < params.iterations; i = i + 1u) {\n x0 = cos(sin(x0));\n x1 = cos(sin(x1));\n x2 = cos(sin(x2));\n x3 = cos(sin(x3));\n x4 = cos(sin(x4));\n x5 = cos(sin(x5));\n x6 = cos(sin(x6));\n x7 = cos(sin(x7));\n x0 = cos(sin(x0));\n x1 = cos(sin(x1));\n x2 = cos(sin(x2));\n x3 = cos(sin(x3));\n x4 = cos(sin(x4));\n x5 = cos(sin(x5));\n x6 = cos(sin(x6));\n x7 = cos(sin(x7));\n x0 = cos(sin(x0));\n x1 = cos(sin(x1));\n x2 = cos(sin(x2));\n x3 = cos(sin(x3));\n x4 = cos(sin(x4));\n x5 = cos(sin(x5));\n x6 = cos(sin(x6));\n x7 = cos(sin(x7));\n x0 = cos(sin(x0));\n x1 = cos(sin(x1));\n x2 = cos(sin(x2));\n x3 = cos(sin(x3));\n x4 = cos(sin(x4));\n x5 = cos(sin(x5));\n x6 = cos(sin(x6));\n x7 = cos(sin(x7));\n }\n out[idx] = x0 + x1 + x2 + x3 + x4 + x5 + x6 + x7;\n}\n";
9
+ //# sourceMappingURL=flopsF32Sincos.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"flopsF32Sincos.d.ts","sourceRoot":"","sources":["../../src/shaders/flopsF32Sincos.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,eAAO,MAAM,kBAAkB,2kDA2D9B,CAAC"}
@@ -0,0 +1,68 @@
1
+ /**
2
+ * fp32 sin/cos FLOPS probe. Same shape as {@link flopsF32ScalarWgsl} but
3
+ * `x = cos(sin(x))` in place of the FMA: sin then cos, both naturally
4
+ * bounded to [-1, 1] so the chain needs no extra stabilization. 64 ops (32
5
+ * sins + 32 coss) per loop iteration, same MAC-as-2 convention as the
6
+ * multiply version.
7
+ */
8
+ export const flopsF32SincosWgsl = /* wgsl */ `
9
+ struct Params {
10
+ threads: u32,
11
+ iterations: u32,
12
+ };
13
+
14
+ @group(0) @binding(0) var<uniform> params: Params;
15
+ @group(0) @binding(1) var<storage, read_write> out: array<f32>;
16
+
17
+ @compute @workgroup_size(64)
18
+ fn main(@builtin(global_invocation_id) gid: vec3<u32>) {
19
+ let idx = gid.x;
20
+ if (idx >= params.threads) {
21
+ return;
22
+ }
23
+ var x0: f32 = f32(idx & 255u) * 0.01 + 0.1;
24
+ var x1: f32 = f32(idx & 255u) * 0.01 + 0.2;
25
+ var x2: f32 = f32(idx & 255u) * 0.01 + 0.3;
26
+ var x3: f32 = f32(idx & 255u) * 0.01 + 0.4;
27
+ var x4: f32 = f32(idx & 255u) * 0.01 + 0.5;
28
+ var x5: f32 = f32(idx & 255u) * 0.01 + 0.6;
29
+ var x6: f32 = f32(idx & 255u) * 0.01 + 0.7;
30
+ var x7: f32 = f32(idx & 255u) * 0.01 + 0.8;
31
+ for (var i: u32 = 0u; i < params.iterations; i = i + 1u) {
32
+ x0 = cos(sin(x0));
33
+ x1 = cos(sin(x1));
34
+ x2 = cos(sin(x2));
35
+ x3 = cos(sin(x3));
36
+ x4 = cos(sin(x4));
37
+ x5 = cos(sin(x5));
38
+ x6 = cos(sin(x6));
39
+ x7 = cos(sin(x7));
40
+ x0 = cos(sin(x0));
41
+ x1 = cos(sin(x1));
42
+ x2 = cos(sin(x2));
43
+ x3 = cos(sin(x3));
44
+ x4 = cos(sin(x4));
45
+ x5 = cos(sin(x5));
46
+ x6 = cos(sin(x6));
47
+ x7 = cos(sin(x7));
48
+ x0 = cos(sin(x0));
49
+ x1 = cos(sin(x1));
50
+ x2 = cos(sin(x2));
51
+ x3 = cos(sin(x3));
52
+ x4 = cos(sin(x4));
53
+ x5 = cos(sin(x5));
54
+ x6 = cos(sin(x6));
55
+ x7 = cos(sin(x7));
56
+ x0 = cos(sin(x0));
57
+ x1 = cos(sin(x1));
58
+ x2 = cos(sin(x2));
59
+ x3 = cos(sin(x3));
60
+ x4 = cos(sin(x4));
61
+ x5 = cos(sin(x5));
62
+ x6 = cos(sin(x6));
63
+ x7 = cos(sin(x7));
64
+ }
65
+ out[idx] = x0 + x1 + x2 + x3 + x4 + x5 + x6 + x7;
66
+ }
67
+ `;
68
+ //# sourceMappingURL=flopsF32Sincos.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"flopsF32Sincos.js","sourceRoot":"","sources":["../../src/shaders/flopsF32Sincos.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,UAAU,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2D5C,CAAC"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * fp32 sqrt-add FLOPS probe. Same shape as {@link flopsF32ScalarWgsl} but
3
+ * `x = sqrt(x) + b` in place of the FMA: sqrt(x) for x > 1 is a contraction
4
+ * towards 1, so adding a positive `b` each step keeps the chain bounded and
5
+ * positive forever. 64 ops (32 sqrts + 32 adds) per loop iteration, same
6
+ * MAC-as-2 convention as the multiply version.
7
+ */
8
+ export declare const flopsF32SqrtWgsl = "\nstruct Params {\n threads: u32,\n iterations: u32,\n};\n\n@group(0) @binding(0) var<uniform> params: Params;\n@group(0) @binding(1) var<storage, read_write> out: array<f32>;\n\n@compute @workgroup_size(64)\nfn main(@builtin(global_invocation_id) gid: vec3<u32>) {\n let idx = gid.x;\n if (idx >= params.threads) {\n return;\n }\n let b: f32 = 0.5 + f32(idx & 7u) * 0.001;\n var x0: f32 = f32(idx & 255u) * 0.0001 + 0.01;\n var x1: f32 = f32(idx & 255u) * 0.0001 + 0.02;\n var x2: f32 = f32(idx & 255u) * 0.0001 + 0.03;\n var x3: f32 = f32(idx & 255u) * 0.0001 + 0.04;\n var x4: f32 = f32(idx & 255u) * 0.0001 + 0.05;\n var x5: f32 = f32(idx & 255u) * 0.0001 + 0.06;\n var x6: f32 = f32(idx & 255u) * 0.0001 + 0.07;\n var x7: f32 = f32(idx & 255u) * 0.0001 + 0.08;\n for (var i: u32 = 0u; i < params.iterations; i = i + 1u) {\n x0 = sqrt(x0) + b;\n x1 = sqrt(x1) + b;\n x2 = sqrt(x2) + b;\n x3 = sqrt(x3) + b;\n x4 = sqrt(x4) + b;\n x5 = sqrt(x5) + b;\n x6 = sqrt(x6) + b;\n x7 = sqrt(x7) + b;\n x0 = sqrt(x0) + b;\n x1 = sqrt(x1) + b;\n x2 = sqrt(x2) + b;\n x3 = sqrt(x3) + b;\n x4 = sqrt(x4) + b;\n x5 = sqrt(x5) + b;\n x6 = sqrt(x6) + b;\n x7 = sqrt(x7) + b;\n x0 = sqrt(x0) + b;\n x1 = sqrt(x1) + b;\n x2 = sqrt(x2) + b;\n x3 = sqrt(x3) + b;\n x4 = sqrt(x4) + b;\n x5 = sqrt(x5) + b;\n x6 = sqrt(x6) + b;\n x7 = sqrt(x7) + b;\n x0 = sqrt(x0) + b;\n x1 = sqrt(x1) + b;\n x2 = sqrt(x2) + b;\n x3 = sqrt(x3) + b;\n x4 = sqrt(x4) + b;\n x5 = sqrt(x5) + b;\n x6 = sqrt(x6) + b;\n x7 = sqrt(x7) + b;\n }\n out[idx] = x0 + x1 + x2 + x3 + x4 + x5 + x6 + x7;\n}\n";
9
+ //# sourceMappingURL=flopsF32Sqrt.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"flopsF32Sqrt.d.ts","sourceRoot":"","sources":["../../src/shaders/flopsF32Sqrt.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,eAAO,MAAM,gBAAgB,gpDA4D5B,CAAC"}
@@ -0,0 +1,69 @@
1
+ /**
2
+ * fp32 sqrt-add FLOPS probe. Same shape as {@link flopsF32ScalarWgsl} but
3
+ * `x = sqrt(x) + b` in place of the FMA: sqrt(x) for x > 1 is a contraction
4
+ * towards 1, so adding a positive `b` each step keeps the chain bounded and
5
+ * positive forever. 64 ops (32 sqrts + 32 adds) per loop iteration, same
6
+ * MAC-as-2 convention as the multiply version.
7
+ */
8
+ export const flopsF32SqrtWgsl = /* wgsl */ `
9
+ struct Params {
10
+ threads: u32,
11
+ iterations: u32,
12
+ };
13
+
14
+ @group(0) @binding(0) var<uniform> params: Params;
15
+ @group(0) @binding(1) var<storage, read_write> out: array<f32>;
16
+
17
+ @compute @workgroup_size(64)
18
+ fn main(@builtin(global_invocation_id) gid: vec3<u32>) {
19
+ let idx = gid.x;
20
+ if (idx >= params.threads) {
21
+ return;
22
+ }
23
+ let b: f32 = 0.5 + f32(idx & 7u) * 0.001;
24
+ var x0: f32 = f32(idx & 255u) * 0.0001 + 0.01;
25
+ var x1: f32 = f32(idx & 255u) * 0.0001 + 0.02;
26
+ var x2: f32 = f32(idx & 255u) * 0.0001 + 0.03;
27
+ var x3: f32 = f32(idx & 255u) * 0.0001 + 0.04;
28
+ var x4: f32 = f32(idx & 255u) * 0.0001 + 0.05;
29
+ var x5: f32 = f32(idx & 255u) * 0.0001 + 0.06;
30
+ var x6: f32 = f32(idx & 255u) * 0.0001 + 0.07;
31
+ var x7: f32 = f32(idx & 255u) * 0.0001 + 0.08;
32
+ for (var i: u32 = 0u; i < params.iterations; i = i + 1u) {
33
+ x0 = sqrt(x0) + b;
34
+ x1 = sqrt(x1) + b;
35
+ x2 = sqrt(x2) + b;
36
+ x3 = sqrt(x3) + b;
37
+ x4 = sqrt(x4) + b;
38
+ x5 = sqrt(x5) + b;
39
+ x6 = sqrt(x6) + b;
40
+ x7 = sqrt(x7) + b;
41
+ x0 = sqrt(x0) + b;
42
+ x1 = sqrt(x1) + b;
43
+ x2 = sqrt(x2) + b;
44
+ x3 = sqrt(x3) + b;
45
+ x4 = sqrt(x4) + b;
46
+ x5 = sqrt(x5) + b;
47
+ x6 = sqrt(x6) + b;
48
+ x7 = sqrt(x7) + b;
49
+ x0 = sqrt(x0) + b;
50
+ x1 = sqrt(x1) + b;
51
+ x2 = sqrt(x2) + b;
52
+ x3 = sqrt(x3) + b;
53
+ x4 = sqrt(x4) + b;
54
+ x5 = sqrt(x5) + b;
55
+ x6 = sqrt(x6) + b;
56
+ x7 = sqrt(x7) + b;
57
+ x0 = sqrt(x0) + b;
58
+ x1 = sqrt(x1) + b;
59
+ x2 = sqrt(x2) + b;
60
+ x3 = sqrt(x3) + b;
61
+ x4 = sqrt(x4) + b;
62
+ x5 = sqrt(x5) + b;
63
+ x6 = sqrt(x6) + b;
64
+ x7 = sqrt(x7) + b;
65
+ }
66
+ out[idx] = x0 + x1 + x2 + x3 + x4 + x5 + x6 + x7;
67
+ }
68
+ `;
69
+ //# sourceMappingURL=flopsF32Sqrt.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"flopsF32Sqrt.js","sourceRoot":"","sources":["../../src/shaders/flopsF32Sqrt.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,UAAU,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA4D1C,CAAC"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * fp32 vec4 FLOPS probe: a single FMA chain held in a `vec4<f32>` register.
3
+ * On scalar-SIMT GPUs (Apple, NVIDIA, AMD) this compiles to 4 independent
4
+ * scalar FMAs per step, so it measures 4-wide instruction-level parallelism
5
+ * rather than a wider ALU. Same runtime-derived operands/loop count as the
6
+ * scalar probe to defeat constant folding.
7
+ */
8
+ export declare const flopsF32Vec4Wgsl = "\nstruct Params {\n threads: u32,\n iterations: u32,\n};\n\n@group(0) @binding(0) var<uniform> params: Params;\n@group(0) @binding(1) var<storage, read_write> out: array<f32>;\n\n@compute @workgroup_size(64)\nfn main(@builtin(global_invocation_id) gid: vec3<u32>) {\n let idx = gid.x;\n if (idx >= params.threads) {\n return;\n }\n let s: f32 = f32(idx & 15u) * 0.001;\n let a: vec4<f32> = vec4<f32>(1.0 - s, 1.0 - 2.0 * s, 1.0 - 3.0 * s, 1.0 - 4.0 * s);\n let b: vec4<f32> = vec4<f32>(0.5 + s, 0.5 + 2.0 * s, 0.5 + 3.0 * s, 0.5 + 4.0 * s);\n var x: vec4<f32> = vec4<f32>(f32(idx & 255u) * 0.0001);\n for (var i: u32 = 0u; i < params.iterations; i = i + 1u) {\n x = x * a + b;\n }\n out[idx] = x.x + x.y + x.z + x.w;\n}\n";
9
+ //# sourceMappingURL=flopsF32Vec4.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"flopsF32Vec4.d.ts","sourceRoot":"","sources":["../../src/shaders/flopsF32Vec4.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,eAAO,MAAM,gBAAgB,wuBAwB5B,CAAC"}
@@ -0,0 +1,33 @@
1
+ /**
2
+ * fp32 vec4 FLOPS probe: a single FMA chain held in a `vec4<f32>` register.
3
+ * On scalar-SIMT GPUs (Apple, NVIDIA, AMD) this compiles to 4 independent
4
+ * scalar FMAs per step, so it measures 4-wide instruction-level parallelism
5
+ * rather than a wider ALU. Same runtime-derived operands/loop count as the
6
+ * scalar probe to defeat constant folding.
7
+ */
8
+ export const flopsF32Vec4Wgsl = /* wgsl */ `
9
+ struct Params {
10
+ threads: u32,
11
+ iterations: u32,
12
+ };
13
+
14
+ @group(0) @binding(0) var<uniform> params: Params;
15
+ @group(0) @binding(1) var<storage, read_write> out: array<f32>;
16
+
17
+ @compute @workgroup_size(64)
18
+ fn main(@builtin(global_invocation_id) gid: vec3<u32>) {
19
+ let idx = gid.x;
20
+ if (idx >= params.threads) {
21
+ return;
22
+ }
23
+ let s: f32 = f32(idx & 15u) * 0.001;
24
+ let a: vec4<f32> = vec4<f32>(1.0 - s, 1.0 - 2.0 * s, 1.0 - 3.0 * s, 1.0 - 4.0 * s);
25
+ let b: vec4<f32> = vec4<f32>(0.5 + s, 0.5 + 2.0 * s, 0.5 + 3.0 * s, 0.5 + 4.0 * s);
26
+ var x: vec4<f32> = vec4<f32>(f32(idx & 255u) * 0.0001);
27
+ for (var i: u32 = 0u; i < params.iterations; i = i + 1u) {
28
+ x = x * a + b;
29
+ }
30
+ out[idx] = x.x + x.y + x.z + x.w;
31
+ }
32
+ `;
33
+ //# sourceMappingURL=flopsF32Vec4.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"flopsF32Vec4.js","sourceRoot":"","sources":["../../src/shaders/flopsF32Vec4.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,UAAU,CAAC;;;;;;;;;;;;;;;;;;;;;;;;CAwB1C,CAAC"}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * i32 divide-add ops probe. Same shape as {@link flopsI8ScalarWgsl} (eight
3
+ * independent chains, unrolled 4x) but with the multiply replaced by integer
4
+ * division: `x = x / a + b`. `a` is always >= 2 so each step shrinks `x`
5
+ * (bounded, no overflow) and never divides by zero. 64 ops (32 divides + 32
6
+ * adds) per loop iteration, same MAC-as-2 convention as the other scalar
7
+ * probes.
8
+ */
9
+ export declare const flopsI32DivWgsl = "\nstruct Params {\n threads: u32,\n iterations: u32,\n};\n\n@group(0) @binding(0) var<uniform> params: Params;\n@group(0) @binding(1) var<storage, read_write> out: array<f32>;\n\n@compute @workgroup_size(64)\nfn main(@builtin(global_invocation_id) gid: vec3<u32>) {\n let idx = gid.x;\n if (idx >= params.threads) {\n return;\n }\n let a: i32 = 2 + i32(idx & 3u);\n let b: i32 = 5 + i32(idx & 7u);\n var x0: i32 = i32(idx & 255u) + 1000;\n var x1: i32 = i32(idx & 255u) + 2000;\n var x2: i32 = i32(idx & 255u) + 3000;\n var x3: i32 = i32(idx & 255u) + 4000;\n var x4: i32 = i32(idx & 255u) + 5000;\n var x5: i32 = i32(idx & 255u) + 6000;\n var x6: i32 = i32(idx & 255u) + 7000;\n var x7: i32 = i32(idx & 255u) + 8000;\n for (var i: u32 = 0u; i < params.iterations; i = i + 1u) {\n x0 = x0 / a + b;\n x1 = x1 / a + b;\n x2 = x2 / a + b;\n x3 = x3 / a + b;\n x4 = x4 / a + b;\n x5 = x5 / a + b;\n x6 = x6 / a + b;\n x7 = x7 / a + b;\n x0 = x0 / a + b;\n x1 = x1 / a + b;\n x2 = x2 / a + b;\n x3 = x3 / a + b;\n x4 = x4 / a + b;\n x5 = x5 / a + b;\n x6 = x6 / a + b;\n x7 = x7 / a + b;\n x0 = x0 / a + b;\n x1 = x1 / a + b;\n x2 = x2 / a + b;\n x3 = x3 / a + b;\n x4 = x4 / a + b;\n x5 = x5 / a + b;\n x6 = x6 / a + b;\n x7 = x7 / a + b;\n x0 = x0 / a + b;\n x1 = x1 / a + b;\n x2 = x2 / a + b;\n x3 = x3 / a + b;\n x4 = x4 / a + b;\n x5 = x5 / a + b;\n x6 = x6 / a + b;\n x7 = x7 / a + b;\n }\n out[idx] = f32(x0 + x1 + x2 + x3 + x4 + x5 + x6 + x7);\n}\n";
10
+ //# sourceMappingURL=flopsI32Div.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"flopsI32Div.d.ts","sourceRoot":"","sources":["../../src/shaders/flopsI32Div.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,eAAO,MAAM,eAAe,siDA6D3B,CAAC"}
@@ -0,0 +1,71 @@
1
+ /**
2
+ * i32 divide-add ops probe. Same shape as {@link flopsI8ScalarWgsl} (eight
3
+ * independent chains, unrolled 4x) but with the multiply replaced by integer
4
+ * division: `x = x / a + b`. `a` is always >= 2 so each step shrinks `x`
5
+ * (bounded, no overflow) and never divides by zero. 64 ops (32 divides + 32
6
+ * adds) per loop iteration, same MAC-as-2 convention as the other scalar
7
+ * probes.
8
+ */
9
+ export const flopsI32DivWgsl = /* wgsl */ `
10
+ struct Params {
11
+ threads: u32,
12
+ iterations: u32,
13
+ };
14
+
15
+ @group(0) @binding(0) var<uniform> params: Params;
16
+ @group(0) @binding(1) var<storage, read_write> out: array<f32>;
17
+
18
+ @compute @workgroup_size(64)
19
+ fn main(@builtin(global_invocation_id) gid: vec3<u32>) {
20
+ let idx = gid.x;
21
+ if (idx >= params.threads) {
22
+ return;
23
+ }
24
+ let a: i32 = 2 + i32(idx & 3u);
25
+ let b: i32 = 5 + i32(idx & 7u);
26
+ var x0: i32 = i32(idx & 255u) + 1000;
27
+ var x1: i32 = i32(idx & 255u) + 2000;
28
+ var x2: i32 = i32(idx & 255u) + 3000;
29
+ var x3: i32 = i32(idx & 255u) + 4000;
30
+ var x4: i32 = i32(idx & 255u) + 5000;
31
+ var x5: i32 = i32(idx & 255u) + 6000;
32
+ var x6: i32 = i32(idx & 255u) + 7000;
33
+ var x7: i32 = i32(idx & 255u) + 8000;
34
+ for (var i: u32 = 0u; i < params.iterations; i = i + 1u) {
35
+ x0 = x0 / a + b;
36
+ x1 = x1 / a + b;
37
+ x2 = x2 / a + b;
38
+ x3 = x3 / a + b;
39
+ x4 = x4 / a + b;
40
+ x5 = x5 / a + b;
41
+ x6 = x6 / a + b;
42
+ x7 = x7 / a + b;
43
+ x0 = x0 / a + b;
44
+ x1 = x1 / a + b;
45
+ x2 = x2 / a + b;
46
+ x3 = x3 / a + b;
47
+ x4 = x4 / a + b;
48
+ x5 = x5 / a + b;
49
+ x6 = x6 / a + b;
50
+ x7 = x7 / a + b;
51
+ x0 = x0 / a + b;
52
+ x1 = x1 / a + b;
53
+ x2 = x2 / a + b;
54
+ x3 = x3 / a + b;
55
+ x4 = x4 / a + b;
56
+ x5 = x5 / a + b;
57
+ x6 = x6 / a + b;
58
+ x7 = x7 / a + b;
59
+ x0 = x0 / a + b;
60
+ x1 = x1 / a + b;
61
+ x2 = x2 / a + b;
62
+ x3 = x3 / a + b;
63
+ x4 = x4 / a + b;
64
+ x5 = x5 / a + b;
65
+ x6 = x6 / a + b;
66
+ x7 = x7 / a + b;
67
+ }
68
+ out[idx] = f32(x0 + x1 + x2 + x3 + x4 + x5 + x6 + x7);
69
+ }
70
+ `;
71
+ //# sourceMappingURL=flopsI32Div.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"flopsI32Div.js","sourceRoot":"","sources":["../../src/shaders/flopsI32Div.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,UAAU,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA6DzC,CAAC"}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * i32<->fp16 round-trip FLOPS probe: `xi -> f32 -> pack2x16float ->
3
+ * unpack2x16float -> f32*a+b -> xi`. There's no native int<->f16 builtin, so
4
+ * this is what that conversion actually costs — chained through f32, like
5
+ * the real path. `a` < 1 keeps the round-tripped integer bounded. Eight
6
+ * independent i32 lanes, unrolled 4x; 6 ops/lane/step (f32-convert, pack,
7
+ * unpack, multiply, add, i32-convert). 192 ops per loop iteration.
8
+ */
9
+ export declare const flopsI32F16ConvertWgsl = "\nstruct Params {\n threads: u32,\n iterations: u32,\n};\n\n@group(0) @binding(0) var<uniform> params: Params;\n@group(0) @binding(1) var<storage, read_write> out: array<f32>;\n\n@compute @workgroup_size(64)\nfn main(@builtin(global_invocation_id) gid: vec3<u32>) {\n let idx = gid.x;\n if (idx >= params.threads) {\n return;\n }\n let a: f32 = 0.9 + f32(idx & 15u) * 0.005;\n let b: f32 = 3.0 + f32(idx & 7u) * 0.1;\n var x0: i32 = i32(idx & 255u) + 100;\n var x1: i32 = i32(idx & 255u) + 200;\n var x2: i32 = i32(idx & 255u) + 300;\n var x3: i32 = i32(idx & 255u) + 400;\n var x4: i32 = i32(idx & 255u) + 500;\n var x5: i32 = i32(idx & 255u) + 600;\n var x6: i32 = i32(idx & 255u) + 700;\n var x7: i32 = i32(idx & 255u) + 800;\n for (var i: u32 = 0u; i < params.iterations; i = i + 1u) {\n x0 = i32(unpack2x16float(pack2x16float(vec2<f32>(f32(x0)))).x * a + b);\n x1 = i32(unpack2x16float(pack2x16float(vec2<f32>(f32(x1)))).x * a + b);\n x2 = i32(unpack2x16float(pack2x16float(vec2<f32>(f32(x2)))).x * a + b);\n x3 = i32(unpack2x16float(pack2x16float(vec2<f32>(f32(x3)))).x * a + b);\n x4 = i32(unpack2x16float(pack2x16float(vec2<f32>(f32(x4)))).x * a + b);\n x5 = i32(unpack2x16float(pack2x16float(vec2<f32>(f32(x5)))).x * a + b);\n x6 = i32(unpack2x16float(pack2x16float(vec2<f32>(f32(x6)))).x * a + b);\n x7 = i32(unpack2x16float(pack2x16float(vec2<f32>(f32(x7)))).x * a + b);\n x0 = i32(unpack2x16float(pack2x16float(vec2<f32>(f32(x0)))).x * a + b);\n x1 = i32(unpack2x16float(pack2x16float(vec2<f32>(f32(x1)))).x * a + b);\n x2 = i32(unpack2x16float(pack2x16float(vec2<f32>(f32(x2)))).x * a + b);\n x3 = i32(unpack2x16float(pack2x16float(vec2<f32>(f32(x3)))).x * a + b);\n x4 = i32(unpack2x16float(pack2x16float(vec2<f32>(f32(x4)))).x * a + b);\n x5 = i32(unpack2x16float(pack2x16float(vec2<f32>(f32(x5)))).x * a + b);\n x6 = i32(unpack2x16float(pack2x16float(vec2<f32>(f32(x6)))).x * a + b);\n x7 = i32(unpack2x16float(pack2x16float(vec2<f32>(f32(x7)))).x * a + b);\n x0 = i32(unpack2x16float(pack2x16float(vec2<f32>(f32(x0)))).x * a + b);\n x1 = i32(unpack2x16float(pack2x16float(vec2<f32>(f32(x1)))).x * a + b);\n x2 = i32(unpack2x16float(pack2x16float(vec2<f32>(f32(x2)))).x * a + b);\n x3 = i32(unpack2x16float(pack2x16float(vec2<f32>(f32(x3)))).x * a + b);\n x4 = i32(unpack2x16float(pack2x16float(vec2<f32>(f32(x4)))).x * a + b);\n x5 = i32(unpack2x16float(pack2x16float(vec2<f32>(f32(x5)))).x * a + b);\n x6 = i32(unpack2x16float(pack2x16float(vec2<f32>(f32(x6)))).x * a + b);\n x7 = i32(unpack2x16float(pack2x16float(vec2<f32>(f32(x7)))).x * a + b);\n x0 = i32(unpack2x16float(pack2x16float(vec2<f32>(f32(x0)))).x * a + b);\n x1 = i32(unpack2x16float(pack2x16float(vec2<f32>(f32(x1)))).x * a + b);\n x2 = i32(unpack2x16float(pack2x16float(vec2<f32>(f32(x2)))).x * a + b);\n x3 = i32(unpack2x16float(pack2x16float(vec2<f32>(f32(x3)))).x * a + b);\n x4 = i32(unpack2x16float(pack2x16float(vec2<f32>(f32(x4)))).x * a + b);\n x5 = i32(unpack2x16float(pack2x16float(vec2<f32>(f32(x5)))).x * a + b);\n x6 = i32(unpack2x16float(pack2x16float(vec2<f32>(f32(x6)))).x * a + b);\n x7 = i32(unpack2x16float(pack2x16float(vec2<f32>(f32(x7)))).x * a + b);\n }\n out[idx] = f32(x0 + x1 + x2 + x3 + x4 + x5 + x6 + x7);\n}\n";
10
+ //# sourceMappingURL=flopsI32F16Convert.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"flopsI32F16Convert.d.ts","sourceRoot":"","sources":["../../src/shaders/flopsI32F16Convert.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,eAAO,MAAM,sBAAsB,ixGA6DlC,CAAC"}
@@ -0,0 +1,71 @@
1
+ /**
2
+ * i32<->fp16 round-trip FLOPS probe: `xi -> f32 -> pack2x16float ->
3
+ * unpack2x16float -> f32*a+b -> xi`. There's no native int<->f16 builtin, so
4
+ * this is what that conversion actually costs — chained through f32, like
5
+ * the real path. `a` < 1 keeps the round-tripped integer bounded. Eight
6
+ * independent i32 lanes, unrolled 4x; 6 ops/lane/step (f32-convert, pack,
7
+ * unpack, multiply, add, i32-convert). 192 ops per loop iteration.
8
+ */
9
+ export const flopsI32F16ConvertWgsl = /* wgsl */ `
10
+ struct Params {
11
+ threads: u32,
12
+ iterations: u32,
13
+ };
14
+
15
+ @group(0) @binding(0) var<uniform> params: Params;
16
+ @group(0) @binding(1) var<storage, read_write> out: array<f32>;
17
+
18
+ @compute @workgroup_size(64)
19
+ fn main(@builtin(global_invocation_id) gid: vec3<u32>) {
20
+ let idx = gid.x;
21
+ if (idx >= params.threads) {
22
+ return;
23
+ }
24
+ let a: f32 = 0.9 + f32(idx & 15u) * 0.005;
25
+ let b: f32 = 3.0 + f32(idx & 7u) * 0.1;
26
+ var x0: i32 = i32(idx & 255u) + 100;
27
+ var x1: i32 = i32(idx & 255u) + 200;
28
+ var x2: i32 = i32(idx & 255u) + 300;
29
+ var x3: i32 = i32(idx & 255u) + 400;
30
+ var x4: i32 = i32(idx & 255u) + 500;
31
+ var x5: i32 = i32(idx & 255u) + 600;
32
+ var x6: i32 = i32(idx & 255u) + 700;
33
+ var x7: i32 = i32(idx & 255u) + 800;
34
+ for (var i: u32 = 0u; i < params.iterations; i = i + 1u) {
35
+ x0 = i32(unpack2x16float(pack2x16float(vec2<f32>(f32(x0)))).x * a + b);
36
+ x1 = i32(unpack2x16float(pack2x16float(vec2<f32>(f32(x1)))).x * a + b);
37
+ x2 = i32(unpack2x16float(pack2x16float(vec2<f32>(f32(x2)))).x * a + b);
38
+ x3 = i32(unpack2x16float(pack2x16float(vec2<f32>(f32(x3)))).x * a + b);
39
+ x4 = i32(unpack2x16float(pack2x16float(vec2<f32>(f32(x4)))).x * a + b);
40
+ x5 = i32(unpack2x16float(pack2x16float(vec2<f32>(f32(x5)))).x * a + b);
41
+ x6 = i32(unpack2x16float(pack2x16float(vec2<f32>(f32(x6)))).x * a + b);
42
+ x7 = i32(unpack2x16float(pack2x16float(vec2<f32>(f32(x7)))).x * a + b);
43
+ x0 = i32(unpack2x16float(pack2x16float(vec2<f32>(f32(x0)))).x * a + b);
44
+ x1 = i32(unpack2x16float(pack2x16float(vec2<f32>(f32(x1)))).x * a + b);
45
+ x2 = i32(unpack2x16float(pack2x16float(vec2<f32>(f32(x2)))).x * a + b);
46
+ x3 = i32(unpack2x16float(pack2x16float(vec2<f32>(f32(x3)))).x * a + b);
47
+ x4 = i32(unpack2x16float(pack2x16float(vec2<f32>(f32(x4)))).x * a + b);
48
+ x5 = i32(unpack2x16float(pack2x16float(vec2<f32>(f32(x5)))).x * a + b);
49
+ x6 = i32(unpack2x16float(pack2x16float(vec2<f32>(f32(x6)))).x * a + b);
50
+ x7 = i32(unpack2x16float(pack2x16float(vec2<f32>(f32(x7)))).x * a + b);
51
+ x0 = i32(unpack2x16float(pack2x16float(vec2<f32>(f32(x0)))).x * a + b);
52
+ x1 = i32(unpack2x16float(pack2x16float(vec2<f32>(f32(x1)))).x * a + b);
53
+ x2 = i32(unpack2x16float(pack2x16float(vec2<f32>(f32(x2)))).x * a + b);
54
+ x3 = i32(unpack2x16float(pack2x16float(vec2<f32>(f32(x3)))).x * a + b);
55
+ x4 = i32(unpack2x16float(pack2x16float(vec2<f32>(f32(x4)))).x * a + b);
56
+ x5 = i32(unpack2x16float(pack2x16float(vec2<f32>(f32(x5)))).x * a + b);
57
+ x6 = i32(unpack2x16float(pack2x16float(vec2<f32>(f32(x6)))).x * a + b);
58
+ x7 = i32(unpack2x16float(pack2x16float(vec2<f32>(f32(x7)))).x * a + b);
59
+ x0 = i32(unpack2x16float(pack2x16float(vec2<f32>(f32(x0)))).x * a + b);
60
+ x1 = i32(unpack2x16float(pack2x16float(vec2<f32>(f32(x1)))).x * a + b);
61
+ x2 = i32(unpack2x16float(pack2x16float(vec2<f32>(f32(x2)))).x * a + b);
62
+ x3 = i32(unpack2x16float(pack2x16float(vec2<f32>(f32(x3)))).x * a + b);
63
+ x4 = i32(unpack2x16float(pack2x16float(vec2<f32>(f32(x4)))).x * a + b);
64
+ x5 = i32(unpack2x16float(pack2x16float(vec2<f32>(f32(x5)))).x * a + b);
65
+ x6 = i32(unpack2x16float(pack2x16float(vec2<f32>(f32(x6)))).x * a + b);
66
+ x7 = i32(unpack2x16float(pack2x16float(vec2<f32>(f32(x7)))).x * a + b);
67
+ }
68
+ out[idx] = f32(x0 + x1 + x2 + x3 + x4 + x5 + x6 + x7);
69
+ }
70
+ `;
71
+ //# sourceMappingURL=flopsI32F16Convert.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"flopsI32F16Convert.js","sourceRoot":"","sources":["../../src/shaders/flopsI32F16Convert.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,UAAU,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA6DhD,CAAC"}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * i32<->f32 conversion FLOPS probe. Same shape as {@link flopsF32ScalarWgsl}
3
+ * but each step is `xf = f32(xi) * a + b; xi = i32(xf)`: two conversions
4
+ * plus the same FMA as the fp32 scalar test, so the delta against that test
5
+ * isolates conversion cost. `a` < 1 keeps the round-tripped integer bounded.
6
+ * 128 ops (32 x [f32-convert, multiply, add, i32-convert]) per loop
7
+ * iteration.
8
+ */
9
+ export declare const flopsI32F32ConvertWgsl = "\nstruct Params {\n threads: u32,\n iterations: u32,\n};\n\n@group(0) @binding(0) var<uniform> params: Params;\n@group(0) @binding(1) var<storage, read_write> out: array<f32>;\n\n@compute @workgroup_size(64)\nfn main(@builtin(global_invocation_id) gid: vec3<u32>) {\n let idx = gid.x;\n if (idx >= params.threads) {\n return;\n }\n let a: f32 = 0.9 + f32(idx & 15u) * 0.005;\n let b: f32 = 3.0 + f32(idx & 7u) * 0.1;\n var x0: i32 = i32(idx & 255u) + 100;\n var x1: i32 = i32(idx & 255u) + 200;\n var x2: i32 = i32(idx & 255u) + 300;\n var x3: i32 = i32(idx & 255u) + 400;\n var x4: i32 = i32(idx & 255u) + 500;\n var x5: i32 = i32(idx & 255u) + 600;\n var x6: i32 = i32(idx & 255u) + 700;\n var x7: i32 = i32(idx & 255u) + 800;\n for (var i: u32 = 0u; i < params.iterations; i = i + 1u) {\n x0 = i32(f32(x0) * a + b);\n x1 = i32(f32(x1) * a + b);\n x2 = i32(f32(x2) * a + b);\n x3 = i32(f32(x3) * a + b);\n x4 = i32(f32(x4) * a + b);\n x5 = i32(f32(x5) * a + b);\n x6 = i32(f32(x6) * a + b);\n x7 = i32(f32(x7) * a + b);\n x0 = i32(f32(x0) * a + b);\n x1 = i32(f32(x1) * a + b);\n x2 = i32(f32(x2) * a + b);\n x3 = i32(f32(x3) * a + b);\n x4 = i32(f32(x4) * a + b);\n x5 = i32(f32(x5) * a + b);\n x6 = i32(f32(x6) * a + b);\n x7 = i32(f32(x7) * a + b);\n x0 = i32(f32(x0) * a + b);\n x1 = i32(f32(x1) * a + b);\n x2 = i32(f32(x2) * a + b);\n x3 = i32(f32(x3) * a + b);\n x4 = i32(f32(x4) * a + b);\n x5 = i32(f32(x5) * a + b);\n x6 = i32(f32(x6) * a + b);\n x7 = i32(f32(x7) * a + b);\n x0 = i32(f32(x0) * a + b);\n x1 = i32(f32(x1) * a + b);\n x2 = i32(f32(x2) * a + b);\n x3 = i32(f32(x3) * a + b);\n x4 = i32(f32(x4) * a + b);\n x5 = i32(f32(x5) * a + b);\n x6 = i32(f32(x6) * a + b);\n x7 = i32(f32(x7) * a + b);\n }\n out[idx] = f32(x0 + x1 + x2 + x3 + x4 + x5 + x6 + x7);\n}\n";
10
+ //# sourceMappingURL=flopsI32F32Convert.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"flopsI32F32Convert.d.ts","sourceRoot":"","sources":["../../src/shaders/flopsI32F32Convert.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,eAAO,MAAM,sBAAsB,i3DA6DlC,CAAC"}
@@ -0,0 +1,71 @@
1
+ /**
2
+ * i32<->f32 conversion FLOPS probe. Same shape as {@link flopsF32ScalarWgsl}
3
+ * but each step is `xf = f32(xi) * a + b; xi = i32(xf)`: two conversions
4
+ * plus the same FMA as the fp32 scalar test, so the delta against that test
5
+ * isolates conversion cost. `a` < 1 keeps the round-tripped integer bounded.
6
+ * 128 ops (32 x [f32-convert, multiply, add, i32-convert]) per loop
7
+ * iteration.
8
+ */
9
+ export const flopsI32F32ConvertWgsl = /* wgsl */ `
10
+ struct Params {
11
+ threads: u32,
12
+ iterations: u32,
13
+ };
14
+
15
+ @group(0) @binding(0) var<uniform> params: Params;
16
+ @group(0) @binding(1) var<storage, read_write> out: array<f32>;
17
+
18
+ @compute @workgroup_size(64)
19
+ fn main(@builtin(global_invocation_id) gid: vec3<u32>) {
20
+ let idx = gid.x;
21
+ if (idx >= params.threads) {
22
+ return;
23
+ }
24
+ let a: f32 = 0.9 + f32(idx & 15u) * 0.005;
25
+ let b: f32 = 3.0 + f32(idx & 7u) * 0.1;
26
+ var x0: i32 = i32(idx & 255u) + 100;
27
+ var x1: i32 = i32(idx & 255u) + 200;
28
+ var x2: i32 = i32(idx & 255u) + 300;
29
+ var x3: i32 = i32(idx & 255u) + 400;
30
+ var x4: i32 = i32(idx & 255u) + 500;
31
+ var x5: i32 = i32(idx & 255u) + 600;
32
+ var x6: i32 = i32(idx & 255u) + 700;
33
+ var x7: i32 = i32(idx & 255u) + 800;
34
+ for (var i: u32 = 0u; i < params.iterations; i = i + 1u) {
35
+ x0 = i32(f32(x0) * a + b);
36
+ x1 = i32(f32(x1) * a + b);
37
+ x2 = i32(f32(x2) * a + b);
38
+ x3 = i32(f32(x3) * a + b);
39
+ x4 = i32(f32(x4) * a + b);
40
+ x5 = i32(f32(x5) * a + b);
41
+ x6 = i32(f32(x6) * a + b);
42
+ x7 = i32(f32(x7) * a + b);
43
+ x0 = i32(f32(x0) * a + b);
44
+ x1 = i32(f32(x1) * a + b);
45
+ x2 = i32(f32(x2) * a + b);
46
+ x3 = i32(f32(x3) * a + b);
47
+ x4 = i32(f32(x4) * a + b);
48
+ x5 = i32(f32(x5) * a + b);
49
+ x6 = i32(f32(x6) * a + b);
50
+ x7 = i32(f32(x7) * a + b);
51
+ x0 = i32(f32(x0) * a + b);
52
+ x1 = i32(f32(x1) * a + b);
53
+ x2 = i32(f32(x2) * a + b);
54
+ x3 = i32(f32(x3) * a + b);
55
+ x4 = i32(f32(x4) * a + b);
56
+ x5 = i32(f32(x5) * a + b);
57
+ x6 = i32(f32(x6) * a + b);
58
+ x7 = i32(f32(x7) * a + b);
59
+ x0 = i32(f32(x0) * a + b);
60
+ x1 = i32(f32(x1) * a + b);
61
+ x2 = i32(f32(x2) * a + b);
62
+ x3 = i32(f32(x3) * a + b);
63
+ x4 = i32(f32(x4) * a + b);
64
+ x5 = i32(f32(x5) * a + b);
65
+ x6 = i32(f32(x6) * a + b);
66
+ x7 = i32(f32(x7) * a + b);
67
+ }
68
+ out[idx] = f32(x0 + x1 + x2 + x3 + x4 + x5 + x6 + x7);
69
+ }
70
+ `;
71
+ //# sourceMappingURL=flopsI32F32Convert.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"flopsI32F32Convert.js","sourceRoot":"","sources":["../../src/shaders/flopsI32F32Convert.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,UAAU,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA6DhD,CAAC"}
@@ -0,0 +1,23 @@
1
+ /**
2
+ * int8 packed-dot-product FLOPS probe: uses the `packed_4x8_integer_dot_product`
3
+ * extension's `dot4I8Packed` builtin directly (two u32s, each four packed
4
+ * signed int8 lanes, one instruction) in a tight accumulation loop, to
5
+ * isolate the instruction's peak throughput. `a` is fed back from the
6
+ * running accumulator every iteration (not just `idx`-derived and fixed),
7
+ * so `dot4I8Packed(a, b)` is genuinely loop-carried — a compiler that
8
+ * noticed `a`/`b` were loop-invariant could otherwise hoist the call out of
9
+ * the loop and replace all `iterations` of it with one call + a multiply,
10
+ * which is exactly what happened before this fix (the loop collapsed to
11
+ * ~free, and the dispatch finished faster than the timestamp-query clock's
12
+ * resolution, reading back as a literal 0ns elapsed).
13
+ *
14
+ * `packed_4x8_integer_dot_product` is a WGSL *language extension* (gated by
15
+ * `navigator.gpu.wgslLanguageFeatures`, checked as `ctx.info.supportsI8Dot`
16
+ * in flopsCommon.ts), not an enable-extension tied to a GPUFeatureName like
17
+ * `f16` — so it's opted into with the `requires` directive, not `enable`.
18
+ * Using `enable` here fails shader compilation ("Expected 'clip_distances',
19
+ * 'f16', or 'primitive_index'" — the compiler listing valid enable-extension
20
+ * names), which used to go undetected and read back as a silent 0ns result.
21
+ */
22
+ export declare const flopsI8Dp4aWgsl = "\nrequires packed_4x8_integer_dot_product;\n\nstruct Params {\n threads: u32,\n iterations: u32,\n};\n\n@group(0) @binding(0) var<uniform> params: Params;\n@group(0) @binding(1) var<storage, read_write> out: array<f32>;\n\n@compute @workgroup_size(64)\nfn main(@builtin(global_invocation_id) gid: vec3<u32>) {\n let idx = gid.x;\n if (idx >= params.threads) {\n return;\n }\n let b: u32 = 0x05060708u ^ (idx * 0x85ebca6bu);\n var a: u32 = 0x01020304u ^ (idx * 0x9e3779b1u);\n var acc: i32 = i32(idx & 255u);\n for (var i: u32 = 0u; i < params.iterations; i = i + 1u) {\n acc = acc + dot4I8Packed(a, b);\n a = a ^ u32(acc);\n }\n out[idx] = f32(acc);\n}\n";
23
+ //# sourceMappingURL=flopsI8Dp4a.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"flopsI8Dp4a.d.ts","sourceRoot":"","sources":["../../src/shaders/flopsI8Dp4a.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,eAAO,MAAM,eAAe,uqBA0B3B,CAAC"}