@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
@@ -1 +1 @@
1
- {"version":3,"file":"core-shape.js","sourceRoot":"","sources":["../../../src/primitives/core-shape.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAIhD,iJAAiJ;AACjJ,MAAM,CAAC,MAAM,cAAc,GAAG,EAAE,CAAC;AAQjC;;;;;;GAMG;AACH,MAAM,UAAU,aAAa,CAAC,IAAiB;IAC3C,MAAM,EAAE,IAAI,EAAE,GAA4C,IAAI,CAAC,QAAQ,CAAC;IACxE,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;QACrB,MAAM,IAAI,gBAAgB,CAAC,oBAAoB,EAAE,OAAO,IAAI,CAAC,IAAI,2BAA2B,EAAE;YAC1F,QAAQ,EAAE,MAAM;YAChB,KAAK,EAAE,IAAI,CAAC,IAAI;YAChB,QAAQ,EAAE,8DAA8D;SAC3E,CAAC,CAAC;IACP,CAAC;IACD,MAAM,EAAE,GAAkC,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC;IACtE,MAAM,SAAS,GACX,EAAE,KAAK,SAAS;QAChB,EAAE,CAAC,MAAM,KAAK,CAAC;QACf,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC;QACX,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,IAAI,KAAK,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;IACvF,IAAI,CAAC,SAAS,IAAI,EAAE,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,IAAI,GAAG,CAAC,EAAE,CAAC;QACxC,MAAM,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AAC,CAAC,QAAQ,CAAC,MAAM,KAAK,SAAS,IAAI,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC;IAC1G,MAAM,OAAO,GAAG,CAAC,CAAC,QAAQ,CAAC,OAAO,KAAK,SAAS,IAAI,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC;IAC9G,MAAM,KAAK,GAAG,MAAM,KAAK,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,GAAG,CAAC,CAAC;IACpD,IAAI,KAAK,KAAK,QAAQ,EAAE,CAAC;QACrB,MAAM,IAAI,gBAAgB,CACtB,oBAAoB,EACpB,OAAO,CAAC,CAAC,IAAI,eAAe,KAAK,sCAAsC,QAAQ,EAAE,EACjF;YACI,QAAQ,EAAE,UAAU;YACpB,KAAK,EAAE,QAAQ;YACf,QAAQ,EAAE,KAAK;SAClB,CACJ,CAAC;IACN,CAAC;IACD,OAAO,MAAM,CAAC,MAAM,CAAC;QACjB,MAAM,EAAE,CAAC,CAAC;QACV,IAAI,EAAE,UAAmB;QACzB,MAAM;QACN,MAAM;QACN,OAAO;QACP,SAAS,EAAE,IAAI;QACf,SAAS,EAAE,IAAI;QACf,OAAO,EAAE,IAAI;QACb,UAAU,EAAE,IAAI;QAChB,UAAU,EAAE,OAAO,KAAK,IAAI;KAC/B,CAAC,CAAC;AACP,CAAC"}
@@ -0,0 +1,156 @@
1
+ /**
2
+ * The `Frontier` of design 6 row 7 and the device-side dispatch selector of design 5.4 (P8-T4; the P8 plan's PD-1,
3
+ * PD-3, PD-8, PD-23, DEP-P8-A, DEP-P8-C). A traversal's per-level state is two n-slot vertex queues, ONE 24-word
4
+ * counters block (every counter of the phase is a word of it: a four-byte word is never a legal storage-binding
5
+ * offset, and the selector must reach every count it acts on through one binding), the indirect args buffer of
6
+ * `MAX_LEVELS_PER_SUBMIT x FRONTIER_CANDIDATES` 16-byte slots, and the edge queue. The host never reads a counter
7
+ * inside a submit: `frontier-finalize`, one lane, runs at the START of every level (role 0: rotates
8
+ * `nextFrontierCount` into `frontierCount`, advances `level`, decides `done`, writes this level's slots) and again once
9
+ * the edge queue is filled (role 1: clamps `edgeCount`, sizes the contract slot, or on an overflow --
10
+ * `edgeCountUnclamped > edgeCapacity` -- sizes the fused-retry slot instead, PD-23), and the kernels that follow
11
+ * dispatch indirectly from those slots. The host records up to `MAX_LEVELS_PER_SUBMIT` levels per submit and reads
12
+ * `done` (four bytes) once per submit; a boundary that finds `done` set zeroes its slots and moves no counter, so the
13
+ * recorded levels past the end are no-ops and the counters freeze at the finishing boundary's values.
14
+ *
15
+ * The seed: `frontierCount` is NEVER seeded, because the first boundary rotates it out unread. A BFS driver calls
16
+ * `reset(queue, source, { nextFrontierCount: 1, level: U32_MAX })`: the first boundary rotates the 1 in, adds it into
17
+ * `visitedCount`, and wraps `level` to 0, so the level-0 expansion claims the source's neighbours at `level + 1 == 1`.
18
+ * `reset` is a queue write, ordered before the submit that follows, and it puts the source on side 0.
19
+ *
20
+ * Every buffer comes from the caller's ONE lease (`scope.scratch`, `scope.indirect`) so the algorithm's dispose()
21
+ * releases them together (design 4.4). The two vertex queues are two BUFFERS, never two ranges of one: `Kernel.bind`
22
+ * rejects one buffer bound read-only and read-write in one dispatch even for disjoint ranges. `src/primitives/**`
23
+ * never imports `src/context.ts`.
24
+ */
25
+ import { type Binding } from "../types/memory.js";
26
+ import { type ReduceScope } from "./reduce.js";
27
+ /** The seven indirect slots of one level (`FRONTIER_CANDIDATES`), by the kernel that dispatches from each. */
28
+ export declare const SLOT: Readonly<{
29
+ expand: 0;
30
+ contract: 1;
31
+ fused: 2;
32
+ fillBits: 3;
33
+ bitset: 4;
34
+ bottomUp: 5;
35
+ fusedRetry: 6;
36
+ }>;
37
+ /** The words of the counters block (`FRONTIER_COUNTERS`), by index: byte offset 4 x word; no driver types a number. */
38
+ export declare const W: Readonly<{
39
+ frontierCount: 0;
40
+ nextFrontierCount: 1;
41
+ frontierDegreeSum: 2;
42
+ prevFrontierCount: 3;
43
+ prevDegreeSum: 4;
44
+ unvisitedCount: 5;
45
+ unvisitedDegreeSum: 6;
46
+ unvisitedListLen: 7;
47
+ edgeCount: 8;
48
+ edgeCountUnclamped: 9;
49
+ overflowLevels: 10;
50
+ level: 11;
51
+ visitedCount: 12;
52
+ switches: 13;
53
+ direction: 14;
54
+ done: 15;
55
+ arcsScanned: 16;
56
+ fusedLevels: 17;
57
+ twoPhaseLevels: 18;
58
+ bottomUpLevels: 19;
59
+ farCount: 20;
60
+ nextFarCount: 21;
61
+ thresholdBits: 22;
62
+ deltaBits: 23;
63
+ path: 24;
64
+ }>;
65
+ /** The words a `reset` seeds (every other word is zeroed). */
66
+ export type FrontierSeed = Readonly<Partial<Record<keyof typeof W, number>>>;
67
+ /** A ReduceScope that can also lease an INDIRECT buffer (the args of the frontier); `algorithmScope` is one. */
68
+ export interface FrontierScope extends ReduceScope {
69
+ /** A STORAGE | INDIRECT | COPY_DST | COPY_SRC buffer of the scope's lease. */
70
+ indirect(byteLength: number, label: string): GPUBuffer;
71
+ }
72
+ /** The `FrontierParams` fields a caller passes to `recordFinalize`; the planner fills `role`, `slotBase`, `wg`, `edgeCapacity` and `n` itself. A missing field is written as 0. */
73
+ export type FrontierFinalizeFields = Readonly<Partial<Record<"alpha" | "beta" | "fusedMax" | "maxDepth" | "mode" | "cutoffBits" | "arcBase" | "arcEnd" | "predKind" | "bitsBase" | "source" | "stride" | "firstOfSubmit" | "iteration", number>>>;
74
+ /** The frontier queue of design 6 row 7: two vertex queues, the counters block, the args buffer and the edge queue, all leased by the caller's scope. */
75
+ export declare class Frontier {
76
+ /** The two n-slot u32 vertex queues (`vertices[side]` is the input of the current level). */
77
+ readonly vertices: readonly [Binding, Binding];
78
+ /** The `FrontierCounters` block, 96 B, bound by every kernel as `array<atomic<u32>>`. */
79
+ readonly counters: Binding;
80
+ /** The indirect args, `MAX_LEVELS_PER_SUBMIT x FRONTIER_CANDIDATES` 16-byte slots (usage INDIRECT | STORAGE | COPY_DST | COPY_SRC). */
81
+ readonly args: Binding;
82
+ /** The edge queue: `edgeCapacity` entries of u32 (the target vertex of an arc). */
83
+ readonly edgeQueue: Binding;
84
+ /** How many entries the edge queue holds; role 1 clamps `edgeCount` to it and detects an overflow above it. */
85
+ readonly edgeCapacity: number;
86
+ /** The vertex count (a `reset` source is below it). */
87
+ readonly n: number;
88
+ private sideIndex;
89
+ /**
90
+ * Wraps the leased buffers; use prepareFrontier().
91
+ * @param vertices - the two vertex queues
92
+ * @param counters - the counters block
93
+ * @param args - the args buffer
94
+ * @param edgeQueue - the edge queue
95
+ * @param edgeCapacity - the edge queue's entry count
96
+ * @param n - the vertex count
97
+ */
98
+ constructor(vertices: readonly [Binding, Binding], counters: Binding, args: Binding, edgeQueue: Binding, edgeCapacity: number, n: number);
99
+ /**
100
+ * Which vertex queue is the input of the current level (a host-side index between two cached bind-group sets).
101
+ * @returns 0 or 1
102
+ */
103
+ get side(): 0 | 1;
104
+ /**
105
+ * The vertex queue the current level expands from.
106
+ * @returns `vertices[side]`
107
+ */
108
+ get input(): Binding;
109
+ /**
110
+ * The vertex queue the current level's claims append to.
111
+ * @returns `vertices[1 - side]`
112
+ */
113
+ get output(): Binding;
114
+ /** Flips the two vertex queues; the counts rotate inside the block, so nothing else moves. */
115
+ swap(): void;
116
+ /**
117
+ * Seeds a traversal: one `queue.writeBuffer` of the whole 96-byte block (zero except the caller's words) and one of
118
+ * `vertices[0][0] = source`, both ordered before the submit that follows; the source is on side 0 afterwards.
119
+ * `frontierCount` is not a word to seed: the first boundary rotates word 1 into it (the BFS seed is
120
+ * `{ nextFrontierCount: 1, level: U32_MAX }`). A source outside `[0, n)`, an unknown word or a value that is not a
121
+ * u32 is E_INVALID_ARGUMENT before anything is written.
122
+ * @param queue - the device queue
123
+ * @param source - the source vertex
124
+ * @param seed - the words to seed
125
+ */
126
+ reset(queue: GPUQueue, source: number, seed: FrontierSeed): void;
127
+ }
128
+ /** A prepared frontier (design 6 row 7): the leased queue and the recorded selector dispatches. */
129
+ export interface FrontierPlanner {
130
+ /** The queue the planner sizes the slots of. */
131
+ readonly frontier: Frontier;
132
+ /**
133
+ * Records one `frontier-finalize` dispatch (one workgroup) in `role` for `level` of the current submit: one
134
+ * `FrontierParams` record with `slotBase = level x FRONTIER_CANDIDATES`, `wg`, `edgeCapacity` and `n` filled by the
135
+ * planner and every other field from `fields`. A level outside `[0, MAX_LEVELS_PER_SUBMIT)` or a role outside
136
+ * `[0, 3]` is E_INVALID_ARGUMENT before anything is recorded.
137
+ * @param pass - the compute pass
138
+ * @param role - 0 the level boundary, 1 the edge-queue role (2 and 3 are P8-T9's)
139
+ * @param level - the level inside the submit
140
+ * @param fields - the tuning and window words
141
+ */
142
+ recordFinalize(pass: GPUComputePassEncoder, role: number, level: number, fields: FrontierFinalizeFields): void;
143
+ }
144
+ /**
145
+ * Leases the frontier's buffers from the scope and compiles the selector so `recordFinalize` is synchronous. The
146
+ * edge capacity defaults to `max(1, min(arcCount, floor(maxStorageBufferBindingSize / 4)))` (never a zero-length
147
+ * buffer: the one-node graph has no arcs); a test passes a small one to force the overflow path. The planner lives
148
+ * exactly as long as the scope: never use it after the scope's dispose().
149
+ * @param scope - the caller's scope (device, caps, cache, scratch, indirect, params)
150
+ * @param n - the vertex count
151
+ * @param arcCount - the arc count (the natural edge-queue size)
152
+ * @param edgeCapacity - the edge queue's entry count, when the caller chooses it (an integer >= 1)
153
+ * @returns the planner
154
+ */
155
+ export declare function prepareFrontier(scope: FrontierScope, n: number, arcCount: number, edgeCapacity?: number): Promise<FrontierPlanner>;
156
+ //# sourceMappingURL=frontier.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"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B,IAAI,EAAE,OAAO,EACb,SAAS,EAAE,OAAO,EAClB,YAAY,EAAE,MAAM,EACpB,CAAC,EAAE,MAAM;IAUb;;;OAGG;IACH,IAAI,IAAI,IAAI,CAAC,GAAG,CAAC,CAEhB;IAED;;;OAGG;IACH,IAAI,KAAK,IAAI,OAAO,CAEnB;IAED;;;OAGG;IACH,IAAI,MAAM,IAAI,OAAO,CAEpB;IAED,8FAA8F;IAC9F,IAAI,IAAI,IAAI;IAIZ;;;;;;;;;OASG;IACH,KAAK,CAAC,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,YAAY,GAAG,IAAI;CAcnE;AAED,mGAAmG;AACnG,MAAM,WAAW,eAAe;IAC5B,gDAAgD;IAChD,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC;IAC5B;;;;;;;;;OASG;IACH,cAAc,CAAC,IAAI,EAAE,qBAAqB,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,sBAAsB,GAAG,IAAI,CAAC;CAClH;AAED;;;;;;;;;;GAUG;AACH,wBAAsB,eAAe,CACjC,KAAK,EAAE,aAAa,EACpB,CAAC,EAAE,MAAM,EACT,QAAQ,EAAE,MAAM,EAChB,YAAY,CAAC,EAAE,MAAM,GACtB,OAAO,CAAC,eAAe,CAAC,CAuC1B"}
@@ -0,0 +1,259 @@
1
+ /**
2
+ * The `Frontier` of design 6 row 7 and the device-side dispatch selector of design 5.4 (P8-T4; the P8 plan's PD-1,
3
+ * PD-3, PD-8, PD-23, DEP-P8-A, DEP-P8-C). A traversal's per-level state is two n-slot vertex queues, ONE 24-word
4
+ * counters block (every counter of the phase is a word of it: a four-byte word is never a legal storage-binding
5
+ * offset, and the selector must reach every count it acts on through one binding), the indirect args buffer of
6
+ * `MAX_LEVELS_PER_SUBMIT x FRONTIER_CANDIDATES` 16-byte slots, and the edge queue. The host never reads a counter
7
+ * inside a submit: `frontier-finalize`, one lane, runs at the START of every level (role 0: rotates
8
+ * `nextFrontierCount` into `frontierCount`, advances `level`, decides `done`, writes this level's slots) and again once
9
+ * the edge queue is filled (role 1: clamps `edgeCount`, sizes the contract slot, or on an overflow --
10
+ * `edgeCountUnclamped > edgeCapacity` -- sizes the fused-retry slot instead, PD-23), and the kernels that follow
11
+ * dispatch indirectly from those slots. The host records up to `MAX_LEVELS_PER_SUBMIT` levels per submit and reads
12
+ * `done` (four bytes) once per submit; a boundary that finds `done` set zeroes its slots and moves no counter, so the
13
+ * recorded levels past the end are no-ops and the counters freeze at the finishing boundary's values.
14
+ *
15
+ * The seed: `frontierCount` is NEVER seeded, because the first boundary rotates it out unread. A BFS driver calls
16
+ * `reset(queue, source, { nextFrontierCount: 1, level: U32_MAX })`: the first boundary rotates the 1 in, adds it into
17
+ * `visitedCount`, and wraps `level` to 0, so the level-0 expansion claims the source's neighbours at `level + 1 == 1`.
18
+ * `reset` is a queue write, ordered before the submit that follows, and it puts the source on side 0.
19
+ *
20
+ * Every buffer comes from the caller's ONE lease (`scope.scratch`, `scope.indirect`) so the algorithm's dispose()
21
+ * releases them together (design 4.4). The two vertex queues are two BUFFERS, never two ranges of one: `Kernel.bind`
22
+ * rejects one buffer bound read-only and read-write in one dispatch even for disjoint ranges. `src/primitives/**`
23
+ * never imports `src/context.ts`.
24
+ */
25
+ import { FRONTIER_CANDIDATES, MAX_LEVELS_PER_SUBMIT, U32_MAX } from "../constants.js";
26
+ import { WebGpuGraphError } from "../errors.js";
27
+ import { plan1d } from "../kernel/dispatch.js";
28
+ import { INDIRECT_ARGS_STRIDE } from "../kernel/kernel.js";
29
+ import { FRONTIER_COUNTERS, FRONTIER_PARAMS, kernelSpec } from "../kernels.js";
30
+ /** The seven indirect slots of one level (`FRONTIER_CANDIDATES`), by the kernel that dispatches from each. */
31
+ export const SLOT = Object.freeze({ expand: 0, contract: 1, fused: 2, fillBits: 3, bitset: 4, bottomUp: 5, fusedRetry: 6 });
32
+ /** The words of the counters block (`FRONTIER_COUNTERS`), by index: byte offset 4 x word; no driver types a number. */
33
+ export const W = Object.freeze({
34
+ frontierCount: 0,
35
+ nextFrontierCount: 1,
36
+ frontierDegreeSum: 2,
37
+ prevFrontierCount: 3,
38
+ prevDegreeSum: 4,
39
+ unvisitedCount: 5,
40
+ unvisitedDegreeSum: 6,
41
+ unvisitedListLen: 7,
42
+ edgeCount: 8,
43
+ edgeCountUnclamped: 9,
44
+ overflowLevels: 10,
45
+ level: 11,
46
+ visitedCount: 12,
47
+ switches: 13,
48
+ direction: 14,
49
+ done: 15,
50
+ arcsScanned: 16,
51
+ fusedLevels: 17,
52
+ twoPhaseLevels: 18,
53
+ bottomUpLevels: 19,
54
+ farCount: 20,
55
+ nextFarCount: 21,
56
+ thresholdBits: 22,
57
+ deltaBits: 23,
58
+ path: 24,
59
+ });
60
+ /**
61
+ * The given words of a partial record (a key spelled with an undefined value is dropped, so the block writer sees
62
+ * only numbers).
63
+ * @param words - the partial record
64
+ * @returns the defined entries
65
+ */
66
+ function definedWords(words) {
67
+ const out = {};
68
+ for (const [name, value] of Object.entries(words)) {
69
+ if (value !== undefined) {
70
+ out[name] = value;
71
+ }
72
+ }
73
+ return out;
74
+ }
75
+ /** The largest role `frontier-finalize` knows: 0 and 1 land here (P8-T4), 2 and 3 are the SSSP piles' (P8-T9). */
76
+ const MAX_ROLE = 3;
77
+ /**
78
+ * The E_INVALID_ARGUMENT of a value that is not a non-negative integer.
79
+ * @param argument - the argument name
80
+ * @param value - the value
81
+ */
82
+ function assertCount(argument, value) {
83
+ if (!Number.isSafeInteger(value) || value < 0) {
84
+ throw new WebGpuGraphError("E_INVALID_ARGUMENT", `frontier: ${argument} must be a non-negative integer`, {
85
+ argument,
86
+ value,
87
+ expected: "a non-negative integer",
88
+ });
89
+ }
90
+ }
91
+ /** The frontier queue of design 6 row 7: two vertex queues, the counters block, the args buffer and the edge queue, all leased by the caller's scope. */
92
+ export class Frontier {
93
+ /**
94
+ * Wraps the leased buffers; use prepareFrontier().
95
+ * @param vertices - the two vertex queues
96
+ * @param counters - the counters block
97
+ * @param args - the args buffer
98
+ * @param edgeQueue - the edge queue
99
+ * @param edgeCapacity - the edge queue's entry count
100
+ * @param n - the vertex count
101
+ */
102
+ constructor(vertices, counters, args, edgeQueue, edgeCapacity, n) {
103
+ this.sideIndex = 0;
104
+ this.vertices = vertices;
105
+ this.counters = counters;
106
+ this.args = args;
107
+ this.edgeQueue = edgeQueue;
108
+ this.edgeCapacity = edgeCapacity;
109
+ this.n = n;
110
+ }
111
+ /**
112
+ * Which vertex queue is the input of the current level (a host-side index between two cached bind-group sets).
113
+ * @returns 0 or 1
114
+ */
115
+ get side() {
116
+ return this.sideIndex;
117
+ }
118
+ /**
119
+ * The vertex queue the current level expands from.
120
+ * @returns `vertices[side]`
121
+ */
122
+ get input() {
123
+ return this.sideIndex === 0 ? this.vertices[0] : this.vertices[1];
124
+ }
125
+ /**
126
+ * The vertex queue the current level's claims append to.
127
+ * @returns `vertices[1 - side]`
128
+ */
129
+ get output() {
130
+ return this.sideIndex === 0 ? this.vertices[1] : this.vertices[0];
131
+ }
132
+ /** Flips the two vertex queues; the counts rotate inside the block, so nothing else moves. */
133
+ swap() {
134
+ this.sideIndex = this.sideIndex === 0 ? 1 : 0;
135
+ }
136
+ /**
137
+ * Seeds a traversal: one `queue.writeBuffer` of the whole 96-byte block (zero except the caller's words) and one of
138
+ * `vertices[0][0] = source`, both ordered before the submit that follows; the source is on side 0 afterwards.
139
+ * `frontierCount` is not a word to seed: the first boundary rotates word 1 into it (the BFS seed is
140
+ * `{ nextFrontierCount: 1, level: U32_MAX }`). A source outside `[0, n)`, an unknown word or a value that is not a
141
+ * u32 is E_INVALID_ARGUMENT before anything is written.
142
+ * @param queue - the device queue
143
+ * @param source - the source vertex
144
+ * @param seed - the words to seed
145
+ */
146
+ reset(queue, source, seed) {
147
+ if (!Number.isInteger(source) || source < 0 || source >= this.n) {
148
+ throw new WebGpuGraphError("E_INVALID_ARGUMENT", `frontier: source ${source} is outside [0, ${this.n})`, {
149
+ argument: "source",
150
+ value: source,
151
+ expected: `an integer in [0, ${this.n})`,
152
+ });
153
+ }
154
+ const bytes = new ArrayBuffer(FRONTIER_COUNTERS.byteLength);
155
+ FRONTIER_COUNTERS.write(new DataView(bytes), definedWords(seed));
156
+ this.sideIndex = 0;
157
+ queue.writeBuffer(this.counters.buffer, this.counters.offset, bytes);
158
+ queue.writeBuffer(this.vertices[0].buffer, this.vertices[0].offset, Uint32Array.of(source));
159
+ }
160
+ }
161
+ /**
162
+ * Leases the frontier's buffers from the scope and compiles the selector so `recordFinalize` is synchronous. The
163
+ * edge capacity defaults to `max(1, min(arcCount, floor(maxStorageBufferBindingSize / 4)))` (never a zero-length
164
+ * buffer: the one-node graph has no arcs); a test passes a small one to force the overflow path. The planner lives
165
+ * exactly as long as the scope: never use it after the scope's dispose().
166
+ * @param scope - the caller's scope (device, caps, cache, scratch, indirect, params)
167
+ * @param n - the vertex count
168
+ * @param arcCount - the arc count (the natural edge-queue size)
169
+ * @param edgeCapacity - the edge queue's entry count, when the caller chooses it (an integer >= 1)
170
+ * @returns the planner
171
+ */
172
+ export async function prepareFrontier(scope, n, arcCount, edgeCapacity) {
173
+ assertCount("n", n);
174
+ assertCount("arcCount", arcCount);
175
+ const capacity = edgeCapacity ?? Math.max(1, Math.min(arcCount, Math.floor(scope.caps.limits.maxStorageBufferBindingSize / 4)));
176
+ if (!Number.isSafeInteger(capacity) || capacity < 1 || capacity > U32_MAX) {
177
+ throw new WebGpuGraphError("E_INVALID_ARGUMENT", "frontier: edgeCapacity must be an integer >= 1", {
178
+ argument: "edgeCapacity",
179
+ value: capacity,
180
+ expected: "an integer in [1, 2^32)",
181
+ });
182
+ }
183
+ const kernel = await scope.pipelines.kernel(kernelSpec("frontier-finalize"));
184
+ const queueBytes = 4 * Math.max(1, n);
185
+ const argsBytes = MAX_LEVELS_PER_SUBMIT * FRONTIER_CANDIDATES * INDIRECT_ARGS_STRIDE;
186
+ const vertices = [
187
+ { buffer: scope.scratch(queueBytes, "frontier/vertices-0"), offset: 0, size: queueBytes, window: null },
188
+ { buffer: scope.scratch(queueBytes, "frontier/vertices-1"), offset: 0, size: queueBytes, window: null },
189
+ ];
190
+ const counters = {
191
+ buffer: scope.scratch(FRONTIER_COUNTERS.byteLength, "frontier/counters"),
192
+ offset: 0,
193
+ size: FRONTIER_COUNTERS.byteLength,
194
+ window: null,
195
+ };
196
+ const args = {
197
+ buffer: scope.indirect(argsBytes, "frontier/args"),
198
+ offset: 0,
199
+ size: argsBytes,
200
+ window: null,
201
+ };
202
+ const edgeQueue = {
203
+ buffer: scope.scratch(4 * capacity, "frontier/edge-queue"),
204
+ offset: 0,
205
+ size: 4 * capacity,
206
+ window: null,
207
+ };
208
+ const frontier = new Frontier(vertices, counters, args, edgeQueue, capacity, n);
209
+ return new FrontierPlannerImpl(scope, kernel, frontier);
210
+ }
211
+ /** The planner: the selector kernel bound once to the frontier's block and args. */
212
+ class FrontierPlannerImpl {
213
+ /**
214
+ * Wraps the resolved kernel; use prepareFrontier().
215
+ * @param scope - the caller's scope
216
+ * @param kernel - the `frontier-finalize` kernel
217
+ * @param frontier - the leased queue
218
+ */
219
+ constructor(scope, kernel, frontier) {
220
+ this.scope = scope;
221
+ this.kernel = kernel;
222
+ this.frontier = frontier;
223
+ }
224
+ /**
225
+ * Records one selector dispatch (see the interface).
226
+ * @param pass - the compute pass
227
+ * @param role - the role
228
+ * @param level - the level inside the submit
229
+ * @param fields - the caller's fields
230
+ */
231
+ recordFinalize(pass, role, level, fields) {
232
+ if (!Number.isInteger(level) || level < 0 || level >= MAX_LEVELS_PER_SUBMIT) {
233
+ throw new WebGpuGraphError("E_INVALID_ARGUMENT", `frontier: level ${level} is outside the submit`, {
234
+ argument: "level",
235
+ value: level,
236
+ expected: `an integer in [0, ${MAX_LEVELS_PER_SUBMIT})`,
237
+ });
238
+ }
239
+ if (!Number.isInteger(role) || role < 0 || role > MAX_ROLE) {
240
+ throw new WebGpuGraphError("E_INVALID_ARGUMENT", `frontier: role ${role} is not a finalize role`, {
241
+ argument: "role",
242
+ value: role,
243
+ expected: `an integer in [0, ${MAX_ROLE}]`,
244
+ });
245
+ }
246
+ const { scope, frontier } = this;
247
+ const params = scope.params(FRONTIER_PARAMS, {
248
+ ...definedWords(fields),
249
+ role,
250
+ slotBase: level * FRONTIER_CANDIDATES,
251
+ wg: scope.workgroupSize,
252
+ edgeCapacity: frontier.edgeCapacity,
253
+ n: frontier.n,
254
+ });
255
+ const bound = this.kernel.bind({ counters: frontier.counters, args: frontier.args, P: params.binding });
256
+ this.kernel.dispatch(pass, bound, plan1d(1, scope.workgroupSize, scope.caps), [params.offset]);
257
+ }
258
+ }
259
+ //# sourceMappingURL=frontier.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"frontier.js","sourceRoot":"","sources":["../../../src/primitives/frontier.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,EAAE,mBAAmB,EAAE,qBAAqB,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AACtF,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAC/C,OAAO,EAAE,oBAAoB,EAAe,MAAM,qBAAqB,CAAC;AACxE,OAAO,EAAE,iBAAiB,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAI/E,8GAA8G;AAC9G,MAAM,CAAC,MAAM,IAAI,GAQZ,MAAM,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,QAAQ,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,QAAQ,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,QAAQ,EAAE,CAAC,EAAE,UAAU,EAAE,CAAC,EAAE,CAAC,CAAC;AAE7G,uHAAuH;AACvH,MAAM,CAAC,MAAM,CAAC,GA0BT,MAAM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MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,IAAI,GAAG,CAAC,IAAI,IAAI,GAAG,QAAQ,EAAE,CAAC;YACzD,MAAM,IAAI,gBAAgB,CAAC,oBAAoB,EAAE,kBAAkB,IAAI,yBAAyB,EAAE;gBAC9F,QAAQ,EAAE,MAAM;gBAChB,KAAK,EAAE,IAAI;gBACX,QAAQ,EAAE,qBAAqB,QAAQ,GAAG;aAC7C,CAAC,CAAC;QACP,CAAC;QACD,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,GAAG,IAAI,CAAC;QACjC,MAAM,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC,eAAe,EAAE;YACzC,GAAG,YAAY,CAAC,MAAM,CAAC;YACvB,IAAI;YACJ,QAAQ,EAAE,KAAK,GAAG,mBAAmB;YACrC,EAAE,EAAE,KAAK,CAAC,aAAa;YACvB,YAAY,EAAE,QAAQ,CAAC,YAAY;YACnC,CAAC,EAAE,QAAQ,CAAC,CAAC;SAChB,CAAC,CAAC;QACH,MAAM,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,QAAQ,EAAE,QAAQ,CAAC,QAAQ,EAAE,IAAI,EAAE,QAAQ,CAAC,IAAI,EAAE,CAAC,EAAE,MAAM,CAAC,OAAO,EAAE,CAAC,CAAC;QACxG,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC,EAAE,KAAK,CAAC,aAAa,EAAE,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC;IACnG,CAAC;CACJ"}
@@ -4,15 +4,16 @@
4
4
  * this package's public surface is unchanged; `test/types/conformance.test-d.ts` is the cross-compile that holds
5
5
  * them honest. Types only.
6
6
  */
7
- import type { AlgorithmAccelerator, ApspResultLike, BellmanFordResultLike, BetweennessAcceleratorOptions, BfsResultLike, CommunityResultLike, CorenessResultLike, EdgeScoresResultLike, HitsOptionsLike, HitsResultLike, LabelResultLike, MstResultLike, PageRankResultLike, ScoresResultLike, SsspResultLike } from "@graphty/algorithms";
7
+ import type { AlgorithmAccelerator, ApspResultLike, BellmanFordResultLike, BetweennessAcceleratorOptions, BfsOptions, BfsResultLike, CommunityResultLike, CorenessResultLike, EdgeScoresResultLike, HitsOptionsLike, HitsResultLike, LabelResultLike, MstResultLike, PageRankResultLike, ScoresResultLike, SsspOptions, SsspResultLike } from "@graphty/algorithms";
8
8
  import type { F32, F64, GraphSnapshot } from "@graphty/graph-format";
9
9
  import type { LayoutAccelerator, LayoutSimulation } from "@graphty/layout";
10
10
  import type { GpuContext } from "../context.js";
11
11
  import type { ComponentsOptions, EigenvectorOptions, GpuHitsResult, GpuLabelResult, GpuPageRankResult, GpuScoresResult, HitsOptions, KatzOptions, PageRankOptions } from "./algorithms.js";
12
12
  import type { ForceAtlas2Stats, FruchtermanReingoldStats, GpuLayoutSimulation, GpuLayoutTuning, SpringElectricalStats } from "./layout.js";
13
13
  import type { ForceAtlas2Options, FruchtermanReingoldOptions, SpringElectricalOptions } from "./options.js";
14
+ import type { GpuBellmanFordResult, GpuBfsResult, GpuSsspResult } from "./traversal.js";
14
15
  export type { LayoutAccelerator, LayoutSimulation };
15
- export type { AlgorithmAccelerator, ApspResultLike, BellmanFordResultLike, BetweennessAcceleratorOptions, BfsResultLike, CommunityResultLike, CorenessResultLike, EdgeScoresResultLike, HitsOptionsLike, HitsResultLike, LabelResultLike, MstResultLike, PageRankResultLike, ScoresResultLike, SsspResultLike, };
16
+ export type { AlgorithmAccelerator, ApspResultLike, BellmanFordResultLike, BetweennessAcceleratorOptions, BfsOptions, BfsResultLike, CommunityResultLike, CorenessResultLike, EdgeScoresResultLike, HitsOptionsLike, HitsResultLike, LabelResultLike, MstResultLike, PageRankResultLike, ScoresResultLike, SsspOptions, SsspResultLike, };
16
17
  /**
17
18
  * Spec 3.3 AcceleratorOptions, verbatim.
18
19
  * Exported: consumed by src/accelerator.ts (P3-T3); re-exported from src/index.ts at P3-T3.
@@ -31,11 +32,15 @@ export interface AcceleratorOptions {
31
32
  * The injectable object (spec 3.3): P3's forceAtlas2, release and dispose, P5's fruchtermanReingold and
32
33
  * springElectrical (the two other optional members of the real LayoutAccelerator, spec 9.3; the CPU option types in,
33
34
  * the GPU simulations out), plus P7's seven algorithm members
34
- * (spec 8.2, 8.3; M8b-T8), non-optional here and returning the `Gpu*Result` shapes, which satisfy the `*ResultLike`
35
- * mirrors (spec 9.7: `precision` is an extra field, `F32` is a `NumericVector`). `connectedComponents` and
36
- * `weaklyConnectedComponents` are the same algorithm (spec 3.3: WCC semantics on directed input) under both names
37
- * the mirror declares; their options parameter stays OPTIONAL, because the mirror declares none and an extra
38
- * REQUIRED parameter would stop the member satisfying it. Later phases add one member per shipped algorithm.
35
+ * (spec 8.2, 8.3; M8b-T8) and P8's four traversal members (spec 8.4; P8-T13 PD-16), non-optional here and returning
36
+ * the `Gpu*Result` shapes, which satisfy the `*ResultLike` mirrors (spec 9.7: `precision` is an extra field, `F32` is
37
+ * a `NumericVector`). `connectedComponents` and `weaklyConnectedComponents` are the same algorithm (spec 3.3: WCC
38
+ * semantics on directed input) under both names the mirror declares; their options parameter stays OPTIONAL, because
39
+ * the mirror declares none and an extra REQUIRED parameter would stop the member satisfying it. The four traversals
40
+ * take the seam's OWN option types (PD-19: `BfsOptions`, `SsspOptions` for both `sssp` and `bellmanFord`,
41
+ * `HitsOptionsLike` for `closenessCentrality`), so a key the CPU dispatcher forwards is exactly a key the GPU reads;
42
+ * `test/types/conformance.test-d.ts` holds each parameter EQUAL to the seam's, not merely assignable. Later phases add
43
+ * one member per shipped algorithm.
39
44
  * Exported: implemented by src/accelerator.ts (P3-T3); re-exported from src/index.ts at P3-T3.
40
45
  * @public
41
46
  */
@@ -53,6 +58,10 @@ export interface GpuAccelerator extends AlgorithmAccelerator, LayoutAccelerator
53
58
  katzCentrality(s: GraphSnapshot, options?: KatzOptions): Promise<GpuScoresResult>;
54
59
  connectedComponents(s: GraphSnapshot, options?: ComponentsOptions): Promise<GpuLabelResult>;
55
60
  weaklyConnectedComponents(s: GraphSnapshot, options?: ComponentsOptions): Promise<GpuLabelResult>;
61
+ breadthFirstSearch(s: GraphSnapshot, source: number, options?: BfsOptions): Promise<GpuBfsResult>;
62
+ sssp(s: GraphSnapshot, source: number, options?: SsspOptions): Promise<GpuSsspResult>;
63
+ bellmanFord(s: GraphSnapshot, source: number, options?: SsspOptions): Promise<GpuBellmanFordResult>;
64
+ closenessCentrality(s: GraphSnapshot, options?: HitsOptionsLike): Promise<GpuScoresResult>;
56
65
  release(s: GraphSnapshot): void;
57
66
  dispose(): void;
58
67
  }
@@ -1 +1 @@
1
- {"version":3,"file":"accelerator.d.ts","sourceRoot":"","sources":["../../../src/types/accelerator.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EACR,oBAAoB,EACpB,cAAc,EACd,qBAAqB,EACrB,6BAA6B,EAC7B,aAAa,EACb,mBAAmB,EACnB,kBAAkB,EAClB,oBAAoB,EACpB,eAAe,EACf,cAAc,EACd,eAAe,EACf,aAAa,EACb,kBAAkB,EAClB,gBAAgB,EAChB,cAAc,EACjB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EAAE,GAAG,EAAE,GAAG,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACrE,OAAO,KAAK,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAE3E,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,KAAK,EACR,iBAAiB,EACjB,kBAAkB,EAClB,aAAa,EACb,cAAc,EACd,iBAAiB,EACjB,eAAe,EACf,WAAW,EACX,WAAW,EACX,eAAe,EAClB,MAAM,iBAAiB,CAAC;AACzB,OAAO,KAAK,EACR,gBAAgB,EAChB,wBAAwB,EACxB,mBAAmB,EACnB,eAAe,EACf,qBAAqB,EACxB,MAA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EAAE,aAAa,EAAE,OAAO,CAAC,EAAE,iBAAiB,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC;IAC5F,yBAAyB,CAAC,CAAC,EAAE,aAAa,EAAE,OAAO,CAAC,EAAE,iBAAiB,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC;IAClG,kBAAkB,CAAC,CAAC,EAAE,aAAa,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,UAAU,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC;IAClG,IAAI,CAAC,CAAC,EAAE,aAAa,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC;IACtF,WAAW,CAAC,CAAC,EAAE,aAAa,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAAC;IACpG,mBAAmB,CAAC,CAAC,EAAE,aAAa,EAAE,OAAO,CAAC,EAAE,eAAe,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC;IAC3F,OAAO,CAAC,CAAC,EAAE,aAAa,GAAG,IAAI,CAAC;IAChC,OAAO,IAAI,IAAI,CAAC;CACnB"}
@@ -0,0 +1,53 @@
1
+ /**
2
+ * The result records of the P8 frontier family (design 3.3 lines 830-832, 9.7), verbatim. The OPTION types are the
3
+ * seam's own -- `BfsOptions` and `SsspOptions` from `@graphty/algorithms`, re-exported through
4
+ * `src/types/accelerator.ts` beside `HitsOptionsLike` -- and are deliberately NOT redeclared here (P8 PD-19): a
5
+ * member the CPU dispatcher forwards options into must read exactly the keys the CPU port reads. Every sentinel is
6
+ * spelled on its field, because a consumer who reads `parent[root] === 4294967295` and guesses is the failure this
7
+ * file prevents. Types only: this file imports nothing at runtime.
8
+ */
9
+ import type { F32, U32 } from "@graphty/graph-format";
10
+ /**
11
+ * Design 3.3 line 830: what `breadthFirstSearch` returns. Satisfies the seam's `BfsResultLike` (`depth`, `parent`,
12
+ * `order`, `visitedCount`) with `levels` and `switches` on top. Every array is bitwise reproducible (PD-14).
13
+ */
14
+ export interface GpuBfsResult {
15
+ /** Per node: its hop count from the source; `INVALID_INDEX` (4294967295) = unreached. */
16
+ readonly depth: U32;
17
+ /**
18
+ * Per node: the SMALLEST node index `u` with `depth[u] + 1 == depth[v]` and an arc `u -> v` (PD-24: a post-pass over
19
+ * the settled depths, so the chain to the source strictly decreases `depth`); `INVALID_INDEX` for the source and
20
+ * for an unreached node.
21
+ */
22
+ readonly parent: U32;
23
+ /** Length `visitedCount`: the reached nodes grouped by depth, ascending by node index within a depth (PD-14). */
24
+ readonly order: U32;
25
+ /** How many nodes were reached, the source included. */
26
+ readonly visitedCount: number;
27
+ /** `max depth + 1`; 1 for a source with no out-arcs. */
28
+ readonly levels: number;
29
+ /** Direction changes of the direction-optimizing search (a device counter, design 8.4); 0 on a top-down-only run. */
30
+ readonly switches: number;
31
+ }
32
+ /**
33
+ * Design 3.3 line 831: what `sssp` returns. Satisfies the seam's `SsspResultLike` (`dist: NumericVector` admits `F32`;
34
+ * `predArc: U32`). `dist` is bitwise reproducible (PD-9) and `predArc` is a function of it alone (PD-27).
35
+ */
36
+ export interface GpuSsspResult {
37
+ /** Per node: its shortest distance from the source in f32; `+Infinity` = unreached, which includes beyond `cutoff`. */
38
+ readonly dist: F32;
39
+ /**
40
+ * Per node `v`: a TIGHT arc `a` into `v` (`fround(dist[src(a)] + w(a)) == dist[v]`) whose source sits one PD-27 key
41
+ * step below `v`, the smallest such arc index; the chain `v -> src(a) -> ...` always ends at the source.
42
+ * `INVALID_INDEX` (4294967295) for the source and for an unreached node.
43
+ */
44
+ readonly predArc: U32;
45
+ /** How many nodes have a finite `dist`, the source included. */
46
+ readonly reachedCount: number;
47
+ }
48
+ /** Design 3.3 line 832: what `bellmanFord` returns. Satisfies the seam's `BellmanFordResultLike`. */
49
+ export interface GpuBellmanFordResult extends GpuSsspResult {
50
+ /** When true, `dist` and `predArc` are the values of the last round, not shortest paths. */
51
+ readonly hasNegativeCycle: boolean;
52
+ }
53
+ //# sourceMappingURL=traversal.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"traversal.d.ts","sourceRoot":"","sources":["../../../src/types/traversal.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAC;AAEtD;;;GAGG;AACH,MAAM,WAAW,YAAY;IACzB,yFAAyF;IACzF,QAAQ,CAAC,KAAK,EAAE,GAAG,CAAC;IACpB;;;;OAIG;IACH,QAAQ,CAAC,MAAM,EAAE,GAAG,CAAC;IACrB,iHAAiH;IACjH,QAAQ,CAAC,KAAK,EAAE,GAAG,CAAC;IACpB,wDAAwD;IACxD,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,wDAAwD;IACxD,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,qHAAqH;IACrH,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;CAC7B;AAED;;;GAGG;AACH,MAAM,WAAW,aAAa;IAC1B,uHAAuH;IACvH,QAAQ,CAAC,IAAI,EAAE,GAAG,CAAC;IACnB;;;;OAIG;IACH,QAAQ,CAAC,OAAO,EAAE,GAAG,CAAC;IACtB,gEAAgE;IAChE,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;CACjC;AAED,qGAAqG;AACrG,MAAM,WAAW,oBAAqB,SAAQ,aAAa;IACvD,4FAA4F;IAC5F,QAAQ,CAAC,gBAAgB,EAAE,OAAO,CAAC;CACtC"}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * The result records of the P8 frontier family (design 3.3 lines 830-832, 9.7), verbatim. The OPTION types are the
3
+ * seam's own -- `BfsOptions` and `SsspOptions` from `@graphty/algorithms`, re-exported through
4
+ * `src/types/accelerator.ts` beside `HitsOptionsLike` -- and are deliberately NOT redeclared here (P8 PD-19): a
5
+ * member the CPU dispatcher forwards options into must read exactly the keys the CPU port reads. Every sentinel is
6
+ * spelled on its field, because a consumer who reads `parent[root] === 4294967295` and guesses is the failure this
7
+ * file prevents. Types only: this file imports nothing at runtime.
8
+ */
9
+ export {};
10
+ //# sourceMappingURL=traversal.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"traversal.js","sourceRoot":"","sources":["../../../src/types/traversal.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG"}
@@ -0,0 +1,19 @@
1
+ /**
2
+ * The `advance-expand` kernel body (design 6 row 8, 8.10 "BFS expand"; P8-T5, the P8 plan's PD-23): Gunrock's
3
+ * block-mapped expansion of a vertex frontier into the edge queue. Each workgroup loads up to `WG` frontier entries,
4
+ * reads their degrees clipped to the bound arc window `[P.arcBase, P.arcEnd)` (so the window-aware form of P8-T12
5
+ * changes nothing here), runs the prelude's INCLUSIVE workgroup scan `wg_scan_u32` over those degrees -- the subgroup
6
+ * form when the device has the feature, the Hillis-Steele form otherwise, which is the ONLY text that differs between
7
+ * the twin's two compilations -- and then every invocation strips the range `[0, aggregate)` with a binary search
8
+ * (`upper_bound`) over the scanned degrees to find which entry its arc belongs to. One `atomicAdd` per WORKGROUP
9
+ * reserves the block's span in the queue (`edgeCount`), the same aggregate lands in `edgeCountUnclamped` (the overflow
10
+ * detector, never clamped) and in `frontierDegreeSum` (Beamer's m_f); a lane whose queue position is at or past
11
+ * `P.edgeCapacity` writes nothing (the clamp). The queue holds the TARGET vertex of each arc only (PD-24: `parent`
12
+ * comes from the post-pass). Uniformity (spec 3.5 rule 1): the guarded loads write locals, the scan call and the
13
+ * `workgroupUniformLoad` sit unconditionally after the guard, and the strip loop is bounded by a uniform value.
14
+ * There is no `TIER` override: a hub row is balanced over all `WG` lanes inside its block, and the small-frontier
15
+ * workgroup-per-row structure is `bfs-fused` (P8-T7). Body only (spec 3.5, D9); the text is normative: the
16
+ * sabotage rows of test/helpers/sabotage.ts are textual edits of it.
17
+ */
18
+ export declare const advanceExpandWgsl = "\nvar<workgroup> sh: array<u32, WG>; // the block's degrees, then their inclusive scan\nvar<workgroup> rowStart: array<u32, WG>; // the first bound arc of each entry's row\nvar<workgroup> base: u32; // the block's reserved span in the edge queue\nvar<workgroup> wcount: u32; // the frontier's length on a two-phase level, 0 on any other\n\n@compute @workgroup_size(WG)\nfn advance_expand(@builtin(workgroup_id) wid: vec3<u32>, @builtin(local_invocation_id) lid: vec3<u32>) {\n if (lid.x == 0u) { wcount = select(0u, atomicLoad(&counters[0]), atomicLoad(&counters[24]) == 1u); } // frontierCount, on the two-phase path only (the path word)\n let count = workgroupUniformLoad(&wcount); // uniform: the block loop below holds barriers\n for (var b0 = group_id(wid) * WG; b0 < count; b0 = b0 + P.stride) { // grid-stride over blocks of WG entries (a direct dispatch of the plan's groups)\n let i = b0 + lid.x; // this lane's frontier entry\n var deg = 0u;\n var start = 0u;\n if (i < count) { // guarded loads into locals (3.5 rule 1)\n let v = frontierIn[i];\n let lo = max(rowPtr[v], P.arcBase); // the row clipped to the bound window (P8-T12)\n let hi = min(rowPtr[v + 1u], P.arcEnd);\n start = lo;\n deg = select(0u, hi - lo, hi > lo);\n }\n let inclusive = wg_scan_u32(deg, lid.x); // the prelude's inclusive scan in LANE order (P8-T1 Step 5); the twin\n sh[lid.x] = inclusive; // sh is monotone in lid.x, the index the binary search walks\n rowStart[lid.x] = start;\n workgroupBarrier();\n let aggregate = workgroupUniformLoad(&sh[WG - 1u]); // uniform; includes a barrier\n if (lid.x == 0u) {\n base = atomicAdd(&counters[8], aggregate); // edgeCount: ONE reservation per workgroup, not one per arc\n atomicAdd(&counters[9], aggregate); // edgeCountUnclamped: the overflow detector (PD-23)\n atomicAdd(&counters[2], aggregate); // frontierDegreeSum: Beamer's m_f (P8-T8)\n }\n workgroupBarrier();\n for (var p = lid.x; p < aggregate; p = p + WG) { // strip [0, aggregate): lane j takes j, j + WG, ...\n var lo = 0u; // upper_bound: the first k with sh[k] > p owns arc p\n var hi = WG;\n loop {\n if (lo >= hi) { break; }\n let mid = (lo + hi) / 2u;\n if (sh[mid] > p) { hi = mid; } else { lo = mid + 1u; }\n }\n let k = lo;\n var exclusive = 0u;\n if (k > 0u) { exclusive = sh[k - 1u]; }\n let arc = rowStart[k] + (p - exclusive);\n let q = base + p;\n if (q < P.edgeCapacity) { edgeQueue[q] = colIdx[arc - P.arcBase]; } // the clamp of PD-23; the queue holds the target vertex only (PD-24)\n }\n workgroupBarrier(); // sh, rowStart and base are reused by the next block\n }\n}\n";
19
+ //# sourceMappingURL=advance-expand.wgsl.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"advance-expand.wgsl.d.ts","sourceRoot":"","sources":["../../../src/wgsl/advance-expand.wgsl.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,iBAAiB,s0GAkD7B,CAAC"}