@graphty/webgpu-graph-algorithms 0.0.0 → 0.2.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.
Files changed (269) hide show
  1. package/README.md +344 -23
  2. package/dist/browser.d.ts +1 -0
  3. package/dist/browser.js +32 -0
  4. package/dist/browser.js.map +1 -0
  5. package/dist/chunks/context-E6iKaeuJ.js +3136 -0
  6. package/dist/chunks/context-E6iKaeuJ.js.map +1 -0
  7. package/dist/node.d.ts +1 -0
  8. package/dist/node.js +131 -0
  9. package/dist/node.js.map +1 -0
  10. package/dist/src/accelerator.d.ts +26 -0
  11. package/dist/src/accelerator.d.ts.map +1 -0
  12. package/dist/src/accelerator.js +101 -0
  13. package/dist/src/accelerator.js.map +1 -0
  14. package/dist/src/algorithms/degree.d.ts +35 -0
  15. package/dist/src/algorithms/degree.d.ts.map +1 -0
  16. package/dist/src/algorithms/degree.js +119 -0
  17. package/dist/src/algorithms/degree.js.map +1 -0
  18. package/dist/src/browser/index.d.ts +23 -0
  19. package/dist/src/browser/index.d.ts.map +1 -0
  20. package/dist/src/browser/index.js +48 -0
  21. package/dist/src/browser/index.js.map +1 -0
  22. package/dist/src/constants.d.ts +92 -0
  23. package/dist/src/constants.d.ts.map +1 -0
  24. package/dist/src/constants.js +92 -0
  25. package/dist/src/constants.js.map +1 -0
  26. package/dist/src/context.d.ts +84 -0
  27. package/dist/src/context.d.ts.map +1 -0
  28. package/dist/src/context.js +304 -0
  29. package/dist/src/context.js.map +1 -0
  30. package/dist/src/device/acquire.d.ts +57 -0
  31. package/dist/src/device/acquire.d.ts.map +1 -0
  32. package/dist/src/device/acquire.js +232 -0
  33. package/dist/src/device/acquire.js.map +1 -0
  34. package/dist/src/device/caps.d.ts +43 -0
  35. package/dist/src/device/caps.d.ts.map +1 -0
  36. package/dist/src/device/caps.js +104 -0
  37. package/dist/src/device/caps.js.map +1 -0
  38. package/dist/src/device/error-scope.d.ts +75 -0
  39. package/dist/src/device/error-scope.d.ts.map +1 -0
  40. package/dist/src/device/error-scope.js +152 -0
  41. package/dist/src/device/error-scope.js.map +1 -0
  42. package/dist/src/device/lost.d.ts +51 -0
  43. package/dist/src/device/lost.d.ts.map +1 -0
  44. package/dist/src/device/lost.js +130 -0
  45. package/dist/src/device/lost.js.map +1 -0
  46. package/dist/src/device/webgpu-constants.d.ts +31 -0
  47. package/dist/src/device/webgpu-constants.d.ts.map +1 -0
  48. package/dist/src/device/webgpu-constants.js +31 -0
  49. package/dist/src/device/webgpu-constants.js.map +1 -0
  50. package/dist/src/errors.d.ts +56 -0
  51. package/dist/src/errors.d.ts.map +1 -0
  52. package/dist/src/errors.js +57 -0
  53. package/dist/src/errors.js.map +1 -0
  54. package/dist/src/index.d.ts +29 -0
  55. package/dist/src/index.d.ts.map +1 -0
  56. package/dist/src/index.js +27 -0
  57. package/dist/src/index.js.map +1 -0
  58. package/dist/src/kernel/batch.d.ts +116 -0
  59. package/dist/src/kernel/batch.d.ts.map +1 -0
  60. package/dist/src/kernel/batch.js +335 -0
  61. package/dist/src/kernel/batch.js.map +1 -0
  62. package/dist/src/kernel/dispatch.d.ts +59 -0
  63. package/dist/src/kernel/dispatch.d.ts.map +1 -0
  64. package/dist/src/kernel/dispatch.js +139 -0
  65. package/dist/src/kernel/dispatch.js.map +1 -0
  66. package/dist/src/kernel/kernel.d.ts +84 -0
  67. package/dist/src/kernel/kernel.d.ts.map +1 -0
  68. package/dist/src/kernel/kernel.js +239 -0
  69. package/dist/src/kernel/kernel.js.map +1 -0
  70. package/dist/src/kernel/pipeline-cache.d.ts +90 -0
  71. package/dist/src/kernel/pipeline-cache.d.ts.map +1 -0
  72. package/dist/src/kernel/pipeline-cache.js +251 -0
  73. package/dist/src/kernel/pipeline-cache.js.map +1 -0
  74. package/dist/src/kernel/prelude.d.ts +35 -0
  75. package/dist/src/kernel/prelude.d.ts.map +1 -0
  76. package/dist/src/kernel/prelude.js +211 -0
  77. package/dist/src/kernel/prelude.js.map +1 -0
  78. package/dist/src/kernel/profiler.d.ts +64 -0
  79. package/dist/src/kernel/profiler.d.ts.map +1 -0
  80. package/dist/src/kernel/profiler.js +120 -0
  81. package/dist/src/kernel/profiler.js.map +1 -0
  82. package/dist/src/kernel/struct-block.d.ts +122 -0
  83. package/dist/src/kernel/struct-block.d.ts.map +1 -0
  84. package/dist/src/kernel/struct-block.js +353 -0
  85. package/dist/src/kernel/struct-block.js.map +1 -0
  86. package/dist/src/kernel/uniform-ring.d.ts +70 -0
  87. package/dist/src/kernel/uniform-ring.d.ts.map +1 -0
  88. package/dist/src/kernel/uniform-ring.js +146 -0
  89. package/dist/src/kernel/uniform-ring.js.map +1 -0
  90. package/dist/src/kernel/wgsl.d.ts +88 -0
  91. package/dist/src/kernel/wgsl.d.ts.map +1 -0
  92. package/dist/src/kernel/wgsl.js +390 -0
  93. package/dist/src/kernel/wgsl.js.map +1 -0
  94. package/dist/src/kernels.d.ts +81 -0
  95. package/dist/src/kernels.d.ts.map +1 -0
  96. package/dist/src/kernels.js +417 -0
  97. package/dist/src/kernels.js.map +1 -0
  98. package/dist/src/layouts/force-simulation.d.ts +498 -0
  99. package/dist/src/layouts/force-simulation.d.ts.map +1 -0
  100. package/dist/src/layouts/force-simulation.js +1650 -0
  101. package/dist/src/layouts/force-simulation.js.map +1 -0
  102. package/dist/src/layouts/forceatlas2.d.ts +210 -0
  103. package/dist/src/layouts/forceatlas2.d.ts.map +1 -0
  104. package/dist/src/layouts/forceatlas2.js +759 -0
  105. package/dist/src/layouts/forceatlas2.js.map +1 -0
  106. package/dist/src/layouts/inputs.d.ts +40 -0
  107. package/dist/src/layouts/inputs.d.ts.map +1 -0
  108. package/dist/src/layouts/inputs.js +185 -0
  109. package/dist/src/layouts/inputs.js.map +1 -0
  110. package/dist/src/layouts/repulsion-exact.d.ts +85 -0
  111. package/dist/src/layouts/repulsion-exact.d.ts.map +1 -0
  112. package/dist/src/layouts/repulsion-exact.js +134 -0
  113. package/dist/src/layouts/repulsion-exact.js.map +1 -0
  114. package/dist/src/layouts/seed.d.ts +56 -0
  115. package/dist/src/layouts/seed.d.ts.map +1 -0
  116. package/dist/src/layouts/seed.js +173 -0
  117. package/dist/src/layouts/seed.js.map +1 -0
  118. package/dist/src/memory/buffer-pool.d.ts +73 -0
  119. package/dist/src/memory/buffer-pool.d.ts.map +1 -0
  120. package/dist/src/memory/buffer-pool.js +170 -0
  121. package/dist/src/memory/buffer-pool.js.map +1 -0
  122. package/dist/src/memory/lease.d.ts +53 -0
  123. package/dist/src/memory/lease.d.ts.map +1 -0
  124. package/dist/src/memory/lease.js +85 -0
  125. package/dist/src/memory/lease.js.map +1 -0
  126. package/dist/src/memory/readback.d.ts +143 -0
  127. package/dist/src/memory/readback.d.ts.map +1 -0
  128. package/dist/src/memory/readback.js +375 -0
  129. package/dist/src/memory/readback.js.map +1 -0
  130. package/dist/src/memory/residency.d.ts +83 -0
  131. package/dist/src/memory/residency.d.ts.map +1 -0
  132. package/dist/src/memory/residency.js +573 -0
  133. package/dist/src/memory/residency.js.map +1 -0
  134. package/dist/src/memory/upload-plan.d.ts +101 -0
  135. package/dist/src/memory/upload-plan.d.ts.map +1 -0
  136. package/dist/src/memory/upload-plan.js +265 -0
  137. package/dist/src/memory/upload-plan.js.map +1 -0
  138. package/dist/src/node/index.d.ts +64 -0
  139. package/dist/src/node/index.d.ts.map +1 -0
  140. package/dist/src/node/index.js +183 -0
  141. package/dist/src/node/index.js.map +1 -0
  142. package/dist/src/primitives/reduce.d.ts +57 -0
  143. package/dist/src/primitives/reduce.d.ts.map +1 -0
  144. package/dist/src/primitives/reduce.js +161 -0
  145. package/dist/src/primitives/reduce.js.map +1 -0
  146. package/dist/src/primitives/segmented-reduce.d.ts +38 -0
  147. package/dist/src/primitives/segmented-reduce.d.ts.map +1 -0
  148. package/dist/src/primitives/segmented-reduce.js +211 -0
  149. package/dist/src/primitives/segmented-reduce.js.map +1 -0
  150. package/dist/src/types/accelerator.d.ts +209 -0
  151. package/dist/src/types/accelerator.d.ts.map +1 -0
  152. package/dist/src/types/accelerator.js +8 -0
  153. package/dist/src/types/accelerator.js.map +1 -0
  154. package/dist/src/types/context.d.ts +114 -0
  155. package/dist/src/types/context.d.ts.map +1 -0
  156. package/dist/src/types/context.js +7 -0
  157. package/dist/src/types/context.js.map +1 -0
  158. package/dist/src/types/layout.d.ts +95 -0
  159. package/dist/src/types/layout.d.ts.map +1 -0
  160. package/dist/src/types/layout.js +6 -0
  161. package/dist/src/types/layout.js.map +1 -0
  162. package/dist/src/types/memory.d.ts +22 -0
  163. package/dist/src/types/memory.d.ts.map +1 -0
  164. package/dist/src/types/memory.js +7 -0
  165. package/dist/src/types/memory.js.map +1 -0
  166. package/dist/src/types/options.d.ts +78 -0
  167. package/dist/src/types/options.d.ts.map +1 -0
  168. package/dist/src/types/options.js +7 -0
  169. package/dist/src/types/options.js.map +1 -0
  170. package/dist/src/types/run.d.ts +13 -0
  171. package/dist/src/types/run.d.ts.map +1 -0
  172. package/dist/src/types/run.js +6 -0
  173. package/dist/src/types/run.js.map +1 -0
  174. package/dist/src/wgsl/degree.wgsl.d.ts +10 -0
  175. package/dist/src/wgsl/degree.wgsl.d.ts.map +1 -0
  176. package/dist/src/wgsl/degree.wgsl.js +25 -0
  177. package/dist/src/wgsl/degree.wgsl.js.map +1 -0
  178. package/dist/src/wgsl/fa2-attraction.wgsl.d.ts +12 -0
  179. package/dist/src/wgsl/fa2-attraction.wgsl.d.ts.map +1 -0
  180. package/dist/src/wgsl/fa2-attraction.wgsl.js +37 -0
  181. package/dist/src/wgsl/fa2-attraction.wgsl.js.map +1 -0
  182. package/dist/src/wgsl/fa2-integrate.wgsl.d.ts +13 -0
  183. package/dist/src/wgsl/fa2-integrate.wgsl.d.ts.map +1 -0
  184. package/dist/src/wgsl/fa2-integrate.wgsl.js +69 -0
  185. package/dist/src/wgsl/fa2-integrate.wgsl.js.map +1 -0
  186. package/dist/src/wgsl/fa2-repulsion-exact.wgsl.d.ts +12 -0
  187. package/dist/src/wgsl/fa2-repulsion-exact.wgsl.d.ts.map +1 -0
  188. package/dist/src/wgsl/fa2-repulsion-exact.wgsl.js +79 -0
  189. package/dist/src/wgsl/fa2-repulsion-exact.wgsl.js.map +1 -0
  190. package/dist/src/wgsl/fa2-speed-finalize.wgsl.d.ts +15 -0
  191. package/dist/src/wgsl/fa2-speed-finalize.wgsl.d.ts.map +1 -0
  192. package/dist/src/wgsl/fa2-speed-finalize.wgsl.js +54 -0
  193. package/dist/src/wgsl/fa2-speed-finalize.wgsl.js.map +1 -0
  194. package/dist/src/wgsl/fa2-stats-finalize.wgsl.d.ts +14 -0
  195. package/dist/src/wgsl/fa2-stats-finalize.wgsl.d.ts.map +1 -0
  196. package/dist/src/wgsl/fa2-stats-finalize.wgsl.js +57 -0
  197. package/dist/src/wgsl/fa2-stats-finalize.wgsl.js.map +1 -0
  198. package/dist/src/wgsl/fa2-to-scene.wgsl.d.ts +11 -0
  199. package/dist/src/wgsl/fa2-to-scene.wgsl.d.ts.map +1 -0
  200. package/dist/src/wgsl/fa2-to-scene.wgsl.js +19 -0
  201. package/dist/src/wgsl/fa2-to-scene.wgsl.js.map +1 -0
  202. package/dist/src/wgsl/fill.wgsl.d.ts +7 -0
  203. package/dist/src/wgsl/fill.wgsl.d.ts.map +1 -0
  204. package/dist/src/wgsl/fill.wgsl.js +14 -0
  205. package/dist/src/wgsl/fill.wgsl.js.map +1 -0
  206. package/dist/src/wgsl/reduce.wgsl.d.ts +10 -0
  207. package/dist/src/wgsl/reduce.wgsl.d.ts.map +1 -0
  208. package/dist/src/wgsl/reduce.wgsl.js +63 -0
  209. package/dist/src/wgsl/reduce.wgsl.js.map +1 -0
  210. package/dist/src/wgsl/segmented-reduce.wgsl.d.ts +13 -0
  211. package/dist/src/wgsl/segmented-reduce.wgsl.d.ts.map +1 -0
  212. package/dist/src/wgsl/segmented-reduce.wgsl.js +35 -0
  213. package/dist/src/wgsl/segmented-reduce.wgsl.js.map +1 -0
  214. package/dist/tsconfig.build.tsbuildinfo +1 -0
  215. package/dist/webgpu-graph-algorithms.d.ts +1 -0
  216. package/dist/webgpu-graph-algorithms.js +4454 -0
  217. package/dist/webgpu-graph-algorithms.js.map +1 -0
  218. package/package.json +108 -17
  219. package/src/accelerator.ts +117 -0
  220. package/src/algorithms/degree.ts +142 -0
  221. package/src/browser/index.ts +57 -0
  222. package/src/constants.ts +116 -0
  223. package/src/context.ts +399 -0
  224. package/src/device/acquire.ts +256 -0
  225. package/src/device/caps.ts +122 -0
  226. package/src/device/error-scope.ts +171 -0
  227. package/src/device/lost.ts +142 -0
  228. package/src/device/webgpu-constants.ts +44 -0
  229. package/src/errors.ts +94 -0
  230. package/src/index.ts +102 -0
  231. package/src/kernel/batch.ts +427 -0
  232. package/src/kernel/dispatch.ts +162 -0
  233. package/src/kernel/kernel.ts +311 -0
  234. package/src/kernel/pipeline-cache.ts +288 -0
  235. package/src/kernel/prelude.ts +229 -0
  236. package/src/kernel/profiler.ts +148 -0
  237. package/src/kernel/struct-block.ts +439 -0
  238. package/src/kernel/uniform-ring.ts +184 -0
  239. package/src/kernel/wgsl.ts +490 -0
  240. package/src/kernels.ts +511 -0
  241. package/src/layouts/force-simulation.ts +2111 -0
  242. package/src/layouts/forceatlas2.ts +942 -0
  243. package/src/layouts/inputs.ts +252 -0
  244. package/src/layouts/repulsion-exact.ts +183 -0
  245. package/src/layouts/seed.ts +198 -0
  246. package/src/memory/buffer-pool.ts +204 -0
  247. package/src/memory/lease.ts +93 -0
  248. package/src/memory/readback.ts +429 -0
  249. package/src/memory/residency.ts +753 -0
  250. package/src/memory/upload-plan.ts +350 -0
  251. package/src/node/index.ts +230 -0
  252. package/src/primitives/reduce.ts +233 -0
  253. package/src/primitives/segmented-reduce.ts +270 -0
  254. package/src/types/accelerator.ts +236 -0
  255. package/src/types/context.ts +135 -0
  256. package/src/types/layout.ts +103 -0
  257. package/src/types/memory.ts +23 -0
  258. package/src/types/options.ts +84 -0
  259. package/src/types/run.ts +13 -0
  260. package/src/wgsl/degree.wgsl.ts +24 -0
  261. package/src/wgsl/fa2-attraction.wgsl.ts +37 -0
  262. package/src/wgsl/fa2-integrate.wgsl.ts +69 -0
  263. package/src/wgsl/fa2-repulsion-exact.wgsl.ts +78 -0
  264. package/src/wgsl/fa2-speed-finalize.wgsl.ts +53 -0
  265. package/src/wgsl/fa2-stats-finalize.wgsl.ts +57 -0
  266. package/src/wgsl/fa2-to-scene.wgsl.ts +19 -0
  267. package/src/wgsl/fill.wgsl.ts +13 -0
  268. package/src/wgsl/reduce.wgsl.ts +62 -0
  269. package/src/wgsl/segmented-reduce.wgsl.ts +35 -0
@@ -0,0 +1,573 @@
1
+ /**
2
+ * The upload cache of spec 4.1 / 4.3 / 4.5: every core array, view array, column and ad hoc array a kernel binds
3
+ * lives on the device exactly once per snapshot core, keyed on the typed-array object (or the Column object for
4
+ * columns, PLAN DECISION 8), recorded per serial so `release(snapshot)` destroys every buffer of a snapshot and its
5
+ * withColumns() siblings, and tombstoned so a live user learns of the release through `isReleased` (spec 4.5).
6
+ * Uploads follow the pure planner of ./upload-plan.ts: the arena path writes ONE buffer with ONE writeBuffer of the
7
+ * hot prefix (or the full arena when a cold segment is needed and fits) and binds segments at
8
+ * `segment.byteOffset - arena.byteOffset`; the perArray path writes one buffer per array; a windowed plan is
9
+ * E_TOO_LARGE until P4 executes windows (PLAN DECISION 2). Identity permutations are never materialised: presence is
10
+ * decided from counts and flags, and the arcToEdge / edgeToArc getters are read only when a segment exists. Nothing
11
+ * is freed by garbage collection; the once-only warning above warnUnreleasedSnapshots names the missing release.
12
+ */
13
+ import { BufferUsage } from "../device/webgpu-constants.js";
14
+ import { WebGpuGraphError } from "../errors.js";
15
+ import { planUpload } from "./upload-plan.js";
16
+ /** The core arrays a kernel binds by default (spec 4.1); the cold segments are named explicitly by the caller. */
17
+ const DEFAULT_NEED = Object.freeze(["rowPtr", "colIdx", "weights"]);
18
+ /** The five core arrays in arena (hot-to-cold) order. */
19
+ const CORE_ORDER = Object.freeze(["rowPtr", "colIdx", "weights", "arcToEdge", "edgeToArc"]);
20
+ /** Every resident buffer is bound by kernels, filled by writeBuffer and readable back (tests, readbacks of state). */
21
+ const RESIDENT_USAGE = BufferUsage.STORAGE | BufferUsage.COPY_DST | BufferUsage.COPY_SRC;
22
+ /**
23
+ * Whether an ArrayBuffer-like is a SharedArrayBuffer (checked by tag so the global need not exist).
24
+ * @param buffer - the buffer to test
25
+ * @returns true for a SharedArrayBuffer
26
+ */
27
+ function isSharedBuffer(buffer) {
28
+ return Object.prototype.toString.call(buffer) === "[object SharedArrayBuffer]";
29
+ }
30
+ /**
31
+ * The E_INVALID_ARGUMENT error of a bad residency argument.
32
+ * @param argument - the argument name
33
+ * @param value - the value given
34
+ * @param expected - what was expected
35
+ * @returns the error to throw
36
+ */
37
+ function invalid(argument, value, expected) {
38
+ return new WebGpuGraphError("E_INVALID_ARGUMENT", `${argument}: expected ${expected}`, {
39
+ argument,
40
+ value,
41
+ expected,
42
+ });
43
+ }
44
+ /**
45
+ * Throws E_SNAPSHOT { reason: "detached" } for a snapshot whose core was transferred away.
46
+ * @param s - the snapshot
47
+ */
48
+ function assertAttached(s) {
49
+ if (s.detached) {
50
+ throw new WebGpuGraphError("E_SNAPSHOT", `snapshot ${s.serial} is detached (its core was transferred away)`, {
51
+ reason: "detached",
52
+ serial: s.serial,
53
+ });
54
+ }
55
+ }
56
+ /**
57
+ * Whether a core array exists on the snapshot, from counts and flags alone (mirrors coreByteLengths of
58
+ * ./upload-plan.ts; spec 5.6: zero-length arrays are never uploaded; spec 4.1: identity permutations never
59
+ * materialised).
60
+ * @param s - the snapshot
61
+ * @param name - the core array
62
+ * @returns true when the array has bytes to upload
63
+ */
64
+ function isPresent(s, name) {
65
+ switch (name) {
66
+ case "rowPtr":
67
+ return true;
68
+ case "colIdx":
69
+ return s.arcCount > 0;
70
+ case "weights":
71
+ return s.flags.weighted && s.arcCount > 0;
72
+ case "arcToEdge":
73
+ return !s.flags.arcToEdgeIsIdentity && s.arcCount > 0;
74
+ case "edgeToArc":
75
+ return !s.flags.arcToEdgeIsIdentity && s.edgeCount > 0;
76
+ default:
77
+ return false;
78
+ }
79
+ }
80
+ /**
81
+ * The array object of a PRESENT core array (the caller checked isPresent, so the two getters never materialise).
82
+ * @param s - the snapshot
83
+ * @param name - the core array
84
+ * @returns the array
85
+ */
86
+ function coreArray(s, name) {
87
+ switch (name) {
88
+ case "rowPtr":
89
+ return s.rowPtr;
90
+ case "colIdx":
91
+ return s.colIdx;
92
+ case "weights": {
93
+ const { weights } = s;
94
+ if (weights === null) {
95
+ throw invalid("weights", null, "a weighted snapshot");
96
+ }
97
+ return weights;
98
+ }
99
+ case "arcToEdge":
100
+ return s.arcToEdge;
101
+ case "edgeToArc":
102
+ return s.edgeToArc;
103
+ default:
104
+ throw invalid("name", name, "a core array name");
105
+ }
106
+ }
107
+ /** The upload cache (spec 4.1): WeakMap on array objects, WeakMap on snapshots, a strong Map by serial; @internal (reached as ctx.residency). */
108
+ export class GraphResidency {
109
+ /**
110
+ * Creates an empty residency over a device.
111
+ * @param device - the device (queue.writeBuffer)
112
+ * @param caps - the device capabilities the planner reads
113
+ * @param allocator - the context's OOM-scoped allocator (every buffer is created and destroyed through it)
114
+ * @param options - the once-only warning
115
+ * @param options.warnUnreleasedSnapshots - the resident-snapshot count above which the warning fires once
116
+ * @param options.warn - the warning sink; default console.warn
117
+ */
118
+ constructor(device, caps, allocator, options) {
119
+ /** Fast lookup by the uploaded object (a typed array or a Column). */
120
+ this.residents = new WeakMap();
121
+ /** Fast lookup of a snapshot's record (entries of released records are recognised by `released`). */
122
+ this.records = new WeakMap();
123
+ /** The strong map by serial: withColumns() siblings share one record; cleared by release. */
124
+ this.bySerial = new Map();
125
+ /** Owner-less ad hoc arrays. */
126
+ this.orphans = new Set();
127
+ /** Serials released and not re-uploaded. */
128
+ this.tombstones = new Set();
129
+ this.liveCount = 0;
130
+ this.liveBytesValue = 0;
131
+ this.warned = false;
132
+ this.disposed = false;
133
+ this.device = device;
134
+ this.caps = caps;
135
+ this.allocator = allocator;
136
+ this.warnUnreleasedSnapshots = options.warnUnreleasedSnapshots;
137
+ this.warn =
138
+ options.warn ??
139
+ ((message) => {
140
+ console.warn(message);
141
+ });
142
+ }
143
+ /**
144
+ * Uploads (or finds) the core; `need` defaults to ["rowPtr", "colIdx", "weights"]; cold segments on demand
145
+ * (spec 4.2). Never materialises an identity permutation. A windowed plan throws E_TOO_LARGE { path: "windowed" }
146
+ * until P4 (PLAN DECISION 2); a tombstoned serial is lifted and re-uploaded (PLAN DECISION 7).
147
+ * @param s - the snapshot
148
+ * @param need - the core arrays to bind (rowPtr is always included; absent arrays are ignored)
149
+ * @returns the core binding (a frozen object; grows as cold segments are added)
150
+ */
151
+ core(s, need) {
152
+ this.assertLive();
153
+ assertAttached(s);
154
+ const wanted = need ?? DEFAULT_NEED;
155
+ const names = CORE_ORDER.filter((name) => (name === "rowPtr" || wanted.includes(name)) && isPresent(s, name));
156
+ const plan = planUpload(s, this.caps, names);
157
+ if (plan.kind === "windowed") {
158
+ throw new WebGpuGraphError("E_TOO_LARGE", `snapshot ${s.serial}: an arc array of ${4 * s.arcCount} bytes needs arc windows (${plan.windows.length}), which P1-P3 plan but do not execute`, {
159
+ needed: 4 * s.arcCount,
160
+ limit: this.caps.limits.maxStorageBufferBindingSize,
161
+ path: "windowed",
162
+ algorithm: null,
163
+ });
164
+ }
165
+ const record = this.ensureRecord(s);
166
+ if (record.plan === null) {
167
+ record.plan = plan.kind;
168
+ if (plan.kind === "arena" && s.arena !== null) {
169
+ const { arena } = s;
170
+ const resident = this.upload(record, s.rowPtr, new Uint8Array(arena.buffer, arena.byteOffset, plan.bytes), `residency:core:${record.serial}:arena`);
171
+ record.arena = { buffer: resident.buffer, segments: plan.segments };
172
+ }
173
+ }
174
+ for (const name of names) {
175
+ if (!record.bindings.has(name)) {
176
+ record.bindings.set(name, this.bindCore(record, s, name));
177
+ }
178
+ }
179
+ const rowPtr = record.bindings.get("rowPtr");
180
+ if (rowPtr === undefined) {
181
+ throw invalid("rowPtr", null, "a bound rowPtr (internal invariant)");
182
+ }
183
+ const weights = record.bindings.get("weights") ?? null;
184
+ return Object.freeze({
185
+ serial: record.serial,
186
+ plan: plan.kind,
187
+ rowPtr,
188
+ colIdx: record.bindings.get("colIdx") ?? null,
189
+ weights,
190
+ arcToEdge: record.bindings.get("arcToEdge") ?? null,
191
+ edgeToArc: record.bindings.get("edgeToArc") ?? null,
192
+ windows: null,
193
+ hasWeights: weights !== null,
194
+ });
195
+ }
196
+ /**
197
+ * Uploads (or finds) a view; P1-P3 support outDegree / inDegree / degreeOrder / reverseDegreeOrder; the others
198
+ * -> E_UNSUPPORTED until P7. packViews is accepted and ignored until P7 (a `true` request is E_UNSUPPORTED
199
+ * { option: "packViews" }, PLAN DECISION 9).
200
+ * @param s - the snapshot
201
+ * @param name - the view
202
+ * @param options - view options
203
+ * @param options.packViews - P7's packed reverse upload; `true` is E_UNSUPPORTED until then
204
+ * @returns the view binding
205
+ */
206
+ view(s, name, options) {
207
+ this.assertLive();
208
+ assertAttached(s);
209
+ if (options?.packViews === true) {
210
+ throw new WebGpuGraphError("E_UNSUPPORTED", "packViews is not supported before the P7 view uploads", {
211
+ option: "packViews",
212
+ hint: "omit packViews; the four reverse arrays are uploaded separately",
213
+ });
214
+ }
215
+ let array;
216
+ let bindingName;
217
+ let scalars = {};
218
+ switch (name) {
219
+ case "outDegree":
220
+ this.assertNotReleased(s);
221
+ this.assertNonEmpty(s);
222
+ array = s.outDegree();
223
+ bindingName = "outDegree";
224
+ break;
225
+ case "inDegree":
226
+ this.assertNotReleased(s);
227
+ this.assertNonEmpty(s);
228
+ array = s.inDegree();
229
+ bindingName = "inDegree";
230
+ break;
231
+ case "degreeOrder": {
232
+ this.assertNotReleased(s);
233
+ this.assertNonEmpty(s);
234
+ const order = s.degreeOrder();
235
+ array = order.perm;
236
+ bindingName = "perm";
237
+ scalars = { segmentOffsets: Array.from(order.segmentOffsets) };
238
+ break;
239
+ }
240
+ case "reverseDegreeOrder": {
241
+ this.assertNotReleased(s);
242
+ this.assertNonEmpty(s);
243
+ const order = s.degreeOrder({ of: "reverse" });
244
+ array = order.perm;
245
+ bindingName = "perm";
246
+ scalars = { segmentOffsets: Array.from(order.segmentOffsets) };
247
+ break;
248
+ }
249
+ case "reverse":
250
+ case "coo":
251
+ case "edgeList":
252
+ case "mate":
253
+ throw new WebGpuGraphError("E_UNSUPPORTED", `the ${name} view is not uploaded before P7`, {
254
+ feature: `view:${name}`,
255
+ hint: "P1-P3 upload outDegree, inDegree, degreeOrder and reverseDegreeOrder",
256
+ });
257
+ default:
258
+ throw invalid("name", name, "a view name");
259
+ }
260
+ const record = this.ensureRecord(s);
261
+ const resident = this.upload(record, array, array, `residency:view:${record.serial}:${name}`);
262
+ const binding = { buffer: resident.buffer, offset: 0, size: resident.byteLength, window: null };
263
+ return Object.freeze({
264
+ view: name,
265
+ bindings: Object.freeze({ [bindingName]: binding }),
266
+ scalars: Object.freeze(scalars),
267
+ });
268
+ }
269
+ /**
270
+ * gpuView(name) + column.version; re-uploads in place when the version changed and the byte length did not
271
+ * (spec 4.3). CONTRACT DECISION: `owner` is required so release(owner) can find the buffer (a table has no
272
+ * back-reference to its snapshot). The key is the Column object (PLAN DECISION 8). E_GPU_INELIGIBLE and
273
+ * E_UNKNOWN_COLUMN from the format pass through unchanged.
274
+ * @param table - the table holding the column
275
+ * @param name - the column name
276
+ * @param owner - the snapshot the buffer is recorded against
277
+ * @returns the column binding
278
+ */
279
+ column(table, name, owner) {
280
+ this.assertLive();
281
+ assertAttached(owner);
282
+ this.assertNotReleased(owner);
283
+ const column = table.require(name);
284
+ const data = table.gpuView(name);
285
+ if (data.byteLength === 0) {
286
+ throw invalid("column", name, "a column with at least one row (zero-length arrays are never uploaded)");
287
+ }
288
+ const record = this.ensureRecord(owner);
289
+ const label = `residency:column:${record.serial}:${column.meta.domain}.${name}`;
290
+ const existing = this.residents.get(column);
291
+ let resident;
292
+ if (existing !== undefined &&
293
+ !existing.destroyed &&
294
+ existing.serial === record.serial &&
295
+ existing.byteLength === data.byteLength) {
296
+ resident = existing;
297
+ if (resident.version !== column.version) {
298
+ this.device.queue.writeBuffer(resident.buffer, 0, data);
299
+ resident.version = column.version;
300
+ }
301
+ }
302
+ else {
303
+ if (existing !== undefined) {
304
+ // the stale buffer stays in its record until release (spec 4.1: no leak, no stale read)
305
+ this.residents.delete(column);
306
+ }
307
+ resident = this.upload(record, column, data, label);
308
+ resident.version = column.version;
309
+ }
310
+ return Object.freeze({
311
+ binding: { buffer: resident.buffer, offset: 0, size: resident.byteLength, window: null },
312
+ column,
313
+ version: resident.version,
314
+ eligibility: column.gpu,
315
+ components: column.meta.components,
316
+ });
317
+ }
318
+ /**
319
+ * Any format array keyed on the object; registered against `owner` when given (spec 4.1).
320
+ * @param key - the array (a non-empty, 4-byte-multiple array over a plain ArrayBuffer)
321
+ * @param label - the buffer label suffix
322
+ * @param owner - the snapshot to record the buffer against, or undefined for a caller-owned buffer
323
+ * @returns the array binding; `destroy()` is idempotent (PLAN DECISION 12)
324
+ */
325
+ array(key, label, owner) {
326
+ this.assertLive();
327
+ if (key.byteLength === 0 || key.byteLength % 4 !== 0) {
328
+ throw invalid("key", key.byteLength, "a non-empty array whose byteLength is a multiple of 4");
329
+ }
330
+ if (isSharedBuffer(key.buffer)) {
331
+ throw invalid("key", "SharedArrayBuffer", "an array over a plain ArrayBuffer");
332
+ }
333
+ let record = null;
334
+ if (owner !== undefined) {
335
+ assertAttached(owner);
336
+ this.assertNotReleased(owner);
337
+ record = this.ensureRecord(owner);
338
+ }
339
+ const resident = this.upload(record, key, key, `residency:array:${label}`);
340
+ const binding = { buffer: resident.buffer, offset: 0, size: resident.byteLength, window: null };
341
+ return {
342
+ binding,
343
+ byteLength: resident.byteLength,
344
+ owner: owner ?? null,
345
+ destroy: () => {
346
+ this.destroyResident(resident, record);
347
+ },
348
+ };
349
+ }
350
+ /**
351
+ * Destroys every buffer recorded for s.serial (siblings included, Q-27) and tombstones the serial; idempotent
352
+ * (spec 4.5); safe on a snapshot never uploaded (nothing to tombstone, PLAN DECISION 7).
353
+ * @param s - the snapshot (or any withColumns() sibling)
354
+ */
355
+ release(s) {
356
+ const record = this.bySerial.get(s.serial);
357
+ if (record === undefined) {
358
+ return;
359
+ }
360
+ for (const resident of [...record.entries]) {
361
+ this.destroyResident(resident, record);
362
+ }
363
+ this.forget(record);
364
+ this.tombstones.add(s.serial);
365
+ }
366
+ /** Drops every record WITHOUT destroying (device lost: the buffers are gone). @internal */
367
+ clearOnLoss() {
368
+ for (const record of [...this.bySerial.values()]) {
369
+ for (const resident of record.entries) {
370
+ resident.destroyed = true;
371
+ if (this.residents.get(resident.key) === resident) {
372
+ this.residents.delete(resident.key);
373
+ }
374
+ }
375
+ record.entries.length = 0;
376
+ this.forget(record);
377
+ }
378
+ for (const resident of this.orphans) {
379
+ resident.destroyed = true;
380
+ if (this.residents.get(resident.key) === resident) {
381
+ this.residents.delete(resident.key);
382
+ }
383
+ }
384
+ this.orphans.clear();
385
+ this.liveCount = 0;
386
+ this.liveBytesValue = 0;
387
+ }
388
+ /** Destroys everything (ctx.dispose()); idempotent. @internal */
389
+ destroyAll() {
390
+ for (const record of [...this.bySerial.values()]) {
391
+ for (const resident of [...record.entries]) {
392
+ this.destroyResident(resident, record);
393
+ }
394
+ this.forget(record);
395
+ }
396
+ for (const resident of [...this.orphans]) {
397
+ this.destroyResident(resident, null);
398
+ }
399
+ this.disposed = true;
400
+ }
401
+ /**
402
+ * The resident buffers, bytes and snapshots (spec 4.1).
403
+ * @returns the statistics
404
+ */
405
+ stats() {
406
+ const perSnapshot = [...this.bySerial.values()].map((record) => ({
407
+ serial: record.serial,
408
+ label: record.label,
409
+ bytes: record.entries.reduce((sum, resident) => sum + resident.byteLength, 0),
410
+ buffers: record.entries.length,
411
+ }));
412
+ return { buffers: this.liveCount, bytes: this.liveBytesValue, snapshots: this.bySerial.size, perSnapshot };
413
+ }
414
+ /**
415
+ * Bytes of every resident buffer (graft: C R-18).
416
+ * @returns the resident byte count
417
+ */
418
+ get residentBytes() {
419
+ return this.liveBytesValue;
420
+ }
421
+ /**
422
+ * True when the serial was released and not re-uploaded. @internal
423
+ * @param serial - a snapshot serial
424
+ * @returns whether a live user holding bindings of that serial must stop
425
+ */
426
+ isReleased(serial) {
427
+ return this.tombstones.has(serial);
428
+ }
429
+ /**
430
+ * Binds one core array: a segment of the arena buffer when the buffer holds it, else its own buffer keyed on
431
+ * the array object (the cold-segment-on-demand path of spec 4.2, and the whole perArray path).
432
+ * @param record - the snapshot's record
433
+ * @param s - the snapshot
434
+ * @param name - a PRESENT core array
435
+ * @returns the binding
436
+ */
437
+ bindCore(record, s, name) {
438
+ if (record.arena !== null) {
439
+ const segment = record.arena.segments[name];
440
+ if (segment !== null) {
441
+ return { buffer: record.arena.buffer, offset: segment.offset, size: segment.size, window: null };
442
+ }
443
+ }
444
+ const array = coreArray(s, name);
445
+ const resident = this.upload(record, array, array, `residency:core:${record.serial}:${name}`);
446
+ return { buffer: resident.buffer, offset: 0, size: resident.byteLength, window: null };
447
+ }
448
+ /**
449
+ * Uploads `data` into a new buffer keyed on `key`, or returns the resident already uploaded for that key by
450
+ * the same owner (PLAN DECISION 11: a resident belongs to one record).
451
+ * @param record - the owning record, or null for an owner-less array
452
+ * @param key - the object the buffer is keyed on
453
+ * @param data - the bytes (byteLength a multiple of 4, graph-format invariant I10; a view over a plain
454
+ * ArrayBuffer, which is what writeBuffer's GPUAllowSharedBufferSource accepts under @webgpu/types 0.1.72)
455
+ * @param label - the buffer label
456
+ * @returns the resident
457
+ */
458
+ upload(record, key, data, label) {
459
+ const serial = record === null ? null : record.serial;
460
+ const existing = this.residents.get(key);
461
+ if (existing !== undefined && !existing.destroyed && existing.serial === serial) {
462
+ return existing;
463
+ }
464
+ const buffer = this.allocator.createBuffer({ label, size: data.byteLength, usage: RESIDENT_USAGE });
465
+ this.device.queue.writeBuffer(buffer, 0, data);
466
+ const resident = { key, buffer, byteLength: data.byteLength, serial, version: 0, destroyed: false };
467
+ this.residents.set(key, resident);
468
+ if (record === null) {
469
+ this.orphans.add(resident);
470
+ }
471
+ else {
472
+ record.entries.push(resident);
473
+ }
474
+ this.liveCount++;
475
+ this.liveBytesValue += data.byteLength;
476
+ return resident;
477
+ }
478
+ /**
479
+ * Destroys one resident buffer and unregisters it; idempotent.
480
+ * @param resident - the resident
481
+ * @param record - its owning record, or null for an orphan
482
+ */
483
+ destroyResident(resident, record) {
484
+ if (resident.destroyed) {
485
+ return;
486
+ }
487
+ resident.destroyed = true;
488
+ this.allocator.destroy(resident.buffer);
489
+ if (this.residents.get(resident.key) === resident) {
490
+ this.residents.delete(resident.key);
491
+ }
492
+ if (record === null) {
493
+ this.orphans.delete(resident);
494
+ }
495
+ else {
496
+ const index = record.entries.indexOf(resident);
497
+ if (index >= 0) {
498
+ record.entries.splice(index, 1);
499
+ }
500
+ }
501
+ this.liveCount--;
502
+ this.liveBytesValue -= resident.byteLength;
503
+ }
504
+ /**
505
+ * Marks a record released and drops it from the serial map (the snapshot WeakMap entries recognise it by the flag).
506
+ * @param record - the record
507
+ */
508
+ forget(record) {
509
+ record.released = true;
510
+ record.bindings.clear();
511
+ record.arena = null;
512
+ record.plan = null;
513
+ this.bySerial.delete(record.serial);
514
+ }
515
+ /**
516
+ * The record of a snapshot's serial, created when absent (which lifts a tombstone and may fire the warning).
517
+ * @param s - the snapshot
518
+ * @returns the record
519
+ */
520
+ ensureRecord(s) {
521
+ let record = this.records.get(s);
522
+ if (record !== undefined && record.released) {
523
+ record = undefined;
524
+ }
525
+ if (record === undefined) {
526
+ record = this.bySerial.get(s.serial);
527
+ }
528
+ if (record === undefined) {
529
+ record = {
530
+ serial: s.serial,
531
+ label: s.label,
532
+ entries: [],
533
+ plan: null,
534
+ arena: null,
535
+ bindings: new Map(),
536
+ released: false,
537
+ };
538
+ this.bySerial.set(s.serial, record);
539
+ this.tombstones.delete(s.serial);
540
+ if (!this.warned && this.bySerial.size > this.warnUnreleasedSnapshots) {
541
+ this.warned = true;
542
+ this.warn(`[webgpu-graph-algorithms] ${this.bySerial.size} snapshots are resident on the device (warnUnreleasedSnapshots = ${this.warnUnreleasedSnapshots}); call ctx.release(snapshot) for superseded snapshots -- GPU memory is never freed by garbage collection (spec 4.1)`);
543
+ }
544
+ }
545
+ this.records.set(s, record);
546
+ return record;
547
+ }
548
+ /**
549
+ * Throws E_RELEASED for a tombstoned serial (a bind without a fresh core()).
550
+ * @param s - the snapshot
551
+ */
552
+ assertNotReleased(s) {
553
+ if (this.tombstones.has(s.serial)) {
554
+ throw new WebGpuGraphError("E_RELEASED", `snapshot ${s.serial} was released; upload it again through core() before binding views, columns or arrays`, { serial: s.serial });
555
+ }
556
+ }
557
+ /**
558
+ * Throws E_INVALID_ARGUMENT for an empty snapshot (a view of it would be a zero-length array, spec 5.6).
559
+ * @param s - the snapshot
560
+ */
561
+ assertNonEmpty(s) {
562
+ if (s.nodeCount === 0) {
563
+ throw invalid("snapshot", 0, "nodeCount > 0 (an empty snapshot has no per-node view to upload)");
564
+ }
565
+ }
566
+ /** Throws E_DISPOSED after destroyAll() (PLAN DECISION 13). */
567
+ assertLive() {
568
+ if (this.disposed) {
569
+ throw new WebGpuGraphError("E_DISPOSED", "the residency was disposed", { label: "residency" });
570
+ }
571
+ }
572
+ }
573
+ //# sourceMappingURL=residency.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"residency.js","sourceRoot":"","sources":["../../../src/memory/residency.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAYH,OAAO,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AAC5D,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAGhD,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C,kHAAkH;AAClH,MAAM,YAAY,GAA6B,MAAM,CAAC,MAAM,CAAC,CAAC,QAAQ,EAAE,QAAQ,EAAE,SAAS,CAAC,C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