@graphty/webgpu-graph-algorithms 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +68 -25
- package/dist/browser.js +1 -1
- package/dist/chunks/{context-E6iKaeuJ.js → context-CRbw2Wyo.js} +178 -19
- package/dist/chunks/{context-E6iKaeuJ.js.map → context-CRbw2Wyo.js.map} +1 -1
- package/dist/node.js +1 -1
- package/dist/src/accelerator.d.ts +9 -6
- package/dist/src/accelerator.d.ts.map +1 -1
- package/dist/src/accelerator.js +85 -6
- package/dist/src/accelerator.js.map +1 -1
- package/dist/src/algorithms/components.d.ts +30 -0
- package/dist/src/algorithms/components.d.ts.map +1 -0
- package/dist/src/algorithms/components.js +300 -0
- package/dist/src/algorithms/components.js.map +1 -0
- package/dist/src/algorithms/pagerank.d.ts +39 -0
- package/dist/src/algorithms/pagerank.d.ts.map +1 -0
- package/dist/src/algorithms/pagerank.js +298 -0
- package/dist/src/algorithms/pagerank.js.map +1 -0
- package/dist/src/algorithms/power-iteration.d.ts +109 -0
- package/dist/src/algorithms/power-iteration.d.ts.map +1 -0
- package/dist/src/algorithms/power-iteration.js +206 -0
- package/dist/src/algorithms/power-iteration.js.map +1 -0
- package/dist/src/algorithms/scope.d.ts +26 -0
- package/dist/src/algorithms/scope.d.ts.map +1 -0
- package/dist/src/algorithms/scope.js +41 -0
- package/dist/src/algorithms/scope.js.map +1 -0
- package/dist/src/algorithms/spectral.d.ts +50 -0
- package/dist/src/algorithms/spectral.d.ts.map +1 -0
- package/dist/src/algorithms/spectral.js +247 -0
- package/dist/src/algorithms/spectral.js.map +1 -0
- package/dist/src/index.d.ts +4 -0
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +4 -0
- package/dist/src/index.js.map +1 -1
- package/dist/src/kernel/dispatch.d.ts +4 -1
- package/dist/src/kernel/dispatch.d.ts.map +1 -1
- package/dist/src/kernel/dispatch.js +12 -5
- package/dist/src/kernel/dispatch.js.map +1 -1
- package/dist/src/kernels.d.ts +20 -4
- package/dist/src/kernels.d.ts.map +1 -1
- package/dist/src/kernels.js +172 -2
- package/dist/src/kernels.js.map +1 -1
- package/dist/src/memory/residency.d.ts.map +1 -1
- package/dist/src/memory/residency.js +164 -11
- package/dist/src/memory/residency.js.map +1 -1
- package/dist/src/primitives/core-shape.d.ts +41 -0
- package/dist/src/primitives/core-shape.d.ts.map +1 -0
- package/dist/src/primitives/core-shape.js +89 -0
- package/dist/src/primitives/core-shape.js.map +1 -0
- package/dist/src/primitives/segmented-reduce.d.ts.map +1 -1
- package/dist/src/primitives/segmented-reduce.js +4 -30
- package/dist/src/primitives/segmented-reduce.js.map +1 -1
- package/dist/src/primitives/spmv.d.ts +56 -0
- package/dist/src/primitives/spmv.d.ts.map +1 -0
- package/dist/src/primitives/spmv.js +101 -0
- package/dist/src/primitives/spmv.js.map +1 -0
- package/dist/src/types/accelerator.d.ts +14 -2
- package/dist/src/types/accelerator.d.ts.map +1 -1
- package/dist/src/types/algorithms.d.ts +73 -0
- package/dist/src/types/algorithms.d.ts.map +1 -0
- package/dist/src/types/algorithms.js +17 -0
- package/dist/src/types/algorithms.js.map +1 -0
- package/dist/src/wgsl/pr-finalize.wgsl.d.ts +11 -0
- package/dist/src/wgsl/pr-finalize.wgsl.d.ts.map +1 -0
- package/dist/src/wgsl/pr-finalize.wgsl.js +36 -0
- package/dist/src/wgsl/pr-finalize.wgsl.js.map +1 -0
- package/dist/src/wgsl/pr-scale.wgsl.d.ts +14 -0
- package/dist/src/wgsl/pr-scale.wgsl.d.ts.map +1 -0
- package/dist/src/wgsl/pr-scale.wgsl.js +48 -0
- package/dist/src/wgsl/pr-scale.wgsl.js.map +1 -0
- package/dist/src/wgsl/spmv-pull.wgsl.d.ts +15 -0
- package/dist/src/wgsl/spmv-pull.wgsl.d.ts.map +1 -0
- package/dist/src/wgsl/spmv-pull.wgsl.js +47 -0
- package/dist/src/wgsl/spmv-pull.wgsl.js.map +1 -0
- package/dist/src/wgsl/wcc-compress.wgsl.d.ts +9 -0
- package/dist/src/wgsl/wcc-compress.wgsl.d.ts.map +1 -0
- package/dist/src/wgsl/wcc-compress.wgsl.js +26 -0
- package/dist/src/wgsl/wcc-compress.wgsl.js.map +1 -0
- package/dist/src/wgsl/wcc-link-edges.wgsl.d.ts +13 -0
- package/dist/src/wgsl/wcc-link-edges.wgsl.d.ts.map +1 -0
- package/dist/src/wgsl/wcc-link-edges.wgsl.js +46 -0
- package/dist/src/wgsl/wcc-link-edges.wgsl.js.map +1 -0
- package/dist/src/wgsl/wcc-link-sample.wgsl.d.ts +11 -0
- package/dist/src/wgsl/wcc-link-sample.wgsl.d.ts.map +1 -0
- package/dist/src/wgsl/wcc-link-sample.wgsl.js +45 -0
- package/dist/src/wgsl/wcc-link-sample.wgsl.js.map +1 -0
- package/dist/src/wgsl/wcc-sample.wgsl.d.ts +10 -0
- package/dist/src/wgsl/wcc-sample.wgsl.d.ts.map +1 -0
- package/dist/src/wgsl/wcc-sample.wgsl.js +18 -0
- package/dist/src/wgsl/wcc-sample.wgsl.js.map +1 -0
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/dist/webgpu-graph-algorithms.js +1550 -29
- package/dist/webgpu-graph-algorithms.js.map +1 -1
- package/package.json +3 -3
- package/src/accelerator.ts +101 -7
- package/src/algorithms/components.ts +348 -0
- package/src/algorithms/pagerank.ts +343 -0
- package/src/algorithms/power-iteration.ts +278 -0
- package/src/algorithms/scope.ts +52 -0
- package/src/algorithms/spectral.ts +300 -0
- package/src/index.ts +18 -0
- package/src/kernel/dispatch.ts +12 -5
- package/src/kernels.ts +206 -5
- package/src/memory/residency.ts +200 -11
- package/src/primitives/core-shape.ts +103 -0
- package/src/primitives/segmented-reduce.ts +4 -36
- package/src/primitives/spmv.ts +155 -0
- package/src/types/accelerator.ts +28 -2
- package/src/types/algorithms.ts +82 -0
- package/src/wgsl/pr-finalize.wgsl.ts +36 -0
- package/src/wgsl/pr-scale.wgsl.ts +48 -0
- package/src/wgsl/spmv-pull.wgsl.ts +47 -0
- package/src/wgsl/wcc-compress.wgsl.ts +26 -0
- package/src/wgsl/wcc-link-edges.wgsl.ts +46 -0
- package/src/wgsl/wcc-link-sample.wgsl.ts +45 -0
- package/src/wgsl/wcc-sample.wgsl.ts +18 -0
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The shape helpers every core-walking primitive shares (spec 4.1): the row count and the arc count a CoreBinding
|
|
3
|
+
* implies, the windowed rejection of P4, and the ViewBinding -> CoreBinding adapter the P7 pull kernels need.
|
|
4
|
+
* Moved out of segmented-reduce.ts by M8b-T4 so spmv.ts can use them without duplicating them; the `primitive`
|
|
5
|
+
* argument keeps each caller's error details byte-identical to what they were when the helpers were private.
|
|
6
|
+
*/
|
|
7
|
+
import { type CoreBinding, type ViewBinding } from "../memory/residency.js";
|
|
8
|
+
/**
|
|
9
|
+
* The row count of a core from its rowPtr binding (4(n + 1) bytes).
|
|
10
|
+
* @param core - the core
|
|
11
|
+
* @param primitive - the caller's name, used in the message and the detail
|
|
12
|
+
* @returns n
|
|
13
|
+
*/
|
|
14
|
+
export declare function rowCountOf(core: CoreBinding, primitive: string): number;
|
|
15
|
+
/**
|
|
16
|
+
* The arc count a core implies: the colIdx binding is 4 bytes per arc, and a null colIdx is an arc-less snapshot.
|
|
17
|
+
* @param core - the core
|
|
18
|
+
* @returns the arc count
|
|
19
|
+
*/
|
|
20
|
+
export declare function arcCountOf(core: CoreBinding): number;
|
|
21
|
+
/**
|
|
22
|
+
* Rejects a windowed core (executed at P4).
|
|
23
|
+
* @param core - the core
|
|
24
|
+
* @param primitive - the caller's name, used in the message and the feature detail
|
|
25
|
+
*/
|
|
26
|
+
export declare function assertNotWindowed(core: CoreBinding, primitive: string): void;
|
|
27
|
+
/**
|
|
28
|
+
* The CoreBinding shape of a residency VIEW (spec 4.3). residency.view() returns a ViewBinding -- a name -> Binding
|
|
29
|
+
* record -- while graphBindings / graphOverrides and every core-walking primitive read rowPtr / colIdx / weights as
|
|
30
|
+
* top-level fields (src/kernels.ts graphBindings / graphOverrides). This is the only adapter between the two in the
|
|
31
|
+
* package. `plan` is "perArray" because views always upload per array (spec 4.3 lines 1182-1186) and `windows` is
|
|
32
|
+
* null because a view is never windowed, which is what makes assertNotWindowed pass for a view. `serial` is -1: a
|
|
33
|
+
* view is not a core and no caller of this function reads serial (nothing in src/primitives or src/algorithms
|
|
34
|
+
* reads CoreBinding.serial).
|
|
35
|
+
* @param v - the view binding, from residency.view(s, "reverse") or view(s, "edgeList")
|
|
36
|
+
* @param arcCount - the arc count of the view, from v.scalars.arcCount[0]; it must agree with the colIdx binding,
|
|
37
|
+
* which is what record() derives the arc window from (E_INVALID_ARGUMENT { argument: "arcCount" } otherwise)
|
|
38
|
+
* @returns the equivalent CoreBinding
|
|
39
|
+
*/
|
|
40
|
+
export declare function coreOfView(v: ViewBinding, arcCount: number): CoreBinding;
|
|
41
|
+
//# sourceMappingURL=core-shape.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"core-shape.d.ts","sourceRoot":"","sources":["../../../src/primitives/core-shape.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,KAAK,WAAW,EAAE,KAAK,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAG5E;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,CAcvE;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,WAAW,GAAG,MAAM,CAEpD;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,GAAG,IAAI,CAM5E;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,UAAU,CAAC,CAAC,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,GAAG,WAAW,CAkCxE"}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The shape helpers every core-walking primitive shares (spec 4.1): the row count and the arc count a CoreBinding
|
|
3
|
+
* implies, the windowed rejection of P4, and the ViewBinding -> CoreBinding adapter the P7 pull kernels need.
|
|
4
|
+
* Moved out of segmented-reduce.ts by M8b-T4 so spmv.ts can use them without duplicating them; the `primitive`
|
|
5
|
+
* argument keeps each caller's error details byte-identical to what they were when the helpers were private.
|
|
6
|
+
*/
|
|
7
|
+
import { WebGpuGraphError } from "../errors.js";
|
|
8
|
+
/**
|
|
9
|
+
* The row count of a core from its rowPtr binding (4(n + 1) bytes).
|
|
10
|
+
* @param core - the core
|
|
11
|
+
* @param primitive - the caller's name, used in the message and the detail
|
|
12
|
+
* @returns n
|
|
13
|
+
*/
|
|
14
|
+
export function rowCountOf(core, primitive) {
|
|
15
|
+
const bytes = core.rowPtr.size;
|
|
16
|
+
if (bytes < 4 || bytes % 4 !== 0) {
|
|
17
|
+
throw new WebGpuGraphError("E_INVALID_ARGUMENT", `${primitive}: a rowPtr binding of ${bytes} bytes is not 4(n + 1)`, {
|
|
18
|
+
argument: "core.rowPtr",
|
|
19
|
+
value: bytes,
|
|
20
|
+
expected: "a positive multiple of 4",
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
return bytes / 4 - 1;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* The arc count a core implies: the colIdx binding is 4 bytes per arc, and a null colIdx is an arc-less snapshot.
|
|
27
|
+
* @param core - the core
|
|
28
|
+
* @returns the arc count
|
|
29
|
+
*/
|
|
30
|
+
export function arcCountOf(core) {
|
|
31
|
+
return core.colIdx === null ? 0 : core.colIdx.size / 4;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Rejects a windowed core (executed at P4).
|
|
35
|
+
* @param core - the core
|
|
36
|
+
* @param primitive - the caller's name, used in the message and the feature detail
|
|
37
|
+
*/
|
|
38
|
+
export function assertNotWindowed(core, primitive) {
|
|
39
|
+
if (core.plan === "windowed" || core.windows !== null) {
|
|
40
|
+
throw new WebGpuGraphError("E_UNSUPPORTED", `${primitive}: windowed cores are executed at P4`, {
|
|
41
|
+
feature: `${primitive}.windowed`,
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* The CoreBinding shape of a residency VIEW (spec 4.3). residency.view() returns a ViewBinding -- a name -> Binding
|
|
47
|
+
* record -- while graphBindings / graphOverrides and every core-walking primitive read rowPtr / colIdx / weights as
|
|
48
|
+
* top-level fields (src/kernels.ts graphBindings / graphOverrides). This is the only adapter between the two in the
|
|
49
|
+
* package. `plan` is "perArray" because views always upload per array (spec 4.3 lines 1182-1186) and `windows` is
|
|
50
|
+
* null because a view is never windowed, which is what makes assertNotWindowed pass for a view. `serial` is -1: a
|
|
51
|
+
* view is not a core and no caller of this function reads serial (nothing in src/primitives or src/algorithms
|
|
52
|
+
* reads CoreBinding.serial).
|
|
53
|
+
* @param v - the view binding, from residency.view(s, "reverse") or view(s, "edgeList")
|
|
54
|
+
* @param arcCount - the arc count of the view, from v.scalars.arcCount[0]; it must agree with the colIdx binding,
|
|
55
|
+
* which is what record() derives the arc window from (E_INVALID_ARGUMENT { argument: "arcCount" } otherwise)
|
|
56
|
+
* @returns the equivalent CoreBinding
|
|
57
|
+
*/
|
|
58
|
+
export function coreOfView(v, arcCount) {
|
|
59
|
+
const { rowPtr } = v.bindings;
|
|
60
|
+
if (rowPtr === undefined) {
|
|
61
|
+
throw new WebGpuGraphError("E_INVALID_ARGUMENT", `the ${v.view} view has no rowPtr binding`, {
|
|
62
|
+
argument: "view",
|
|
63
|
+
value: v.view,
|
|
64
|
+
expected: "a view with a rowPtr binding (reverse)",
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
const colIdx = v.bindings.colIdx ?? null;
|
|
68
|
+
const weights = v.bindings.weights ?? null;
|
|
69
|
+
const bound = colIdx === null ? 0 : colIdx.size / 4;
|
|
70
|
+
if (bound !== arcCount) {
|
|
71
|
+
throw new WebGpuGraphError("E_INVALID_ARGUMENT", `the ${v.view} view binds ${bound} arcs but its arcCount scalar says ${arcCount}`, {
|
|
72
|
+
argument: "arcCount",
|
|
73
|
+
value: arcCount,
|
|
74
|
+
expected: bound,
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
return Object.freeze({
|
|
78
|
+
serial: -1,
|
|
79
|
+
plan: "perArray",
|
|
80
|
+
rowPtr,
|
|
81
|
+
colIdx,
|
|
82
|
+
weights,
|
|
83
|
+
arcToEdge: null,
|
|
84
|
+
edgeToArc: null,
|
|
85
|
+
windows: null,
|
|
86
|
+
hasWeights: weights !== null,
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
//# sourceMappingURL=core-shape.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"core-shape.js","sourceRoot":"","sources":["../../../src/primitives/core-shape.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAIhD;;;;;GAKG;AACH,MAAM,UAAU,UAAU,CAAC,IAAiB,EAAE,SAAiB;IAC3D,MAAM,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC;IAC/B,IAAI,KAAK,GAAG,CAAC,IAAI,KAAK,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC;QAC/B,MAAM,IAAI,gBAAgB,CACtB,oBAAoB,EACpB,GAAG,SAAS,yBAAyB,KAAK,wBAAwB,EAClE;YACI,QAAQ,EAAE,aAAa;YACvB,KAAK,EAAE,KAAK;YACZ,QAAQ,EAAE,0BAA0B;SACvC,CACJ,CAAC;IACN,CAAC;IACD,OAAO,KAAK,GAAG,CAAC,GAAG,CAAC,CAAC;AACzB,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,UAAU,CAAC,IAAiB;IACxC,OAAO,IAAI,CAAC,MAAM,KAAK,IAAI,C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ACpB,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,OAAO,KAAK,IAAI;KAC/B,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"segmented-reduce.d.ts","sourceRoot":"","sources":["../../../src/primitives/segmented-reduce.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAMH,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"segmented-reduce.d.ts","sourceRoot":"","sources":["../../../src/primitives/segmented-reduce.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAMH,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAElD,OAAO,EAAE,KAAK,QAAQ,EAAE,KAAK,WAAW,EAAE,MAAM,aAAa,CAAC;AAE9D,gIAAgI;AAChI,MAAM,WAAW,WAAW;IACxB,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IACvB,QAAQ,CAAC,cAAc,EAAE,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;CAC9E;AAED,iMAAiM;AACjM,MAAM,WAAW,sBAAsB;IACnC,QAAQ,CAAC,EAAE,EAAE,QAAQ,CAAC;IACtB,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,KAAK,EAAE,WAAW,GAAG,IAAI,CAAC;IACnC,QAAQ,CAAC,UAAU,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;CAC7C;AAED,0JAA0J;AAC1J,MAAM,WAAW,sBAAsB;IACnC,qIAAqI;IACrI,MAAM,CAAC,IAAI,EAAE,qBAAqB,EAAE,IAAI,EAAE,WAAW,EAAE,GAAG,EAAE,OAAO,GAAG,IAAI,CAAC;CAC9E;AAgLD;;;;;;GAMG;AACH,wBAAsB,sBAAsB,CACxC,KAAK,EAAE,WAAW,EAClB,IAAI,EAAE,WAAW,EACjB,OAAO,EAAE,sBAAsB,GAChC,OAAO,CAAC,sBAAsB,CAAC,CAajC"}
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
import { WebGpuGraphError } from "../errors.js";
|
|
11
11
|
import { plan1d } from "../kernel/dispatch.js";
|
|
12
12
|
import { graphBindings, graphOverrides, kernelSpec, RANGE_PARAMS } from "../kernels.js";
|
|
13
|
+
import { assertNotWindowed, rowCountOf } from "./core-shape.js";
|
|
13
14
|
/** The identifiers a VALUE snippet may name (contract 3.11, 4.5); every other identifier is rejected textually before compose. */
|
|
14
15
|
const VALUE_SNIPPET_VOCABULARY = new Set(["row", "arc", "nbr", "weight", "v"]);
|
|
15
16
|
/**
|
|
@@ -105,33 +106,6 @@ function validateValueSnippet(snippet) {
|
|
|
105
106
|
throw new WebGpuGraphError("E_SHADER_COMPILE", `segmentedReduce: the VALUE snippet names "${token}"; the only identifiers allowed are row, arc, nbr, weight and v`, { id: "segmented-reduce", stage: "compose", slot: "VALUE", identifier: token });
|
|
106
107
|
}
|
|
107
108
|
}
|
|
108
|
-
/**
|
|
109
|
-
* The row count of a core from its rowPtr binding (4(n + 1) bytes).
|
|
110
|
-
* @param core - the core
|
|
111
|
-
* @returns n
|
|
112
|
-
*/
|
|
113
|
-
function rowCountOf(core) {
|
|
114
|
-
const bytes = core.rowPtr.size;
|
|
115
|
-
if (bytes < 4 || bytes % 4 !== 0) {
|
|
116
|
-
throw new WebGpuGraphError("E_INVALID_ARGUMENT", `segmentedReduce: a rowPtr binding of ${bytes} bytes is not 4(n + 1)`, {
|
|
117
|
-
argument: "core.rowPtr",
|
|
118
|
-
value: bytes,
|
|
119
|
-
expected: "a positive multiple of 4",
|
|
120
|
-
});
|
|
121
|
-
}
|
|
122
|
-
return bytes / 4 - 1;
|
|
123
|
-
}
|
|
124
|
-
/**
|
|
125
|
-
* Rejects a windowed core (executed at P4).
|
|
126
|
-
* @param core - the core
|
|
127
|
-
*/
|
|
128
|
-
function assertNotWindowed(core) {
|
|
129
|
-
if (core.plan === "windowed" || core.windows !== null) {
|
|
130
|
-
throw new WebGpuGraphError("E_UNSUPPORTED", "segmentedReduce: windowed cores are executed at P4", {
|
|
131
|
-
feature: "segmentedReduce.windowed",
|
|
132
|
-
});
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
109
|
/** The thread-per-row planner: ONE `segmented-reduce` dispatch with TIER 0 over every row. */
|
|
136
110
|
class ThreadPerRowPlanner {
|
|
137
111
|
/**
|
|
@@ -155,7 +129,7 @@ class ThreadPerRowPlanner {
|
|
|
155
129
|
* @param out - at least 4n bytes of f32
|
|
156
130
|
*/
|
|
157
131
|
record(pass, core, out) {
|
|
158
|
-
assertNotWindowed(core);
|
|
132
|
+
assertNotWindowed(core, "segmentedReduce");
|
|
159
133
|
if ((core.weights !== null) !== this.hasWeights) {
|
|
160
134
|
throw new WebGpuGraphError("E_INVALID_ARGUMENT", "segmentedReduce: the core's weights pattern differs from the one prepared", {
|
|
161
135
|
argument: "core",
|
|
@@ -163,7 +137,7 @@ class ThreadPerRowPlanner {
|
|
|
163
137
|
expected: this.hasWeights,
|
|
164
138
|
});
|
|
165
139
|
}
|
|
166
|
-
const n = rowCountOf(core);
|
|
140
|
+
const n = rowCountOf(core, "segmentedReduce");
|
|
167
141
|
if (n === 0) {
|
|
168
142
|
return;
|
|
169
143
|
}
|
|
@@ -200,7 +174,7 @@ export async function prepareSegmentedReduce(scope, core, options) {
|
|
|
200
174
|
feature: "segmentedReduce.tiers",
|
|
201
175
|
});
|
|
202
176
|
}
|
|
203
|
-
assertNotWindowed(core);
|
|
177
|
+
assertNotWindowed(core, "segmentedReduce");
|
|
204
178
|
const op = opCode(options.op);
|
|
205
179
|
validateValueSnippet(options.valueSnippet);
|
|
206
180
|
const overrides = { ...graphOverrides(core, null), OP: op, TIER: 0 };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"segmented-reduce.js","sourceRoot":"","sources":["../../../src/primitives/segmented-reduce.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAE/C,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"segmented-reduce.js","sourceRoot":"","sources":["../../../src/primitives/segmented-reduce.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAE/C,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAGxF,OAAO,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAuBhE,kIAAkI;AAClI,MAAM,wBAAwB,GAAwB,IAAI,GAAG,CAAC,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,GAAG,CAAC,CAAC,CAAC;AAEpG;;;;;GAKG;AACH,MAAM,wBAAwB,GAAwB,IAAI,GAAG,CAAC;IAC1D,IAAI;IACJ,MAAM;IACN,KAAK;IACL,KAAK;IACL,OAAO;IACP,MAAM;IACN,OAAO;IACP,KA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;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,sBAAsB,CACxC,KAAkB,EAClB,IAAiB,EACjB,OAA+B;IAE/B,IAAI,OAAO,CAAC,KAAK,KAAK,IAAI,EAAE,CAAC;QACzB,MAAM,IAAI,gBAAgB,CAAC,eAAe,EAAE,gEAAgE,EAAE;YAC1G,OAAO,EAAE,uBAAuB;SACnC,CAAC,CAAC;IACP,CAAC;IACD,iBAAiB,CAAC,IAAI,EAAE,iBAAiB,CAAC,CAAC;IAC3C,MAAM,EAAE,GAAG,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;IAC9B,oBAAoB,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;IAC3C,MAAM,SAAS,GAAG,EAAE,GAAG,cAAc,CAAC,IAAI,EAAE,IAAI,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC;IACrE,MAAM,IAAI,GAAG,UAAU,CAAC,kBAAkB,EAAE,SAAS,EAAE,EAAE,KAAK,EAAE,OAAO,CAAC,YAAY,EAAE,CAAC,CAAC;IACxF,MAAM,MAAM,GAAG,MAAM,KAAK,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAClD,OAAO,IAAI,mBAAmB,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,CAAC,OAAO,KAAK,IAAI,EAAE,OAAO,CAAC,UAAU,KAAK,IAAI,CAAC,CAAC;AACtG,CAAC"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The pull SpMV primitive of spec 6 row 9 / 8.2 in its thread-per-row tier (P7; M8b plan PD-1 / PD-2): one
|
|
3
|
+
* grid-stride dispatch of the `spmv-pull` module over the rows of a REVERSE adjacency, each invocation folding
|
|
4
|
+
* `weight * xNorm[nbr]` over its row's in-arcs (Kahan-compensated, f32) and writing
|
|
5
|
+
* `rankOut[v] = beta * pv + alpha * (sum + danglingMass * pv)`, where `pv` is `personalization[v]` under
|
|
6
|
+
* HAS_PERSONALIZATION and the uniform `P.uniformP` otherwise, and `danglingMass` is `partials[0].danglingMass`
|
|
7
|
+
* under USE_DANGLING. PageRank sets alpha to the damping, beta to 1 - alpha and USE_DANGLING; HITS and eigenvector
|
|
8
|
+
* set alpha 1, beta 0, uniformP 0; Katz sets alpha to the attenuation, beta to its constant and uniformP 1.
|
|
9
|
+
*
|
|
10
|
+
* It is its own registry entry rather than a `segmentedReduce` VALUE snippet (PD-1): the snippet vocabulary is
|
|
11
|
+
* `row, arc, nbr, weight, v` and cannot read `xNorm[nbr]`, and the design's binding table gives the kernel eight
|
|
12
|
+
* storage bindings of its own. The in-degree tiers of `reverseDegreeOrder()` land at P4 (PD-2): `tiers !== null` is
|
|
13
|
+
* E_UNSUPPORTED and USE_PERM is always false (the perm slot carries the rowPtr dummy of graphBindings). The row and
|
|
14
|
+
* arc counts come from the core's binding sizes exactly as segmentedReduce derives them.
|
|
15
|
+
*/
|
|
16
|
+
import { type CoreBinding } from "../memory/residency.js";
|
|
17
|
+
import { type Binding } from "../types/memory.js";
|
|
18
|
+
import { type ReduceScope } from "./reduce.js";
|
|
19
|
+
import { type DegreeTiers } from "./segmented-reduce.js";
|
|
20
|
+
/** The group-1 bindings of one pull: the pre-scaled input, the output, the personalization (null binds xNorm as the dummy) and the PrPartial block whose header carries danglingMass. */
|
|
21
|
+
export interface SpmvResources {
|
|
22
|
+
readonly xNorm: Binding;
|
|
23
|
+
readonly rankOut: Binding;
|
|
24
|
+
readonly personalization: Binding | null;
|
|
25
|
+
readonly partials: Binding;
|
|
26
|
+
}
|
|
27
|
+
/** The scalar coefficients of one pull (SpmvParams alpha / beta / uniformP). */
|
|
28
|
+
export interface SpmvCoefficients {
|
|
29
|
+
readonly alpha: number;
|
|
30
|
+
readonly beta: number;
|
|
31
|
+
readonly uniformP: number;
|
|
32
|
+
}
|
|
33
|
+
/** Options of prepareSpmvPull: the two variant flags, the weights binding and the tiers (must be null at P7). */
|
|
34
|
+
export interface SpmvPullOptions {
|
|
35
|
+
readonly personalization: boolean;
|
|
36
|
+
readonly dangling: boolean;
|
|
37
|
+
/** The weights binding to fold with: `undefined` takes the core's, `null` runs UNWEIGHTED on a weighted core. */
|
|
38
|
+
readonly weights?: Binding | null | undefined;
|
|
39
|
+
readonly tiers: DegreeTiers | null;
|
|
40
|
+
}
|
|
41
|
+
/** A prepared pull: records ONE grid-stride dispatch over the rows of a reverse core into a pass. */
|
|
42
|
+
export interface SpmvPullPlanner {
|
|
43
|
+
/** Records the dispatch over rows [0, n) of `rev` writing rankOut[v] (f32) per row; nothing for n = 0. */
|
|
44
|
+
record(pass: GPUComputePassEncoder, rev: CoreBinding, resources: SpmvResources, coefficients: SpmvCoefficients): void;
|
|
45
|
+
/** Dispatches the last record() issued (1, or 0 for n = 0). */
|
|
46
|
+
readonly lastDispatches: number;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Prepares the thread-per-row pull pipeline for a reverse core's weights pattern and the two variant flags.
|
|
50
|
+
* @param scope - the reduce scope (pipelines, params writer)
|
|
51
|
+
* @param rev - the reverse core whose weights pattern selects HAS_WEIGHTS (USE_PERM is false: no tiers at P7)
|
|
52
|
+
* @param options - personalization, dangling, weights, tiers (must be null)
|
|
53
|
+
* @returns the planner
|
|
54
|
+
*/
|
|
55
|
+
export declare function prepareSpmvPull(scope: ReduceScope, rev: CoreBinding, options: SpmvPullOptions): Promise<SpmvPullPlanner>;
|
|
56
|
+
//# sourceMappingURL=spmv.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"spmv.d.ts","sourceRoot":"","sources":["../../../src/primitives/spmv.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAMH,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAElD,OAAO,EAAE,KAAK,WAAW,EAAE,MAA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of spec 6 row 9 / 8.2 in its thread-per-row tier (P7; M8b plan PD-1 / PD-2): one
|
|
3
|
+
* grid-stride dispatch of the `spmv-pull` module over the rows of a REVERSE adjacency, each invocation folding
|
|
4
|
+
* `weight * xNorm[nbr]` over its row's in-arcs (Kahan-compensated, f32) and writing
|
|
5
|
+
* `rankOut[v] = beta * pv + alpha * (sum + danglingMass * pv)`, where `pv` is `personalization[v]` under
|
|
6
|
+
* HAS_PERSONALIZATION and the uniform `P.uniformP` otherwise, and `danglingMass` is `partials[0].danglingMass`
|
|
7
|
+
* under USE_DANGLING. PageRank sets alpha to the damping, beta to 1 - alpha and USE_DANGLING; HITS and eigenvector
|
|
8
|
+
* set alpha 1, beta 0, uniformP 0; Katz sets alpha to the attenuation, beta to its constant and uniformP 1.
|
|
9
|
+
*
|
|
10
|
+
* It is its own registry entry rather than a `segmentedReduce` VALUE snippet (PD-1): the snippet vocabulary is
|
|
11
|
+
* `row, arc, nbr, weight, v` and cannot read `xNorm[nbr]`, and the design's binding table gives the kernel eight
|
|
12
|
+
* storage bindings of its own. The in-degree tiers of `reverseDegreeOrder()` land at P4 (PD-2): `tiers !== null` is
|
|
13
|
+
* E_UNSUPPORTED and USE_PERM is always false (the perm slot carries the rowPtr dummy of graphBindings). The row and
|
|
14
|
+
* arc counts come from the core's binding sizes exactly as segmentedReduce derives them.
|
|
15
|
+
*/
|
|
16
|
+
import { WebGpuGraphError } from "../errors.js";
|
|
17
|
+
import { planGridStride } from "../kernel/dispatch.js";
|
|
18
|
+
import { graphBindings, graphOverrides, kernelSpec, SPMV_PARAMS } from "../kernels.js";
|
|
19
|
+
import { arcCountOf, assertNotWindowed, rowCountOf } from "./core-shape.js";
|
|
20
|
+
/** The thread-per-row planner: ONE `spmv-pull` dispatch, grid-stride over every row. */
|
|
21
|
+
class SpmvPullPlannerImpl {
|
|
22
|
+
/**
|
|
23
|
+
* Wraps a compiled pipeline with the weights choice it was compiled for.
|
|
24
|
+
* @param scope - the scope the pipeline was prepared in
|
|
25
|
+
* @param kernel - the compiled kernel
|
|
26
|
+
* @param weights - the weights option the pipeline's HAS_WEIGHTS was derived from; record() binds the same way
|
|
27
|
+
*/
|
|
28
|
+
constructor(scope, kernel, weights) {
|
|
29
|
+
this.dispatches = 0;
|
|
30
|
+
this.scope = scope;
|
|
31
|
+
this.kernel = kernel;
|
|
32
|
+
this.weights = weights;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Dispatches the last record() issued.
|
|
36
|
+
* @returns 1, or 0 when the last record covered no rows
|
|
37
|
+
*/
|
|
38
|
+
get lastDispatches() {
|
|
39
|
+
return this.dispatches;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Records the dispatch: rows [0, n), arcs [0, arcCount), planGridStride(n); nothing for n = 0 (no zero-length
|
|
43
|
+
* binding is ever created). `personalization ?? xNorm` follows the group-0 dummy rule: both slots are
|
|
44
|
+
* storage-ro, so the aliasing check of Kernel.bind does not fire, and HAS_PERSONALIZATION false never reads it.
|
|
45
|
+
* @param pass - the pass to record into
|
|
46
|
+
* @param rev - the reverse core (any snapshot with the weights pattern the planner was prepared for)
|
|
47
|
+
* @param resources - xNorm, rankOut, personalization, partials
|
|
48
|
+
* @param coefficients - alpha, beta, uniformP
|
|
49
|
+
*/
|
|
50
|
+
record(pass, rev, resources, coefficients) {
|
|
51
|
+
const n = rowCountOf(rev, "spmvPull");
|
|
52
|
+
const plan = planGridStride(n, this.scope.workgroupSize, this.scope.caps);
|
|
53
|
+
if (plan.x === 0) {
|
|
54
|
+
this.dispatches = 0;
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
const params = this.scope.params(SPMV_PARAMS, {
|
|
58
|
+
n,
|
|
59
|
+
arcBase: 0,
|
|
60
|
+
arcEnd: arcCountOf(rev),
|
|
61
|
+
stride: plan.stride ?? n,
|
|
62
|
+
alpha: coefficients.alpha,
|
|
63
|
+
beta: coefficients.beta,
|
|
64
|
+
uniformP: coefficients.uniformP,
|
|
65
|
+
pad0: 0,
|
|
66
|
+
});
|
|
67
|
+
const bound = this.kernel.bind({
|
|
68
|
+
...graphBindings(rev, null, this.weights),
|
|
69
|
+
xNorm: resources.xNorm,
|
|
70
|
+
rankOut: resources.rankOut,
|
|
71
|
+
personalization: resources.personalization ?? resources.xNorm,
|
|
72
|
+
partials: resources.partials,
|
|
73
|
+
P: params.binding,
|
|
74
|
+
});
|
|
75
|
+
this.kernel.dispatch(pass, bound, plan, [params.offset]);
|
|
76
|
+
this.dispatches = 1;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Prepares the thread-per-row pull pipeline for a reverse core's weights pattern and the two variant flags.
|
|
81
|
+
* @param scope - the reduce scope (pipelines, params writer)
|
|
82
|
+
* @param rev - the reverse core whose weights pattern selects HAS_WEIGHTS (USE_PERM is false: no tiers at P7)
|
|
83
|
+
* @param options - personalization, dangling, weights, tiers (must be null)
|
|
84
|
+
* @returns the planner
|
|
85
|
+
*/
|
|
86
|
+
export async function prepareSpmvPull(scope, rev, options) {
|
|
87
|
+
if (options.tiers !== null) {
|
|
88
|
+
throw new WebGpuGraphError("E_UNSUPPORTED", "spmvPull: the in-degree tiers land at P4; pass tiers: null", {
|
|
89
|
+
feature: "spmvPull.tiers",
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
assertNotWindowed(rev, "spmvPull");
|
|
93
|
+
const spec = kernelSpec("spmv-pull", {
|
|
94
|
+
...graphOverrides(rev, null, options.weights),
|
|
95
|
+
HAS_PERSONALIZATION: options.personalization,
|
|
96
|
+
USE_DANGLING: options.dangling,
|
|
97
|
+
});
|
|
98
|
+
const kernel = await scope.pipelines.kernel(spec);
|
|
99
|
+
return new SpmvPullPlannerImpl(scope, kernel, options.weights);
|
|
100
|
+
}
|
|
101
|
+
//# sourceMappingURL=spmv.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"spmv.js","sourceRoot":"","sources":["../../../src/primitives/spmv.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,CAAC;IACH,MAAM,MAAM,GAAG,MAAM,KAAK,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAClD,OAAO,IAAI,mBAAmB,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC;AACnE,CAAC"}
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import type { F32, F64, GraphSnapshot, NodeMask, NumericVector, U32 } from "@graphty/graph-format";
|
|
8
8
|
import type { GpuContext } from "../context.js";
|
|
9
|
+
import type { ComponentsOptions, EigenvectorOptions, GpuHitsResult, GpuLabelResult, GpuPageRankResult, GpuScoresResult, HitsOptions, KatzOptions, PageRankOptions } from "./algorithms.js";
|
|
9
10
|
import type { ForceAtlas2Stats, GpuLayoutSimulation, GpuLayoutTuning } from "./layout.js";
|
|
10
11
|
import type { ForceAtlas2Options, FruchtermanReingoldOptions, SpringElectricalOptions } from "./options.js";
|
|
11
12
|
/** Design 14.3 LayoutSimulation, verbatim. */
|
|
@@ -193,8 +194,12 @@ export interface AcceleratorOptions {
|
|
|
193
194
|
} | undefined;
|
|
194
195
|
}
|
|
195
196
|
/**
|
|
196
|
-
* The injectable object (spec 3.3)
|
|
197
|
-
*
|
|
197
|
+
* The injectable object (spec 3.3): P3's forceAtlas2, release and dispose, plus P7's seven algorithm members
|
|
198
|
+
* (spec 8.2, 8.3; M8b-T8), non-optional here and returning the `Gpu*Result` shapes, which satisfy the `*ResultLike`
|
|
199
|
+
* mirrors (spec 9.7: `precision` is an extra field, `F32` is a `NumericVector`). `connectedComponents` and
|
|
200
|
+
* `weaklyConnectedComponents` are the same algorithm (spec 3.3: WCC semantics on directed input) under both names
|
|
201
|
+
* the mirror declares; their options parameter stays OPTIONAL, because the mirror declares none and an extra
|
|
202
|
+
* REQUIRED parameter would stop the member satisfying it. Later phases add one member per shipped algorithm.
|
|
198
203
|
* Exported: implemented by src/accelerator.ts (P3-T3); re-exported from src/index.ts at P3-T3.
|
|
199
204
|
* @public
|
|
200
205
|
*/
|
|
@@ -203,6 +208,13 @@ export interface GpuAccelerator extends AlgorithmAccelerator, LayoutAccelerator
|
|
|
203
208
|
readonly ctx: GpuContext;
|
|
204
209
|
readonly options: Readonly<AcceleratorOptions>;
|
|
205
210
|
forceAtlas2(options?: ForceAtlas2Options): GpuLayoutSimulation<ForceAtlas2Options, ForceAtlas2Stats>;
|
|
211
|
+
pageRank(s: GraphSnapshot, options?: PageRankOptions): Promise<GpuPageRankResult>;
|
|
212
|
+
personalizedPageRank(s: GraphSnapshot, personalization: F32 | F64, options?: PageRankOptions): Promise<GpuPageRankResult>;
|
|
213
|
+
hits(s: GraphSnapshot, options?: HitsOptions): Promise<GpuHitsResult>;
|
|
214
|
+
eigenvectorCentrality(s: GraphSnapshot, options?: EigenvectorOptions): Promise<GpuScoresResult>;
|
|
215
|
+
katzCentrality(s: GraphSnapshot, options?: KatzOptions): Promise<GpuScoresResult>;
|
|
216
|
+
connectedComponents(s: GraphSnapshot, options?: ComponentsOptions): Promise<GpuLabelResult>;
|
|
217
|
+
weaklyConnectedComponents(s: GraphSnapshot, options?: ComponentsOptions): Promise<GpuLabelResult>;
|
|
206
218
|
release(s: GraphSnapshot): void;
|
|
207
219
|
dispose(): void;
|
|
208
220
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"accelerator.d.ts","sourceRoot":"","sources":["../../../src/types/accelerator.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,GAAG,EAAE,GAAG,EAAE,aAAa,EAAE,QAAQ,EAAE,aAAa,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAC;AAEnG,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,KAAK,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC1F,OAAO,KAAK,EAAE,kBAAkB,EAAE,0BAA0B,EAAE,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Ac,CAAC,CAAC,EAAE,aAAa,EAAE,OAAO,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC;IAClF,mBAAmB,CAAC,CAAC,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,OAAO,CAAC,CAAC,EAAE,aAAa,GAAG,IAAI,CAAC;IAChC,OAAO,IAAI,IAAI,CAAC;CACnB"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The result and option records of the P7 algorithms (spec 3.3 lines 815-828, 9.7). The `Gpu*Result` shapes are the
|
|
3
|
+
* design's verbatim; the option records are this package's own, spelled MEMBER FOR MEMBER as the CPU seam spells
|
|
4
|
+
* them so one object literal satisfies both sides (the same D27 mirror rule src/types/options.ts follows for the
|
|
5
|
+
* layout options). Types only: this file imports nothing at runtime.
|
|
6
|
+
*
|
|
7
|
+
* The CPU counterparts, when phase M8a lands them (plan 2026-09-19-webgpu-m8a-algorithms-seam, Task M8a-T8):
|
|
8
|
+
* `PageRankOptions` here is `IndexedPageRankOptions` there (`{ dampingFactor?, maxIterations?, tolerance?,
|
|
9
|
+
* weighted? }`); `HitsOptions`, `EigenvectorOptions` and `KatzOptions` here all correspond to the ONE
|
|
10
|
+
* `HitsOptionsLike` there (`{ maxIterations?, tolerance?, weighted? }`), which is why every one of them carries
|
|
11
|
+
* those three members and `KatzOptions` adds `alpha` / `beta` on top; `ComponentsOptions` has no CPU counterpart at
|
|
12
|
+
* all, because `AlgorithmAccelerator.connectedComponents?(s: GraphSnapshot): Promise<LabelResultLike>` declares no
|
|
13
|
+
* options parameter. `weighted`, never `weight`: that is the member name graph-format design 14.2 fixes at
|
|
14
|
+
* `design/graph-format/graph-format-design.md:3892` and the one M8a ports.
|
|
15
|
+
*/
|
|
16
|
+
import type { F32, U32 } from "@graphty/graph-format";
|
|
17
|
+
/** Spec 3.3 line 815: every score result carries `precision` so a consumer can label GPU scores (Q-24). */
|
|
18
|
+
export interface GpuScoresResult {
|
|
19
|
+
readonly scores: F32;
|
|
20
|
+
readonly iterations: number;
|
|
21
|
+
readonly converged: boolean;
|
|
22
|
+
readonly precision: "f32";
|
|
23
|
+
}
|
|
24
|
+
/** Spec 3.3 line 816: `iterations` is the first iteration whose L1 delta fell below the tolerance (8.2), not the batch boundary. */
|
|
25
|
+
export interface GpuPageRankResult extends GpuScoresResult {
|
|
26
|
+
readonly danglingMass: number;
|
|
27
|
+
}
|
|
28
|
+
/** Spec 3.3 line 817. */
|
|
29
|
+
export interface GpuHitsResult {
|
|
30
|
+
readonly hubs: F32;
|
|
31
|
+
readonly authorities: F32;
|
|
32
|
+
readonly iterations: number;
|
|
33
|
+
readonly converged: boolean;
|
|
34
|
+
readonly precision: "f32";
|
|
35
|
+
}
|
|
36
|
+
/** Spec 3.3 line 818: labels dense 0..count-1 in first-seen order (renumberPartition); groups() is index-aligned. */
|
|
37
|
+
export interface GpuLabelResult {
|
|
38
|
+
readonly labels: U32;
|
|
39
|
+
readonly count: number;
|
|
40
|
+
groups(): U32[];
|
|
41
|
+
}
|
|
42
|
+
/** The CPU seam's IndexedPageRankOptions, member for member (M8a Task M8a-T8; graph-format design 14.2 :3892). */
|
|
43
|
+
export interface PageRankOptions {
|
|
44
|
+
readonly dampingFactor?: number | undefined;
|
|
45
|
+
readonly maxIterations?: number | undefined;
|
|
46
|
+
readonly tolerance?: number | undefined;
|
|
47
|
+
readonly weighted?: boolean | undefined;
|
|
48
|
+
}
|
|
49
|
+
/** The CPU seam's HitsOptionsLike, member for member (M8a Task M8a-T8). */
|
|
50
|
+
export interface HitsOptions {
|
|
51
|
+
readonly maxIterations?: number | undefined;
|
|
52
|
+
readonly tolerance?: number | undefined;
|
|
53
|
+
readonly weighted?: boolean | undefined;
|
|
54
|
+
}
|
|
55
|
+
/** The CPU seam's HitsOptionsLike again: `eigenvectorCentrality` takes that same shape on the CPU side. */
|
|
56
|
+
export interface EigenvectorOptions {
|
|
57
|
+
readonly maxIterations?: number | undefined;
|
|
58
|
+
readonly tolerance?: number | undefined;
|
|
59
|
+
readonly weighted?: boolean | undefined;
|
|
60
|
+
}
|
|
61
|
+
/** HitsOptionsLike plus Katz's own two: `alpha` is the attenuation and `beta` the constant term. */
|
|
62
|
+
export interface KatzOptions {
|
|
63
|
+
readonly alpha?: number | undefined;
|
|
64
|
+
readonly beta?: number | undefined;
|
|
65
|
+
readonly maxIterations?: number | undefined;
|
|
66
|
+
readonly tolerance?: number | undefined;
|
|
67
|
+
readonly weighted?: boolean | undefined;
|
|
68
|
+
}
|
|
69
|
+
/** GPU-only (spec 3.3 line 797: `renumber: true` by default, Q-12); the CPU seam's connectedComponents takes none. */
|
|
70
|
+
export interface ComponentsOptions {
|
|
71
|
+
readonly renumber?: boolean | undefined;
|
|
72
|
+
}
|
|
73
|
+
//# sourceMappingURL=algorithms.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"algorithms.d.ts","sourceRoot":"","sources":["../../../src/types/algorithms.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAC;AAEtD,2GAA2G;AAC3G,MAAM,WAAW,eAAe;IAC5B,QAAQ,CAAC,MAAM,EAAE,GAAG,CAAC;IACrB,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC;IAC5B,QAAQ,CAAC,SAAS,EAAE,KAAK,CAAC;CAC7B;AAED,oIAAoI;AACpI,MAAM,WAAW,iBAAkB,SAAQ,eAAe;IACtD,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;CACjC;AAED,yBAAyB;AACzB,MAAM,W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CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACpC,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACnC,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC5C,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACxC,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;CAC3C;AAED,sHAAsH;AACtH,MAAM,WAAW,iBAAiB;IAC9B,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;CAC3C"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The result and option records of the P7 algorithms (spec 3.3 lines 815-828, 9.7). The `Gpu*Result` shapes are the
|
|
3
|
+
* design's verbatim; the option records are this package's own, spelled MEMBER FOR MEMBER as the CPU seam spells
|
|
4
|
+
* them so one object literal satisfies both sides (the same D27 mirror rule src/types/options.ts follows for the
|
|
5
|
+
* layout options). Types only: this file imports nothing at runtime.
|
|
6
|
+
*
|
|
7
|
+
* The CPU counterparts, when phase M8a lands them (plan 2026-09-19-webgpu-m8a-algorithms-seam, Task M8a-T8):
|
|
8
|
+
* `PageRankOptions` here is `IndexedPageRankOptions` there (`{ dampingFactor?, maxIterations?, tolerance?,
|
|
9
|
+
* weighted? }`); `HitsOptions`, `EigenvectorOptions` and `KatzOptions` here all correspond to the ONE
|
|
10
|
+
* `HitsOptionsLike` there (`{ maxIterations?, tolerance?, weighted? }`), which is why every one of them carries
|
|
11
|
+
* those three members and `KatzOptions` adds `alpha` / `beta` on top; `ComponentsOptions` has no CPU counterpart at
|
|
12
|
+
* all, because `AlgorithmAccelerator.connectedComponents?(s: GraphSnapshot): Promise<LabelResultLike>` declares no
|
|
13
|
+
* options parameter. `weighted`, never `weight`: that is the member name graph-format design 14.2 fixes at
|
|
14
|
+
* `design/graph-format/graph-format-design.md:3892` and the one M8a ports.
|
|
15
|
+
*/
|
|
16
|
+
export {};
|
|
17
|
+
//# sourceMappingURL=algorithms.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"algorithms.js","sourceRoot":"","sources":["../../../src/types/algorithms.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `pr-finalize` kernel body (spec 8.2 dispatch (b)): ONE workgroup folds the `P.groups` per-workgroup partials
|
|
3
|
+
* into the header at `partials[0]` -- a STORAGE region, never a uniform, read by the next dispatch of the same
|
|
4
|
+
* pass -- and records `firstConverged` the first time the delta falls below `P.convergeThreshold`. NORM_MODE 2
|
|
5
|
+
* stores the square root of the folded norm (the L2 case). The recorded iteration is `P.iteration - 1u` because
|
|
6
|
+
* the delta a scale pass produces at iteration i is `|x(i-1) - x(i-2)|`, the error of iteration i - 1 (PD-9).
|
|
7
|
+
* The body is normative: a sabotage mutation is a textual edit of it, so it is not restyled.
|
|
8
|
+
*/
|
|
9
|
+
/** Entry point `pr_finalize`; override NORM_MODE (2 takes the square root of the folded norm, every other value stores it as folded). */
|
|
10
|
+
export declare const prFinalizeWgsl = "\n@compute @workgroup_size(WG)\nfn pr_finalize(@builtin(local_invocation_id) lid: vec3<u32>) {\n var d = 0.0;\n var e = 0.0;\n var m = 0.0;\n for (var g = lid.x; g < P.groups; g = g + WG) {\n d = d + partials[1u + g].danglingMass;\n e = e + partials[1u + g].delta;\n m = m + partials[1u + g].norm;\n }\n let folded = wg_reduce_vec4(vec4f(d, e, m, 0.0), lid.x, 0u);\n if (lid.x == 0u) {\n partials[0].danglingMass = folded.x;\n partials[0].delta = folded.y;\n var norm = folded.z;\n if (NORM_MODE == 2u) { norm = sqrt(max(0.0, folded.z)); }\n partials[0].norm = norm;\n partials[0].iteration = P.iteration;\n let unset = partials[0].firstConverged == U32_MAX;\n if (P.trackConvergence == 1u && P.iteration >= 2u && folded.y < P.convergeThreshold && unset) {\n partials[0].firstConverged = P.iteration - 1u;\n }\n }\n}\n";
|
|
11
|
+
//# sourceMappingURL=pr-finalize.wgsl.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pr-finalize.wgsl.d.ts","sourceRoot":"","sources":["../../../src/wgsl/pr-finalize.wgsl.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,yIAAyI;AACzI,eAAO,MAAM,cAAc,86BAyB1B,CAAC"}
|