@graphty/webgpu-graph-algorithms 0.6.3 → 0.6.5
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.
- package/README.md +62 -32
- package/dist/browser.js +1 -1
- package/dist/chunks/{context-BXqgCifx.js → context-hzGggHeM.js} +68 -24
- package/dist/chunks/context-hzGggHeM.js.map +1 -0
- package/dist/node.js +1 -1
- package/dist/src/accelerator.d.ts +8 -6
- package/dist/src/accelerator.d.ts.map +1 -1
- package/dist/src/accelerator.js +57 -6
- package/dist/src/accelerator.js.map +1 -1
- package/dist/src/algorithms/bellman-ford.d.ts +60 -0
- package/dist/src/algorithms/bellman-ford.d.ts.map +1 -0
- package/dist/src/algorithms/bellman-ford.js +301 -0
- package/dist/src/algorithms/bellman-ford.js.map +1 -0
- package/dist/src/algorithms/bfs.d.ts +67 -0
- package/dist/src/algorithms/bfs.d.ts.map +1 -0
- package/dist/src/algorithms/bfs.js +534 -0
- package/dist/src/algorithms/bfs.js.map +1 -0
- package/dist/src/algorithms/closeness.d.ts +53 -0
- package/dist/src/algorithms/closeness.d.ts.map +1 -0
- package/dist/src/algorithms/closeness.js +323 -0
- package/dist/src/algorithms/closeness.js.map +1 -0
- package/dist/src/algorithms/scope.d.ts +3 -1
- package/dist/src/algorithms/scope.d.ts.map +1 -1
- package/dist/src/algorithms/scope.js +1 -0
- package/dist/src/algorithms/scope.js.map +1 -1
- package/dist/src/algorithms/sssp.d.ts +72 -0
- package/dist/src/algorithms/sssp.d.ts.map +1 -0
- package/dist/src/algorithms/sssp.js +586 -0
- package/dist/src/algorithms/sssp.js.map +1 -0
- package/dist/src/constants.d.ts +10 -0
- package/dist/src/constants.d.ts.map +1 -1
- package/dist/src/constants.js +10 -0
- package/dist/src/constants.js.map +1 -1
- package/dist/src/index.d.ts +8 -2
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +7 -1
- package/dist/src/index.js.map +1 -1
- package/dist/src/kernel/prelude.d.ts +4 -4
- package/dist/src/kernel/prelude.d.ts.map +1 -1
- package/dist/src/kernel/prelude.js +39 -5
- package/dist/src/kernel/prelude.js.map +1 -1
- package/dist/src/kernel/uniform-ring.d.ts +8 -0
- package/dist/src/kernel/uniform-ring.d.ts.map +1 -1
- package/dist/src/kernel/uniform-ring.js +13 -0
- package/dist/src/kernel/uniform-ring.js.map +1 -1
- package/dist/src/kernels.d.ts +45 -4
- package/dist/src/kernels.d.ts.map +1 -1
- package/dist/src/kernels.js +368 -3
- package/dist/src/kernels.js.map +1 -1
- package/dist/src/primitives/advance.d.ts +63 -0
- package/dist/src/primitives/advance.d.ts.map +1 -0
- package/dist/src/primitives/advance.js +95 -0
- package/dist/src/primitives/advance.js.map +1 -0
- package/dist/src/primitives/compact.d.ts +89 -0
- package/dist/src/primitives/compact.d.ts.map +1 -0
- package/dist/src/primitives/compact.js +233 -0
- package/dist/src/primitives/compact.js.map +1 -0
- package/dist/src/primitives/core-shape.d.ts +22 -1
- package/dist/src/primitives/core-shape.d.ts.map +1 -1
- package/dist/src/primitives/core-shape.js +33 -3
- package/dist/src/primitives/core-shape.js.map +1 -1
- package/dist/src/primitives/frontier.d.ts +151 -0
- package/dist/src/primitives/frontier.d.ts.map +1 -0
- package/dist/src/primitives/frontier.js +250 -0
- package/dist/src/primitives/frontier.js.map +1 -0
- package/dist/src/types/accelerator.d.ts +16 -7
- package/dist/src/types/accelerator.d.ts.map +1 -1
- package/dist/src/types/traversal.d.ts +53 -0
- package/dist/src/types/traversal.d.ts.map +1 -0
- package/dist/src/types/traversal.js +10 -0
- package/dist/src/types/traversal.js.map +1 -0
- package/dist/src/wgsl/advance-expand.wgsl.d.ts +19 -0
- package/dist/src/wgsl/advance-expand.wgsl.d.ts.map +1 -0
- package/dist/src/wgsl/advance-expand.wgsl.js +69 -0
- package/dist/src/wgsl/advance-expand.wgsl.js.map +1 -0
- package/dist/src/wgsl/bf-relax.wgsl.d.ts +22 -0
- package/dist/src/wgsl/bf-relax.wgsl.d.ts.map +1 -0
- package/dist/src/wgsl/bf-relax.wgsl.js +58 -0
- package/dist/src/wgsl/bf-relax.wgsl.js.map +1 -0
- package/dist/src/wgsl/bfs-bitset-build.wgsl.d.ts +15 -0
- package/dist/src/wgsl/bfs-bitset-build.wgsl.d.ts.map +1 -0
- package/dist/src/wgsl/bfs-bitset-build.wgsl.js +24 -0
- package/dist/src/wgsl/bfs-bitset-build.wgsl.js.map +1 -0
- package/dist/src/wgsl/bfs-bottom-up.wgsl.d.ts +20 -0
- package/dist/src/wgsl/bfs-bottom-up.wgsl.d.ts.map +1 -0
- package/dist/src/wgsl/bfs-bottom-up.wgsl.js +67 -0
- package/dist/src/wgsl/bfs-bottom-up.wgsl.js.map +1 -0
- package/dist/src/wgsl/bfs-contract.wgsl.d.ts +20 -0
- package/dist/src/wgsl/bfs-contract.wgsl.d.ts.map +1 -0
- package/dist/src/wgsl/bfs-contract.wgsl.js +55 -0
- package/dist/src/wgsl/bfs-contract.wgsl.js.map +1 -0
- package/dist/src/wgsl/bfs-fused.wgsl.d.ts +25 -0
- package/dist/src/wgsl/bfs-fused.wgsl.d.ts.map +1 -0
- package/dist/src/wgsl/bfs-fused.wgsl.js +78 -0
- package/dist/src/wgsl/bfs-fused.wgsl.js.map +1 -0
- package/dist/src/wgsl/bfs-unvisited-flags.wgsl.d.ts +18 -0
- package/dist/src/wgsl/bfs-unvisited-flags.wgsl.d.ts.map +1 -0
- package/dist/src/wgsl/bfs-unvisited-flags.wgsl.js +42 -0
- package/dist/src/wgsl/bfs-unvisited-flags.wgsl.js.map +1 -0
- package/dist/src/wgsl/closeness-reduce.wgsl.d.ts +17 -0
- package/dist/src/wgsl/closeness-reduce.wgsl.d.ts.map +1 -0
- package/dist/src/wgsl/closeness-reduce.wgsl.js +65 -0
- package/dist/src/wgsl/closeness-reduce.wgsl.js.map +1 -0
- package/dist/src/wgsl/closeness-sweep.wgsl.d.ts +20 -0
- package/dist/src/wgsl/closeness-sweep.wgsl.d.ts.map +1 -0
- package/dist/src/wgsl/closeness-sweep.wgsl.js +96 -0
- package/dist/src/wgsl/closeness-sweep.wgsl.js.map +1 -0
- package/dist/src/wgsl/compact-scatter.wgsl.d.ts +9 -0
- package/dist/src/wgsl/compact-scatter.wgsl.d.ts.map +1 -0
- package/dist/src/wgsl/compact-scatter.wgsl.js +17 -0
- package/dist/src/wgsl/compact-scatter.wgsl.js.map +1 -0
- package/dist/src/wgsl/dedupe-claim.wgsl.d.ts +10 -0
- package/dist/src/wgsl/dedupe-claim.wgsl.d.ts.map +1 -0
- package/dist/src/wgsl/dedupe-claim.wgsl.js +19 -0
- package/dist/src/wgsl/dedupe-claim.wgsl.js.map +1 -0
- package/dist/src/wgsl/dedupe-filter.wgsl.d.ts +12 -0
- package/dist/src/wgsl/dedupe-filter.wgsl.d.ts.map +1 -0
- package/dist/src/wgsl/dedupe-filter.wgsl.js +46 -0
- package/dist/src/wgsl/dedupe-filter.wgsl.js.map +1 -0
- package/dist/src/wgsl/frontier-finalize.wgsl.d.ts +53 -0
- package/dist/src/wgsl/frontier-finalize.wgsl.d.ts.map +1 -0
- package/dist/src/wgsl/frontier-finalize.wgsl.js +164 -0
- package/dist/src/wgsl/frontier-finalize.wgsl.js.map +1 -0
- package/dist/src/wgsl/sssp-pred.wgsl.d.ts +28 -0
- package/dist/src/wgsl/sssp-pred.wgsl.d.ts.map +1 -0
- package/dist/src/wgsl/sssp-pred.wgsl.js +80 -0
- package/dist/src/wgsl/sssp-pred.wgsl.js.map +1 -0
- package/dist/src/wgsl/sssp-relax.wgsl.d.ts +30 -0
- package/dist/src/wgsl/sssp-relax.wgsl.d.ts.map +1 -0
- package/dist/src/wgsl/sssp-relax.wgsl.js +72 -0
- package/dist/src/wgsl/sssp-relax.wgsl.js.map +1 -0
- package/dist/webgpu-graph-algorithms.js +3155 -384
- package/dist/webgpu-graph-algorithms.js.map +1 -1
- package/package.json +5 -4
- package/src/accelerator.ts +65 -7
- package/src/algorithms/bellman-ford.ts +387 -0
- package/src/algorithms/bfs.ts +626 -0
- package/src/algorithms/closeness.ts +395 -0
- package/src/algorithms/scope.ts +4 -1
- package/src/algorithms/sssp.ts +768 -0
- package/src/constants.ts +10 -0
- package/src/index.ts +14 -1
- package/src/kernel/prelude.ts +39 -4
- package/src/kernel/uniform-ring.ts +14 -0
- package/src/kernels.ts +447 -6
- package/src/primitives/advance.ts +131 -0
- package/src/primitives/compact.ts +323 -0
- package/src/primitives/core-shape.ts +41 -3
- package/src/primitives/frontier.ts +372 -0
- package/src/types/accelerator.ts +18 -5
- package/src/types/traversal.ts +56 -0
- package/src/wgsl/advance-expand.wgsl.ts +68 -0
- package/src/wgsl/bf-relax.wgsl.ts +57 -0
- package/src/wgsl/bfs-bitset-build.wgsl.ts +23 -0
- package/src/wgsl/bfs-bottom-up.wgsl.ts +66 -0
- package/src/wgsl/bfs-contract.wgsl.ts +54 -0
- package/src/wgsl/bfs-fused.wgsl.ts +77 -0
- package/src/wgsl/bfs-unvisited-flags.wgsl.ts +41 -0
- package/src/wgsl/closeness-reduce.wgsl.ts +64 -0
- package/src/wgsl/closeness-sweep.wgsl.ts +95 -0
- package/src/wgsl/compact-scatter.wgsl.ts +16 -0
- package/src/wgsl/dedupe-claim.wgsl.ts +18 -0
- package/src/wgsl/dedupe-filter.wgsl.ts +45 -0
- package/src/wgsl/frontier-finalize.wgsl.ts +163 -0
- package/src/wgsl/sssp-pred.wgsl.ts +79 -0
- package/src/wgsl/sssp-relax.wgsl.ts +71 -0
- 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,CAA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AAC,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,151 @@
|
|
|
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 25-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) and the edge queue. The host
|
|
6
|
+
* never reads a counter inside a submit: `frontier-finalize`, one lane, runs at the START of every level (role 0:
|
|
7
|
+
* rotates `nextFrontierCount` into `frontierCount`, advances `level`, decides `done`, chooses the level's path) and
|
|
8
|
+
* again once the edge queue is filled (role 1: clamps `edgeCount`, or on an overflow -- `edgeCountUnclamped >
|
|
9
|
+
* edgeCapacity` -- switches the path to the fused retry, PD-23). The choice is the block's `path` word (`W.path`,
|
|
10
|
+
* word 24); every level kernel is a direct grid-stride dispatch that reads it first and does nothing unless the
|
|
11
|
+
* word names it (design/decisions/2026-09-25-frontier-kernels-dispatch-directly.md: the seven indirect slots the
|
|
12
|
+
* selector once wrote per level cost about 0.4 ms of Dawn validation each and were 97 % of a traversal's wall
|
|
13
|
+
* time; they and their args buffer are gone). The host records up to `MAX_LEVELS_PER_SUBMIT` levels per submit and
|
|
14
|
+
* reads `done` (four bytes) once per submit; a boundary that finds `done` set writes path 0 and moves no counter,
|
|
15
|
+
* so the recorded levels past the end are no-ops and the counters freeze at the finishing boundary's values.
|
|
16
|
+
*
|
|
17
|
+
* The seed: `frontierCount` is NEVER seeded, because the first boundary rotates it out unread. A BFS driver calls
|
|
18
|
+
* `reset(queue, source, { nextFrontierCount: 1, level: U32_MAX })`: the first boundary rotates the 1 in, adds it into
|
|
19
|
+
* `visitedCount`, and wraps `level` to 0, so the level-0 expansion claims the source's neighbours at `level + 1 == 1`.
|
|
20
|
+
* `reset` is a queue write, ordered before the submit that follows, and it puts the source on side 0.
|
|
21
|
+
*
|
|
22
|
+
* Every buffer comes from the caller's ONE lease (`scope.scratch`) so the algorithm's dispose()
|
|
23
|
+
* releases them together (design 4.4). The two vertex queues are two BUFFERS, never two ranges of one: `Kernel.bind`
|
|
24
|
+
* rejects one buffer bound read-only and read-write in one dispatch even for disjoint ranges. `src/primitives/**`
|
|
25
|
+
* never imports `src/context.ts`.
|
|
26
|
+
*/
|
|
27
|
+
import { type Binding } from "../types/memory.js";
|
|
28
|
+
import { type ReduceScope } from "./reduce.js";
|
|
29
|
+
/** The values of the `path` word (`W.path`): what a level's kernels run; every level kernel reads it first. */
|
|
30
|
+
export declare const PATH: Readonly<{
|
|
31
|
+
none: 0;
|
|
32
|
+
twoPhase: 1;
|
|
33
|
+
fused: 2;
|
|
34
|
+
bottomUp: 3;
|
|
35
|
+
fusedRetry: 4;
|
|
36
|
+
near: 5;
|
|
37
|
+
far: 6;
|
|
38
|
+
}>;
|
|
39
|
+
/** The words of the counters block (`FRONTIER_COUNTERS`), by index: byte offset 4 x word; no driver types a number. */
|
|
40
|
+
export declare const W: Readonly<{
|
|
41
|
+
frontierCount: 0;
|
|
42
|
+
nextFrontierCount: 1;
|
|
43
|
+
frontierDegreeSum: 2;
|
|
44
|
+
prevFrontierCount: 3;
|
|
45
|
+
prevDegreeSum: 4;
|
|
46
|
+
unvisitedCount: 5;
|
|
47
|
+
unvisitedDegreeSum: 6;
|
|
48
|
+
unvisitedListLen: 7;
|
|
49
|
+
edgeCount: 8;
|
|
50
|
+
edgeCountUnclamped: 9;
|
|
51
|
+
overflowLevels: 10;
|
|
52
|
+
level: 11;
|
|
53
|
+
visitedCount: 12;
|
|
54
|
+
switches: 13;
|
|
55
|
+
direction: 14;
|
|
56
|
+
done: 15;
|
|
57
|
+
arcsScanned: 16;
|
|
58
|
+
fusedLevels: 17;
|
|
59
|
+
twoPhaseLevels: 18;
|
|
60
|
+
bottomUpLevels: 19;
|
|
61
|
+
farCount: 20;
|
|
62
|
+
nextFarCount: 21;
|
|
63
|
+
thresholdBits: 22;
|
|
64
|
+
deltaBits: 23;
|
|
65
|
+
path: 24;
|
|
66
|
+
}>;
|
|
67
|
+
/** The words a `reset` seeds (every other word is zeroed). */
|
|
68
|
+
export type FrontierSeed = Readonly<Partial<Record<keyof typeof W, number>>>;
|
|
69
|
+
/** The `FrontierParams` fields a caller passes to `recordFinalize`; the planner fills `role`, `wg`, `edgeCapacity` and `n` itself. A missing field is written as 0. */
|
|
70
|
+
export type FrontierFinalizeFields = Readonly<Partial<Record<"alpha" | "beta" | "fusedMax" | "maxDepth" | "mode" | "cutoffBits" | "arcBase" | "arcEnd" | "predKind" | "bitsBase" | "source" | "stride" | "firstOfSubmit" | "iteration", number>>>;
|
|
71
|
+
/** The frontier queue of design 6 row 7: two vertex queues, the counters block and the edge queue, all leased by the caller's scope. */
|
|
72
|
+
export declare class Frontier {
|
|
73
|
+
/** The two n-slot u32 vertex queues (`vertices[side]` is the input of the current level). */
|
|
74
|
+
readonly vertices: readonly [Binding, Binding];
|
|
75
|
+
/** The `FrontierCounters` block, 112 B, bound by every kernel as `array<atomic<u32>>`. */
|
|
76
|
+
readonly counters: Binding;
|
|
77
|
+
/** The edge queue: `edgeCapacity` entries of u32 (the target vertex of an arc). */
|
|
78
|
+
readonly edgeQueue: Binding;
|
|
79
|
+
/** How many entries the edge queue holds; role 1 clamps `edgeCount` to it and detects an overflow above it. */
|
|
80
|
+
readonly edgeCapacity: number;
|
|
81
|
+
/** The vertex count (a `reset` source is below it). */
|
|
82
|
+
readonly n: number;
|
|
83
|
+
private sideIndex;
|
|
84
|
+
/**
|
|
85
|
+
* Wraps the leased buffers; use prepareFrontier().
|
|
86
|
+
* @param vertices - the two vertex queues
|
|
87
|
+
* @param counters - the counters block
|
|
88
|
+
* @param edgeQueue - the edge queue
|
|
89
|
+
* @param edgeCapacity - the edge queue's entry count
|
|
90
|
+
* @param n - the vertex count
|
|
91
|
+
*/
|
|
92
|
+
constructor(vertices: readonly [Binding, Binding], counters: Binding, edgeQueue: Binding, edgeCapacity: number, n: number);
|
|
93
|
+
/**
|
|
94
|
+
* Which vertex queue is the input of the current level (a host-side index between two cached bind-group sets).
|
|
95
|
+
* @returns 0 or 1
|
|
96
|
+
*/
|
|
97
|
+
get side(): 0 | 1;
|
|
98
|
+
/**
|
|
99
|
+
* The vertex queue the current level expands from.
|
|
100
|
+
* @returns `vertices[side]`
|
|
101
|
+
*/
|
|
102
|
+
get input(): Binding;
|
|
103
|
+
/**
|
|
104
|
+
* The vertex queue the current level's claims append to.
|
|
105
|
+
* @returns `vertices[1 - side]`
|
|
106
|
+
*/
|
|
107
|
+
get output(): Binding;
|
|
108
|
+
/** Flips the two vertex queues; the counts rotate inside the block, so nothing else moves. */
|
|
109
|
+
swap(): void;
|
|
110
|
+
/**
|
|
111
|
+
* Seeds a traversal: one `queue.writeBuffer` of the whole 112-byte block (zero except the caller's words) and one of
|
|
112
|
+
* `vertices[0][0] = source`, both ordered before the submit that follows; the source is on side 0 afterwards.
|
|
113
|
+
* `frontierCount` is not a word to seed: the first boundary rotates word 1 into it (the BFS seed is
|
|
114
|
+
* `{ nextFrontierCount: 1, level: U32_MAX }`). A source outside `[0, n)`, an unknown word or a value that is not a
|
|
115
|
+
* u32 is E_INVALID_ARGUMENT before anything is written.
|
|
116
|
+
* @param queue - the device queue
|
|
117
|
+
* @param source - the source vertex
|
|
118
|
+
* @param seed - the words to seed
|
|
119
|
+
*/
|
|
120
|
+
reset(queue: GPUQueue, source: number, seed: FrontierSeed): void;
|
|
121
|
+
}
|
|
122
|
+
/** A prepared frontier (design 6 row 7): the leased queue and the recorded selector dispatches. */
|
|
123
|
+
export interface FrontierPlanner {
|
|
124
|
+
/** The queue the planner's selector rotates and chooses the path of. */
|
|
125
|
+
readonly frontier: Frontier;
|
|
126
|
+
/**
|
|
127
|
+
* Records one `frontier-finalize` dispatch (one workgroup) in `role` for `level` of the current submit: one
|
|
128
|
+
* `FrontierParams` record with `wg`, `edgeCapacity` and `n` filled by the planner and every other field from
|
|
129
|
+
* `fields`. A level outside `[0, MAX_LEVELS_PER_SUBMIT)` (the selector addresses nothing by level any more, but
|
|
130
|
+
* the host's submit cadence still is the bound) or a role outside `[0, 3]` is E_INVALID_ARGUMENT before
|
|
131
|
+
* anything is recorded.
|
|
132
|
+
* @param pass - the compute pass
|
|
133
|
+
* @param role - 0 the level boundary, 1 the edge-queue role (2 and 3 are P8-T9's)
|
|
134
|
+
* @param level - the level inside the submit
|
|
135
|
+
* @param fields - the tuning and window words
|
|
136
|
+
*/
|
|
137
|
+
recordFinalize(pass: GPUComputePassEncoder, role: number, level: number, fields: FrontierFinalizeFields): void;
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Leases the frontier's buffers from the scope and compiles the selector so `recordFinalize` is synchronous. The
|
|
141
|
+
* edge capacity defaults to `max(1, min(arcCount, floor(maxStorageBufferBindingSize / 4)))` (never a zero-length
|
|
142
|
+
* buffer: the one-node graph has no arcs); a test passes a small one to force the overflow path. The planner lives
|
|
143
|
+
* exactly as long as the scope: never use it after the scope's dispose().
|
|
144
|
+
* @param scope - the caller's scope (device, caps, cache, scratch, params)
|
|
145
|
+
* @param n - the vertex count
|
|
146
|
+
* @param arcCount - the arc count (the natural edge-queue size)
|
|
147
|
+
* @param edgeCapacity - the edge queue's entry count, when the caller chooses it (an integer >= 1)
|
|
148
|
+
* @returns the planner
|
|
149
|
+
*/
|
|
150
|
+
export declare function prepareFrontier(scope: ReduceScope, n: number, arcCount: number, edgeCapacity?: number): Promise<FrontierPlanner>;
|
|
151
|
+
//# sourceMappingURL=frontier.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"frontier.d.ts","sourceRoot":"","sources":["../../../src/primitives/frontier.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAOH,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,aAAa,CAAC;AAE/C,+GAA+G;AAC/G,eAAO,MAAM,IAAI,EAAE,QAAQ,CAAC;IACxB,IAAI,EAAE,CAAC,CAAC;IACR,QAAQ,EAAE,CAAC,CAAC;IACZ,KAAK,EAAE,CAAC,CAAC;IACT,QAAQ,EAAE,CAAC,CAAC;IACZ,UAAU,EAAE,CAAC,CAAC;IACd,IAAI,EAAE,CAAC,CAAC;IACR,GAAG,EAAE,CAAC,CAAC;CACV,CAAkG,CAAC;AAEpG,uHAAuH;AACvH,eAAO,MAAM,CAAC,EAAE,QAAQ,CAAC;IACrB,aAAa,EAAE,CAAC,CAAC;IACjB,iBAAiB,EAAE,CAAC,CAAC;IACrB,iBAAiB,EAAE,CAAC,CAAC;IACrB,iBAAiB,EAAE,CAAC,CAAC;IACrB,aAAa,EAAE,CAAC,CAAC;IACjB,c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8 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 25-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) and the edge queue. The host
|
|
6
|
+
* never reads a counter inside a submit: `frontier-finalize`, one lane, runs at the START of every level (role 0:
|
|
7
|
+
* rotates `nextFrontierCount` into `frontierCount`, advances `level`, decides `done`, chooses the level's path) and
|
|
8
|
+
* again once the edge queue is filled (role 1: clamps `edgeCount`, or on an overflow -- `edgeCountUnclamped >
|
|
9
|
+
* edgeCapacity` -- switches the path to the fused retry, PD-23). The choice is the block's `path` word (`W.path`,
|
|
10
|
+
* word 24); every level kernel is a direct grid-stride dispatch that reads it first and does nothing unless the
|
|
11
|
+
* word names it (design/decisions/2026-09-25-frontier-kernels-dispatch-directly.md: the seven indirect slots the
|
|
12
|
+
* selector once wrote per level cost about 0.4 ms of Dawn validation each and were 97 % of a traversal's wall
|
|
13
|
+
* time; they and their args buffer are gone). The host records up to `MAX_LEVELS_PER_SUBMIT` levels per submit and
|
|
14
|
+
* reads `done` (four bytes) once per submit; a boundary that finds `done` set writes path 0 and moves no counter,
|
|
15
|
+
* so the recorded levels past the end are no-ops and the counters freeze at the finishing boundary's values.
|
|
16
|
+
*
|
|
17
|
+
* The seed: `frontierCount` is NEVER seeded, because the first boundary rotates it out unread. A BFS driver calls
|
|
18
|
+
* `reset(queue, source, { nextFrontierCount: 1, level: U32_MAX })`: the first boundary rotates the 1 in, adds it into
|
|
19
|
+
* `visitedCount`, and wraps `level` to 0, so the level-0 expansion claims the source's neighbours at `level + 1 == 1`.
|
|
20
|
+
* `reset` is a queue write, ordered before the submit that follows, and it puts the source on side 0.
|
|
21
|
+
*
|
|
22
|
+
* Every buffer comes from the caller's ONE lease (`scope.scratch`) so the algorithm's dispose()
|
|
23
|
+
* releases them together (design 4.4). The two vertex queues are two BUFFERS, never two ranges of one: `Kernel.bind`
|
|
24
|
+
* rejects one buffer bound read-only and read-write in one dispatch even for disjoint ranges. `src/primitives/**`
|
|
25
|
+
* never imports `src/context.ts`.
|
|
26
|
+
*/
|
|
27
|
+
import { MAX_LEVELS_PER_SUBMIT, U32_MAX } from "../constants.js";
|
|
28
|
+
import { WebGpuGraphError } from "../errors.js";
|
|
29
|
+
import { plan1d } from "../kernel/dispatch.js";
|
|
30
|
+
import { FRONTIER_COUNTERS, FRONTIER_PARAMS, kernelSpec } from "../kernels.js";
|
|
31
|
+
/** The values of the `path` word (`W.path`): what a level's kernels run; every level kernel reads it first. */
|
|
32
|
+
export const PATH = Object.freeze({ none: 0, twoPhase: 1, fused: 2, bottomUp: 3, fusedRetry: 4, near: 5, far: 6 });
|
|
33
|
+
/** The words of the counters block (`FRONTIER_COUNTERS`), by index: byte offset 4 x word; no driver types a number. */
|
|
34
|
+
export const W = Object.freeze({
|
|
35
|
+
frontierCount: 0,
|
|
36
|
+
nextFrontierCount: 1,
|
|
37
|
+
frontierDegreeSum: 2,
|
|
38
|
+
prevFrontierCount: 3,
|
|
39
|
+
prevDegreeSum: 4,
|
|
40
|
+
unvisitedCount: 5,
|
|
41
|
+
unvisitedDegreeSum: 6,
|
|
42
|
+
unvisitedListLen: 7,
|
|
43
|
+
edgeCount: 8,
|
|
44
|
+
edgeCountUnclamped: 9,
|
|
45
|
+
overflowLevels: 10,
|
|
46
|
+
level: 11,
|
|
47
|
+
visitedCount: 12,
|
|
48
|
+
switches: 13,
|
|
49
|
+
direction: 14,
|
|
50
|
+
done: 15,
|
|
51
|
+
arcsScanned: 16,
|
|
52
|
+
fusedLevels: 17,
|
|
53
|
+
twoPhaseLevels: 18,
|
|
54
|
+
bottomUpLevels: 19,
|
|
55
|
+
farCount: 20,
|
|
56
|
+
nextFarCount: 21,
|
|
57
|
+
thresholdBits: 22,
|
|
58
|
+
deltaBits: 23,
|
|
59
|
+
path: 24,
|
|
60
|
+
});
|
|
61
|
+
/**
|
|
62
|
+
* The given words of a partial record (a key spelled with an undefined value is dropped, so the block writer sees
|
|
63
|
+
* only numbers).
|
|
64
|
+
* @param words - the partial record
|
|
65
|
+
* @returns the defined entries
|
|
66
|
+
*/
|
|
67
|
+
function definedWords(words) {
|
|
68
|
+
const out = {};
|
|
69
|
+
for (const [name, value] of Object.entries(words)) {
|
|
70
|
+
if (value !== undefined) {
|
|
71
|
+
out[name] = value;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
return out;
|
|
75
|
+
}
|
|
76
|
+
/** The largest role `frontier-finalize` knows: 0 and 1 land here (P8-T4), 2 and 3 are the SSSP piles' (P8-T9). */
|
|
77
|
+
const MAX_ROLE = 3;
|
|
78
|
+
/**
|
|
79
|
+
* The E_INVALID_ARGUMENT of a value that is not a non-negative integer.
|
|
80
|
+
* @param argument - the argument name
|
|
81
|
+
* @param value - the value
|
|
82
|
+
*/
|
|
83
|
+
function assertCount(argument, value) {
|
|
84
|
+
if (!Number.isSafeInteger(value) || value < 0) {
|
|
85
|
+
throw new WebGpuGraphError("E_INVALID_ARGUMENT", `frontier: ${argument} must be a non-negative integer`, {
|
|
86
|
+
argument,
|
|
87
|
+
value,
|
|
88
|
+
expected: "a non-negative integer",
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
/** The frontier queue of design 6 row 7: two vertex queues, the counters block and the edge queue, all leased by the caller's scope. */
|
|
93
|
+
export class Frontier {
|
|
94
|
+
/**
|
|
95
|
+
* Wraps the leased buffers; use prepareFrontier().
|
|
96
|
+
* @param vertices - the two vertex queues
|
|
97
|
+
* @param counters - the counters block
|
|
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, edgeQueue, edgeCapacity, n) {
|
|
103
|
+
this.sideIndex = 0;
|
|
104
|
+
this.vertices = vertices;
|
|
105
|
+
this.counters = counters;
|
|
106
|
+
this.edgeQueue = edgeQueue;
|
|
107
|
+
this.edgeCapacity = edgeCapacity;
|
|
108
|
+
this.n = n;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Which vertex queue is the input of the current level (a host-side index between two cached bind-group sets).
|
|
112
|
+
* @returns 0 or 1
|
|
113
|
+
*/
|
|
114
|
+
get side() {
|
|
115
|
+
return this.sideIndex;
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* The vertex queue the current level expands from.
|
|
119
|
+
* @returns `vertices[side]`
|
|
120
|
+
*/
|
|
121
|
+
get input() {
|
|
122
|
+
return this.sideIndex === 0 ? this.vertices[0] : this.vertices[1];
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* The vertex queue the current level's claims append to.
|
|
126
|
+
* @returns `vertices[1 - side]`
|
|
127
|
+
*/
|
|
128
|
+
get output() {
|
|
129
|
+
return this.sideIndex === 0 ? this.vertices[1] : this.vertices[0];
|
|
130
|
+
}
|
|
131
|
+
/** Flips the two vertex queues; the counts rotate inside the block, so nothing else moves. */
|
|
132
|
+
swap() {
|
|
133
|
+
this.sideIndex = this.sideIndex === 0 ? 1 : 0;
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Seeds a traversal: one `queue.writeBuffer` of the whole 112-byte block (zero except the caller's words) and one of
|
|
137
|
+
* `vertices[0][0] = source`, both ordered before the submit that follows; the source is on side 0 afterwards.
|
|
138
|
+
* `frontierCount` is not a word to seed: the first boundary rotates word 1 into it (the BFS seed is
|
|
139
|
+
* `{ nextFrontierCount: 1, level: U32_MAX }`). A source outside `[0, n)`, an unknown word or a value that is not a
|
|
140
|
+
* u32 is E_INVALID_ARGUMENT before anything is written.
|
|
141
|
+
* @param queue - the device queue
|
|
142
|
+
* @param source - the source vertex
|
|
143
|
+
* @param seed - the words to seed
|
|
144
|
+
*/
|
|
145
|
+
reset(queue, source, seed) {
|
|
146
|
+
if (!Number.isInteger(source) || source < 0 || source >= this.n) {
|
|
147
|
+
throw new WebGpuGraphError("E_INVALID_ARGUMENT", `frontier: source ${source} is outside [0, ${this.n})`, {
|
|
148
|
+
argument: "source",
|
|
149
|
+
value: source,
|
|
150
|
+
expected: `an integer in [0, ${this.n})`,
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
const bytes = new ArrayBuffer(FRONTIER_COUNTERS.byteLength);
|
|
154
|
+
FRONTIER_COUNTERS.write(new DataView(bytes), definedWords(seed));
|
|
155
|
+
this.sideIndex = 0;
|
|
156
|
+
queue.writeBuffer(this.counters.buffer, this.counters.offset, bytes);
|
|
157
|
+
queue.writeBuffer(this.vertices[0].buffer, this.vertices[0].offset, Uint32Array.of(source));
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Leases the frontier's buffers from the scope and compiles the selector so `recordFinalize` is synchronous. The
|
|
162
|
+
* edge capacity defaults to `max(1, min(arcCount, floor(maxStorageBufferBindingSize / 4)))` (never a zero-length
|
|
163
|
+
* buffer: the one-node graph has no arcs); a test passes a small one to force the overflow path. The planner lives
|
|
164
|
+
* exactly as long as the scope: never use it after the scope's dispose().
|
|
165
|
+
* @param scope - the caller's scope (device, caps, cache, scratch, params)
|
|
166
|
+
* @param n - the vertex count
|
|
167
|
+
* @param arcCount - the arc count (the natural edge-queue size)
|
|
168
|
+
* @param edgeCapacity - the edge queue's entry count, when the caller chooses it (an integer >= 1)
|
|
169
|
+
* @returns the planner
|
|
170
|
+
*/
|
|
171
|
+
export async function prepareFrontier(scope, n, arcCount, edgeCapacity) {
|
|
172
|
+
assertCount("n", n);
|
|
173
|
+
assertCount("arcCount", arcCount);
|
|
174
|
+
const capacity = edgeCapacity ?? Math.max(1, Math.min(arcCount, Math.floor(scope.caps.limits.maxStorageBufferBindingSize / 4)));
|
|
175
|
+
if (!Number.isSafeInteger(capacity) || capacity < 1 || capacity > U32_MAX) {
|
|
176
|
+
throw new WebGpuGraphError("E_INVALID_ARGUMENT", "frontier: edgeCapacity must be an integer >= 1", {
|
|
177
|
+
argument: "edgeCapacity",
|
|
178
|
+
value: capacity,
|
|
179
|
+
expected: "an integer in [1, 2^32)",
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
const kernel = await scope.pipelines.kernel(kernelSpec("frontier-finalize"));
|
|
183
|
+
const queueBytes = 4 * Math.max(1, n);
|
|
184
|
+
const vertices = [
|
|
185
|
+
{ buffer: scope.scratch(queueBytes, "frontier/vertices-0"), offset: 0, size: queueBytes, window: null },
|
|
186
|
+
{ buffer: scope.scratch(queueBytes, "frontier/vertices-1"), offset: 0, size: queueBytes, window: null },
|
|
187
|
+
];
|
|
188
|
+
const counters = {
|
|
189
|
+
buffer: scope.scratch(FRONTIER_COUNTERS.byteLength, "frontier/counters"),
|
|
190
|
+
offset: 0,
|
|
191
|
+
size: FRONTIER_COUNTERS.byteLength,
|
|
192
|
+
window: null,
|
|
193
|
+
};
|
|
194
|
+
const edgeQueue = {
|
|
195
|
+
buffer: scope.scratch(4 * capacity, "frontier/edge-queue"),
|
|
196
|
+
offset: 0,
|
|
197
|
+
size: 4 * capacity,
|
|
198
|
+
window: null,
|
|
199
|
+
};
|
|
200
|
+
const frontier = new Frontier(vertices, counters, edgeQueue, capacity, n);
|
|
201
|
+
return new FrontierPlannerImpl(scope, kernel, frontier);
|
|
202
|
+
}
|
|
203
|
+
/** The planner: the selector kernel bound once to the frontier's block. */
|
|
204
|
+
class FrontierPlannerImpl {
|
|
205
|
+
/**
|
|
206
|
+
* Wraps the resolved kernel; use prepareFrontier().
|
|
207
|
+
* @param scope - the caller's scope
|
|
208
|
+
* @param kernel - the `frontier-finalize` kernel
|
|
209
|
+
* @param frontier - the leased queue
|
|
210
|
+
*/
|
|
211
|
+
constructor(scope, kernel, frontier) {
|
|
212
|
+
this.scope = scope;
|
|
213
|
+
this.kernel = kernel;
|
|
214
|
+
this.frontier = frontier;
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* Records one selector dispatch (see the interface).
|
|
218
|
+
* @param pass - the compute pass
|
|
219
|
+
* @param role - the role
|
|
220
|
+
* @param level - the level inside the submit
|
|
221
|
+
* @param fields - the caller's fields
|
|
222
|
+
*/
|
|
223
|
+
recordFinalize(pass, role, level, fields) {
|
|
224
|
+
if (!Number.isInteger(level) || level < 0 || level >= MAX_LEVELS_PER_SUBMIT) {
|
|
225
|
+
throw new WebGpuGraphError("E_INVALID_ARGUMENT", `frontier: level ${level} is outside the submit`, {
|
|
226
|
+
argument: "level",
|
|
227
|
+
value: level,
|
|
228
|
+
expected: `an integer in [0, ${MAX_LEVELS_PER_SUBMIT})`,
|
|
229
|
+
});
|
|
230
|
+
}
|
|
231
|
+
if (!Number.isInteger(role) || role < 0 || role > MAX_ROLE) {
|
|
232
|
+
throw new WebGpuGraphError("E_INVALID_ARGUMENT", `frontier: role ${role} is not a finalize role`, {
|
|
233
|
+
argument: "role",
|
|
234
|
+
value: role,
|
|
235
|
+
expected: `an integer in [0, ${MAX_ROLE}]`,
|
|
236
|
+
});
|
|
237
|
+
}
|
|
238
|
+
const { scope, frontier } = this;
|
|
239
|
+
const params = scope.params(FRONTIER_PARAMS, {
|
|
240
|
+
...definedWords(fields),
|
|
241
|
+
role,
|
|
242
|
+
wg: scope.workgroupSize,
|
|
243
|
+
edgeCapacity: frontier.edgeCapacity,
|
|
244
|
+
n: frontier.n,
|
|
245
|
+
});
|
|
246
|
+
const bound = this.kernel.bind({ counters: frontier.counters, P: params.binding });
|
|
247
|
+
this.kernel.dispatch(pass, bound, plan1d(1, scope.workgroupSize, scope.caps), [params.offset]);
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
//# sourceMappingURL=frontier.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"frontier.js","sourceRoot":"","sources":["../../../src/primitives/frontier.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,OAAO,EAAE,q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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)
|
|
35
|
-
* mirrors (spec 9.7: `precision` is an extra field, `F32` is
|
|
36
|
-
* `weaklyConnectedComponents` are the same algorithm (spec 3.3: WCC
|
|
37
|
-
* the mirror declares; their options parameter stays OPTIONAL, because
|
|
38
|
-
* REQUIRED parameter would stop the member satisfying it.
|
|
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,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAAE,kBAAkB,EAAE,0BAA0B,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAC;
|
|
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,UAAU,EACV,aAAa,EACb,mBAAmB,EACnB,kBAAkB,EAClB,oBAAoB,EACpB,eAAe,EACf,cAAc,EACd,eAAe,EACf,aAAa,EACb,kBAAkB,EAClB,gBAAgB,EAChB,WAAW,EACX,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,iB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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"}
|