@graphty/webgpu-graph-algorithms 0.6.26 → 0.6.28

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (116) hide show
  1. package/README.md +56 -6
  2. package/dist/acquire.d.ts +2 -0
  3. package/dist/browser.js +18 -1
  4. package/dist/browser.js.map +1 -1
  5. package/dist/chunks/accelerator-B-FjQwaA.js +19173 -0
  6. package/dist/chunks/accelerator-B-FjQwaA.js.map +1 -0
  7. package/dist/chunks/managed-D_GdQtnu.js +98 -0
  8. package/dist/chunks/managed-D_GdQtnu.js.map +1 -0
  9. package/dist/node.js +18 -1
  10. package/dist/node.js.map +1 -1
  11. package/dist/src/accelerator.d.ts.map +1 -1
  12. package/dist/src/accelerator.js +5 -3
  13. package/dist/src/accelerator.js.map +1 -1
  14. package/dist/src/algorithms/all-pairs.d.ts.map +1 -1
  15. package/dist/src/algorithms/all-pairs.js +72 -47
  16. package/dist/src/algorithms/all-pairs.js.map +1 -1
  17. package/dist/src/algorithms/betweenness.d.ts +1 -1
  18. package/dist/src/algorithms/betweenness.js +2 -2
  19. package/dist/src/algorithms/closeness.d.ts +45 -42
  20. package/dist/src/algorithms/closeness.d.ts.map +1 -1
  21. package/dist/src/algorithms/closeness.js +295 -226
  22. package/dist/src/algorithms/closeness.js.map +1 -1
  23. package/dist/src/browser/index.d.ts +10 -0
  24. package/dist/src/browser/index.d.ts.map +1 -1
  25. package/dist/src/browser/index.js +22 -0
  26. package/dist/src/browser/index.js.map +1 -1
  27. package/dist/src/constants.d.ts +13 -3
  28. package/dist/src/constants.d.ts.map +1 -1
  29. package/dist/src/constants.js +13 -3
  30. package/dist/src/constants.js.map +1 -1
  31. package/dist/src/kernels.d.ts +14 -4
  32. package/dist/src/kernels.d.ts.map +1 -1
  33. package/dist/src/kernels.js +62 -28
  34. package/dist/src/kernels.js.map +1 -1
  35. package/dist/src/layouts/force-simulation.d.ts.map +1 -1
  36. package/dist/src/layouts/force-simulation.js +0 -1
  37. package/dist/src/layouts/force-simulation.js.map +1 -1
  38. package/dist/src/layouts/forceatlas2.d.ts.map +1 -1
  39. package/dist/src/layouts/forceatlas2.js +0 -1
  40. package/dist/src/layouts/forceatlas2.js.map +1 -1
  41. package/dist/src/layouts/fruchterman-reingold.d.ts.map +1 -1
  42. package/dist/src/layouts/fruchterman-reingold.js +0 -1
  43. package/dist/src/layouts/fruchterman-reingold.js.map +1 -1
  44. package/dist/src/layouts/repulsion-grid.d.ts +1 -3
  45. package/dist/src/layouts/repulsion-grid.d.ts.map +1 -1
  46. package/dist/src/layouts/repulsion-grid.js +1 -6
  47. package/dist/src/layouts/repulsion-grid.js.map +1 -1
  48. package/dist/src/layouts/spring-electrical.d.ts.map +1 -1
  49. package/dist/src/layouts/spring-electrical.js +0 -1
  50. package/dist/src/layouts/spring-electrical.js.map +1 -1
  51. package/dist/src/managed.d.ts +11 -0
  52. package/dist/src/managed.d.ts.map +1 -0
  53. package/dist/src/managed.js +129 -0
  54. package/dist/src/managed.js.map +1 -0
  55. package/dist/src/node/index.d.ts +11 -0
  56. package/dist/src/node/index.d.ts.map +1 -1
  57. package/dist/src/node/index.js +21 -0
  58. package/dist/src/node/index.js.map +1 -1
  59. package/dist/src/primitives/grid-pyramid.d.ts +16 -15
  60. package/dist/src/primitives/grid-pyramid.d.ts.map +1 -1
  61. package/dist/src/primitives/grid-pyramid.js +20 -28
  62. package/dist/src/primitives/grid-pyramid.js.map +1 -1
  63. package/dist/src/types/accelerator.d.ts +2 -0
  64. package/dist/src/types/accelerator.d.ts.map +1 -1
  65. package/dist/src/types/managed.d.ts +81 -0
  66. package/dist/src/types/managed.d.ts.map +1 -0
  67. package/dist/src/types/managed.js +7 -0
  68. package/dist/src/types/managed.js.map +1 -0
  69. package/dist/src/wgsl/bc-forward.wgsl.d.ts +1 -1
  70. package/dist/src/wgsl/bc-forward.wgsl.js +1 -1
  71. package/dist/src/wgsl/closeness-level.wgsl.d.ts +37 -0
  72. package/dist/src/wgsl/closeness-level.wgsl.d.ts.map +1 -0
  73. package/dist/src/wgsl/closeness-level.wgsl.js +204 -0
  74. package/dist/src/wgsl/closeness-level.wgsl.js.map +1 -0
  75. package/dist/src/wgsl/closeness-rowsum.wgsl.d.ts +11 -0
  76. package/dist/src/wgsl/closeness-rowsum.wgsl.d.ts.map +1 -0
  77. package/dist/src/wgsl/closeness-rowsum.wgsl.js +42 -0
  78. package/dist/src/wgsl/closeness-rowsum.wgsl.js.map +1 -0
  79. package/dist/src/wgsl/grid-centroid-hub.wgsl.d.ts +2 -2
  80. package/dist/src/wgsl/grid-centroid-hub.wgsl.js +2 -2
  81. package/dist/webgpu-graph-algorithms.js +142 -15586
  82. package/dist/webgpu-graph-algorithms.js.map +1 -1
  83. package/package.json +10 -4
  84. package/src/accelerator.ts +5 -3
  85. package/src/algorithms/all-pairs.ts +86 -56
  86. package/src/algorithms/betweenness.ts +2 -2
  87. package/src/algorithms/closeness.ts +353 -256
  88. package/src/browser/index.ts +37 -0
  89. package/src/constants.ts +13 -3
  90. package/src/kernels.ts +65 -36
  91. package/src/layouts/force-simulation.ts +0 -1
  92. package/src/layouts/forceatlas2.ts +0 -1
  93. package/src/layouts/fruchterman-reingold.ts +0 -1
  94. package/src/layouts/repulsion-grid.ts +2 -7
  95. package/src/layouts/spring-electrical.ts +0 -1
  96. package/src/managed.ts +172 -0
  97. package/src/node/index.ts +36 -0
  98. package/src/primitives/grid-pyramid.ts +29 -41
  99. package/src/types/accelerator.ts +2 -0
  100. package/src/types/managed.ts +86 -0
  101. package/src/wgsl/bc-forward.wgsl.ts +1 -1
  102. package/src/wgsl/closeness-level.wgsl.ts +203 -0
  103. package/src/wgsl/closeness-rowsum.wgsl.ts +41 -0
  104. package/src/wgsl/grid-centroid-hub.wgsl.ts +2 -2
  105. package/dist/chunks/context-BZY6SMsM.js +0 -3615
  106. package/dist/chunks/context-BZY6SMsM.js.map +0 -1
  107. package/dist/src/wgsl/closeness-reduce.wgsl.d.ts +0 -20
  108. package/dist/src/wgsl/closeness-reduce.wgsl.d.ts.map +0 -1
  109. package/dist/src/wgsl/closeness-reduce.wgsl.js +0 -69
  110. package/dist/src/wgsl/closeness-reduce.wgsl.js.map +0 -1
  111. package/dist/src/wgsl/closeness-sweep.wgsl.d.ts +0 -22
  112. package/dist/src/wgsl/closeness-sweep.wgsl.d.ts.map +0 -1
  113. package/dist/src/wgsl/closeness-sweep.wgsl.js +0 -106
  114. package/dist/src/wgsl/closeness-sweep.wgsl.js.map +0 -1
  115. package/src/wgsl/closeness-reduce.wgsl.ts +0 -68
  116. package/src/wgsl/closeness-sweep.wgsl.ts +0 -105
@@ -0,0 +1,98 @@
1
+ import { W as WebGpuGraphError, D as isWebGpuGraphError, U as verifyDevice, s as createAccelerator } from "./accelerator-B-FjQwaA.js";
2
+ const SOFTWARE_FIX = "pass acceptSoftware: true to use the software adapter (usually slower than the CPU)";
3
+ const DECLINE_CODES = /* @__PURE__ */ new Set(["E_NO_WEBGPU", "E_NO_ADAPTER", "E_SOFTWARE_ONLY"]);
4
+ function declined(platform, code, reason, rest = {}) {
5
+ let fix = null;
6
+ if (code === "E_SOFTWARE_ONLY") {
7
+ fix = SOFTWARE_FIX;
8
+ } else if (code === "E_NO_WEBGPU") {
9
+ fix = platform.noWebGpuFix();
10
+ }
11
+ return { ok: false, code, reason, fix, adapter: rest.adapter ?? null, check: rest.check ?? null };
12
+ }
13
+ async function acquireOnce(platform, options) {
14
+ const rejectSoftware = options.acceptSoftware !== true;
15
+ const probe = await platform.probe(options, rejectSoftware);
16
+ if (!probe.ok || probe.code !== "OK") {
17
+ const code = probe.code === "OK" ? "E_NO_ADAPTER" : probe.code;
18
+ return declined(platform, code, probe.reason ?? code, { adapter: probe.summary });
19
+ }
20
+ let ctx;
21
+ try {
22
+ ctx = await platform.open(options, probe, rejectSoftware);
23
+ } catch (err) {
24
+ if (isWebGpuGraphError(err) && DECLINE_CODES.has(err.code)) {
25
+ return declined(platform, err.code, err.message, { adapter: probe.summary });
26
+ }
27
+ throw err;
28
+ }
29
+ let accelerator;
30
+ try {
31
+ const check = await (platform.verify ?? verifyDevice)(ctx);
32
+ if (check.mismatch !== null) {
33
+ ctx.dispose();
34
+ const where = check.mismatch.poison ? `${check.mismatch.where} was never written` : `${check.mismatch.where} came back as ${String(check.mismatch.actual)} where ${String(check.mismatch.expected)} was required`;
35
+ return declined(
36
+ platform,
37
+ "E_DEVICE_INCORRECT",
38
+ `the ${check.vendor} device computed a known prefix sum incorrectly: ${where}`,
39
+ { adapter: probe.summary, check }
40
+ );
41
+ }
42
+ accelerator = createAccelerator(ctx, options.accelerator);
43
+ } catch (err) {
44
+ ctx.dispose();
45
+ throw err;
46
+ }
47
+ return { ok: true, code: "OK", accelerator };
48
+ }
49
+ function manageAccelerator(platform, options = {}) {
50
+ let pending = null;
51
+ let ready = null;
52
+ let disposed = false;
53
+ const disposedError = () => new WebGpuGraphError("E_DISPOSED", "the managed accelerator was disposed", { label: "acquireAccelerator" });
54
+ return {
55
+ current() {
56
+ if (disposed) {
57
+ return Promise.reject(disposedError());
58
+ }
59
+ if (ready !== null && ready.ctx.state !== "ready") {
60
+ ready = null;
61
+ pending = null;
62
+ }
63
+ if (pending === null) {
64
+ const attempt = acquireOnce(platform, options).then(
65
+ (result) => {
66
+ if (!result.ok) {
67
+ return result;
68
+ }
69
+ if (disposed) {
70
+ result.accelerator.dispose();
71
+ throw disposedError();
72
+ }
73
+ ready = result.accelerator;
74
+ return result;
75
+ },
76
+ (err) => {
77
+ if (pending === attempt) {
78
+ pending = null;
79
+ }
80
+ throw err;
81
+ }
82
+ );
83
+ pending = attempt;
84
+ }
85
+ return pending;
86
+ },
87
+ dispose() {
88
+ disposed = true;
89
+ ready?.dispose();
90
+ ready = null;
91
+ pending = null;
92
+ }
93
+ };
94
+ }
95
+ export {
96
+ manageAccelerator as m
97
+ };
98
+ //# sourceMappingURL=managed-D_GdQtnu.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"managed-D_GdQtnu.js","sources":["../../src/managed.ts"],"sourcesContent":["/**\n * The managed accelerator behind `acquireAccelerator` (the `./acquire` subpath, and the same function on `./browser`\n * and `./node`): probe, context, device self-check, accelerator, re-acquisition after device loss, disposal. The\n * runtime-specific half (how to probe and how to open a context) comes from the entry that calls `manageAccelerator`;\n * everything else is here once, so no consumer writes it.\n *\n * Every decline is decided before any work runs: a caller with a CPU implementation runs it and reports the reason.\n * A failure of work that already started on the device is never caught here; it reaches the caller of that work.\n */\n\nimport { createAccelerator } from \"./accelerator.js\";\nimport type { GpuContext } from \"./context.js\";\nimport { isWebGpuGraphError, WebGpuGraphError } from \"./errors.js\";\nimport { verifyDevice } from \"./primitives/verify.js\";\nimport type { GpuAccelerator } from \"./types/accelerator.js\";\nimport type { DeviceCheck, ProbeResult } from \"./types/context.js\";\nimport type {\n AcceleratorDeclined,\n AcquireAcceleratorOptions,\n AcquireResult,\n ManagedAccelerator,\n} from \"./types/managed.js\";\n\n/**\n * How one runtime finds a device; supplied by the browser and Node entries.\n * @internal\n */\nexport interface AcceleratorPlatform {\n /** Probes without creating a device; never throws. */\n probe(options: AcquireAcceleratorOptions, rejectSoftware: boolean): Promise<ProbeResult>;\n /** Opens a context on the probed adapter. */\n open(options: AcquireAcceleratorOptions, probe: ProbeResult, rejectSoftware: boolean): Promise<GpuContext>;\n /** What the user can do about E_NO_WEBGPU on this runtime, or null. */\n noWebGpuFix(): string | null;\n /** Test seam: replaces `verifyDevice`. */\n readonly verify?: ((ctx: GpuContext) => Promise<DeviceCheck>) | undefined;\n}\n\n/** The fix of a declined software adapter, on every runtime. */\nconst SOFTWARE_FIX = \"pass acceptSoftware: true to use the software adapter (usually slower than the CPU)\";\n\nconst DECLINE_CODES: ReadonlySet<string> = new Set([\"E_NO_WEBGPU\", \"E_NO_ADAPTER\", \"E_SOFTWARE_ONLY\"]);\n\n/**\n * A decline record.\n * @param platform - the runtime, for the E_NO_WEBGPU fix\n * @param code - the decline code\n * @param reason - the reason in words\n * @param rest - the adapter and the check, when known\n * @returns the record\n */\nfunction declined(\n platform: AcceleratorPlatform,\n code: AcceleratorDeclined[\"code\"],\n reason: string,\n rest: Partial<Pick<AcceleratorDeclined, \"adapter\" | \"check\">> = {},\n): AcceleratorDeclined {\n let fix: string | null = null;\n if (code === \"E_SOFTWARE_ONLY\") {\n fix = SOFTWARE_FIX;\n } else if (code === \"E_NO_WEBGPU\") {\n fix = platform.noWebGpuFix();\n }\n return { ok: false, code, reason, fix, adapter: rest.adapter ?? null, check: rest.check ?? null };\n}\n\n/**\n * One acquisition: probe, open, self-check, accelerator. The context is disposed on every path that does not hand\n * it over.\n * @param platform - the runtime\n * @param options - the caller's options\n * @returns the accelerator, or why there is none\n */\nasync function acquireOnce(platform: AcceleratorPlatform, options: AcquireAcceleratorOptions): Promise<AcquireResult> {\n const rejectSoftware = options.acceptSoftware !== true;\n const probe = await platform.probe(options, rejectSoftware);\n if (!probe.ok || probe.code !== \"OK\") {\n const code = probe.code === \"OK\" ? \"E_NO_ADAPTER\" : probe.code;\n return declined(platform, code, probe.reason ?? code, { adapter: probe.summary });\n }\n let ctx: GpuContext;\n try {\n ctx = await platform.open(options, probe, rejectSoftware);\n } catch (err) {\n // the adapter can change between the probe and the device request (a GPU process restart)\n if (isWebGpuGraphError(err) && DECLINE_CODES.has(err.code)) {\n return declined(platform, err.code as AcceleratorDeclined[\"code\"], err.message, { adapter: probe.summary });\n }\n throw err;\n }\n let accelerator: GpuAccelerator;\n try {\n const check = await (platform.verify ?? verifyDevice)(ctx);\n if (check.mismatch !== null) {\n ctx.dispose();\n const where = check.mismatch.poison\n ? `${check.mismatch.where} was never written`\n : `${check.mismatch.where} came back as ${String(check.mismatch.actual)} where ${String(check.mismatch.expected)} was required`;\n return declined(\n platform,\n \"E_DEVICE_INCORRECT\",\n `the ${check.vendor} device computed a known prefix sum incorrectly: ${where}`,\n { adapter: probe.summary, check },\n );\n }\n accelerator = createAccelerator(ctx, options.accelerator);\n } catch (err) {\n ctx.dispose();\n throw err;\n }\n return { ok: true, code: \"OK\", accelerator };\n}\n\n/**\n * The managed accelerator over one runtime.\n * @param platform - how this runtime probes and opens a context\n * @param options - the caller's options\n * @returns the handle\n * @internal\n */\nexport function manageAccelerator(\n platform: AcceleratorPlatform,\n options: AcquireAcceleratorOptions = {},\n): ManagedAccelerator {\n let pending: Promise<AcquireResult> | null = null;\n let ready: GpuAccelerator | null = null;\n let disposed = false;\n const disposedError = (): WebGpuGraphError =>\n new WebGpuGraphError(\"E_DISPOSED\", \"the managed accelerator was disposed\", { label: \"acquireAccelerator\" });\n return {\n current(): Promise<AcquireResult> {\n if (disposed) {\n return Promise.reject(disposedError());\n }\n if (ready !== null && ready.ctx.state !== \"ready\") {\n // lost, or disposed by its holder: the next answer is a new device\n ready = null;\n pending = null;\n }\n if (pending === null) {\n const attempt = acquireOnce(platform, options).then(\n (result) => {\n if (!result.ok) {\n return result;\n }\n if (disposed) {\n result.accelerator.dispose();\n throw disposedError();\n }\n ready = result.accelerator;\n return result;\n },\n (err: unknown) => {\n // not a decline: the next call tries again rather than remembering a transient failure\n if (pending === attempt) {\n pending = null;\n }\n throw err;\n },\n );\n pending = attempt;\n }\n return pending;\n },\n dispose(): void {\n disposed = true;\n ready?.dispose();\n ready = null;\n pending = null;\n },\n };\n}\n"],"names":[],"mappings":";AAuCA,MAAM,eAAe;AAErB,MAAM,gBAAqC,oBAAI,IAAI,CAAC,eAAe,gBAAgB,iBAAiB,CAAC;AAUrG,SAAS,SACL,UACA,MACA,QACA,OAAgE,CAAA,GAC7C;AACnB,MAAI,MAAqB;AACzB,MAAI,SAAS,mBAAmB;AAC5B,UAAM;AAAA,EACV,WAAW,SAAS,eAAe;AAC/B,UAAM,SAAS,YAAA;AAAA,EACnB;AACA,SAAO,EAAE,IAAI,OAAO,MAAM,QAAQ,KAAK,SAAS,KAAK,WAAW,MAAM,OAAO,KAAK,SAAS,KAAA;AAC/F;AASA,eAAe,YAAY,UAA+B,SAA4D;AAClH,QAAM,iBAAiB,QAAQ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,cAAc,wCAAwC,EAAE,OAAO,sBAAsB;AAC9G,SAAO;AAAA,IACH,UAAkC;AAC9B,UAAI,UAAU;AACV,eAAO,QAAQ,OAAO,eAAe;AAAA,MACzC;AACA,UAAI,UAAU,QAAQ,MAAM,IAAI,UAAU,SAAS;AAE/C,gBAAQ;AACR,kBAAU;AAAA,MACd;AACA,UAAI,YAAY,MAAM;AAClB,cAAM,UAAU,YAAY,UAAU,OAAO,EAAE;AAAA,UAC3C,CAAC,WAAW;AACR,gBAAI,CAAC,OAAO,IAAI;AACZ,qBAAO;AAAA,YACX;AACA,gBAAI,UAAU;AACV,qBAAO,YAAY,QAAA;AACnB,oBAAM,cAAA;AAAA,YACV;AACA,oBAAQ,OAAO;AACf,mBAAO;AAAA,UACX;AAAA,UACA,CAAC,QAAiB;AAEd,gBAAI,YAAY,SAAS;AACrB,wBAAU;AAAA,YACd;AACA,kBAAM;AAAA,UACV;AAAA,QAAA;AAEJ,kBAAU;AAAA,MACd;AACA,aAAO;AAAA,IACX;AAAA,IACA,UAAgB;AACZ,iBAAW;AACX,aAAO,QAAA;AACP,cAAQ;AACR,gBAAU;AAAA,IACd;AAAA,EAAA;AAER;"}
package/dist/node.js CHANGED
@@ -1,4 +1,5 @@
1
- import { W as WebGpuGraphError, G as GpuContext } from "./chunks/context-BZY6SMsM.js";
1
+ import { W as WebGpuGraphError, G as GpuContext } from "./chunks/accelerator-B-FjQwaA.js";
2
+ import { m as manageAccelerator } from "./chunks/managed-D_GdQtnu.js";
2
3
  const INSTALL_HINT = "install the optional peer dependency webgpu@0.4.0";
3
4
  const instances = /* @__PURE__ */ new Map();
4
5
  function isDawnModule(loaded) {
@@ -130,7 +131,23 @@ async function probeNodeWebGpu(options) {
130
131
  handle.dispose();
131
132
  }
132
133
  }
134
+ function acquireAccelerator(options) {
135
+ return manageAccelerator(
136
+ {
137
+ probe: (o, rejectSoftware) => probeNodeWebGpu({ adapter: o.adapter, powerPreference: o.powerPreference, rejectSoftware }),
138
+ open: (o, _probe, rejectSoftware) => createNodeGpuContext({
139
+ adapter: o.adapter,
140
+ powerPreference: o.powerPreference,
141
+ rejectSoftware,
142
+ warnUnreleasedSnapshots: o.warnUnreleasedSnapshots
143
+ }),
144
+ noWebGpuFix: () => INSTALL_HINT
145
+ },
146
+ options
147
+ );
148
+ }
133
149
  export {
150
+ acquireAccelerator,
134
151
  createNodeGpu,
135
152
  createNodeGpuContext,
136
153
  dawnFlags,
package/dist/node.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"node.js","sources":["../src/node/index.ts"],"sourcesContent":["/// <reference types=\"@webgpu/types\" preserve=\"true\" />\n/**\n * The ./node entry (spec 2.1, 2.3, 3.4; contract 3.7): Dawn through the optional peer dependency `webgpu`. The\n * ONLY file of the package that names the \"webgpu\" module, and only inside `await import(\"webgpu\")` in a\n * function body, so the root and browser bundles never carry the specifier (spec 2.5; test/build-output.test.ts,\n * test/layers.test.ts). P0-T3 wrote createNodeGpu, dawnFlags and their types; P1-T1 adds createNodeGpuContext,\n * probeNodeWebGpu and the `extends Omit<GpuContextOptions, ...>` clause of NodeGpuOptions.\n *\n * Rule of spec 2.5 item 5 (also in CLAUDE.md): \"./node\" is imported only by Node entry points and tests.\n */\n\nimport { GpuContext } from \"../context.js\";\nimport { WebGpuGraphError } from \"../errors.js\";\nimport type { GpuContextOptions, ProbeResult } from \"../types/context.js\";\n\n/** Options of the Node helpers (spec 3.4). */\nexport interface NodeGpuOptions extends Omit<GpuContextOptions, \"gpu\" | \"adapter\" | \"device\" | \"runtime\"> {\n /** Dawn `adapter=<substring>`: a substring of the adapter name (`llvmpipe`, `4070`); an empty string is ignored; wins over `software`. */\n readonly adapter?: string | undefined;\n /** Dawn `backend=<name>`; `null` compiles pipelines and runs nothing (spec 5.1; the compile tests use it). */\n readonly backend?: \"vulkan\" | \"d3d12\" | \"d3d11\" | \"metal\" | \"opengl\" | \"opengles\" | \"null\" | undefined;\n /** Dawn toggles, emitted as `enable-dawn-features=a,b`. */\n readonly dawnFeatures?: readonly string[] | undefined;\n /** Shorthand for `adapter=llvmpipe` (Linux / Mesa specific, spec 2.3); ignored when `adapter` is given. */\n readonly software?: boolean | undefined;\n /** Install dawn.globals on globalThis (default true; spec 2.1 rule 2) so user code sees GPUBufferUsage and friends. */\n readonly installGlobals?: boolean | undefined;\n /**\n * Test seam: replaces `() => import(\"webgpu\")` so a missing / broken module can be simulated.\n * @internal\n */\n readonly loadModule?: (() => Promise<unknown>) | undefined;\n}\n\n/**\n * The Dawn GPU handle (spec 2.3). The Dawn instance behind `gpu` is shared by every handle created with the\n * same flags and lives until the process exits (see `createNodeGpu`); it holds no event-loop handle, so it\n * never keeps the process alive.\n */\nexport interface NodeGpuHandle {\n /** The GPU of `dawn.create(flags)`; reading it after dispose() throws E_DISPOSED. */\n readonly gpu: GPU;\n /** Drops this handle's GPU reference (the shared instance stays alive); idempotent. */\n dispose(): void;\n}\n\n/** The install hint of E_NO_WEBGPU (spec 2.5 item 4); P-ENV re-pins the version together with the devDependency. */\nconst INSTALL_HINT = \"install the optional peer dependency webgpu@0.4.0\";\n\n/** The shape of the `webgpu` module (its types.d.ts: create(options: string[]): GPU; globals: Object). */\ninterface DawnModule {\n create(options: string[]): GPU;\n globals?: unknown;\n}\n\n/**\n * Every GPU object `dawn.create()` returned, per module and flag list, kept for the life of the process.\n * webgpu@0.4.0's adapters, devices and queues run their promises through an AsyncRunner that polls the Dawn\n * instance by RAW pointer, and only the GPU object owns that instance: once the GPU object is collected, the\n * next promise on any adapter or device it produced (a requestDevice on a probed adapter, a queue call or a\n * late map / lost callback of a destroyed device) polls freed memory -- SIGSEGV in\n * dawn::native::InstanceBase::ProcessEvents, on Metal and lavapipe alike (issue #30). dawn-node signals no\n * point at which the instance has drained, so no GPU object is ever released; sharing one per flag list\n * bounds what that keeps to one instance per configuration.\n */\nconst instances = new Map<DawnModule, Map<string, GPU>>();\n\n/**\n * Whether a loaded module is usable as Dawn.\n * @param loaded - the module namespace\n * @returns true when it has a create() function\n */\nfunction isDawnModule(loaded: unknown): loaded is DawnModule {\n return (\n typeof loaded === \"object\" && loaded !== null && typeof (loaded as { create?: unknown }).create === \"function\"\n );\n}\n\n/**\n * The message of a thrown value.\n * @param err - what was caught\n * @returns the Error message, or the value as a string\n */\nfunction messageOf(err: unknown): string {\n return err instanceof Error ? err.message : String(err);\n}\n\n/** The handle returned by createNodeGpu(): `gpu` is a getter so dispose() can drop the reference. */\nclass DawnHandle implements NodeGpuHandle {\n private ref: GPU | null;\n\n /**\n * Wraps a GPU object.\n * @param gpu - the object dawn.create() returned\n */\n constructor(gpu: GPU) {\n this.ref = gpu;\n }\n\n /**\n * The GPU object; E_DISPOSED after dispose().\n * @returns the GPU object\n */\n get gpu(): GPU {\n if (this.ref === null) {\n throw new WebGpuGraphError(\"E_DISPOSED\", \"the Dawn GPU handle was disposed\", { label: \"NodeGpuHandle\" });\n }\n return this.ref;\n }\n\n /** Drops the reference; idempotent. */\n dispose(): void {\n this.ref = null;\n }\n}\n\n/**\n * The Dawn flag list a NodeGpuOptions maps to (exported for the tests and scripts/gpu-report.js):\n * adapter=<s>, backend=<s>, enable-dawn-features=a,b, and software -> adapter=llvmpipe; an explicit non-empty\n * `adapter` wins over `software`; an empty feature list emits nothing.\n * @param options - the Node options, or undefined for no flags\n * @returns the strings for dawn.create(), in the order adapter, backend, features\n */\nexport function dawnFlags(options: NodeGpuOptions | undefined): string[] {\n const flags: string[] = [];\n if (options === undefined) {\n return flags;\n }\n if (options.adapter !== undefined && options.adapter !== \"\") {\n flags.push(`adapter=${options.adapter}`);\n } else if (options.software === true) {\n flags.push(\"adapter=llvmpipe\");\n }\n if (options.backend !== undefined) {\n flags.push(`backend=${options.backend}`);\n }\n if (options.dawnFeatures !== undefined && options.dawnFeatures.length > 0) {\n flags.push(`enable-dawn-features=${options.dawnFeatures.join(\",\")}`);\n }\n return flags;\n}\n\n/**\n * import(\"webgpu\"), install dawn.globals unless installGlobals === false, dawn.create(flags) (spec 2.3). The GPU\n * object is created once per flag list and reused by every later call with the same flags; it is never released,\n * because Dawn keeps polling its instance for the adapters and devices it produced (issue #30).\n * @param options - adapter / backend / dawnFeatures / software / installGlobals (and the test seam)\n * @returns the handle; `dispose()` drops the handle's reference, never the shared instance\n * @throws WebGpuGraphError E_NO_WEBGPU { reason, hint } when the module does not load (missing, or its glibc is too old), has no create(), or create(flags) throws\n */\nexport async function createNodeGpu(options?: NodeGpuOptions): Promise<NodeGpuHandle> {\n const load = options?.loadModule ?? ((): Promise<unknown> => import(\"webgpu\"));\n let loaded: unknown;\n try {\n loaded = await load();\n } catch (err) {\n const reason = messageOf(err);\n throw new WebGpuGraphError(\n \"E_NO_WEBGPU\",\n `the webgpu (Dawn) native module did not load: ${reason}; ${INSTALL_HINT}`,\n { reason, hint: INSTALL_HINT },\n );\n }\n if (!isDawnModule(loaded)) {\n const reason = \"the webgpu module exports no create() function\";\n throw new WebGpuGraphError(\"E_NO_WEBGPU\", `${reason}; ${INSTALL_HINT}`, { reason, hint: INSTALL_HINT });\n }\n if (options?.installGlobals !== false && typeof loaded.globals === \"object\" && loaded.globals !== null) {\n Object.assign(globalThis, loaded.globals);\n }\n const flags = dawnFlags(options);\n const key = flags.join(\"\\n\");\n let byFlags = instances.get(loaded);\n if (byFlags === undefined) {\n byFlags = new Map();\n instances.set(loaded, byFlags);\n }\n let gpu = byFlags.get(key);\n if (gpu === undefined) {\n try {\n gpu = loaded.create(flags);\n } catch (err) {\n const reason = `dawn.create() threw: ${messageOf(err)}`;\n throw new WebGpuGraphError(\"E_NO_WEBGPU\", `${reason}; ${INSTALL_HINT}`, { reason, hint: INSTALL_HINT });\n }\n byFlags.set(key, gpu);\n }\n return new DawnHandle(gpu);\n}\n\n/**\n * The GpuContextOptions part of a NodeGpuOptions, copied key by key so the Node-only `adapter` string never\n * reaches GpuContext.create as a GPUAdapter.\n * @param options - the Node options\n * @returns the context options without gpu / adapter / device / runtime\n */\nfunction contextOptionsOf(options: NodeGpuOptions): Omit<GpuContextOptions, \"gpu\" | \"adapter\" | \"device\" | \"runtime\"> {\n return {\n powerPreference: options.powerPreference,\n rejectSoftware: options.rejectSoftware,\n limits: options.limits,\n optionalFeatures: options.optionalFeatures,\n requiredFeatures: options.requiredFeatures,\n label: options.label,\n onError: options.onError,\n warnUnreleasedSnapshots: options.warnUnreleasedSnapshots,\n };\n}\n\n/**\n * createNodeGpu + GpuContext.create({ gpu, runtime: \"node\", ...options }); ctx.dispose() also disposes the\n * handle, and a create() failure disposes it before rethrowing. Disposing is safe at any moment: the Dawn\n * instance itself stays alive for the process (createNodeGpu), so a callback of the destroyed device that\n * arrives late, or a call on `ctx.device` after dispose(), never reaches a freed instance.\n * @param options - the Node options\n * @returns the context\n */\nexport async function createNodeGpuContext(options?: NodeGpuOptions): Promise<GpuContext> {\n const handle = await createNodeGpu(options);\n let ctx: GpuContext;\n try {\n ctx = await GpuContext.create({ ...contextOptionsOf(options ?? {}), gpu: handle.gpu, runtime: \"node\" });\n } catch (err) {\n handle.dispose();\n throw err;\n }\n ctx.attachDisposer(() => {\n handle.dispose();\n });\n return ctx;\n}\n\n/**\n * createNodeGpu + GpuContext.probe + dispose; never throws (a load failure is { code: \"E_NO_WEBGPU\" }).\n * @param options - the Node options\n * @returns the probe result\n */\nexport async function probeNodeWebGpu(options?: NodeGpuOptions): Promise<ProbeResult> {\n let handle: NodeGpuHandle;\n try {\n handle = await createNodeGpu(options);\n } catch (err) {\n return { ok: false, code: \"E_NO_WEBGPU\", reason: messageOf(err), adapter: null, summary: null };\n }\n try {\n return await GpuContext.probe({\n gpu: handle.gpu,\n powerPreference: options?.powerPreference ?? \"high-performance\",\n rejectSoftware: options?.rejectSoftware,\n });\n } finally {\n handle.dispose();\n }\n}\n"],"names":[],"mappings":";AA+CA,MAAM,eAAe;AAkBrB,MAAM,gCAAgB,IAAA;AAOtB,SAAS,aAAa,QAAuC;AACzD,SACI,OAAO,WAAW,YAAY,WAAW,QAAQ,OAAQ,OAAgC,WAAW;AAE5G;AAOA,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B,WAAW,EAAE,GAAG,KAAK,OAAO,KAAK,SAAS,QAAQ;AAAA,EAC1G,SAAS,KAAK;AACV,WAAO,QAAA;AACP,UAAM;AAAA,EACV;AACA,MAAI,eAAe,MAAM;AACrB,WAAO,QAAA;AAAA,EACX,CAAC;AACD,SAAO;AACX;AAOA,eAAsB,gBAAgB,SAAgD;AAClF,MAAI;AACJ,MAAI;AACA,aAAS,MAAM,cAAc,OAAO;AAAA,EACxC,SAAS,KAAK;AACV,WAAO,EAAE,IAAI,OAAO,MAAM,eAAe,QAAQ,UAAU,GAAG,GAAG,SAAS,MAAM,SAAS,KAAA;AAAA,EAC7F;AACA,MAAI;AACA,WAAO,MAAM,WAAW,MAAM;AAAA,MAC1B,KAAK,OAAO;AAAA,MACZ,iBAAiB,SAAS,mBAAmB;AAAA,MAC7C,gBAAgB,SAAS;AAAA,IAAA,CAC5B;AAAA,EACL,UAAA;AACI,WAAO,QAAA;AAAA,EACX;AACJ;"}
1
+ {"version":3,"file":"node.js","sources":["../src/node/index.ts"],"sourcesContent":["/// <reference types=\"@webgpu/types\" preserve=\"true\" />\n/**\n * The ./node entry (spec 2.1, 2.3, 3.4; contract 3.7): Dawn through the optional peer dependency `webgpu`. The\n * ONLY file of the package that names the \"webgpu\" module, and only inside `await import(\"webgpu\")` in a\n * function body, so the root and browser bundles never carry the specifier (spec 2.5; test/build-output.test.ts,\n * test/layers.test.ts). P0-T3 wrote createNodeGpu, dawnFlags and their types; P1-T1 adds createNodeGpuContext,\n * probeNodeWebGpu and the `extends Omit<GpuContextOptions, ...>` clause of NodeGpuOptions.\n *\n * Rule of spec 2.5 item 5 (also in CLAUDE.md): \"./node\" is imported only by Node entry points and tests.\n */\n\nimport { GpuContext } from \"../context.js\";\nimport { WebGpuGraphError } from \"../errors.js\";\nimport { manageAccelerator } from \"../managed.js\";\nimport type { GpuContextOptions, ProbeResult } from \"../types/context.js\";\nimport type { AcquireAcceleratorOptions, ManagedAccelerator } from \"../types/managed.js\";\n\nexport type {\n AcceleratorDeclined,\n AcceleratorReady,\n AcquireAcceleratorOptions,\n AcquireResult,\n ManagedAccelerator,\n} from \"../types/managed.js\";\n\n/** Options of the Node helpers (spec 3.4). */\nexport interface NodeGpuOptions extends Omit<GpuContextOptions, \"gpu\" | \"adapter\" | \"device\" | \"runtime\"> {\n /** Dawn `adapter=<substring>`: a substring of the adapter name (`llvmpipe`, `4070`); an empty string is ignored; wins over `software`. */\n readonly adapter?: string | undefined;\n /** Dawn `backend=<name>`; `null` compiles pipelines and runs nothing (spec 5.1; the compile tests use it). */\n readonly backend?: \"vulkan\" | \"d3d12\" | \"d3d11\" | \"metal\" | \"opengl\" | \"opengles\" | \"null\" | undefined;\n /** Dawn toggles, emitted as `enable-dawn-features=a,b`. */\n readonly dawnFeatures?: readonly string[] | undefined;\n /** Shorthand for `adapter=llvmpipe` (Linux / Mesa specific, spec 2.3); ignored when `adapter` is given. */\n readonly software?: boolean | undefined;\n /** Install dawn.globals on globalThis (default true; spec 2.1 rule 2) so user code sees GPUBufferUsage and friends. */\n readonly installGlobals?: boolean | undefined;\n /**\n * Test seam: replaces `() => import(\"webgpu\")` so a missing / broken module can be simulated.\n * @internal\n */\n readonly loadModule?: (() => Promise<unknown>) | undefined;\n}\n\n/**\n * The Dawn GPU handle (spec 2.3). The Dawn instance behind `gpu` is shared by every handle created with the\n * same flags and lives until the process exits (see `createNodeGpu`); it holds no event-loop handle, so it\n * never keeps the process alive.\n */\nexport interface NodeGpuHandle {\n /** The GPU of `dawn.create(flags)`; reading it after dispose() throws E_DISPOSED. */\n readonly gpu: GPU;\n /** Drops this handle's GPU reference (the shared instance stays alive); idempotent. */\n dispose(): void;\n}\n\n/** The install hint of E_NO_WEBGPU (spec 2.5 item 4); P-ENV re-pins the version together with the devDependency. */\nconst INSTALL_HINT = \"install the optional peer dependency webgpu@0.4.0\";\n\n/** The shape of the `webgpu` module (its types.d.ts: create(options: string[]): GPU; globals: Object). */\ninterface DawnModule {\n create(options: string[]): GPU;\n globals?: unknown;\n}\n\n/**\n * Every GPU object `dawn.create()` returned, per module and flag list, kept for the life of the process.\n * webgpu@0.4.0's adapters, devices and queues run their promises through an AsyncRunner that polls the Dawn\n * instance by RAW pointer, and only the GPU object owns that instance: once the GPU object is collected, the\n * next promise on any adapter or device it produced (a requestDevice on a probed adapter, a queue call or a\n * late map / lost callback of a destroyed device) polls freed memory -- SIGSEGV in\n * dawn::native::InstanceBase::ProcessEvents, on Metal and lavapipe alike (issue #30). dawn-node signals no\n * point at which the instance has drained, so no GPU object is ever released; sharing one per flag list\n * bounds what that keeps to one instance per configuration.\n */\nconst instances = new Map<DawnModule, Map<string, GPU>>();\n\n/**\n * Whether a loaded module is usable as Dawn.\n * @param loaded - the module namespace\n * @returns true when it has a create() function\n */\nfunction isDawnModule(loaded: unknown): loaded is DawnModule {\n return (\n typeof loaded === \"object\" && loaded !== null && typeof (loaded as { create?: unknown }).create === \"function\"\n );\n}\n\n/**\n * The message of a thrown value.\n * @param err - what was caught\n * @returns the Error message, or the value as a string\n */\nfunction messageOf(err: unknown): string {\n return err instanceof Error ? err.message : String(err);\n}\n\n/** The handle returned by createNodeGpu(): `gpu` is a getter so dispose() can drop the reference. */\nclass DawnHandle implements NodeGpuHandle {\n private ref: GPU | null;\n\n /**\n * Wraps a GPU object.\n * @param gpu - the object dawn.create() returned\n */\n constructor(gpu: GPU) {\n this.ref = gpu;\n }\n\n /**\n * The GPU object; E_DISPOSED after dispose().\n * @returns the GPU object\n */\n get gpu(): GPU {\n if (this.ref === null) {\n throw new WebGpuGraphError(\"E_DISPOSED\", \"the Dawn GPU handle was disposed\", { label: \"NodeGpuHandle\" });\n }\n return this.ref;\n }\n\n /** Drops the reference; idempotent. */\n dispose(): void {\n this.ref = null;\n }\n}\n\n/**\n * The Dawn flag list a NodeGpuOptions maps to (exported for the tests and scripts/gpu-report.js):\n * adapter=<s>, backend=<s>, enable-dawn-features=a,b, and software -> adapter=llvmpipe; an explicit non-empty\n * `adapter` wins over `software`; an empty feature list emits nothing.\n * @param options - the Node options, or undefined for no flags\n * @returns the strings for dawn.create(), in the order adapter, backend, features\n */\nexport function dawnFlags(options: NodeGpuOptions | undefined): string[] {\n const flags: string[] = [];\n if (options === undefined) {\n return flags;\n }\n if (options.adapter !== undefined && options.adapter !== \"\") {\n flags.push(`adapter=${options.adapter}`);\n } else if (options.software === true) {\n flags.push(\"adapter=llvmpipe\");\n }\n if (options.backend !== undefined) {\n flags.push(`backend=${options.backend}`);\n }\n if (options.dawnFeatures !== undefined && options.dawnFeatures.length > 0) {\n flags.push(`enable-dawn-features=${options.dawnFeatures.join(\",\")}`);\n }\n return flags;\n}\n\n/**\n * import(\"webgpu\"), install dawn.globals unless installGlobals === false, dawn.create(flags) (spec 2.3). The GPU\n * object is created once per flag list and reused by every later call with the same flags; it is never released,\n * because Dawn keeps polling its instance for the adapters and devices it produced (issue #30).\n * @param options - adapter / backend / dawnFeatures / software / installGlobals (and the test seam)\n * @returns the handle; `dispose()` drops the handle's reference, never the shared instance\n * @throws WebGpuGraphError E_NO_WEBGPU { reason, hint } when the module does not load (missing, or its glibc is too old), has no create(), or create(flags) throws\n */\nexport async function createNodeGpu(options?: NodeGpuOptions): Promise<NodeGpuHandle> {\n const load = options?.loadModule ?? ((): Promise<unknown> => import(\"webgpu\"));\n let loaded: unknown;\n try {\n loaded = await load();\n } catch (err) {\n const reason = messageOf(err);\n throw new WebGpuGraphError(\n \"E_NO_WEBGPU\",\n `the webgpu (Dawn) native module did not load: ${reason}; ${INSTALL_HINT}`,\n { reason, hint: INSTALL_HINT },\n );\n }\n if (!isDawnModule(loaded)) {\n const reason = \"the webgpu module exports no create() function\";\n throw new WebGpuGraphError(\"E_NO_WEBGPU\", `${reason}; ${INSTALL_HINT}`, { reason, hint: INSTALL_HINT });\n }\n if (options?.installGlobals !== false && typeof loaded.globals === \"object\" && loaded.globals !== null) {\n Object.assign(globalThis, loaded.globals);\n }\n const flags = dawnFlags(options);\n const key = flags.join(\"\\n\");\n let byFlags = instances.get(loaded);\n if (byFlags === undefined) {\n byFlags = new Map();\n instances.set(loaded, byFlags);\n }\n let gpu = byFlags.get(key);\n if (gpu === undefined) {\n try {\n gpu = loaded.create(flags);\n } catch (err) {\n const reason = `dawn.create() threw: ${messageOf(err)}`;\n throw new WebGpuGraphError(\"E_NO_WEBGPU\", `${reason}; ${INSTALL_HINT}`, { reason, hint: INSTALL_HINT });\n }\n byFlags.set(key, gpu);\n }\n return new DawnHandle(gpu);\n}\n\n/**\n * The GpuContextOptions part of a NodeGpuOptions, copied key by key so the Node-only `adapter` string never\n * reaches GpuContext.create as a GPUAdapter.\n * @param options - the Node options\n * @returns the context options without gpu / adapter / device / runtime\n */\nfunction contextOptionsOf(options: NodeGpuOptions): Omit<GpuContextOptions, \"gpu\" | \"adapter\" | \"device\" | \"runtime\"> {\n return {\n powerPreference: options.powerPreference,\n rejectSoftware: options.rejectSoftware,\n limits: options.limits,\n optionalFeatures: options.optionalFeatures,\n requiredFeatures: options.requiredFeatures,\n label: options.label,\n onError: options.onError,\n warnUnreleasedSnapshots: options.warnUnreleasedSnapshots,\n };\n}\n\n/**\n * createNodeGpu + GpuContext.create({ gpu, runtime: \"node\", ...options }); ctx.dispose() also disposes the\n * handle, and a create() failure disposes it before rethrowing. Disposing is safe at any moment: the Dawn\n * instance itself stays alive for the process (createNodeGpu), so a callback of the destroyed device that\n * arrives late, or a call on `ctx.device` after dispose(), never reaches a freed instance.\n * @param options - the Node options\n * @returns the context\n */\nexport async function createNodeGpuContext(options?: NodeGpuOptions): Promise<GpuContext> {\n const handle = await createNodeGpu(options);\n let ctx: GpuContext;\n try {\n ctx = await GpuContext.create({ ...contextOptionsOf(options ?? {}), gpu: handle.gpu, runtime: \"node\" });\n } catch (err) {\n handle.dispose();\n throw err;\n }\n ctx.attachDisposer(() => {\n handle.dispose();\n });\n return ctx;\n}\n\n/**\n * createNodeGpu + GpuContext.probe + dispose; never throws (a load failure is { code: \"E_NO_WEBGPU\" }).\n * @param options - the Node options\n * @returns the probe result\n */\nexport async function probeNodeWebGpu(options?: NodeGpuOptions): Promise<ProbeResult> {\n let handle: NodeGpuHandle;\n try {\n handle = await createNodeGpu(options);\n } catch (err) {\n return { ok: false, code: \"E_NO_WEBGPU\", reason: messageOf(err), adapter: null, summary: null };\n }\n try {\n return await GpuContext.probe({\n gpu: handle.gpu,\n powerPreference: options?.powerPreference ?? \"high-performance\",\n rejectSoftware: options?.rejectSoftware,\n });\n } finally {\n handle.dispose();\n }\n}\n\n/**\n * The managed accelerator on Dawn: probe, context, device self-check and accelerator on the first `current()`, a\n * new device after a loss, disposal by `dispose()`. Without the optional `webgpu` package `current()` declines with\n * E_NO_WEBGPU and the install command as its fix; a software adapter is declined unless `acceptSoftware` is set.\n * The same function as the `./acquire` subpath resolves to under Node.\n * @param options - see AcquireAcceleratorOptions; `adapter` picks the Dawn adapter by name\n * @returns the handle; nothing is loaded or probed until `current()` is called\n */\nexport function acquireAccelerator(options?: AcquireAcceleratorOptions): ManagedAccelerator {\n return manageAccelerator(\n {\n probe: (o, rejectSoftware) =>\n probeNodeWebGpu({ adapter: o.adapter, powerPreference: o.powerPreference, rejectSoftware }),\n open: (o, _probe, rejectSoftware) =>\n createNodeGpuContext({\n adapter: o.adapter,\n powerPreference: o.powerPreference,\n rejectSoftware,\n warnUnreleasedSnapshots: o.warnUnreleasedSnapshots,\n }),\n noWebGpuFix: () => INSTALL_HINT,\n },\n options,\n );\n}\n"],"names":[],"mappings":";;AAyDA,MAAM,eAAe;AAkBrB,MAAM,gCAAgB,IAAA;AAOtB,SAAS,aAAa,QAAuC;AACzD,SACI,OAAO,WAAW,YAAY,WAAW,QAAQ,OAAQ,OAAgC,WAAW;AAE5G;AAOA,SAAS,UAAU,KAAsB;AACrC,SAAO,eAAe,QAAQ,IAAI,UAAU,OAAO,GAAG;AAC1D;AAGA,MAAM,WAAoC;AAAA;AAAA;AAAA;AAAA;AAAA,EAOtC,YAAY,KAAU;AAClB,SAAK,MAAM;AAAA,EACf;A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ACD,SAAO;AACX;AAOA,eAAsB,gBAAgB,SAAgD;AAClF,MAAI;AACJ,MAAI;AACA,aAAS,MAAM,cAAc,OAAO;AAAA,EACxC,SAAS,KAAK;AACV,WAAO,EAAE,IAAI,OAAO,MAAM,eAAe,QAAQ,UAAU,GAAG,GAAG,SAAS,MAAM,SAAS,KAAA;AAAA,EAC7F;AACA,MAAI;AACA,WAAO,MAAM,WAAW,MAAM;AAAA,MAC1B,KAAK,OAAO;AAAA,MACZ,iBAAiB,SAAS,mBAAmB;AAAA,MAC7C,gBAAgB,SAAS;AAAA,IAAA,CAC5B;AAAA,EACL,UAAA;AACI,WAAO,QAAA;AAAA,EACX;AACJ;AAUO,SAAS,mBAAmB,SAAyD;AACxF,SAAO;AAAA,IACH;AAAA,MACI,OAAO,CAAC,GAAG,mBACP,gBAAgB,EAAE,SAAS,EAAE,SAAS,iBAAiB,EAAE,iBAAiB,gBAAgB;AAAA,MAC9F,MAAM,CAAC,GAAG,QAAQ,mBACd,qBAAqB;AAAA,QACjB,SAAS,EAAE;AAAA,QACX,iBAAiB,EAAE;AAAA,QACnB;AAAA,QACA,yBAAyB,EAAE;AAAA,MAAA,CAC9B;AAAA,MACL,aAAa,MAAM;AAAA,IAAA;AAAA,IAEvB;AAAA,EAAA;AAER;"}
@@ -1 +1 @@
1
- {"version":3,"file":"accelerator.d.ts","sourceRoot":"","sources":["../../src/accelerator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAgBH,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,cAAc,CAAC;AAK/C,OAAO,EACH,KAAK,kBAAkB,EAIvB,KAAK,cAAc,EAItB,MAAM,wBAAwB,CAAC;AA6GhC;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,UAAU,EAAE,OAAO,CAAC,EAAE,kBAAkB,GAAG,cAAc,CAoR/F"}
1
+ {"version":3,"file":"accelerator.d.ts","sourceRoot":"","sources":["../../src/accelerator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAgBH,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,cAAc,CAAC;AAK/C,OAAO,EACH,KAAK,kBAAkB,EAIvB,KAAK,cAAc,EAItB,MAAM,wBAAwB,CAAC;AA6GhC;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,UAAU,EAAE,OAAO,CAAC,EAAE,kBAAkB,GAAG,cAAc,CAsR/F"}
@@ -118,6 +118,7 @@ export function createAccelerator(ctx, options) {
118
118
  const frozen = freezeOptions(options);
119
119
  return {
120
120
  kind: "webgpu",
121
+ harmonicCloseness: true,
121
122
  ctx,
122
123
  options: frozen,
123
124
  /**
@@ -278,10 +279,11 @@ export function createAccelerator(ctx, options) {
278
279
  return await edgeBetweennessCentrality(ctx, gs, withBetweennessDefaults(frozen.algorithms?.betweenness, o, gs.nodeCount));
279
280
  },
280
281
  /**
281
- * Closeness centrality on the device (spec 8.4; P8-T13): the bit-parallel multi-source sweep, or one `sssp`
282
- * per source when `weighted`. `maxIterations` / `tolerance` are refused when defined (P8 PD-25).
282
+ * Closeness centrality on the device (spec 8.4): the all-pairs sweep with a row sum on small and
283
+ * weighted graphs, the bit-parallel multi-source search otherwise, one `sssp` per source for a weighted graph
284
+ * above the all-pairs ceiling. `maxIterations` / `tolerance` are refused when defined (P8 PD-25).
283
285
  * @param gs - the snapshot
284
- * @param o - `weighted`, and a sampled run's `sources` (undirected snapshots only)
286
+ * @param o - `weighted`, `harmonic` (exact runs), and a sampled run's `sources` (undirected snapshots only)
285
287
  * @returns the f32 scores with `precision: "f32"` (spec 9.7) and `sourcesUsed`
286
288
  */
287
289
  async closenessCentrality(gs, o) {
@@ -1 +1 @@
1
- {"version":3,"file":"accelerator.js","sourceRoot":"","sources":["../../src/accelerator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAIH,OAAO,EAAE,oBAAoB,EAAE,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,+CAA+C,EAAE;oBACzF,MAAM,EAAE,SAAS;oBACjB,IAAI,EAAE,+DAA+D;iBACxE,CAAC,CAAC;YACP,CAAC;YACD,OAAO,MAAM,mBAAmB,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;QAC9C,CAAC;QACD;;;WAGG;QACH,OAAO,CAAC,CAAgB;YACpB,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;QACnB,CAAC;QACD;;WAEG;QACH,OAAO;YACH,GAAG,CAAC,OAAO,EAAE,CAAC;QAClB,CAAC;KACJ,CAAC;AACN,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"all-pairs.d.ts","sourceRoot":"","sources":["../../../src/algorithms/all-pairs.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAG3D,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,eAAe,CAAC;AAOhD,OAAO,EAAE,KAAK,WAAW,EAAE,KAAK,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAC7E,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,iBAAiB,CAAC;AA8KrD;;;;;;;;;;GAUG;AACH,wBAAgB,oBAAoB,CAChC,GAAG,EAAE,UAAU,EACf,CAAC,EAAE,aAAa,EAChB,OAAO,CAAC,EAAE,WAAW,GAAG,aAAa,GACtC,OAAO,CAAC,aAAa,CAAC,CAExB"}
1
+ {"version":3,"file":"all-pairs.d.ts","sourceRoot":"","sources":["../../../src/algorithms/all-pairs.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAG3D,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,eAAe,CAAC;AAOhD,OAAO,EAAE,KAAK,WAAW,EAAE,KAAK,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAE7E,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,iBAAiB,CAAC;AA2MrD;;;;;;;;;;GAUG;AACH,wBAAgB,oBAAoB,CAChC,GAAG,EAAE,UAAU,EACf,CAAC,EAAE,aAAa,EAChB,OAAO,CAAC,EAAE,WAAW,GAAG,aAAa,GACtC,OAAO,CAAC,aAAa,CAAC,CAExB"}
@@ -32,8 +32,11 @@ import { assertDeviceComputes } from "../primitives/verify.js";
32
32
  import { algorithmScope } from "./scope.js";
33
33
  import { aborted, bindingOf, checkDest } from "./sssp.js";
34
34
  const ALGORITHM = "allPairsShortestPath";
35
- /** The rounds one submit holds by default: three dispatches per round. */
36
- const DEFAULT_ROUNDS_PER_SUBMIT = Math.floor(APSP_MAX_DISPATCHES_PER_SUBMIT / 3);
35
+ /**
36
+ * The rounds one submit holds by default: three dispatches per round.
37
+ * @internal
38
+ */
39
+ export const DEFAULT_ROUNDS_PER_SUBMIT = Math.floor(APSP_MAX_DISPATCHES_PER_SUBMIT / 3);
37
40
  /**
38
41
  * The largest node count whose `n x n` f32 matrix fits the device (design 8.7): `floor(sqrt(limit / 4))` over the
39
42
  * smaller of `maxStorageBufferBindingSize` and `maxBufferSize`, corrected so the float square root can never
@@ -56,6 +59,71 @@ export function allPairsCeiling(limits) {
56
59
  }
57
60
  return { maxNodes, limit, limitName };
58
61
  }
62
+ /**
63
+ * The blocked sweep itself, shared with closeness's all-pairs route: the `n x n` matrix leased from `scope`, filled,
64
+ * initialised from the arcs and swept to the shortest distances, every submit awaited; the matrix stays on the device.
65
+ * The caller has checked the ceiling and the weights.
66
+ * @internal
67
+ * @param ctx - the context
68
+ * @param s - the snapshot (n > 0)
69
+ * @param scope - the scope that leases the matrix and the params records (`min(roundsPerSubmit, blocks) + 2` slots)
70
+ * @param weighted - true sums the snapshot's weights, false counts hops
71
+ * @param roundsPerSubmit - the rounds recorded per submit
72
+ * @param options - signal / onProgress (rounds done of `ceil(n / 32)`)
73
+ * @param algorithm - the name errors carry
74
+ * @returns the matrix binding (`4 n^2` bytes, row-major, `dist[i * n + j]` from `i` to `j`)
75
+ */
76
+ export async function sweepAllPairs(ctx, s, scope, weighted, roundsPerSubmit, options, algorithm) {
77
+ const n = s.nodeCount;
78
+ const core = ctx.residency.core(s);
79
+ assertWholeCore(core, s.arcCount, ctx.caps.limits.maxStorageBufferBindingSize, algorithm);
80
+ const blocks = Math.ceil(n / APSP_TILE);
81
+ const wg = ctx.workgroupSize;
82
+ const bytes = 4 * n * n;
83
+ const matrix = bindingOf(scope.scratch(bytes, "dist"), bytes);
84
+ await ctx.allocator.check();
85
+ const weightsBinding = weighted ? undefined : null;
86
+ const fill = await ctx.pipelines.kernel(kernelSpec("fill"));
87
+ const init = await ctx.pipelines.kernel(kernelSpec("apsp-init", graphOverrides(core, null, weightsBinding)));
88
+ const phases = await Promise.all([0, 1, 2].map((phase) => ctx.pipelines.kernel(kernelSpec("apsp-fw", { PHASE: phase }))));
89
+ const graph = graphBindings(core, null, weightsBinding);
90
+ const others = blocks - 1;
91
+ const phasePlans = [plan2d(1, ctx.caps), plan2d(2 * others, ctx.caps), plan2d(others * others, ctx.caps)];
92
+ for (let first = 0; first < blocks; first += roundsPerSubmit) {
93
+ const batch = new CommandBatch(ctx, `${algorithm}/sweep`);
94
+ const pass = batch.pass("apsp");
95
+ if (first === 0) {
96
+ const fillParams = scope.params(FILL_PARAMS, { count: n * n, value: F32_INF_BITS, mode: 0, pad0: 0 });
97
+ fill.dispatch(pass, fill.bind({ dst: matrix, P: fillParams.binding }), plan1d(n * n, wg, ctx.caps), [
98
+ fillParams.offset,
99
+ ]);
100
+ const initParams = scope.params(APSP_PARAMS, { n, round: 0, blocks, infBits: F32_INF_BITS });
101
+ init.dispatch(pass, init.bind({ ...graph, dist: matrix, P: initParams.binding }), plan1d(n, wg, ctx.caps), [
102
+ initParams.offset,
103
+ ]);
104
+ }
105
+ const last = Math.min(first + roundsPerSubmit, blocks);
106
+ for (let round = first; round < last; round++) {
107
+ const params = scope.params(APSP_PARAMS, { n, round, blocks, infBits: F32_INF_BITS });
108
+ for (let phase = 0; phase < 3; phase++) {
109
+ const kernel = phases[phase];
110
+ kernel.dispatch(pass, kernel.bind({ dist: matrix, P: params.binding }), phasePlans[phase], [
111
+ params.offset,
112
+ ]);
113
+ }
114
+ }
115
+ batch.endPass();
116
+ scope.flush();
117
+ const submitted = batch.submit();
118
+ await submitted.readback;
119
+ ctx.assertReady();
120
+ options?.onProgress?.(last, blocks);
121
+ if (options?.signal?.aborted) {
122
+ throw aborted(algorithm, submitted.id);
123
+ }
124
+ }
125
+ return matrix;
126
+ }
59
127
  /**
60
128
  * All-pairs shortest paths with the test knobs; `allPairsShortestPath` is this with an empty tuning.
61
129
  * @internal
@@ -109,53 +177,10 @@ export async function allPairsWithTuning(ctx, s, options, tuning) {
109
177
  return { dist, n };
110
178
  }
111
179
  await assertDeviceComputes(ctx);
112
- const core = ctx.residency.core(s);
113
- assertWholeCore(core, s.arcCount, ctx.caps.limits.maxStorageBufferBindingSize, ALGORITHM);
114
- const blocks = Math.ceil(n / APSP_TILE);
115
- const scope = algorithmScope(ctx, ALGORITHM, Math.min(roundsPerSubmit, blocks) + 2);
180
+ const scope = algorithmScope(ctx, ALGORITHM, Math.min(roundsPerSubmit, Math.ceil(n / APSP_TILE)) + 2);
116
181
  try {
117
- const wg = ctx.workgroupSize;
182
+ const matrix = await sweepAllPairs(ctx, s, scope, weighted, roundsPerSubmit, options, ALGORITHM);
118
183
  const bytes = 4 * n * n;
119
- const matrix = bindingOf(scope.scratch(bytes, "dist"), bytes);
120
- await ctx.allocator.check();
121
- const weightsBinding = weighted ? undefined : null;
122
- const fill = await ctx.pipelines.kernel(kernelSpec("fill"));
123
- const init = await ctx.pipelines.kernel(kernelSpec("apsp-init", graphOverrides(core, null, weightsBinding)));
124
- const phases = await Promise.all([0, 1, 2].map((phase) => ctx.pipelines.kernel(kernelSpec("apsp-fw", { PHASE: phase }))));
125
- const graph = graphBindings(core, null, weightsBinding);
126
- const others = blocks - 1;
127
- const phasePlans = [plan2d(1, ctx.caps), plan2d(2 * others, ctx.caps), plan2d(others * others, ctx.caps)];
128
- for (let first = 0; first < blocks; first += roundsPerSubmit) {
129
- const batch = new CommandBatch(ctx, `${ALGORITHM}/sweep`);
130
- const pass = batch.pass("apsp");
131
- if (first === 0) {
132
- const fillParams = scope.params(FILL_PARAMS, { count: n * n, value: F32_INF_BITS, mode: 0, pad0: 0 });
133
- fill.dispatch(pass, fill.bind({ dst: matrix, P: fillParams.binding }), plan1d(n * n, wg, ctx.caps), [
134
- fillParams.offset,
135
- ]);
136
- const initParams = scope.params(APSP_PARAMS, { n, round: 0, blocks, infBits: F32_INF_BITS });
137
- init.dispatch(pass, init.bind({ ...graph, dist: matrix, P: initParams.binding }), plan1d(n, wg, ctx.caps), [initParams.offset]);
138
- }
139
- const last = Math.min(first + roundsPerSubmit, blocks);
140
- for (let round = first; round < last; round++) {
141
- const params = scope.params(APSP_PARAMS, { n, round, blocks, infBits: F32_INF_BITS });
142
- for (let phase = 0; phase < 3; phase++) {
143
- const kernel = phases[phase];
144
- kernel.dispatch(pass, kernel.bind({ dist: matrix, P: params.binding }), phasePlans[phase], [
145
- params.offset,
146
- ]);
147
- }
148
- }
149
- batch.endPass();
150
- scope.flush();
151
- const submitted = batch.submit();
152
- await submitted.readback;
153
- ctx.assertReady();
154
- options?.onProgress?.(last, blocks);
155
- if (options?.signal?.aborted) {
156
- throw aborted(ALGORITHM, submitted.id);
157
- }
158
- }
159
184
  await ctx.readback.read(matrix.buffer, bytes, dist);
160
185
  ctx.assertReady();
161
186
  return { dist, n };
@@ -1 +1 @@
1
- {"version":3,"file":"all-pairs.js","sourceRoot":"","sources":["../../../src/algorithms/all-pairs.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAIH,OAAO,EAAE,8BAA8B,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE1F,OAAO,EAAE,gBAAgB,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E,KAAK,EAAE,QAAQ,EAAE,eAAe,EAAE,OAAO,EAAE,SAAS,CAAC,CAAC;QACjG,MAAM,KAAK,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QACxB,MAAM,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC;QACpD,GAAG,CAAC,WAAW,EAAE,CAAC;QAClB,OAAO,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC;IACvB,CAAC;YAAS,CAAC;QACP,KAAK,CAAC,OAAO,EAAE,CAAC;IACpB,CAAC;AACL,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,UAAU,oBAAoB,CAChC,GAAe,EACf,CAAgB,EAChB,OAAqC;IAErC,OAAO,kBAAkB,CAAC,GAAG,EAAE,CAAC,EAAE,OAAO,EAAE,EAAE,CAAC,CAAC;AACnD,CAAC"}
@@ -30,7 +30,7 @@
30
30
  *
31
31
  * The batch size k is planned from the device limits at 16 bytes per (node, source) -- the three arrays design 4.7
32
32
  * counts plus the 4-byte log entry it omits -- as `min(floor(maxStorageBufferBindingSize / 4n), floor(0.25 x
33
- * maxBufferSize / 16n), 64)`, at least 1 (`planBatchSize`); a graph whose single source does not fit one binding is
33
+ * maxBufferSize / 16n), BC_MAX_BATCH)` (256), at least 1 (`planBatchSize`); a graph whose single source does not fit one binding is
34
34
  * E_TOO_LARGE. The forward form is chosen per batch: the first batch runs `bc-forward`; a later one runs the
35
35
  * edge-parallel form when the previous batch's level count -- the MAXIMUM depth over its sources, the only depth
36
36
  * figure the host has, which over-estimates the median of design 8.4's rule and so errs toward the frontier form --
@@ -30,7 +30,7 @@
30
30
  *
31
31
  * The batch size k is planned from the device limits at 16 bytes per (node, source) -- the three arrays design 4.7
32
32
  * counts plus the 4-byte log entry it omits -- as `min(floor(maxStorageBufferBindingSize / 4n), floor(0.25 x
33
- * maxBufferSize / 16n), 64)`, at least 1 (`planBatchSize`); a graph whose single source does not fit one binding is
33
+ * maxBufferSize / 16n), BC_MAX_BATCH)` (256), at least 1 (`planBatchSize`); a graph whose single source does not fit one binding is
34
34
  * E_TOO_LARGE. The forward form is chosen per batch: the first batch runs `bc-forward`; a later one runs the
35
35
  * edge-parallel form when the previous batch's level count -- the MAXIMUM depth over its sources, the only depth
36
36
  * figure the host has, which over-estimates the median of design 8.4's rule and so errs toward the frontier form --
@@ -71,7 +71,7 @@ const SAMPLE_SEED = 0x9e3779b9;
71
71
  const RING_SLOTS = Math.max(3 * MAX_LEVELS_PER_SUBMIT, BC_BACKWARD_LEVELS_PER_SUBMIT) + 16;
72
72
  /**
73
73
  * The source batch size (design 8.4, 10.1): `min(floor(maxStorageBufferBindingSize / 4n), floor(0.25 x maxBufferSize /
74
- * 16n), 64, remaining)`, at least 1. Each of the four `n x k` arrays is one binding of `4 n k` bytes, and the batch's
74
+ * 16n), BC_MAX_BATCH, remaining)`, at least 1. Each of the four `n x k` arrays is one binding of `4 n k` bytes, and the batch's
75
75
  * four together stay inside a quarter of the largest buffer.
76
76
  * @internal
77
77
  * @param n - the vertex count (>= 1)