@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 @@
|
|
|
1
|
+
{"version":3,"file":"power-iteration.js","sourceRoot":"","sources":["../../../src/algorithms/power-iteration.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAIH,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAE1C,OAAO,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AACpE,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAElE,OAAO,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AACzD,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAExD,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAE5C,+CAA+C;AAC/C,MAAM,KAAK,GAAG,CAAC,CAAC;AAChB,oHAAoH;AACpH,MAAM,UAAU,GAAG,CAAC,GAAG,KAAK,GAAG,CAAC,CAAC;AA4CjC;;;;;;GAMG;AACH,MAAM,UAAU,SAAS,CAAC,IAA4C,EAAE,CAAS,EAAE,SAAiB;IAChG,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;QACrB,OAAO,IAAI,CAAC;IAChB,CAAC;IACD,IAAI,IAAI,YAAY,YAAY,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,IAAI,IAAI,CAAC,MAAM,YAAY,WAAW,EAAE,CAAC;QAC1F,OAAO,IAAW,CAAC;IACvB,CAAC;I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AAE,SAAS,CAAC,EAAE,CAAC,CAAC;YAC9C,CAAC;YACD,MAAM,CAAC,UAAU,EAAE,CAAC,aAAa,EAAE,MAAM,CAAC,aAAa,CAAC,CAAC;YACzD,MAAM,MAAM,GAAG,UAAU,CAAC,IAAI,CAAC,IAAI,QAAQ,CAAC,IAAI,CAAC,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;YACzE,MAAM,cAAc,GAAG,MAAM,CAAC,cAAwB,CAAC;YACvD,MAAM,SAAS,GAAG,cAAc,KAAK,OAAO,CAAC;YAC7C,IAAI,SAAS,IAAI,aAAa,IAAI,MAAM,CAAC,aAAa,EAAE,CAAC;gBACrD,IAAI,SAAS,IAAI,aAAa,GAAG,MAAM,CAAC,aAAa,EAAE,CAAC;oBACpD,MAAM,CAAC,UAAU,EAAE,CAAC,MAAM,CAAC,aAAa,EAAE,MAAM,CAAC,aAAa,CAAC,CAAC;gBACpE,CAAC;gBACD,OAAO;oBACH,MAAM,EAAE,IAAI,YAAY,CAAC,IAAI,EAAE,aAAa,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,KAAK,EAAE;oBAC/D,QAAQ,EAAE,eAAe,KAAK,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,YAAY,CAAC,IAAI,EAAE,eAAe,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,KAAK,EAAE;oBACrG,UAAU,EAAE,SAAS,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,aAAa;oBACtD,SAAS;oBACT,aAAa;iBAChB,CAAC;YACN,CAAC;QACL,CAAC;IACL,CAAC;YAAS,CAAC;QACP,KAAK,CAAC,OAAO,EAAE,CAAC;IACpB,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The ReduceScope an algorithm driver hands the primitives (contract 3.11), built over a GpuContext: `scratch` comes
|
|
3
|
+
* from ONE Lease (released by `dispose()` in the algorithm's `finally`, spec 4.4) and `params` from a UniformRing
|
|
4
|
+
* slot, so a batch of k iterations writes k parameter blocks into one buffer and dispatches with dynamic offsets
|
|
5
|
+
* instead of allocating a uniform buffer per dispatch (spec 5.3). The src/ twin of the tests' testReduceScope
|
|
6
|
+
* (test/helpers/segmented-reduce.ts). `slots` sizes the ring for the LARGEST batch the caller records: reserve()
|
|
7
|
+
* wraps, so a ring too small silently reuses a slot another dispatch of the same batch still reads.
|
|
8
|
+
*/
|
|
9
|
+
import { type GpuContext } from "../context.js";
|
|
10
|
+
import { type ReduceScope } from "../primitives/reduce.js";
|
|
11
|
+
/** A ReduceScope over a context plus the two lifecycle calls an algorithm makes: flush() before submit, dispose() in its finally. */
|
|
12
|
+
export interface AlgorithmScope extends ReduceScope {
|
|
13
|
+
/** queue.writeBuffer of the params slots written since the last flush (called before the batch is submitted). */
|
|
14
|
+
flush(): void;
|
|
15
|
+
/** Destroys the ring and releases every scratch buffer of the lease; idempotent. */
|
|
16
|
+
dispose(): void;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* The scope of one algorithm call.
|
|
20
|
+
* @param ctx - the context
|
|
21
|
+
* @param label - the label prefix of the ring and every scratch buffer
|
|
22
|
+
* @param slots - the params slots of the ring: at least the parameter blocks of the largest batch recorded
|
|
23
|
+
* @returns the scope
|
|
24
|
+
*/
|
|
25
|
+
export declare function algorithmScope(ctx: GpuContext, label: string, slots: number): AlgorithmScope;
|
|
26
|
+
//# sourceMappingURL=scope.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scope.d.ts","sourceRoot":"","sources":["../../../src/algorithms/scope.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,eAAe,CAAC;AAEhD,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAE3D,qIAAqI;AACrI,MAAM,WAAW,cAAe,SAAQ,WAAW;IAC/C,iHAAiH;IACjH,KAAK,IAAI,IAAI,CAAC;IACd,oFAAoF;IACpF,OAAO,IAAI,IAAI,CAAC;CACnB;AAED;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,cAAc,CAuB5F"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The ReduceScope an algorithm driver hands the primitives (contract 3.11), built over a GpuContext: `scratch` comes
|
|
3
|
+
* from ONE Lease (released by `dispose()` in the algorithm's `finally`, spec 4.4) and `params` from a UniformRing
|
|
4
|
+
* slot, so a batch of k iterations writes k parameter blocks into one buffer and dispatches with dynamic offsets
|
|
5
|
+
* instead of allocating a uniform buffer per dispatch (spec 5.3). The src/ twin of the tests' testReduceScope
|
|
6
|
+
* (test/helpers/segmented-reduce.ts). `slots` sizes the ring for the LARGEST batch the caller records: reserve()
|
|
7
|
+
* wraps, so a ring too small silently reuses a slot another dispatch of the same batch still reads.
|
|
8
|
+
*/
|
|
9
|
+
import { UniformRing } from "../kernel/uniform-ring.js";
|
|
10
|
+
/**
|
|
11
|
+
* The scope of one algorithm call.
|
|
12
|
+
* @param ctx - the context
|
|
13
|
+
* @param label - the label prefix of the ring and every scratch buffer
|
|
14
|
+
* @param slots - the params slots of the ring: at least the parameter blocks of the largest batch recorded
|
|
15
|
+
* @returns the scope
|
|
16
|
+
*/
|
|
17
|
+
export function algorithmScope(ctx, label, slots) {
|
|
18
|
+
const lease = ctx.pool.lease();
|
|
19
|
+
const ring = new UniformRing(ctx.device, ctx.allocator, slots, `${label}/ring`);
|
|
20
|
+
return {
|
|
21
|
+
device: ctx.device,
|
|
22
|
+
caps: ctx.caps,
|
|
23
|
+
pipelines: ctx.pipelines,
|
|
24
|
+
pool: ctx.pool,
|
|
25
|
+
workgroupSize: ctx.workgroupSize,
|
|
26
|
+
scratch: (byteLength, scratchLabel) => lease.storage(byteLength, `${label}/${scratchLabel}`),
|
|
27
|
+
params(block, values) {
|
|
28
|
+
const slot = ring.reserve(1);
|
|
29
|
+
ring.write(slot, block, values);
|
|
30
|
+
return { binding: ring.binding(block), offset: ring.offsetOf(slot) };
|
|
31
|
+
},
|
|
32
|
+
flush: () => {
|
|
33
|
+
ring.flush();
|
|
34
|
+
},
|
|
35
|
+
dispose() {
|
|
36
|
+
ring.destroy();
|
|
37
|
+
lease.release();
|
|
38
|
+
},
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=scope.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scope.js","sourceRoot":"","sources":["../../../src/algorithms/scope.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAWxD;;;;;;GAMG;AACH,MAAM,UAAU,cAAc,CAAC,GAAe,EAAE,KAAa,EAAE,KAAa;IACxE,MAAM,KAAK,GAAG,GAAG,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC;IAC/B,MAAM,IAAI,GAAG,IAAI,WAAW,CAAC,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,SAAS,EAAE,KAAK,EAAE,GAAG,KAAK,OAAO,CAAC,CAAC;IAChF,OAAO;QACH,MAAM,EAAE,GAAG,CAAC,MAAM;QAClB,IAAI,EAAE,GAAG,CAAC,IAAI;QACd,SAAS,EAAE,GAAG,CAAC,SAAS;QACxB,IAAI,EAAE,GAAG,CAAC,IAAI;QACd,aAAa,EAAE,GAAG,CAAC,aAAa;QAChC,OAAO,EAAE,CAAC,UAAU,EAAE,YAAY,EAAE,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,UAAU,EAAE,GAAG,KAAK,IAAI,YAAY,EAAE,CAAC;QAC5F,MAAM,CAAC,KAAK,EAAE,MAAM;YAChB,MAAM,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;YAC7B,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC;YAChC,OAAO,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;QACzE,CAAC;QACD,KAAK,EAAE,GAAG,EAAE;YACR,IAAI,CAAC,KAAK,EAAE,CAAC;QACjB,CAAC;QACD,OAAO;YACH,IAAI,CAAC,OAAO,EAAE,CAAC;YACf,KAAK,CAAC,OAAO,EAAE,CAAC;QACpB,CAAC;KACJ,CAAC;AACN,CAAC"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HITS, eigenvector centrality and Katz centrality on the device (spec 3.3 lines 794-796, 8.2 lines 2603-2605):
|
|
3
|
+
* three entry points over the ONE power-iteration driver, differing only in the adjacency the pull walks, the
|
|
4
|
+
* normaliser and the coefficients. Eigenvector is the L2-normalised iteration over the forward core; Katz is
|
|
5
|
+
* `alpha * A^T x + beta` over the reverse view with no per-iteration normaliser; HITS alternates the two pulls with
|
|
6
|
+
* sum normalisation, `a(i) = A^T norm(h(i-1))` and `h(i) = A norm(a(i-1))` (the CPU package's recurrence, which
|
|
7
|
+
* design 9.7 makes the parity target), as TWO interleaved chains of the driver -- the reverse-first chain from the
|
|
8
|
+
* hub seed and the forward-first chain from the authority seed -- so a call is still two runs and two readbacks.
|
|
9
|
+
* Every result is normalised ONCE on the host after the readback (sum for HITS, L2 for the other two), matching
|
|
10
|
+
* the f64 oracle; the per-iteration normaliser never leaves the device (PD-10).
|
|
11
|
+
*/
|
|
12
|
+
import { type GraphSnapshot } from "@graphty/graph-format";
|
|
13
|
+
import { type GpuContext } from "../context.js";
|
|
14
|
+
import { type EigenvectorOptions, type GpuHitsResult, type GpuScoresResult, type HitsOptions, type KatzOptions } from "../types/algorithms.js";
|
|
15
|
+
import { type GpuRunOptions } from "../types/run.js";
|
|
16
|
+
/**
|
|
17
|
+
* Eigenvector centrality on the device (spec 3.3, 8.2): the L2-normalised power iteration over the forward
|
|
18
|
+
* adjacency, converging on `delta < n * tolerance`; the scores are L2-normalised.
|
|
19
|
+
* @param ctx - the context whose device runs the kernels
|
|
20
|
+
* @param s - the snapshot (uploaded through ctx.residency, or found there)
|
|
21
|
+
* @param options - maxIterations 100 / tolerance 1e-6 / weighted true, plus dest / signal / onProgress
|
|
22
|
+
* @returns the scores, iterations, converged and precision
|
|
23
|
+
*/
|
|
24
|
+
export declare function eigenvectorCentrality(ctx: GpuContext, s: GraphSnapshot, options?: EigenvectorOptions & GpuRunOptions): Promise<GpuScoresResult>;
|
|
25
|
+
/**
|
|
26
|
+
* Katz centrality on the device (spec 3.3, 8.2): `x = alpha * A^T x + beta` over the reverse adjacency with no
|
|
27
|
+
* per-iteration normaliser; the scores are L2-normalised once at the end.
|
|
28
|
+
* @param ctx - the context whose device runs the kernels
|
|
29
|
+
* @param s - the snapshot (uploaded through ctx.residency, or found there)
|
|
30
|
+
* @param options - alpha 0.1 / beta 1 / maxIterations 100 / tolerance 1e-6 / weighted true, plus dest / signal / onProgress
|
|
31
|
+
* @returns the scores, iterations, converged and precision
|
|
32
|
+
*/
|
|
33
|
+
export declare function katzCentrality(ctx: GpuContext, s: GraphSnapshot, options?: KatzOptions & GpuRunOptions): Promise<GpuScoresResult>;
|
|
34
|
+
/**
|
|
35
|
+
* HITS on the device (spec 3.3, 8.2): `a(i) = A^T norm(h(i-1))` and `h(i) = A norm(a(i-1))` from uniform seeds,
|
|
36
|
+
* sum-normalised. Those two recurrences interleave into two independent chains, each alternating the reverse and
|
|
37
|
+
* the forward pull, so the driver runs twice: the chain seeded as hubs pulls reverse first and holds h(m) after an
|
|
38
|
+
* even number m of iterations and a(m) after an odd one; the chain seeded as authorities is the mirror image. Each
|
|
39
|
+
* chain stops at its own batch boundary, so the two can end on opposite parities holding the SAME kind; the result
|
|
40
|
+
* takes the latest iterate of each kind across both chains (a chain's last two iterates are one of each kind),
|
|
41
|
+
* which is h(m) and a(m) when both ran m iterations and never two vectors of one kind otherwise.
|
|
42
|
+
* `iterations` is the larger of the two and `converged` their conjunction. `dest`, when given, receives the hubs.
|
|
43
|
+
* Both vectors are sum-normalised.
|
|
44
|
+
* @param ctx - the context whose device runs the kernels
|
|
45
|
+
* @param s - the snapshot (uploaded through ctx.residency, or found there)
|
|
46
|
+
* @param options - maxIterations 100 / tolerance 1e-6 / weighted true, plus dest / signal / onProgress
|
|
47
|
+
* @returns hubs, authorities, iterations, converged and precision
|
|
48
|
+
*/
|
|
49
|
+
export declare function hits(ctx: GpuContext, s: GraphSnapshot, options?: HitsOptions & GpuRunOptions): Promise<GpuHitsResult>;
|
|
50
|
+
//# sourceMappingURL=spectral.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"spectral.d.ts","sourceRoot":"","sources":["../../../src/algorithms/spectral.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAY,KAAK,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAErE,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,eAAe,CAAC;AAEhD,OAAO,EACH,KAAK,kBAAkB,EACvB,KAAK,aAAa,EAClB,KAAK,eAAe,EACpB,KAAK,WAAW,EAChB,KAAK,WAAW,EACnB,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAoIrD;;;;;;;GAOG;AACH,wBAAsB,qBAAqB,CACvC,GAAG,EAAE,UAAU,EACf,CAAC,EAAE,aAAa,EAChB,OAAO,CAAC,EAAE,kBAAkB,GAAG,aAAa,GAC7C,OAAO,CAAC,eAAe,CAAC,CAqB1B;AAED;;;;;;;GAOG;AACH,wBAAsB,cAAc,CAChC,GAAG,EAAE,UAAU,EACf,CAAC,EAAE,aAAa,EAChB,OAAO,CAAC,EAAE,WAAW,GAAG,aAAa,GACtC,OAAO,CAAC,eAAe,CAAC,CAuB1B;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,IAAI,CACtB,GAAG,EAAE,UAAU,EACf,CAAC,EAAE,aAAa,EAChB,OAAO,CAAC,EAAE,WAAW,GAAG,aAAa,GACtC,OAAO,CAAC,aAAa,CAAC,CAoDxB"}
|
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HITS, eigenvector centrality and Katz centrality on the device (spec 3.3 lines 794-796, 8.2 lines 2603-2605):
|
|
3
|
+
* three entry points over the ONE power-iteration driver, differing only in the adjacency the pull walks, the
|
|
4
|
+
* normaliser and the coefficients. Eigenvector is the L2-normalised iteration over the forward core; Katz is
|
|
5
|
+
* `alpha * A^T x + beta` over the reverse view with no per-iteration normaliser; HITS alternates the two pulls with
|
|
6
|
+
* sum normalisation, `a(i) = A^T norm(h(i-1))` and `h(i) = A norm(a(i-1))` (the CPU package's recurrence, which
|
|
7
|
+
* design 9.7 makes the parity target), as TWO interleaved chains of the driver -- the reverse-first chain from the
|
|
8
|
+
* hub seed and the forward-first chain from the authority seed -- so a call is still two runs and two readbacks.
|
|
9
|
+
* Every result is normalised ONCE on the host after the readback (sum for HITS, L2 for the other two), matching
|
|
10
|
+
* the f64 oracle; the per-iteration normaliser never leaves the device (PD-10).
|
|
11
|
+
*/
|
|
12
|
+
import { WebGpuGraphError } from "../errors.js";
|
|
13
|
+
import { aborted, checkDest, coreOf, reverseOf, runPowerIteration } from "./power-iteration.js";
|
|
14
|
+
/**
|
|
15
|
+
* Resolves and validates the shared options and the run options' `dest` / `signal`.
|
|
16
|
+
* @param ctx - the context
|
|
17
|
+
* @param s - the snapshot
|
|
18
|
+
* @param options - maxIterations / tolerance / weighted plus dest / signal
|
|
19
|
+
* @param algorithm - the public name, for messages
|
|
20
|
+
* @returns the resolved options
|
|
21
|
+
*/
|
|
22
|
+
function resolve(ctx, s, options, algorithm) {
|
|
23
|
+
ctx.assertReady();
|
|
24
|
+
const n = s.nodeCount;
|
|
25
|
+
const maxIterations = options?.maxIterations ?? 100;
|
|
26
|
+
const tolerance = options?.tolerance ?? 1e-6;
|
|
27
|
+
if (!Number.isInteger(maxIterations) || maxIterations < 1) {
|
|
28
|
+
throw new WebGpuGraphError("E_INVALID_ARGUMENT", `${algorithm}: maxIterations must be a positive integer`, {
|
|
29
|
+
argument: "maxIterations",
|
|
30
|
+
value: maxIterations,
|
|
31
|
+
expected: "a positive integer",
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
const dest = checkDest(options?.dest, n, algorithm);
|
|
35
|
+
if (options?.signal?.aborted) {
|
|
36
|
+
throw aborted(algorithm);
|
|
37
|
+
}
|
|
38
|
+
// weighted: false runs UNWEIGHTED on a weighted snapshot: the pull folds 1 per arc (prepareSpmvPull's null)
|
|
39
|
+
return { n, maxIterations, tolerance, weights: options?.weighted === false ? null : undefined, dest };
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* A finite coefficient, or E_INVALID_ARGUMENT.
|
|
43
|
+
* @param value - the caller's value, or undefined for the default
|
|
44
|
+
* @param fallback - the default
|
|
45
|
+
* @param argument - the option name
|
|
46
|
+
* @returns the coefficient
|
|
47
|
+
*/
|
|
48
|
+
function finite(value, fallback, argument) {
|
|
49
|
+
const resolved = value ?? fallback;
|
|
50
|
+
if (!Number.isFinite(resolved)) {
|
|
51
|
+
throw new WebGpuGraphError("E_INVALID_ARGUMENT", `katzCentrality: ${argument} must be a finite number`, {
|
|
52
|
+
argument,
|
|
53
|
+
value: resolved,
|
|
54
|
+
expected: "a finite number",
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
return resolved;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Copies the raw iterate into its destination divided by its norm (unchanged when the norm is not positive).
|
|
61
|
+
* @param raw - the driver's iterate
|
|
62
|
+
* @param dest - the caller's destination, or null for the raw array itself
|
|
63
|
+
* @param norm - "sum" (L1) or "l2"
|
|
64
|
+
* @returns the normalised scores
|
|
65
|
+
*/
|
|
66
|
+
function normalised(raw, dest, norm) {
|
|
67
|
+
let acc = 0;
|
|
68
|
+
for (const v of raw) {
|
|
69
|
+
acc += norm === "sum" ? Math.abs(v) : v * v;
|
|
70
|
+
}
|
|
71
|
+
const scale = norm === "sum" ? acc : Math.sqrt(acc);
|
|
72
|
+
const out = dest ?? raw;
|
|
73
|
+
for (let v = 0; v < raw.length; v++) {
|
|
74
|
+
out[v] = scale > 0 ? raw[v] / scale : raw[v];
|
|
75
|
+
}
|
|
76
|
+
return out;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* The score result of one run.
|
|
80
|
+
* @param run - the driver's run
|
|
81
|
+
* @param dest - the caller's destination, or null
|
|
82
|
+
* @param norm - the final normaliser
|
|
83
|
+
* @returns the result
|
|
84
|
+
*/
|
|
85
|
+
function scoresOf(run, dest, norm) {
|
|
86
|
+
return {
|
|
87
|
+
scores: normalised(run.scores, dest, norm),
|
|
88
|
+
iterations: run.iterations,
|
|
89
|
+
converged: run.converged,
|
|
90
|
+
precision: "f32",
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* The n = 0 result: nothing to iterate.
|
|
95
|
+
* @param dest - the caller's destination, or null
|
|
96
|
+
* @param total - the run's progress denominator, reported to onProgress as both done and total
|
|
97
|
+
* @param onProgress - the caller's progress callback
|
|
98
|
+
* @returns the empty result
|
|
99
|
+
*/
|
|
100
|
+
function empty(dest, total, onProgress) {
|
|
101
|
+
onProgress?.(total, total);
|
|
102
|
+
return { scores: dest ?? new Float32Array(0), iterations: 0, converged: true, precision: "f32" };
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* The latest iterate of one kind across the two HITS chains: a chain holds its seed's kind after an even number of
|
|
106
|
+
* iterations m (in `scores`, index m) and the other kind's last iterate one back (in `previous`, index m - 1, never
|
|
107
|
+
* null on an alternating run; the fallback only satisfies the type).
|
|
108
|
+
* @param sameSeed - the chain seeded with the wanted kind
|
|
109
|
+
* @param otherSeed - the chain seeded with the other kind
|
|
110
|
+
* @returns the raw iterate with the higher index
|
|
111
|
+
*/
|
|
112
|
+
function latestOfKind(sameSeed, otherSeed) {
|
|
113
|
+
const fromSame = sameSeed.iterationsRun % 2 === 0 ? sameSeed.iterationsRun : sameSeed.iterationsRun - 1;
|
|
114
|
+
const fromOther = otherSeed.iterationsRun % 2 === 1 ? otherSeed.iterationsRun : otherSeed.iterationsRun - 1;
|
|
115
|
+
const chain = fromSame >= fromOther ? sameSeed : otherSeed;
|
|
116
|
+
const index = Math.max(fromSame, fromOther);
|
|
117
|
+
return (index === chain.iterationsRun ? chain.scores : chain.previous) ?? chain.scores;
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Eigenvector centrality on the device (spec 3.3, 8.2): the L2-normalised power iteration over the forward
|
|
121
|
+
* adjacency, converging on `delta < n * tolerance`; the scores are L2-normalised.
|
|
122
|
+
* @param ctx - the context whose device runs the kernels
|
|
123
|
+
* @param s - the snapshot (uploaded through ctx.residency, or found there)
|
|
124
|
+
* @param options - maxIterations 100 / tolerance 1e-6 / weighted true, plus dest / signal / onProgress
|
|
125
|
+
* @returns the scores, iterations, converged and precision
|
|
126
|
+
*/
|
|
127
|
+
export async function eigenvectorCentrality(ctx, s, options) {
|
|
128
|
+
const algorithm = "eigenvectorCentrality";
|
|
129
|
+
const r = resolve(ctx, s, options, algorithm);
|
|
130
|
+
if (r.n === 0) {
|
|
131
|
+
return empty(r.dest, r.maxIterations, options?.onProgress);
|
|
132
|
+
}
|
|
133
|
+
const run = await runPowerIteration(ctx, r.n, {
|
|
134
|
+
normMode: 2,
|
|
135
|
+
adjacency: coreOf(ctx, s, algorithm),
|
|
136
|
+
alternate: null,
|
|
137
|
+
alpha: 1,
|
|
138
|
+
beta: 0,
|
|
139
|
+
uniformP: 0,
|
|
140
|
+
maxIterations: r.maxIterations,
|
|
141
|
+
tolerance: r.tolerance,
|
|
142
|
+
weights: r.weights,
|
|
143
|
+
label: algorithm,
|
|
144
|
+
signal: options?.signal,
|
|
145
|
+
onProgress: options?.onProgress,
|
|
146
|
+
});
|
|
147
|
+
return scoresOf(run, r.dest, "l2");
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Katz centrality on the device (spec 3.3, 8.2): `x = alpha * A^T x + beta` over the reverse adjacency with no
|
|
151
|
+
* per-iteration normaliser; the scores are L2-normalised once at the end.
|
|
152
|
+
* @param ctx - the context whose device runs the kernels
|
|
153
|
+
* @param s - the snapshot (uploaded through ctx.residency, or found there)
|
|
154
|
+
* @param options - alpha 0.1 / beta 1 / maxIterations 100 / tolerance 1e-6 / weighted true, plus dest / signal / onProgress
|
|
155
|
+
* @returns the scores, iterations, converged and precision
|
|
156
|
+
*/
|
|
157
|
+
export async function katzCentrality(ctx, s, options) {
|
|
158
|
+
const algorithm = "katzCentrality";
|
|
159
|
+
const alpha = finite(options?.alpha, 0.1, "alpha");
|
|
160
|
+
const beta = finite(options?.beta, 1, "beta");
|
|
161
|
+
const r = resolve(ctx, s, options, algorithm);
|
|
162
|
+
if (r.n === 0) {
|
|
163
|
+
return empty(r.dest, r.maxIterations, options?.onProgress);
|
|
164
|
+
}
|
|
165
|
+
const run = await runPowerIteration(ctx, r.n, {
|
|
166
|
+
normMode: 4,
|
|
167
|
+
adjacency: reverseOf(ctx, s),
|
|
168
|
+
alternate: null,
|
|
169
|
+
alpha,
|
|
170
|
+
beta,
|
|
171
|
+
uniformP: 1,
|
|
172
|
+
maxIterations: r.maxIterations,
|
|
173
|
+
tolerance: r.tolerance,
|
|
174
|
+
weights: r.weights,
|
|
175
|
+
label: algorithm,
|
|
176
|
+
signal: options?.signal,
|
|
177
|
+
onProgress: options?.onProgress,
|
|
178
|
+
});
|
|
179
|
+
return scoresOf(run, r.dest, "l2");
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* HITS on the device (spec 3.3, 8.2): `a(i) = A^T norm(h(i-1))` and `h(i) = A norm(a(i-1))` from uniform seeds,
|
|
183
|
+
* sum-normalised. Those two recurrences interleave into two independent chains, each alternating the reverse and
|
|
184
|
+
* the forward pull, so the driver runs twice: the chain seeded as hubs pulls reverse first and holds h(m) after an
|
|
185
|
+
* even number m of iterations and a(m) after an odd one; the chain seeded as authorities is the mirror image. Each
|
|
186
|
+
* chain stops at its own batch boundary, so the two can end on opposite parities holding the SAME kind; the result
|
|
187
|
+
* takes the latest iterate of each kind across both chains (a chain's last two iterates are one of each kind),
|
|
188
|
+
* which is h(m) and a(m) when both ran m iterations and never two vectors of one kind otherwise.
|
|
189
|
+
* `iterations` is the larger of the two and `converged` their conjunction. `dest`, when given, receives the hubs.
|
|
190
|
+
* Both vectors are sum-normalised.
|
|
191
|
+
* @param ctx - the context whose device runs the kernels
|
|
192
|
+
* @param s - the snapshot (uploaded through ctx.residency, or found there)
|
|
193
|
+
* @param options - maxIterations 100 / tolerance 1e-6 / weighted true, plus dest / signal / onProgress
|
|
194
|
+
* @returns hubs, authorities, iterations, converged and precision
|
|
195
|
+
*/
|
|
196
|
+
export async function hits(ctx, s, options) {
|
|
197
|
+
const algorithm = "hits";
|
|
198
|
+
const r = resolve(ctx, s, options, algorithm);
|
|
199
|
+
const total = 2 * r.maxIterations;
|
|
200
|
+
if (r.n === 0) {
|
|
201
|
+
const { scores, iterations, converged, precision } = empty(r.dest, total, options?.onProgress);
|
|
202
|
+
return { hubs: scores, authorities: new Float32Array(0), iterations, converged, precision };
|
|
203
|
+
}
|
|
204
|
+
const onProgress = options?.onProgress;
|
|
205
|
+
const shared = {
|
|
206
|
+
normMode: 1,
|
|
207
|
+
alpha: 1,
|
|
208
|
+
beta: 0,
|
|
209
|
+
uniformP: 0,
|
|
210
|
+
maxIterations: r.maxIterations,
|
|
211
|
+
tolerance: r.tolerance,
|
|
212
|
+
weights: r.weights,
|
|
213
|
+
signal: options?.signal,
|
|
214
|
+
};
|
|
215
|
+
const forward = coreOf(ctx, s, algorithm);
|
|
216
|
+
const reverse = reverseOf(ctx, s);
|
|
217
|
+
const hubSeeded = await runPowerIteration(ctx, r.n, {
|
|
218
|
+
...shared,
|
|
219
|
+
adjacency: reverse,
|
|
220
|
+
alternate: forward,
|
|
221
|
+
label: `${algorithm}/hub-seeded`,
|
|
222
|
+
onProgress: onProgress === undefined
|
|
223
|
+
? undefined
|
|
224
|
+
: (done) => {
|
|
225
|
+
onProgress(done, total);
|
|
226
|
+
},
|
|
227
|
+
});
|
|
228
|
+
const authoritySeeded = await runPowerIteration(ctx, r.n, {
|
|
229
|
+
...shared,
|
|
230
|
+
adjacency: forward,
|
|
231
|
+
alternate: reverse,
|
|
232
|
+
label: `${algorithm}/authority-seeded`,
|
|
233
|
+
onProgress: onProgress === undefined
|
|
234
|
+
? undefined
|
|
235
|
+
: (done) => {
|
|
236
|
+
onProgress(r.maxIterations + done, total);
|
|
237
|
+
},
|
|
238
|
+
});
|
|
239
|
+
return {
|
|
240
|
+
hubs: normalised(latestOfKind(hubSeeded, authoritySeeded), r.dest, "sum"),
|
|
241
|
+
authorities: normalised(latestOfKind(authoritySeeded, hubSeeded), null, "sum"),
|
|
242
|
+
iterations: Math.max(hubSeeded.iterations, authoritySeeded.iterations),
|
|
243
|
+
converged: hubSeeded.converged && authoritySeeded.converged,
|
|
244
|
+
precision: "f32",
|
|
245
|
+
};
|
|
246
|
+
}
|
|
247
|
+
//# sourceMappingURL=spectral.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"spectral.js","sourceRoot":"","sources":["../../../src/algorithms/spectral.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAKH,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAUhD,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,EAA0B,SAAS,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAWxH;;;;;;;GAOG;AACH,SAAS,OAAO,CACZ,GAAe,EACf,CAAgB,EAChB,OAAkD,EAClD,SAAiB;IAEjB,GAA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I,EAAE,KAAK,CAAC;QACzE,WAAW,EAAE,UAAU,CAAC,YAAY,CAAC,eAAe,EAAE,SAAS,CAAC,EAAE,IAAI,EAAE,KAAK,CAAC;QAC9E,UAAU,EAAE,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC,UAAU,EAAE,eAAe,CAAC,UAAU,CAAC;QACtE,SAAS,EAAE,SAAS,CAAC,SAAS,IAAI,eAAe,CAAC,SAAS;QAC3D,SAAS,EAAE,KAAK;KACnB,CAAC;AACN,CAAC"}
|
package/dist/src/index.d.ts
CHANGED
|
@@ -18,10 +18,14 @@ export { GpuContext } from "./context.js";
|
|
|
18
18
|
export { isSoftwareAdapter } from "./device/acquire.js";
|
|
19
19
|
export type { PassTiming, Profiler } from "./kernel/profiler.js";
|
|
20
20
|
export { degree } from "./algorithms/degree.js";
|
|
21
|
+
export { connectedComponents } from "./algorithms/components.js";
|
|
22
|
+
export { pageRank, personalizedPageRank } from "./algorithms/pagerank.js";
|
|
23
|
+
export { eigenvectorCentrality, hits, katzCentrality } from "./algorithms/spectral.js";
|
|
21
24
|
export { createAccelerator } from "./accelerator.js";
|
|
22
25
|
export { createForceAtlas2 } from "./layouts/forceatlas2.js";
|
|
23
26
|
export { seedPositions } from "./layouts/seed.js";
|
|
24
27
|
export type { AcceleratorOptions, AlgorithmAccelerator, ApspResultLike, BellmanFordResultLike, BfsResultLike, CommunityResultLike, CorenessResultLike, CpuAlgorithmOptions, EdgeScoresResultLike, GpuAccelerator, HitsResultLike, LabelResultLike, LayoutAccelerator, LayoutSimulation, MstResultLike, PageRankResultLike, ScoresResultLike, SsspResultLike, } from "./types/accelerator.js";
|
|
28
|
+
export type { ComponentsOptions, EigenvectorOptions, GpuHitsResult, GpuLabelResult, GpuPageRankResult, GpuScoresResult, HitsOptions, KatzOptions, PageRankOptions, } from "./types/algorithms.js";
|
|
25
29
|
export type { AdapterInfoLike, AdapterSummary, GpuCaps, GpuContextOptions, LimitPolicy, PlanCaps, PlanLimits, ProbeOptions, ProbeResult, RaisableLimit, } from "./types/context.js";
|
|
26
30
|
export type { ForceAtlas2Stats, ForceAtlas2TraceRecord, GpuLayoutSimulation, GpuLayoutTuning, LayoutStatsBase, RunOptions, } from "./types/layout.js";
|
|
27
31
|
export type { CommonLayoutOptions, ForceAtlas2Options, FruchtermanReingoldOptions, SimulationOptions, SpringElectricalOptions, } from "./types/options.js";
|
package/dist/src/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AACA;;;;;;;;;;;;GAYG;;AAGH,OAAO,EACH,gBAAgB,EAChB,eAAe,EACf,YAAY,EACZ,sBAAsB,EACtB,YAAY,EACZ,sBAAsB,EACtB,aAAa,EACb,cAAc,GACjB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACH,YAAY,EACZ,kBAAkB,EAClB,wBAAwB,EACxB,gBAAgB,EAChB,KAAK,oBAAoB,GAC5B,MAAM,aAAa,CAAC;AAGrB,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,YAAY,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAGjE,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAGhD,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAGlD,YAAY,EACR,kBAAkB,EAClB,oBAAoB,EACpB,cAAc,EACd,qBAAqB,EACrB,aAAa,EACb,mBAAmB,EACnB,kBAAkB,EAClB,mBAAmB,EACnB,oBAAoB,EACpB,cAAc,EACd,cAAc,EACd,eAAe,EACf,iBAAiB,EACjB,gBAAgB,EAChB,aAAa,EACb,kBAAkB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AE,MAAM,0BAA0B,CAAC;AAGvF,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAGlD,YAAY,EACR,kBAAkB,EAClB,oBAAoB,EACpB,cAAc,EACd,qBAAqB,EACrB,aAAa,EACb,mBAAmB,EACnB,kBAAkB,EAClB,mBAAmB,EACnB,oBAAoB,EACpB,cAAc,EACd,cAAc,EACd,eAAe,EACf,iBAAiB,EACjB,gBAAgB,EAChB,aAAa,EACb,kBAAkB,EAClB,gBAAgB,EAChB,cAAc,GACjB,MAAM,wBAAwB,CAAC;AAGhC,YAAY,EACR,iBAAiB,EACjB,kBAAkB,EAClB,aAAa,EACb,cAAc,EACd,iBAAiB,EACjB,eAAe,EACf,WAAW,EACX,WAAW,EACX,eAAe,GAClB,MAAM,uBAAuB,CAAC;AAG/B,YAAY,EACR,eAAe,EACf,cAAc,EACd,OAAO,EACP,iBAAiB,EACjB,WAAW,EACX,QAAQ,EACR,UAAU,EACV,YAAY,EACZ,WAAW,EACX,aAAa,GAChB,MAAM,oBAAoB,CAAC;AAG5B,YAAY,EACR,gBAAgB,EAChB,sBAAsB,EACtB,mBAAmB,EACnB,eAAe,EACf,eAAe,EACf,UAAU,GACb,MAAM,mBAAmB,CAAC;AAC3B,YAAY,EACR,mBAAmB,EACnB,kBAAkB,EAClB,0BAA0B,EAC1B,iBAAiB,EACjB,uBAAuB,GAC1B,MAAM,oBAAoB,CAAC;AAG5B,YAAY,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC"}
|
package/dist/src/index.js
CHANGED
|
@@ -20,6 +20,10 @@ export { GpuContext } from "./context.js";
|
|
|
20
20
|
export { isSoftwareAdapter } from "./device/acquire.js";
|
|
21
21
|
// ==================== algorithms (P1: the walking-skeleton diagnostic, spec 3.3)
|
|
22
22
|
export { degree } from "./algorithms/degree.js";
|
|
23
|
+
// ==================== algorithms (P7: the SpMV family and WCC, spec 8.2, 8.3)
|
|
24
|
+
export { connectedComponents } from "./algorithms/components.js";
|
|
25
|
+
export { pageRank, personalizedPageRank } from "./algorithms/pagerank.js";
|
|
26
|
+
export { eigenvectorCentrality, hits, katzCentrality } from "./algorithms/spectral.js";
|
|
23
27
|
// ==================== layouts and the accelerator (P3)
|
|
24
28
|
export { createAccelerator } from "./accelerator.js";
|
|
25
29
|
export { createForceAtlas2 } from "./layouts/forceatlas2.js";
|
package/dist/src/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,uDAAuD;AACvD;;;;;;;;;;;;GAYG;AAEH,uGAAuG;AACvG,OAAO,EACH,gBAAgB,EAChB,eAAe,EACf,YAAY,EACZ,sBAAsB,EACtB,YAAY,EACZ,sBAAsB,EACtB,aAAa,EACb,cAAc,GACjB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACH,YAAY,EACZ,kBAAkB,EAClB,wBAAwB,EACxB,gBAAgB,GAEnB,MAAM,aAAa,CAAC;AAErB,uEAAuE;AACvE,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAGxD,kFAAkF;AAClF,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAEhD,wDAAwD;AACxD,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,uDAAuD;AACvD;;;;;;;;;;;;GAYG;AAEH,uGAAuG;AACvG,OAAO,EACH,gBAAgB,EAChB,eAAe,EACf,YAAY,EACZ,sBAAsB,EACtB,YAAY,EACZ,sBAAsB,EACtB,aAAa,EACb,cAAc,GACjB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACH,YAAY,EACZ,kBAAkB,EAClB,wBAAwB,EACxB,gBAAgB,GAEnB,MAAM,aAAa,CAAC;AAErB,uEAAuE;AACvE,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAGxD,kFAAkF;AAClF,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAEhD,+EAA+E;AAC/E,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,EAAE,QAAQ,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAC1E,OAAO,EAAE,qBAAqB,EAAE,IAAI,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAEvF,wDAAwD;AACxD,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC"}
|
|
@@ -33,7 +33,9 @@ export declare function plan1d(items: number, wg: number, caps: PlanCaps): Dispa
|
|
|
33
33
|
*/
|
|
34
34
|
export declare function plan2d(groups: number, caps: PlanCaps): DispatchPlan;
|
|
35
35
|
/**
|
|
36
|
-
* P7 (spec 5.2): groups = min(
|
|
36
|
+
* P7 (spec 5.2): groups = min(ceil(items / wg), maxGroups ?? (caps.software ? 64 : 4096), the per-dimension limit) with the kernel looping by `stride = groups * wg`; items 0 -> { x: 0, stride: null }.
|
|
37
|
+
* The cap is the ONE performance default in src/ that may read `caps.software` (spec 2.4, 5.2): a grid-stride map is
|
|
38
|
+
* order-independent, so the result never depends on it and the same body serves both adapters.
|
|
37
39
|
* PLAN DECISION: `maxGroups?` is spelled `?: number` rather than the contract's `?: number | undefined` because the
|
|
38
40
|
* root ESLint rule no-duplicate-type-constituents rejects the explicit undefined on an optional parameter (the call
|
|
39
41
|
* signature is identical).
|
|
@@ -41,6 +43,7 @@ export declare function plan2d(groups: number, caps: PlanCaps): DispatchPlan;
|
|
|
41
43
|
* @param wg - the workgroup size
|
|
42
44
|
* @param caps - the capability table
|
|
43
45
|
* @param maxGroups - the group cap
|
|
46
|
+
* @returns the plan
|
|
44
47
|
*/
|
|
45
48
|
export declare function planGridStride(items: number, wg: number, caps: PlanCaps, maxGroups?: number): DispatchPlan;
|
|
46
49
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dispatch.d.ts","sourceRoot":"","sources":["../../../src/kernel/dispatch.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAEpD,oGAAoG;AACpG,MAAM,WAAW,YAAY;IACzB,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,CAAC,EAAE,CAAC,CAAC;IACd,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;CAClC;AA8ED;;;;;;GAMG;AACH,wBAAgB,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,GAAG,YAAY,CAI9E;AAED;;;;;;;;;GASG;AACH,wBAAgB,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,GAAG,YAAY,CAGnE;AAED
|
|
1
|
+
{"version":3,"file":"dispatch.d.ts","sourceRoot":"","sources":["../../../src/kernel/dispatch.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAEpD,oGAAoG;AACpG,MAAM,WAAW,YAAY;IACzB,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,CAAC,EAAE,CAAC,CAAC;IACd,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;CAClC;AA8ED;;;;;;GAMG;AACH,wBAAgB,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,GAAG,YAAY,CAI9E;AAED;;;;;;;;;GASG;AACH,wBAAgB,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,GAAG,YAAY,CAGnE;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,YAAY,CAS1G;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,GAAG,YAAY,CAKpF;AAED;;;;GAIG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,YAAY,GAAG,MAAM,CAEnD"}
|
|
@@ -101,7 +101,9 @@ export function plan2d(groups, caps) {
|
|
|
101
101
|
return grid(groups, groups, caps);
|
|
102
102
|
}
|
|
103
103
|
/**
|
|
104
|
-
* P7 (spec 5.2): groups = min(
|
|
104
|
+
* P7 (spec 5.2): groups = min(ceil(items / wg), maxGroups ?? (caps.software ? 64 : 4096), the per-dimension limit) with the kernel looping by `stride = groups * wg`; items 0 -> { x: 0, stride: null }.
|
|
105
|
+
* The cap is the ONE performance default in src/ that may read `caps.software` (spec 2.4, 5.2): a grid-stride map is
|
|
106
|
+
* order-independent, so the result never depends on it and the same body serves both adapters.
|
|
105
107
|
* PLAN DECISION: `maxGroups?` is spelled `?: number` rather than the contract's `?: number | undefined` because the
|
|
106
108
|
* root ESLint rule no-duplicate-type-constituents rejects the explicit undefined on an optional parameter (the call
|
|
107
109
|
* signature is identical).
|
|
@@ -109,12 +111,17 @@ export function plan2d(groups, caps) {
|
|
|
109
111
|
* @param wg - the workgroup size
|
|
110
112
|
* @param caps - the capability table
|
|
111
113
|
* @param maxGroups - the group cap
|
|
114
|
+
* @returns the plan
|
|
112
115
|
*/
|
|
113
116
|
export function planGridStride(items, wg, caps, maxGroups) {
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
117
|
+
assertCount("items", items);
|
|
118
|
+
assertWorkgroupSize(wg);
|
|
119
|
+
if (items === 0) {
|
|
120
|
+
return { x: 0, y: 1, z: 1, items, stride: null };
|
|
121
|
+
}
|
|
122
|
+
const cap = Math.min(maxGroups ?? (caps.software ? 64 : 4096), perDimension(caps));
|
|
123
|
+
const groups = Math.min(Math.ceil(items / wg), cap);
|
|
124
|
+
return { x: groups, y: 1, z: 1, items, stride: groups * wg };
|
|
118
125
|
}
|
|
119
126
|
/**
|
|
120
127
|
* P4 (spec 5.4): the (x, y, 1) args a device-side finalize kernel writes for a count. P1-P3: throws E_UNSUPPORTED { feature: "planIndirect" } (lead f).
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dispatch.js","sourceRoot":"","sources":["../../../src/kernel/dispatch.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AACzD,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAYhD;;;;;;GAMG;AACH,SAAS,YAAY,CAAC,IAAc;IAChC,OAAO,IAAI,CAAC,GAAG,CAAC,sBAAsB,EAAE,IAAI,CAAC,MAAM,CAAC,gCAAgC,CAAC,CAA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16 @@
|
|
|
6
6
|
* test and PipelineCache.warm() iterate this table. P1-T4 lands degree, reduce, fill, fa2-repulsion-exact (K3)
|
|
7
7
|
* and fa2-speed-finalize (K4) together with every generated block of contract 3.10.2; P2-T2 lands
|
|
8
8
|
* segmented-reduce; P3-T2 adds fa2-stats-finalize (K1), fa2-attraction (K2), fa2-integrate (K5) and
|
|
9
|
-
* fa2-to-scene
|
|
9
|
+
* fa2-to-scene; M8b-T3 adds the seven P7 entries: spmv-pull, pr-scale, pr-finalize, wcc-link-sample,
|
|
10
|
+
* wcc-link-edges, wcc-compress and wcc-sample. This file is the only importer of src/wgsl/** (spec 3.2;
|
|
11
|
+
* test/layers.test.ts).
|
|
10
12
|
*/
|
|
11
13
|
import { UniformBlock } from "./kernel/struct-block.js";
|
|
12
14
|
import { type BindingDecl, type OverrideDecl, type WgslModuleSpec } from "./kernel/wgsl.js";
|
|
13
15
|
import { type CoreBinding } from "./memory/residency.js";
|
|
14
16
|
import { type Binding } from "./types/memory.js";
|
|
15
|
-
/** Every module id of P1-P3 (
|
|
16
|
-
export type KernelId = "degree" | "reduce" | "fill" | "segmented-reduce" | "fa2-stats-finalize" | "fa2-attraction" | "fa2-repulsion-exact" | "fa2-speed-finalize" | "fa2-integrate" | "fa2-to-scene";
|
|
17
|
+
/** Every module id of P1-P3 and P7 (later ids are appended, never renamed). */
|
|
18
|
+
export type KernelId = "degree" | "reduce" | "fill" | "segmented-reduce" | "fa2-stats-finalize" | "fa2-attraction" | "fa2-repulsion-exact" | "fa2-speed-finalize" | "fa2-integrate" | "fa2-to-scene" | "spmv-pull" | "pr-scale" | "pr-finalize" | "wcc-link-sample" | "wcc-link-edges" | "wcc-compress" | "wcc-sample";
|
|
17
19
|
/** One registry entry: everything of a WgslModuleSpec except the per-variant overrides and snippets. */
|
|
18
20
|
export interface KernelEntry {
|
|
19
21
|
readonly id: KernelId;
|
|
@@ -27,7 +29,7 @@ export interface KernelEntry {
|
|
|
27
29
|
/** The snippet marker names the body carries (segmented-reduce: ["VALUE"]). */
|
|
28
30
|
readonly snippetSlots: readonly string[];
|
|
29
31
|
/** The phase the entry landed in (documentation and the compile-matrix filter). */
|
|
30
|
-
readonly phase: "P1" | "P2" | "P3";
|
|
32
|
+
readonly phase: "P1" | "P2" | "P3" | "P7";
|
|
31
33
|
}
|
|
32
34
|
/** `RangeParams` (uniform, 32 B): rows `[start, end)` @0 / @4 of the dispatch, the bound arc window `[arcBase, arcEnd)` @8 / @12 (0 and arcCount when not windowed), `accumulate` @16 (1 combines into `out[i]` instead of overwriting: the P4 windowed loop), `n` @20 (the node count that bounds neighbour indices), `pad0` @24, `pad1` @28. */
|
|
33
35
|
export declare const RANGE_PARAMS: UniformBlock;
|
|
@@ -43,6 +45,20 @@ export declare const FA2_STATE: UniformBlock;
|
|
|
43
45
|
export declare const FA2_TRACE: UniformBlock;
|
|
44
46
|
/** `Fa2Partial` (storage record, 64 B; spec 7.3): one per-workgroup partial -- `sum` @0 (xyz = sum of positions, w = sum of |p - centroid|^2), `min` @16, `max` @32 (w = max of |p - centroid|^2, the exact layoutRadius source), written by K5; `swingTraction` @48 (written by K3's epilogue); `dispFree` @56 (x = sum |dp| over free rows, y = the free count as an f32 <= 256, written by K5). */
|
|
45
47
|
export declare const FA2_PARTIAL: UniformBlock;
|
|
48
|
+
/** `SpmvParams` (uniform, 32 B; spec 8.2): `n` @0 rows of the pull, the bound arc window `[arcBase, arcEnd)` @4 / @8 (0 and arcCount when not windowed), the grid-stride step `stride` @12, `alpha` @16, `beta` @20 (the `1 - alpha` term), `uniformP` @24 (the uniform personalization mass `1 / n`, 0 for a pure SpMV), `pad0` @28. */
|
|
49
|
+
export declare const SPMV_PARAMS: UniformBlock;
|
|
50
|
+
/** `PrParams` (uniform, 32 B; spec 8.2): `n` @0, `groups` @4 (the per-workgroup partial count the finalize folds), `iteration` @8 (1-based), `trackConvergence` @12 (1 records firstConverged), `convergeThreshold` @16 (`tolerance * n`, the design's `delta < tol * n`), `pad0` @20, `pad1` @24, `pad2` @28. */
|
|
51
|
+
export declare const PR_PARAMS: UniformBlock;
|
|
52
|
+
/**
|
|
53
|
+
* `PrPartial` (storage record, 32 B; spec 8.2). Element 0 is the HEADER, whose first 16 bytes are exactly the four
|
|
54
|
+
* fields the design names -- `danglingMass` @0, `delta` @4, `firstConvergedIteration` @8, `iteration` @12 -- plus
|
|
55
|
+
* `norm` @16, which M8b adds so HITS / eigenvector / Katz keep their normaliser on the device (PD-10). Element
|
|
56
|
+
* `1 + g` is workgroup g's partial: it uses `danglingMass`, `delta` and `norm` as three sums and leaves the two u32
|
|
57
|
+
* fields zero.
|
|
58
|
+
*/
|
|
59
|
+
export declare const PR_PARTIAL: UniformBlock;
|
|
60
|
+
/** `WccParams` (uniform, 32 B; spec 8.3): `n` @0, `items` @4 (rows for a sample round, edges for an edge round, 1024 for the sampler), `stride` @8, `r` @12 (the neighbour index of the sampled round, and the sampler's seed), `flagIndex` @16 (the changed word inside `comp`, PD-4), `giant` @20 (`U32_MAX` before the sample), `maxSteps` @24, `pad0` @28. */
|
|
61
|
+
export declare const WCC_PARAMS: UniformBlock;
|
|
46
62
|
/** THE registry (spec 3.5): every entry, keyed by id. */
|
|
47
63
|
export declare const KERNELS: Readonly<Record<KernelId, KernelEntry>>;
|
|
48
64
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"kernels.d.ts","sourceRoot":"","sources":["../../src/kernels.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"kernels.d.ts","sourceRoot":"","sources":["../../src/kernels.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAIH,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACxD,OAAO,EAAE,KAAK,WAAW,EAAE,KAAK,YAAY,EAAE,KAAK,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAC5F,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,KAAK,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