@graphty/webgpu-graph-algorithms 0.6.3 → 0.6.4

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 (167) hide show
  1. package/README.md +62 -32
  2. package/dist/browser.js +1 -1
  3. package/dist/chunks/{context-BXqgCifx.js → context-Dvq-Cc6v.js} +71 -25
  4. package/dist/chunks/context-Dvq-Cc6v.js.map +1 -0
  5. package/dist/node.js +1 -1
  6. package/dist/src/accelerator.d.ts +8 -6
  7. package/dist/src/accelerator.d.ts.map +1 -1
  8. package/dist/src/accelerator.js +57 -6
  9. package/dist/src/accelerator.js.map +1 -1
  10. package/dist/src/algorithms/bellman-ford.d.ts +60 -0
  11. package/dist/src/algorithms/bellman-ford.d.ts.map +1 -0
  12. package/dist/src/algorithms/bellman-ford.js +301 -0
  13. package/dist/src/algorithms/bellman-ford.js.map +1 -0
  14. package/dist/src/algorithms/bfs.d.ts +67 -0
  15. package/dist/src/algorithms/bfs.d.ts.map +1 -0
  16. package/dist/src/algorithms/bfs.js +534 -0
  17. package/dist/src/algorithms/bfs.js.map +1 -0
  18. package/dist/src/algorithms/closeness.d.ts +53 -0
  19. package/dist/src/algorithms/closeness.d.ts.map +1 -0
  20. package/dist/src/algorithms/closeness.js +323 -0
  21. package/dist/src/algorithms/closeness.js.map +1 -0
  22. package/dist/src/algorithms/scope.d.ts +5 -3
  23. package/dist/src/algorithms/scope.d.ts.map +1 -1
  24. package/dist/src/algorithms/scope.js +3 -0
  25. package/dist/src/algorithms/scope.js.map +1 -1
  26. package/dist/src/algorithms/sssp.d.ts +71 -0
  27. package/dist/src/algorithms/sssp.d.ts.map +1 -0
  28. package/dist/src/algorithms/sssp.js +585 -0
  29. package/dist/src/algorithms/sssp.js.map +1 -0
  30. package/dist/src/constants.d.ts +12 -0
  31. package/dist/src/constants.d.ts.map +1 -1
  32. package/dist/src/constants.js +12 -0
  33. package/dist/src/constants.js.map +1 -1
  34. package/dist/src/index.d.ts +8 -2
  35. package/dist/src/index.d.ts.map +1 -1
  36. package/dist/src/index.js +7 -1
  37. package/dist/src/index.js.map +1 -1
  38. package/dist/src/kernel/prelude.d.ts +4 -4
  39. package/dist/src/kernel/prelude.d.ts.map +1 -1
  40. package/dist/src/kernel/prelude.js +39 -5
  41. package/dist/src/kernel/prelude.js.map +1 -1
  42. package/dist/src/kernel/uniform-ring.d.ts +8 -0
  43. package/dist/src/kernel/uniform-ring.d.ts.map +1 -1
  44. package/dist/src/kernel/uniform-ring.js +13 -0
  45. package/dist/src/kernel/uniform-ring.js.map +1 -1
  46. package/dist/src/kernels.d.ts +44 -4
  47. package/dist/src/kernels.d.ts.map +1 -1
  48. package/dist/src/kernels.js +371 -3
  49. package/dist/src/kernels.js.map +1 -1
  50. package/dist/src/primitives/advance.d.ts +62 -0
  51. package/dist/src/primitives/advance.d.ts.map +1 -0
  52. package/dist/src/primitives/advance.js +95 -0
  53. package/dist/src/primitives/advance.js.map +1 -0
  54. package/dist/src/primitives/compact.d.ts +89 -0
  55. package/dist/src/primitives/compact.d.ts.map +1 -0
  56. package/dist/src/primitives/compact.js +233 -0
  57. package/dist/src/primitives/compact.js.map +1 -0
  58. package/dist/src/primitives/core-shape.d.ts +22 -1
  59. package/dist/src/primitives/core-shape.d.ts.map +1 -1
  60. package/dist/src/primitives/core-shape.js +33 -3
  61. package/dist/src/primitives/core-shape.js.map +1 -1
  62. package/dist/src/primitives/frontier.d.ts +156 -0
  63. package/dist/src/primitives/frontier.d.ts.map +1 -0
  64. package/dist/src/primitives/frontier.js +259 -0
  65. package/dist/src/primitives/frontier.js.map +1 -0
  66. package/dist/src/types/accelerator.d.ts +16 -7
  67. package/dist/src/types/accelerator.d.ts.map +1 -1
  68. package/dist/src/types/traversal.d.ts +53 -0
  69. package/dist/src/types/traversal.d.ts.map +1 -0
  70. package/dist/src/types/traversal.js +10 -0
  71. package/dist/src/types/traversal.js.map +1 -0
  72. package/dist/src/wgsl/advance-expand.wgsl.d.ts +19 -0
  73. package/dist/src/wgsl/advance-expand.wgsl.d.ts.map +1 -0
  74. package/dist/src/wgsl/advance-expand.wgsl.js +69 -0
  75. package/dist/src/wgsl/advance-expand.wgsl.js.map +1 -0
  76. package/dist/src/wgsl/bf-relax.wgsl.d.ts +22 -0
  77. package/dist/src/wgsl/bf-relax.wgsl.d.ts.map +1 -0
  78. package/dist/src/wgsl/bf-relax.wgsl.js +58 -0
  79. package/dist/src/wgsl/bf-relax.wgsl.js.map +1 -0
  80. package/dist/src/wgsl/bfs-bitset-build.wgsl.d.ts +15 -0
  81. package/dist/src/wgsl/bfs-bitset-build.wgsl.d.ts.map +1 -0
  82. package/dist/src/wgsl/bfs-bitset-build.wgsl.js +24 -0
  83. package/dist/src/wgsl/bfs-bitset-build.wgsl.js.map +1 -0
  84. package/dist/src/wgsl/bfs-bottom-up.wgsl.d.ts +20 -0
  85. package/dist/src/wgsl/bfs-bottom-up.wgsl.d.ts.map +1 -0
  86. package/dist/src/wgsl/bfs-bottom-up.wgsl.js +67 -0
  87. package/dist/src/wgsl/bfs-bottom-up.wgsl.js.map +1 -0
  88. package/dist/src/wgsl/bfs-contract.wgsl.d.ts +20 -0
  89. package/dist/src/wgsl/bfs-contract.wgsl.d.ts.map +1 -0
  90. package/dist/src/wgsl/bfs-contract.wgsl.js +55 -0
  91. package/dist/src/wgsl/bfs-contract.wgsl.js.map +1 -0
  92. package/dist/src/wgsl/bfs-fused.wgsl.d.ts +25 -0
  93. package/dist/src/wgsl/bfs-fused.wgsl.d.ts.map +1 -0
  94. package/dist/src/wgsl/bfs-fused.wgsl.js +78 -0
  95. package/dist/src/wgsl/bfs-fused.wgsl.js.map +1 -0
  96. package/dist/src/wgsl/bfs-unvisited-flags.wgsl.d.ts +18 -0
  97. package/dist/src/wgsl/bfs-unvisited-flags.wgsl.d.ts.map +1 -0
  98. package/dist/src/wgsl/bfs-unvisited-flags.wgsl.js +42 -0
  99. package/dist/src/wgsl/bfs-unvisited-flags.wgsl.js.map +1 -0
  100. package/dist/src/wgsl/closeness-reduce.wgsl.d.ts +17 -0
  101. package/dist/src/wgsl/closeness-reduce.wgsl.d.ts.map +1 -0
  102. package/dist/src/wgsl/closeness-reduce.wgsl.js +65 -0
  103. package/dist/src/wgsl/closeness-reduce.wgsl.js.map +1 -0
  104. package/dist/src/wgsl/closeness-sweep.wgsl.d.ts +20 -0
  105. package/dist/src/wgsl/closeness-sweep.wgsl.d.ts.map +1 -0
  106. package/dist/src/wgsl/closeness-sweep.wgsl.js +96 -0
  107. package/dist/src/wgsl/closeness-sweep.wgsl.js.map +1 -0
  108. package/dist/src/wgsl/compact-scatter.wgsl.d.ts +9 -0
  109. package/dist/src/wgsl/compact-scatter.wgsl.d.ts.map +1 -0
  110. package/dist/src/wgsl/compact-scatter.wgsl.js +17 -0
  111. package/dist/src/wgsl/compact-scatter.wgsl.js.map +1 -0
  112. package/dist/src/wgsl/dedupe-claim.wgsl.d.ts +10 -0
  113. package/dist/src/wgsl/dedupe-claim.wgsl.d.ts.map +1 -0
  114. package/dist/src/wgsl/dedupe-claim.wgsl.js +19 -0
  115. package/dist/src/wgsl/dedupe-claim.wgsl.js.map +1 -0
  116. package/dist/src/wgsl/dedupe-filter.wgsl.d.ts +12 -0
  117. package/dist/src/wgsl/dedupe-filter.wgsl.d.ts.map +1 -0
  118. package/dist/src/wgsl/dedupe-filter.wgsl.js +46 -0
  119. package/dist/src/wgsl/dedupe-filter.wgsl.js.map +1 -0
  120. package/dist/src/wgsl/frontier-finalize.wgsl.d.ts +59 -0
  121. package/dist/src/wgsl/frontier-finalize.wgsl.d.ts.map +1 -0
  122. package/dist/src/wgsl/frontier-finalize.wgsl.js +210 -0
  123. package/dist/src/wgsl/frontier-finalize.wgsl.js.map +1 -0
  124. package/dist/src/wgsl/sssp-pred.wgsl.d.ts +28 -0
  125. package/dist/src/wgsl/sssp-pred.wgsl.d.ts.map +1 -0
  126. package/dist/src/wgsl/sssp-pred.wgsl.js +80 -0
  127. package/dist/src/wgsl/sssp-pred.wgsl.js.map +1 -0
  128. package/dist/src/wgsl/sssp-relax.wgsl.d.ts +30 -0
  129. package/dist/src/wgsl/sssp-relax.wgsl.d.ts.map +1 -0
  130. package/dist/src/wgsl/sssp-relax.wgsl.js +72 -0
  131. package/dist/src/wgsl/sssp-relax.wgsl.js.map +1 -0
  132. package/dist/webgpu-graph-algorithms.js +3207 -377
  133. package/dist/webgpu-graph-algorithms.js.map +1 -1
  134. package/package.json +5 -4
  135. package/src/accelerator.ts +65 -7
  136. package/src/algorithms/bellman-ford.ts +387 -0
  137. package/src/algorithms/bfs.ts +626 -0
  138. package/src/algorithms/closeness.ts +395 -0
  139. package/src/algorithms/scope.ts +13 -3
  140. package/src/algorithms/sssp.ts +767 -0
  141. package/src/constants.ts +12 -0
  142. package/src/index.ts +14 -1
  143. package/src/kernel/prelude.ts +39 -4
  144. package/src/kernel/uniform-ring.ts +14 -0
  145. package/src/kernels.ts +450 -6
  146. package/src/primitives/advance.ts +130 -0
  147. package/src/primitives/compact.ts +323 -0
  148. package/src/primitives/core-shape.ts +41 -3
  149. package/src/primitives/frontier.ts +388 -0
  150. package/src/types/accelerator.ts +18 -5
  151. package/src/types/traversal.ts +56 -0
  152. package/src/wgsl/advance-expand.wgsl.ts +68 -0
  153. package/src/wgsl/bf-relax.wgsl.ts +57 -0
  154. package/src/wgsl/bfs-bitset-build.wgsl.ts +23 -0
  155. package/src/wgsl/bfs-bottom-up.wgsl.ts +66 -0
  156. package/src/wgsl/bfs-contract.wgsl.ts +54 -0
  157. package/src/wgsl/bfs-fused.wgsl.ts +77 -0
  158. package/src/wgsl/bfs-unvisited-flags.wgsl.ts +41 -0
  159. package/src/wgsl/closeness-reduce.wgsl.ts +64 -0
  160. package/src/wgsl/closeness-sweep.wgsl.ts +95 -0
  161. package/src/wgsl/compact-scatter.wgsl.ts +16 -0
  162. package/src/wgsl/dedupe-claim.wgsl.ts +18 -0
  163. package/src/wgsl/dedupe-filter.wgsl.ts +45 -0
  164. package/src/wgsl/frontier-finalize.wgsl.ts +209 -0
  165. package/src/wgsl/sssp-pred.wgsl.ts +79 -0
  166. package/src/wgsl/sssp-relax.wgsl.ts +71 -0
  167. package/dist/chunks/context-BXqgCifx.js.map +0 -1
@@ -0,0 +1,585 @@
1
+ /**
2
+ * Weighted single-source shortest paths on the device (design 8.4, 3.3 line 808, 9.7; P8-T9, the P8 plan's PD-9 /
3
+ * PD-10 / PD-11 / PD-14 / PD-19 / PD-20 / PD-22 / PD-27 / DEP-P8-E): Davidson's near-far queue over the `Frontier`
4
+ * of P8-T4 with the `dedupe` of P8-T3, every per-round decision made ON THE DEVICE. `dist` is `array<atomic<u32>>`
5
+ * holding the f32 bit patterns of the distances (`F32_INF_BITS` = unreached), claimed by `atomicMin`, which is
6
+ * exact on non-negative floats (PD-9): the settled value is the minimum of a fixed set of f32 sums, so it is
7
+ * bitwise reproducible, bitwise identical across adapters, and bitwise equal to the f32 Dijkstra oracle.
8
+ *
9
+ * A round is eight recorded dispatches: `frontier-finalize` role 2 (the round boundary: a non-empty raw near half
10
+ * is deduped into `nearIn` for a near round; an empty one with a non-empty far half raises the threshold by the
11
+ * delta and dedupes the far half into `farIn` for a pass-through; both empty is `done`), `dedupe-claim` and
12
+ * `dedupe-filter` over each half (direct grid-stride dispatches; role 2 writes the chosen half's raw count into that
13
+ * dedupe's count word -- `edgeCount` for the near half, `edgeCountUnclamped` for the far one, two words SSSP borrows
14
+ * -- and 0 into the other's, so the half not chosen is a no-op), role 3 (restarts the raw half), and `sssp-relax`
15
+ * twice (role 0 over `nearIn`, role 1 over `farIn`; the block's `path` word, 5 a near round and 6 a far one, makes
16
+ * the other role's dispatch a no-op). The far pile is re-bucketed by the
17
+ * relax kernel's pass-through, not by `compact` (PD-20): a far entry whose settled distance fell below the previous
18
+ * threshold was relaxed in the near band already and is dropped, the rest go back to near or far against the raised
19
+ * threshold. The near pile is ONE pile (no sub-partitions). The host records `MAX_LEVELS_PER_SUBMIT` rounds per
20
+ * submit and reads four bytes, the `done` word: 1 finished, 2 a raw half above its capacity (E_TOO_LARGE
21
+ * `sssp.pile`: the far half accumulates one entry per improving relaxation beyond the threshold across a bucket's
22
+ * near rounds and is deduped only at the split, so the refusal is reachable on a graph whose vertices improve many
23
+ * times inside one bucket), 3 the f32 threshold absorbed the delta (E_UNSUPPORTED `sssp.thresholdAbsorbed`). The
24
+ * rounds are at most `n + ceil(sum / delta) + 1` (each near round settles the pile's minimum, one pass-through per
25
+ * bucket), so more submits than that is E_VALIDATION, never a hang.
26
+ *
27
+ * The two routings (PD-22) are decided by the RUN's weight vector: `options.weights` when given (`arcCount` long or
28
+ * E_INVALID_ARGUMENT; narrowed to `Float32Array` when it is not one -- a `U32` or `I32` value above 2^24, or the
29
+ * bits of an `F64` value below the f32 ulp, is rounded silently, the package-wide f32 caveat and not a refusal --
30
+ * uploaded into a lease buffer and bound in the graph group's weights slot with `HAS_WEIGHTS` set even on an
31
+ * unweighted snapshot), else the snapshot's column, else none. A run whose vector is all ones, or has none, is the
32
+ * unit-weight BFS of P8-T6 with a depth cap derived from `cutoff` (`dv <= cutoff` on unit weights is
33
+ * `depth <= floor(cutoff)`), its `predArc` from `sssp-pred` in depth mode writing arc indices, `reachedCount` the
34
+ * visited count -- not a fallback, a better algorithm for the input. A negative weight is E_UNSUPPORTED
35
+ * `sssp.negativeWeights` (use bellmanFord), a non-finite one E_UNSUPPORTED `sssp.nonFiniteWeights` (the bit-pattern
36
+ * order is undefined for NaN); `cutoff: NaN` is E_INVALID_ARGUMENT, because the CPU port's `dv <= NaN` relaxes
37
+ * nothing while the kernel's `nd > NaN` guard would relax everything (PD-19). All host-side, before any device work.
38
+ * The delta is `SSSP_DELTA_FACTOR x avgWeight / avgDegree` over the vector in use (1 for an all-zero vector), seeded
39
+ * into the counters block as `deltaBits` and `thresholdBits`.
40
+ *
41
+ * `predArc` is a second pass over the settled distances (PD-11), never packed into the distance atomic: `sssp-pred`
42
+ * in `MODE 0` follows PD-27's plateau rule -- the smallest TIGHT arc whose source sits one key step below `v`, the
43
+ * key `(dist, hops)` with `hops` the plateau depth from a root -- through three roles over one buffer (the arcs,
44
+ * the hop counts, the changed word and the orphan word), so the chain strictly decreases the key, ends at the
45
+ * source, and is bitwise reproducible. A hop batch of `MAX_LEVELS_PER_SUBMIT` passes that still changed something
46
+ * is recorded again without the roots pass; a reached node the key never reached is a kernel bug (E_VALIDATION),
47
+ * never a result. The tuning entry `ssspWithTuning` (PD-26's shape) is what the tests drive; nothing public
48
+ * exposes it.
49
+ *
50
+ * The host-side helpers of the two routings (`resolveWeights`, `normaliseCutoff`, `checkDest`, `assertSource`,
51
+ * `unitWeightRoute`) and the predecessor pass (`predecessorPass`, both PD-27 keys) are shared with
52
+ * `bellman-ford.ts` (P8-T10), which is the same seam type over the same `SsspOptions`; they take the algorithm's
53
+ * name for their messages and are `@internal`.
54
+ */
55
+ import { INVALID_INDEX } from "@graphty/graph-format";
56
+ import { F32_INF_BITS, MAX_LEVELS_PER_SUBMIT, SSSP_DELTA_FACTOR } from "../constants.js";
57
+ import { WebGpuGraphError } from "../errors.js";
58
+ import { CommandBatch } from "../kernel/batch.js";
59
+ import { plan1d, planGridStride } from "../kernel/dispatch.js";
60
+ import { FILL_PARAMS, FRONTIER_COUNTERS, FRONTIER_PARAMS, graphBindings, graphOverrides, kernelSpec, } from "../kernels.js";
61
+ import { prepareCompact } from "../primitives/compact.js";
62
+ import { assertWholeCore } from "../primitives/core-shape.js";
63
+ import { prepareFrontier, W } from "../primitives/frontier.js";
64
+ import { assertDeviceComputes } from "../primitives/verify.js";
65
+ import { bfsWithTuning } from "./bfs.js";
66
+ import { algorithmScope } from "./scope.js";
67
+ const ALGORITHM = "sssp";
68
+ /** The arc-window alignment of the raw halves: the far half's byte offset is `4 x cap`, a multiple of 256, so `dedupe` can bind it alone. */
69
+ const HALF_ALIGN = 64;
70
+ /**
71
+ * Params slots of the ring, COUNTED (`UniformRing.reserve` wraps silently): per round `frontier-finalize` twice and
72
+ * the two dedupe records (4), plus the two relax records shared by every round of a submit (the near and the far
73
+ * role read the same fields), so `4 x MAX_LEVELS_PER_SUBMIT + 2` for a round submit; the predecessor batch is the
74
+ * roots pass, `MAX_LEVELS_PER_SUBMIT` hop passes, one `fill` and the predecessor pass (35) and the setup batch two
75
+ * `fill`s; they flush in their own submits but must fit the same ring.
76
+ */
77
+ const RING_SLOTS = 4 * MAX_LEVELS_PER_SUBMIT + 40;
78
+ /**
79
+ * The f32 bit pattern of a number (the form the counters block and `FrontierParams` carry).
80
+ * @internal
81
+ * @param value - the number (rounded to f32 first)
82
+ * @returns the pattern
83
+ */
84
+ export function bitsOf(value) {
85
+ return new Uint32Array(Float32Array.of(value).buffer)[0];
86
+ }
87
+ /**
88
+ * Whole-buffer binding of a scratch buffer over its first `size` bytes.
89
+ * @internal
90
+ * @param buffer - the buffer
91
+ * @param size - the bound byte length
92
+ * @returns the binding
93
+ */
94
+ export function bindingOf(buffer, size) {
95
+ return { buffer, offset: 0, size, window: null };
96
+ }
97
+ /**
98
+ * The E_ABORTED error of a signal.
99
+ * @internal
100
+ * @param algorithm - the algorithm's name (the message prefix)
101
+ * @param batchId - the last submitted batch, when one exists
102
+ * @returns the error
103
+ */
104
+ export function aborted(algorithm, batchId) {
105
+ return new WebGpuGraphError("E_ABORTED", `${algorithm}: the signal was aborted`, batchId === undefined ? {} : { batchId });
106
+ }
107
+ /**
108
+ * E_INVALID_ARGUMENT unless `source` is an integer in `[0, n)`.
109
+ * @internal
110
+ * @param algorithm - the algorithm's name (the message prefix)
111
+ * @param source - the caller's source node index
112
+ * @param n - the node count
113
+ */
114
+ export function assertSource(algorithm, source, n) {
115
+ if (!Number.isInteger(source) || source < 0 || source >= n) {
116
+ throw new WebGpuGraphError("E_INVALID_ARGUMENT", `${algorithm}: source ${source} is outside [0, ${n})`, {
117
+ argument: "source",
118
+ value: source,
119
+ expected: `an integer in [0, ${n})`,
120
+ });
121
+ }
122
+ }
123
+ /**
124
+ * One scalar word of a decoded block (every FrontierCounters field is a u32, so anything else is a decoder bug).
125
+ * @param block - the decoded block
126
+ * @param name - the field
127
+ * @returns the word
128
+ */
129
+ function wordOf(block, name) {
130
+ const value = block[name];
131
+ if (typeof value !== "number") {
132
+ throw new WebGpuGraphError("E_VALIDATION", `${ALGORITHM}: counters.${name} did not decode to a number`, {
133
+ label: `${ALGORITHM}/counters`,
134
+ message: `the field ${name} did not decode to a number`,
135
+ });
136
+ }
137
+ return value;
138
+ }
139
+ /**
140
+ * Validates `options.dest` for a distance result of `n` elements.
141
+ * @internal
142
+ * @param algorithm - the algorithm's name (the message prefix)
143
+ * @param dest - the caller's destination array, if any
144
+ * @param n - the node count
145
+ * @returns the destination as an F32, or null when none was given
146
+ */
147
+ export function checkDest(algorithm, dest, n) {
148
+ if (dest === undefined) {
149
+ return null;
150
+ }
151
+ if (dest instanceof Float32Array && dest.length === n && dest.buffer instanceof ArrayBuffer) {
152
+ return dest;
153
+ }
154
+ throw new WebGpuGraphError("E_INVALID_ARGUMENT", `${algorithm}: dest must be a Float32Array of length ${n} over an ArrayBuffer`, {
155
+ argument: "dest",
156
+ value: `${dest.constructor.name}(${dest.length})`,
157
+ expected: `Float32Array(${n}) over an ArrayBuffer`,
158
+ });
159
+ }
160
+ /**
161
+ * The CPU port's `cutoff` before any device work: absent is no cap; `NaN` is refused (PD-19: `dv <= NaN` relaxes
162
+ * nothing on the CPU while the kernel's `nd > NaN` guard would relax everything, a silently inverted option);
163
+ * anything else is a finite or infinite number.
164
+ * @internal
165
+ * @param algorithm - the algorithm's name (the message prefix)
166
+ * @param cutoff - the caller's option
167
+ * @returns the cap
168
+ */
169
+ export function normaliseCutoff(algorithm, cutoff) {
170
+ if (cutoff === undefined) {
171
+ return Infinity;
172
+ }
173
+ if (Number.isNaN(cutoff)) {
174
+ throw new WebGpuGraphError("E_INVALID_ARGUMENT", `${algorithm}: cutoff must not be NaN`, {
175
+ argument: "cutoff",
176
+ value: cutoff,
177
+ expected: "a number (the CPU port and the kernel would disagree on NaN)",
178
+ });
179
+ }
180
+ return cutoff;
181
+ }
182
+ /**
183
+ * The weight vector of the run (PD-22): the override, validated and narrowed, else the snapshot's column, else
184
+ * null; scanned once on the host for the routing flags and the sum.
185
+ * @internal
186
+ * @param algorithm - the algorithm's name (the message prefix)
187
+ * @param s - the snapshot
188
+ * @param weights - the caller's override, if any
189
+ * @returns the vector and its flags, or null when the run has no weights at all
190
+ */
191
+ export function resolveWeights(algorithm, s, weights) {
192
+ if (weights === undefined) {
193
+ if (s.weights === null) {
194
+ return null;
195
+ }
196
+ let sum = 0;
197
+ for (const w of s.weights) {
198
+ sum += w;
199
+ }
200
+ return {
201
+ values: s.weights,
202
+ override: null,
203
+ allOne: s.flags.allWeightsOne,
204
+ nonNegative: s.flags.nonNegativeWeights,
205
+ finite: s.flags.finiteWeights,
206
+ sum,
207
+ };
208
+ }
209
+ if (weights.length !== s.arcCount) {
210
+ throw new WebGpuGraphError("E_INVALID_ARGUMENT", `${algorithm}: weights has ${weights.length} entries, the snapshot ${s.arcCount} arcs`, { argument: "weights", value: weights.length, expected: s.arcCount });
211
+ }
212
+ // the f32 narrowing: a U32 / I32 value above 2^24 or the bits of an F64 value below the f32 ulp round silently
213
+ const values = weights instanceof Float32Array ? weights : Float32Array.from(weights);
214
+ let allOne = true;
215
+ let nonNegative = true;
216
+ let finite = true;
217
+ let sum = 0;
218
+ for (const w of values) {
219
+ if (w !== 1) {
220
+ allOne = false;
221
+ }
222
+ if (w < 0) {
223
+ nonNegative = false;
224
+ }
225
+ if (!Number.isFinite(w)) {
226
+ finite = false;
227
+ }
228
+ sum += w;
229
+ }
230
+ return { values, override: values, allOne, nonNegative, finite, sum };
231
+ }
232
+ /**
233
+ * The unit-weight route (PD-22): the BFS with `cutoff` as a depth cap (`dv <= cutoff` on unit weights is
234
+ * `depth <= floor(cutoff)`; no cap or `+Infinity` is no cap, a negative cutoff the source alone), its `parent` in
235
+ * arc form, its depths as f32 distances.
236
+ * @internal
237
+ * @param ctx - the context
238
+ * @param s - the snapshot
239
+ * @param source - the source node index
240
+ * @param cutoff - the normalised cutoff
241
+ * @param dest - the caller's destination, if any
242
+ * @param options - the run options
243
+ * @returns the result
244
+ */
245
+ export async function unitWeightRoute(ctx, s, source, cutoff, dest, options) {
246
+ const maxDepth = cutoff === Infinity ? undefined : Math.floor(cutoff);
247
+ const bfs = await bfsWithTuning(ctx, s, source, { maxDepth, signal: options?.signal, onProgress: options?.onProgress }, { predKind: 0 });
248
+ const dist = dest ?? new Float32Array(s.nodeCount);
249
+ for (let v = 0; v < s.nodeCount; v++) {
250
+ const d = bfs.depth[v];
251
+ dist[v] = d === INVALID_INDEX ? Infinity : d;
252
+ }
253
+ return { dist, predArc: bfs.parent, reachedCount: bfs.visitedCount };
254
+ }
255
+ /**
256
+ * The words of PD-27's `pred` buffer for `n` nodes: the arcs at 0, the hop counts at `hb = roundUp(n, 64)`, the
257
+ * changed word at `2 hb` and the orphan word after it, in a 64-word tail.
258
+ * @internal
259
+ * @param n - the node count
260
+ * @returns the word count (`2 x hb + 64`)
261
+ */
262
+ export function predBufferWords(n) {
263
+ return 2 * Math.ceil(n / 64) * 64 + 64;
264
+ }
265
+ /**
266
+ * The predecessor pass (PD-11, PD-27): the source is the one seeded root and the two flag words are zeroed by
267
+ * `queue.writeBuffer`; then ONE batch of the roots pass (the plateau rule only), `MAX_LEVELS_PER_SUBMIT` hop passes
268
+ * with `P.iteration` counting inside the batch, the arcs re-filled with `INVALID_INDEX` and the predecessor pass,
269
+ * with the readbacks of `dist`, `pred[0, n)` and the two flag words; recorded again without the roots pass while the
270
+ * last hop pass still changed something (a plateau, or a tight subgraph, `k` hops deep needs `ceil((k + 1) / 32)`
271
+ * batches). More than `ceil((n + 1) / MAX_LEVELS_PER_SUBMIT) + 1` batches is E_VALIDATION, because a hop count is at
272
+ * most `n`. The orphan word is returned, not judged: `sssp` treats it as a kernel bug and `bellmanFord` as the rounded
273
+ * cycle PD-27 names.
274
+ * @internal
275
+ * @param input - the driver's buffers, kernels and key rule
276
+ * @returns the distances, the arcs and the orphan count
277
+ */
278
+ export async function predecessorPass(input) {
279
+ const { algorithm, ctx, scope, predKernel, recordFill, graph, dist, pred, n, arcCount, source, mode } = input;
280
+ const wg = ctx.workgroupSize;
281
+ const { queue } = ctx.device;
282
+ const bytes = 4 * n;
283
+ const hb = Math.ceil(n / 64) * 64;
284
+ const predArcs = { buffer: pred.buffer, offset: pred.offset, size: bytes, window: null };
285
+ queue.writeBuffer(pred.buffer, pred.offset + 4 * (hb + source), Uint32Array.of(0));
286
+ queue.writeBuffer(pred.buffer, pred.offset + 4 * 2 * hb, new Uint32Array(2));
287
+ const predPlan = planGridStride(n, wg, ctx.caps);
288
+ const predFields = {
289
+ wg,
290
+ n,
291
+ arcBase: 0,
292
+ arcEnd: arcCount,
293
+ predKind: 0,
294
+ source,
295
+ stride: predPlan.stride ?? n,
296
+ mode,
297
+ };
298
+ const maxBatches = Math.ceil((n + 1) / MAX_LEVELS_PER_SUBMIT) + 1;
299
+ let batches = 0;
300
+ for (;;) {
301
+ const batch = new CommandBatch(ctx, `${algorithm}/pred`);
302
+ const pass = batch.pass("pred");
303
+ const recordRole = (role, iteration) => {
304
+ const params = scope.params(FRONTIER_PARAMS, { ...predFields, role, iteration });
305
+ const bound = predKernel.bind({ ...graph, dist, pred, P: params.binding });
306
+ predKernel.dispatch(pass, bound, predPlan, [params.offset]);
307
+ };
308
+ if (batches === 0 && mode === 0) {
309
+ recordRole(0, 0);
310
+ }
311
+ for (let iteration = 0; iteration < MAX_LEVELS_PER_SUBMIT; iteration++) {
312
+ recordRole(1, iteration);
313
+ }
314
+ recordFill(pass, predArcs, n, INVALID_INDEX);
315
+ recordRole(2, 0);
316
+ batch.endPass();
317
+ const distRequest = batch.readback(dist.buffer, dist.offset, bytes);
318
+ const predRequest = batch.readback(pred.buffer, pred.offset, bytes);
319
+ const flagsRequest = batch.readback(pred.buffer, pred.offset + 4 * 2 * hb, 8);
320
+ scope.flush();
321
+ const back = await batch.submit().readback;
322
+ ctx.assertReady();
323
+ batches += 1;
324
+ const [changed, orphans] = new Uint32Array(back, flagsRequest.offset, 2);
325
+ if (changed < MAX_LEVELS_PER_SUBMIT) {
326
+ return {
327
+ dist: new Float32Array(back, distRequest.offset, n),
328
+ predArc: new Uint32Array(back, predRequest.offset, n).slice(),
329
+ orphans,
330
+ };
331
+ }
332
+ if (batches > maxBatches) {
333
+ throw new WebGpuGraphError("E_VALIDATION", `${algorithm}: the hop passes still changed something after ${batches} batches (a hop count is at most ${n})`, { label: `${algorithm}/pred`, message: `the hop passes did not converge in ${batches} batches` });
334
+ }
335
+ queue.writeBuffer(pred.buffer, pred.offset + 4 * 2 * hb, new Uint32Array(2));
336
+ }
337
+ }
338
+ /**
339
+ * Single-source shortest paths with the test knobs of PD-26's shape; `sssp` is this with an empty tuning.
340
+ * @internal
341
+ * @param ctx - the context whose device runs the kernels
342
+ * @param s - the snapshot (uploaded through ctx.residency, or found there)
343
+ * @param source - the source node index
344
+ * @param options - `cutoff` and `weights`, plus dest / signal / onProgress
345
+ * @param tuning - the knobs
346
+ * @returns the distances, the predecessor arcs and the reached count
347
+ */
348
+ export async function ssspWithTuning(ctx, s, source, options, tuning) {
349
+ ctx.assertReady();
350
+ await assertDeviceComputes(ctx);
351
+ const n = s.nodeCount;
352
+ assertSource(ALGORITHM, source, n);
353
+ const roundsPerSubmit = tuning.roundsPerSubmit ?? MAX_LEVELS_PER_SUBMIT;
354
+ if (!Number.isInteger(roundsPerSubmit) || roundsPerSubmit < 1 || roundsPerSubmit > MAX_LEVELS_PER_SUBMIT) {
355
+ throw new WebGpuGraphError("E_INVALID_ARGUMENT", `${ALGORITHM}: roundsPerSubmit must be an integer in [1, ${MAX_LEVELS_PER_SUBMIT}]`, {
356
+ argument: "roundsPerSubmit",
357
+ value: roundsPerSubmit,
358
+ expected: `an integer in [1, ${MAX_LEVELS_PER_SUBMIT}]`,
359
+ });
360
+ }
361
+ if (tuning.delta !== undefined && !(Number.isFinite(tuning.delta) && tuning.delta > 0)) {
362
+ throw new WebGpuGraphError("E_INVALID_ARGUMENT", `${ALGORITHM}: delta must be a finite positive number`, {
363
+ argument: "delta",
364
+ value: tuning.delta,
365
+ expected: "a finite positive number",
366
+ });
367
+ }
368
+ const dest = checkDest(ALGORITHM, options?.dest, n);
369
+ const vector = resolveWeights(ALGORITHM, s, options?.weights);
370
+ const cutoff = normaliseCutoff(ALGORITHM, options?.cutoff);
371
+ if (options?.signal?.aborted) {
372
+ throw aborted(ALGORITHM);
373
+ }
374
+ if (vector === null || vector.allOne) {
375
+ return unitWeightRoute(ctx, s, source, cutoff, dest, options);
376
+ }
377
+ if (!vector.nonNegative) {
378
+ throw new WebGpuGraphError("E_UNSUPPORTED", `${ALGORITHM}: a negative weight has no shortest path here`, {
379
+ feature: "sssp.negativeWeights",
380
+ hint: "use bellmanFord",
381
+ });
382
+ }
383
+ if (!vector.finite) {
384
+ throw new WebGpuGraphError("E_UNSUPPORTED", `${ALGORITHM}: a NaN or infinite weight has no bit-pattern order`, {
385
+ feature: "sssp.nonFiniteWeights",
386
+ });
387
+ }
388
+ const { arcCount } = s;
389
+ const core = ctx.residency.core(s);
390
+ const limit = ctx.caps.limits.maxStorageBufferBindingSize;
391
+ assertWholeCore(core, arcCount, limit, ALGORITHM);
392
+ // the raw halves: cap entries each, the far half at word cap so its byte offset is 256-aligned; one binding
393
+ // of both halves is what the relax kernel sees, so the whole buffer is held to the binding limit (DEP-P8-E)
394
+ const cap = Math.ceil(Math.max(1, arcCount) / HALF_ALIGN) * HALF_ALIGN;
395
+ if (8 * cap > limit) {
396
+ throw new WebGpuGraphError("E_TOO_LARGE", `${ALGORITHM}: the near-far queue of ${cap} entries per half needs ${8 * cap} bytes, above the ${limit}-byte binding limit (the relax is never windowed)`, { needed: 8 * cap, limit, path: "sssp.queue", algorithm: ALGORITHM });
397
+ }
398
+ // PD-22: the delta from the vector in use; an all-zero vector would land every relaxation on the far pile
399
+ const delta = Math.fround(tuning.delta ?? (vector.sum === 0 ? 1 : (SSSP_DELTA_FACTOR * (vector.sum / arcCount)) / (arcCount / n)));
400
+ const deltaBits = bitsOf(delta);
401
+ const maxRounds = n + Math.ceil(vector.sum / delta) + 1;
402
+ const maxSubmits = Math.ceil((maxRounds + 1) / roundsPerSubmit) + 1;
403
+ const scope = algorithmScope(ctx, ALGORITHM, RING_SLOTS);
404
+ try {
405
+ const wg = ctx.workgroupSize;
406
+ const bytes = 4 * n;
407
+ const dist = bindingOf(scope.scratch(bytes, "dist"), bytes);
408
+ const owner = bindingOf(scope.scratch(bytes, "owner"), bytes);
409
+ const queueOut = bindingOf(scope.scratch(8 * cap, "queue-out"), 8 * cap);
410
+ const nearHalf = { buffer: queueOut.buffer, offset: 0, size: 4 * cap, window: null };
411
+ const farHalf = { buffer: queueOut.buffer, offset: 4 * cap, size: 4 * cap, window: null };
412
+ // the pred buffer of PD-27: the arcs at 0, the hop counts at hb, the changed word at 2 hb, the orphan word after it
413
+ const predWords = predBufferWords(n);
414
+ const pred = bindingOf(scope.scratch(4 * predWords, "pred"), 4 * predWords);
415
+ const { queue } = ctx.device;
416
+ let weightsBinding;
417
+ if (vector.override !== null) {
418
+ const uploaded = scope.scratch(4 * arcCount, "weights");
419
+ queue.writeBuffer(uploaded, 0, vector.override);
420
+ weightsBinding = bindingOf(uploaded, 4 * arcCount);
421
+ }
422
+ await ctx.allocator.check();
423
+ const planner = await prepareFrontier(scope, n, arcCount, cap);
424
+ const compact = await prepareCompact(scope);
425
+ const overrides = graphOverrides(core, null, weightsBinding);
426
+ const relax = await ctx.pipelines.kernel(kernelSpec("sssp-relax", overrides));
427
+ const predKernel = await ctx.pipelines.kernel(kernelSpec("sssp-pred", { ...overrides, MODE: 0 }));
428
+ const fill = await ctx.pipelines.kernel(kernelSpec("fill"));
429
+ const graph = graphBindings(core, null, weightsBinding);
430
+ const { frontier } = planner;
431
+ const { counters } = frontier;
432
+ const nearIn = frontier.vertices[0];
433
+ const farIn = frontier.vertices[1];
434
+ const recordFill = (pass, dst, count, value) => {
435
+ const params = scope.params(FILL_PARAMS, { count, value, mode: 0, pad0: 0 });
436
+ fill.dispatch(pass, fill.bind({ dst, P: params.binding }), plan1d(count, wg, ctx.caps), [params.offset]);
437
+ };
438
+ const submit = (batch) => {
439
+ scope.flush();
440
+ return batch.submit();
441
+ };
442
+ // setup: dist = +Inf everywhere and the pred buffer INVALID_INDEX; then the source at 0, the seeded block
443
+ // (the source in the RAW near half so the first boundary dedupes a one-entry pile like every later one)
444
+ const setup = new CommandBatch(ctx, `${ALGORITHM}/setup`);
445
+ const setupPass = setup.pass("fill");
446
+ recordFill(setupPass, dist, n, F32_INF_BITS);
447
+ recordFill(setupPass, pred, predWords, INVALID_INDEX);
448
+ setup.endPass();
449
+ await submit(setup).readback;
450
+ ctx.assertReady();
451
+ queue.writeBuffer(dist.buffer, dist.offset + 4 * source, Uint32Array.of(0));
452
+ frontier.reset(queue, source, { nextFrontierCount: 1, thresholdBits: deltaBits, deltaBits });
453
+ queue.writeBuffer(queueOut.buffer, queueOut.offset, Uint32Array.of(source));
454
+ // the rounds: MAX_LEVELS_PER_SUBMIT per submit, four bytes back
455
+ const nearDedupe = {
456
+ queue: nearHalf,
457
+ count: cap,
458
+ countIndex: W.edgeCount, // role 2 writes the raw near count here when it chooses a near round, 0 otherwise
459
+ counters,
460
+ owner,
461
+ out: nearIn,
462
+ outCount: counters,
463
+ outIndex: W.frontierCount,
464
+ };
465
+ const farDedupe = {
466
+ queue: farHalf,
467
+ count: cap,
468
+ countIndex: W.edgeCountUnclamped, // and the raw far count here on a far round
469
+ counters,
470
+ owner,
471
+ out: farIn,
472
+ outCount: counters,
473
+ outIndex: W.farCount,
474
+ };
475
+ const relaxPlan = planGridStride(n, wg, ctx.caps); // a pile holds at most n entries; the kernel loops to the count word
476
+ const relaxFields = {
477
+ wg,
478
+ n,
479
+ edgeCapacity: cap,
480
+ arcBase: 0,
481
+ arcEnd: arcCount,
482
+ cutoffBits: bitsOf(cutoff),
483
+ source,
484
+ stride: relaxPlan.stride ?? wg,
485
+ };
486
+ let roundsRecorded = 0;
487
+ let submits = 0;
488
+ for (;;) {
489
+ const batch = new CommandBatch(ctx, `${ALGORITHM}/rounds`);
490
+ const pass = batch.pass("sssp");
491
+ const near = scope.params(FRONTIER_PARAMS, { ...relaxFields, role: 0 });
492
+ const far = scope.params(FRONTIER_PARAMS, { ...relaxFields, role: 1 });
493
+ const boundNear = relax.bind({ ...graph, dist, counters, queueIn: nearIn, queueOut, P: near.binding });
494
+ const boundFar = relax.bind({ ...graph, dist, counters, queueIn: farIn, queueOut, P: far.binding });
495
+ for (let round = 0; round < roundsPerSubmit; round++) {
496
+ // every dispatch of a round is DIRECT: role 2 writes the chosen half's raw count into the dedupe's count
497
+ // word (the other's is 0) and the path word the relax roles gate on, so the half not chosen is a no-op
498
+ planner.recordFinalize(pass, 2, round, {});
499
+ compact.recordDedupe(pass, nearDedupe);
500
+ compact.recordDedupe(pass, farDedupe);
501
+ planner.recordFinalize(pass, 3, round, {});
502
+ relax.dispatch(pass, boundNear, relaxPlan, [near.offset]);
503
+ relax.dispatch(pass, boundFar, relaxPlan, [far.offset]);
504
+ }
505
+ batch.endPass();
506
+ const doneRequest = batch.readback(counters.buffer, counters.offset + 4 * W.done, 4);
507
+ const inspect = tuning.onRound === undefined
508
+ ? null
509
+ : batch.readback(counters.buffer, counters.offset, FRONTIER_COUNTERS.byteLength);
510
+ const submitted = submit(batch);
511
+ const back = await submitted.readback;
512
+ roundsRecorded += roundsPerSubmit;
513
+ submits += 1;
514
+ ctx.assertReady();
515
+ if (options?.signal?.aborted) {
516
+ throw aborted(ALGORITHM, submitted.id);
517
+ }
518
+ options?.onProgress?.(Math.min(roundsRecorded, maxRounds), maxRounds);
519
+ if (inspect !== null && tuning.onRound !== undefined) {
520
+ tuning.onRound(roundsRecorded - 1, FRONTIER_COUNTERS.read(new DataView(back), inspect.offset));
521
+ }
522
+ const done = new Uint32Array(back, doneRequest.offset, 1)[0];
523
+ if (done === 1) {
524
+ break;
525
+ }
526
+ if (done !== 0) {
527
+ const block = FRONTIER_COUNTERS.read(new DataView(await ctx.readback.read(counters.buffer, FRONTIER_COUNTERS.byteLength, undefined, counters.offset)));
528
+ if (done === 2) {
529
+ const needed = Math.max(wordOf(block, "nextFrontierCount"), wordOf(block, "nextFarCount"));
530
+ throw new WebGpuGraphError("E_TOO_LARGE", `${ALGORITHM}: a raw pile of ${needed} entries overflowed its ${cap}-entry half`, { needed, limit: cap, path: "sssp.pile", algorithm: ALGORITHM });
531
+ }
532
+ throw new WebGpuGraphError("E_UNSUPPORTED", `${ALGORITHM}: the f32 threshold ${wordOf(block, "thresholdBits")} absorbed the delta ${deltaBits} (as bit patterns); the far pile can no longer be bucketed`, { feature: "sssp.thresholdAbsorbed", hint: "the distances outgrew the delta's f32 precision" });
533
+ }
534
+ if (submits > maxSubmits) {
535
+ throw new WebGpuGraphError("E_VALIDATION", `${ALGORITHM}: the done flag never rose in ${submits} submits (at most ${maxRounds} rounds)`, { label: `${ALGORITHM}/rounds`, message: `the done flag never rose in ${submits} submits` });
536
+ }
537
+ }
538
+ // the predecessor pass (PD-11, PD-27) under the plateau rule
539
+ const passed = await predecessorPass({
540
+ algorithm: ALGORITHM,
541
+ ctx,
542
+ scope,
543
+ predKernel,
544
+ recordFill,
545
+ graph,
546
+ dist,
547
+ pred,
548
+ n,
549
+ arcCount,
550
+ source,
551
+ mode: 0,
552
+ });
553
+ if (passed.orphans !== 0) {
554
+ // (2) of PD-27: every reached non-source node has an admitted in-arc under non-negative weights
555
+ throw new WebGpuGraphError("E_VALIDATION", `${ALGORITHM}: ${passed.orphans} reached node(s) the predecessor key never reached (a kernel bug)`, { label: `${ALGORITHM}/pred`, message: `${passed.orphans} orphan(s) in the predecessor pass` });
556
+ }
557
+ const distOut = dest ?? new Float32Array(n);
558
+ distOut.set(passed.dist);
559
+ let reachedCount = 0;
560
+ for (const d of distOut) {
561
+ if (d !== Infinity) {
562
+ reachedCount += 1;
563
+ }
564
+ }
565
+ return { dist: distOut, predArc: passed.predArc, reachedCount };
566
+ }
567
+ finally {
568
+ scope.dispose();
569
+ }
570
+ }
571
+ /**
572
+ * Single-source shortest paths on the device (spec 3.3 line 808, design 8.4, 9.7): `dist` in f32, bitwise equal to
573
+ * the f32 Dijkstra (PD-9), `predArc` a tight arc one PD-27 key step below each reached node (the chain always ends
574
+ * at the source), `reachedCount`; `cutoff` as the CPU port reads it (`dv <= cutoff`), `weights` a per-arc override
575
+ * of the snapshot's column for this run; a run with unit weights is the BFS (PD-22).
576
+ * @param ctx - the context whose device runs the kernels
577
+ * @param s - the snapshot (uploaded through ctx.residency, or found there)
578
+ * @param source - the source node index (E_INVALID_ARGUMENT outside `[0, n)`)
579
+ * @param options - `cutoff` and `weights`, plus dest (a Float32Array of length n for `dist`) / signal / onProgress
580
+ * @returns the distances, the predecessor arcs and the reached count
581
+ */
582
+ export function sssp(ctx, s, source, options) {
583
+ return ssspWithTuning(ctx, s, source, options, {});
584
+ }
585
+ //# sourceMappingURL=sssp.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sssp.js","sourceRoot":"","sources":["../../../src/algorithms/sssp.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqDG;AAEH,OAAO,EAAgC,aAAa,EAAgC,MAAM,uBAAuB,CAAC;AAElH,OAAO,EAAE,YAAY,EAAE,qBAAqB,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAEzF,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAG/D,OAAO,EACH,WAAW,EACX,iBAAiB,EACjB,eAAe,EACf,aAAa,EACb,cAAc,EACd,UAAU,GACb,MAAM,eAAe,CAAC;AACvB,OAAO,EAAqB,cAAc,EAAE,M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AAC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QACzB,IAAI,YAAY,GAAG,CAAC,CAAC;QACrB,KAAK,MAAM,CAAC,IAAI,OAAO,EAAE,CAAC;YACtB,IAAI,CAAC,KAAK,QAAQ,EAAE,CAAC;gBACjB,YAAY,IAAI,CAAC,CAAC;YACtB,CAAC;QACL,CAAC;QACD,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,CAAC,OAAO,EAAE,YAAY,EAAE,CAAC;IACpE,CAAC;YAAS,CAAC;QACP,KAAK,CAAC,OAAO,EAAE,CAAC;IACpB,CAAC;AACL,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,UAAU,IAAI,CAChB,GAAe,EACf,CAAgB,EAChB,MAAc,EACd,OAAqC;IAErC,OAAO,cAAc,CAAC,GAAG,EAAE,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,EAAE,CAAC,CAAC;AACvD,CAAC"}
@@ -166,4 +166,16 @@ export declare const GRID_EXTENT_FLOOR = 0.000001;
166
166
  export declare const GRID_BBOX_MARGIN = 1.01;
167
167
  /** The key width the grid always sorts with (P4 PD-5): three 8-bit passes cover the 19-bit 2D keys at G = 512 and the 22-bit 3D keys at G = 128, and an odd pass count leaves `sortedIdx` in the scratch pair. */
168
168
  export declare const GRID_SORT_BITS = 24;
169
+ /** Design 8.4 (P8 PD-7): traversal levels recorded per submit -- one four-byte readback per 32 BFS levels, SSSP rounds or closeness levels. */
170
+ export declare const MAX_LEVELS_PER_SUBMIT = 32;
171
+ /** Design 8.4 and 6 row 8 (P8): a frontier at most this long runs the fused expand-contract kernel (Merrill's "fleeting iterations"); the default of the `fusedMax` uniform, which a test may set to 0 or `U32_MAX`. */
172
+ export declare const FUSED_FRONTIER_MAX = 4096;
173
+ /** P8-T4: the indirect dispatch slots `frontier-finalize` writes per level (expand, contract, fused, fill-bits, bitset-build, bottom-up, fused-retry); the args buffer is `MAX_LEVELS_PER_SUBMIT x FRONTIER_CANDIDATES x 16` bytes. */
174
+ export declare const FRONTIER_CANDIDATES = 7;
175
+ /** Design 8.4 (P8 PD-21): Beamer's beta -- switch back to top-down when `frontierCount * BEAMER_BETA < unvisitedCount` and the frontier is shrinking; alpha is derived from the graph, so it has no constant. */
176
+ export declare const BEAMER_BETA = 24;
177
+ /** Design 8.4 (P8 PD-22): the near-far split `delta = SSSP_DELTA_FACTOR * avgWeight / avgDegree`, computed on the host from the weight vector the run uses. */
178
+ export declare const SSSP_DELTA_FACTOR = 32;
179
+ /** The bit pattern of +Infinity, the unreached sentinel of `dist` (P8 PD-9); interpolated into the prelude as `F32_INF_BITS` so no body types the literal. */
180
+ export declare const F32_INF_BITS = 2139095040;
169
181
  //# sourceMappingURL=constants.d.ts.map