@luma.gl/graph 10.0.0-beta.3 → 10.0.0-beta.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/arrow/gpu/arrow-gpu-table-conversion.cjs +66 -30
- package/dist/arrow/gpu/arrow-gpu-table-conversion.d.ts +7 -1
- package/dist/arrow/gpu/arrow-gpu-table-conversion.d.ts.map +1 -1
- package/dist/arrow/gpu/arrow-gpu-table-conversion.js +78 -32
- package/dist/arrow/gpu/arrow-gpu-table-conversion.js.map +1 -1
- package/dist/arrow/gpu/arrow-gpu-vector-conversion.cjs +7 -0
- package/dist/arrow/gpu/arrow-gpu-vector-conversion.d.ts +2 -0
- package/dist/arrow/gpu/arrow-gpu-vector-conversion.d.ts.map +1 -1
- package/dist/arrow/gpu/arrow-gpu-vector-conversion.js +14 -0
- package/dist/arrow/gpu/arrow-gpu-vector-conversion.js.map +1 -1
- package/dist/arrow/index.cjs.map +2 -2
- package/dist/arrow/vectors/arrow-temporal-gpu-vector.cjs +1 -2
- package/dist/arrow/vectors/arrow-temporal-gpu-vector.js +2 -2
- package/dist/arrow/vectors/arrow-temporal-gpu-vector.js.map +1 -1
- package/dist/dist.dev.js +62 -27
- package/dist/dist.min.js +48 -47
- package/dist/gpu-core/gpu-command-graph-budget-controller.cjs +10 -2
- package/dist/gpu-core/gpu-command-graph-budget-controller.d.ts +4 -0
- package/dist/gpu-core/gpu-command-graph-budget-controller.d.ts.map +1 -1
- package/dist/gpu-core/gpu-command-graph-budget-controller.js +10 -2
- package/dist/gpu-core/gpu-command-graph-budget-controller.js.map +1 -1
- package/dist/gpu-core/gpu-group-aggregation.cjs +45 -21
- package/dist/gpu-core/gpu-group-aggregation.d.ts +4 -0
- package/dist/gpu-core/gpu-group-aggregation.d.ts.map +1 -1
- package/dist/gpu-core/gpu-group-aggregation.js +58 -24
- package/dist/gpu-core/gpu-group-aggregation.js.map +1 -1
- package/dist/gpu-core/index.cjs.map +1 -1
- package/dist/gpu-dataframe/gpu-global-aggregation-compiler.cjs +6 -2
- package/dist/gpu-dataframe/gpu-global-aggregation-compiler.d.ts +2 -1
- package/dist/gpu-dataframe/gpu-global-aggregation-compiler.d.ts.map +1 -1
- package/dist/gpu-dataframe/gpu-global-aggregation-compiler.js +6 -2
- package/dist/gpu-dataframe/gpu-global-aggregation-compiler.js.map +1 -1
- package/dist/gpu-dataframe/gpu-global-sort-compiler.cjs +61 -54
- package/dist/gpu-dataframe/gpu-global-sort-compiler.d.ts +6 -1
- package/dist/gpu-dataframe/gpu-global-sort-compiler.d.ts.map +1 -1
- package/dist/gpu-dataframe/gpu-global-sort-compiler.js +61 -55
- package/dist/gpu-dataframe/gpu-global-sort-compiler.js.map +1 -1
- package/dist/gpu-dataframe/gpu-group-aggregation-compiler.cjs +88 -13
- package/dist/gpu-dataframe/gpu-group-aggregation-compiler.d.ts +11 -4
- package/dist/gpu-dataframe/gpu-group-aggregation-compiler.d.ts.map +1 -1
- package/dist/gpu-dataframe/gpu-group-aggregation-compiler.js +96 -16
- package/dist/gpu-dataframe/gpu-group-aggregation-compiler.js.map +1 -1
- package/dist/gpu-dataframe/gpu-group-by-query.cjs +12 -3
- package/dist/gpu-dataframe/gpu-group-by-query.d.ts +8 -1
- package/dist/gpu-dataframe/gpu-group-by-query.d.ts.map +1 -1
- package/dist/gpu-dataframe/gpu-group-by-query.js +13 -3
- package/dist/gpu-dataframe/gpu-group-by-query.js.map +1 -1
- package/dist/gpu-dataframe/gpu-join-compiler.cjs +53 -2
- package/dist/gpu-dataframe/gpu-join-compiler.d.ts +9 -1
- package/dist/gpu-dataframe/gpu-join-compiler.d.ts.map +1 -1
- package/dist/gpu-dataframe/gpu-join-compiler.js +51 -0
- package/dist/gpu-dataframe/gpu-join-compiler.js.map +1 -1
- package/dist/gpu-dataframe/gpu-query-compiler.cjs +24 -0
- package/dist/gpu-dataframe/gpu-query-compiler.d.ts +3 -1
- package/dist/gpu-dataframe/gpu-query-compiler.d.ts.map +1 -1
- package/dist/gpu-dataframe/gpu-query-compiler.js +25 -0
- package/dist/gpu-dataframe/gpu-query-compiler.js.map +1 -1
- package/dist/gpu-dataframe/index.cjs.map +3 -3
- package/dist/gpu-graph/index.cjs.map +1 -1
- package/dist/gpu-graph-algorithms/benchmarks.cjs.map +2 -2
- package/dist/gpu-graph-algorithms/gpu-graph-single-source-shortest-path-internals.cjs +182 -62
- package/dist/gpu-graph-algorithms/gpu-graph-single-source-shortest-path-internals.d.ts +29 -2
- package/dist/gpu-graph-algorithms/gpu-graph-single-source-shortest-path-internals.d.ts.map +1 -1
- package/dist/gpu-graph-algorithms/gpu-graph-single-source-shortest-path-internals.js +200 -64
- package/dist/gpu-graph-algorithms/gpu-graph-single-source-shortest-path-internals.js.map +1 -1
- package/dist/gpu-graph-algorithms/gpu-graph-single-source-shortest-path.cjs +135 -9
- package/dist/gpu-graph-algorithms/gpu-graph-single-source-shortest-path.d.ts +55 -8
- package/dist/gpu-graph-algorithms/gpu-graph-single-source-shortest-path.d.ts.map +1 -1
- package/dist/gpu-graph-algorithms/gpu-graph-single-source-shortest-path.js +145 -14
- package/dist/gpu-graph-algorithms/gpu-graph-single-source-shortest-path.js.map +1 -1
- package/dist/gpu-graph-algorithms/index.cjs.map +3 -3
- package/dist/gpu-physics/articulation-tree-shader.cjs +177 -0
- package/dist/gpu-physics/articulation-tree-shader.d.ts +3 -0
- package/dist/gpu-physics/articulation-tree-shader.d.ts.map +1 -0
- package/dist/gpu-physics/articulation-tree-shader.js +159 -0
- package/dist/gpu-physics/articulation-tree-shader.js.map +1 -0
- package/dist/gpu-physics/gpu-articulation-tree.cjs +203 -0
- package/dist/gpu-physics/gpu-articulation-tree.d.ts +81 -0
- package/dist/gpu-physics/gpu-articulation-tree.d.ts.map +1 -0
- package/dist/gpu-physics/gpu-articulation-tree.js +205 -0
- package/dist/gpu-physics/gpu-articulation-tree.js.map +1 -0
- package/dist/gpu-physics/gpu-rigid-body-world.cjs +62 -0
- package/dist/gpu-physics/gpu-rigid-body-world.d.ts +12 -0
- package/dist/gpu-physics/gpu-rigid-body-world.d.ts.map +1 -1
- package/dist/gpu-physics/gpu-rigid-body-world.js +76 -0
- package/dist/gpu-physics/gpu-rigid-body-world.js.map +1 -1
- package/dist/gpu-physics/index.cjs +3 -0
- package/dist/gpu-physics/index.cjs.map +3 -3
- package/dist/gpu-physics/index.d.ts +1 -0
- package/dist/gpu-physics/index.d.ts.map +1 -1
- package/dist/gpu-physics/index.js +1 -0
- package/dist/gpu-physics/index.js.map +1 -1
- package/dist/gpu-physics/rigid-body-joints.d.ts +2 -0
- package/dist/gpu-physics/rigid-body-joints.d.ts.map +1 -1
- package/dist/gpu-physics/rigid-body-joints.js.map +1 -1
- package/dist/gpu-project/graph.cjs.map +2 -2
- package/dist/gpu-simple-graph/index.cjs.map +2 -2
- package/dist/gpu-sql/gpu-sql.cjs +167 -47
- package/dist/gpu-sql/gpu-sql.d.ts +6 -1
- package/dist/gpu-sql/gpu-sql.d.ts.map +1 -1
- package/dist/gpu-sql/gpu-sql.js +187 -47
- package/dist/gpu-sql/gpu-sql.js.map +1 -1
- package/dist/gpu-sql/index.cjs.map +3 -3
- package/dist/index.cjs.map +1 -1
- package/package.json +8 -8
- package/src/arrow/gpu/arrow-gpu-table-conversion.ts +94 -40
- package/src/arrow/gpu/arrow-gpu-vector-conversion.ts +19 -0
- package/src/arrow/vectors/arrow-temporal-gpu-vector.ts +2 -2
- package/src/gpu-core/gpu-command-graph-budget-controller.ts +22 -2
- package/src/gpu-core/gpu-group-aggregation.ts +68 -30
- package/src/gpu-dataframe/gpu-global-aggregation-compiler.ts +9 -2
- package/src/gpu-dataframe/gpu-global-sort-compiler.ts +95 -78
- package/src/gpu-dataframe/gpu-group-aggregation-compiler.ts +191 -24
- package/src/gpu-dataframe/gpu-group-by-query.ts +27 -4
- package/src/gpu-dataframe/gpu-join-compiler.ts +75 -0
- package/src/gpu-dataframe/gpu-query-compiler.ts +41 -1
- package/src/gpu-graph-algorithms/README.md +4 -2
- package/src/gpu-graph-algorithms/gpu-graph-single-source-shortest-path-internals.ts +248 -66
- package/src/gpu-graph-algorithms/gpu-graph-single-source-shortest-path.ts +218 -20
- package/src/gpu-physics/articulation-tree-shader.ts +169 -0
- package/src/gpu-physics/gpu-articulation-tree.ts +279 -0
- package/src/gpu-physics/gpu-rigid-body-world.ts +89 -0
- package/src/gpu-physics/index.ts +7 -0
- package/src/gpu-physics/rigid-body-joints.ts +2 -0
- package/src/gpu-sql/gpu-sql.ts +248 -57
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "10.0.0-beta.
|
|
6
|
+
"version": "10.0.0-beta.4",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"license": "MIT",
|
|
9
9
|
"repository": {
|
|
@@ -242,8 +242,8 @@
|
|
|
242
242
|
}
|
|
243
243
|
},
|
|
244
244
|
"peerDependencies": {
|
|
245
|
-
"@luma.gl/core": "~10.0.0-beta.
|
|
246
|
-
"@luma.gl/shaders": "~10.0.0-beta.
|
|
245
|
+
"@luma.gl/core": "~10.0.0-beta.4",
|
|
246
|
+
"@luma.gl/shaders": "~10.0.0-beta.4",
|
|
247
247
|
"apache-arrow": ">=17.0.0"
|
|
248
248
|
},
|
|
249
249
|
"peerDependenciesMeta": {
|
|
@@ -252,11 +252,11 @@
|
|
|
252
252
|
}
|
|
253
253
|
},
|
|
254
254
|
"dependencies": {
|
|
255
|
-
"@math.gl/core": "^5.0.
|
|
256
|
-
"@math.gl/geometry": "^5.0.
|
|
257
|
-
"@math.gl/geospatial": "^5.0.
|
|
258
|
-
"@math.gl/sql": "^5.0.
|
|
255
|
+
"@math.gl/core": "^5.0.3",
|
|
256
|
+
"@math.gl/geometry": "^5.0.3",
|
|
257
|
+
"@math.gl/geospatial": "^5.0.3",
|
|
258
|
+
"@math.gl/sql": "^5.0.3",
|
|
259
259
|
"probe.gl": "^5.0.0"
|
|
260
260
|
},
|
|
261
|
-
"gitHead": "
|
|
261
|
+
"gitHead": "1b38b0a1eff208ee761dd6b201274b726288f3a8"
|
|
262
262
|
}
|
|
@@ -44,6 +44,8 @@ export type ArrowGPUTableConversionPlan = {
|
|
|
44
44
|
length: number;
|
|
45
45
|
/** Aggregate cost across selected columns. */
|
|
46
46
|
cost: ArrowGPUConversionCost;
|
|
47
|
+
/** Estimated peak retained and temporary GPU bytes while converting columns serially. */
|
|
48
|
+
estimatedPeakGPUBytes: number;
|
|
47
49
|
};
|
|
48
50
|
|
|
49
51
|
/** Prepared generic GPU table plus its inspectable conversion plan. */
|
|
@@ -70,6 +72,10 @@ export type ArrowRecordBatchConversionOptions = {
|
|
|
70
72
|
signal?: AbortSignal;
|
|
71
73
|
/** Maximum estimated GPU payload bytes per batch. Checked before conversion. */
|
|
72
74
|
maxBatchPayloadBytes?: number;
|
|
75
|
+
/** Maximum estimated peak GPU bytes per batch, including conversion scratch. */
|
|
76
|
+
maxBatchGPUBytes?: number;
|
|
77
|
+
/** Split an oversized batch into contiguous rows before uploading. Defaults to false. */
|
|
78
|
+
splitOversizedBatches?: boolean;
|
|
73
79
|
};
|
|
74
80
|
|
|
75
81
|
/** One independently owned GPU record batch produced from an Arrow stream. */
|
|
@@ -108,7 +114,8 @@ export function planArrowTableGPUConversion(
|
|
|
108
114
|
return {
|
|
109
115
|
columns,
|
|
110
116
|
length: table.numRows,
|
|
111
|
-
cost: sumConversionCosts(columns.map(column => column.plan.cost))
|
|
117
|
+
cost: sumConversionCosts(columns.map(column => column.plan.cost)),
|
|
118
|
+
estimatedPeakGPUBytes: estimatePeakGPUBytes(columns)
|
|
112
119
|
};
|
|
113
120
|
}
|
|
114
121
|
|
|
@@ -231,7 +238,12 @@ export async function* convertArrowRecordBatchesToGPURecordBatches(
|
|
|
231
238
|
device: Device,
|
|
232
239
|
source: ArrowRecordBatchConversionSource,
|
|
233
240
|
schema: ArrowGPUTableConversionSchema,
|
|
234
|
-
{
|
|
241
|
+
{
|
|
242
|
+
signal,
|
|
243
|
+
maxBatchPayloadBytes,
|
|
244
|
+
maxBatchGPUBytes,
|
|
245
|
+
splitOversizedBatches
|
|
246
|
+
}: ArrowRecordBatchConversionOptions = {}
|
|
235
247
|
): AsyncGenerator<PreparedArrowGPURecordBatch> {
|
|
236
248
|
if (
|
|
237
249
|
maxBatchPayloadBytes !== undefined &&
|
|
@@ -239,52 +251,79 @@ export async function* convertArrowRecordBatchesToGPURecordBatches(
|
|
|
239
251
|
) {
|
|
240
252
|
throw new Error('Arrow GPU stream payload budget must be a nonnegative safe integer');
|
|
241
253
|
}
|
|
254
|
+
if (
|
|
255
|
+
maxBatchGPUBytes !== undefined &&
|
|
256
|
+
(!Number.isSafeInteger(maxBatchGPUBytes) || maxBatchGPUBytes < 0)
|
|
257
|
+
) {
|
|
258
|
+
throw new Error('Arrow GPU stream peak budget must be a nonnegative safe integer');
|
|
259
|
+
}
|
|
242
260
|
const temporalOrigins = new Map<string, number | bigint>();
|
|
243
261
|
const formats = new Map<string, string | undefined>();
|
|
244
262
|
let sourceBatchIndex = 0;
|
|
245
263
|
let sourceRowIndexOffset = 0;
|
|
246
264
|
for await (const recordBatch of iterateRecordBatches(source, signal)) {
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
columns: schema.columns.map(column => {
|
|
250
|
-
const origin = temporalOrigins.get(column.name);
|
|
251
|
-
return origin === undefined || column.temporal?.origin !== undefined
|
|
252
|
-
? column
|
|
253
|
-
: {...column, temporal: {...column.temporal, origin}};
|
|
254
|
-
})
|
|
255
|
-
};
|
|
256
|
-
if (maxBatchPayloadBytes !== undefined) {
|
|
257
|
-
const {cost} = planArrowTableGPUConversion(device, new Table([recordBatch]), batchSchema);
|
|
258
|
-
if (cost.targetByteLength > maxBatchPayloadBytes) {
|
|
259
|
-
throw new Error(
|
|
260
|
-
`Arrow GPU stream batch ${sourceBatchIndex} needs ${cost.targetByteLength} payload bytes, exceeding the ${maxBatchPayloadBytes} byte budget`
|
|
261
|
-
);
|
|
262
|
-
}
|
|
263
|
-
}
|
|
264
|
-
const prepared = await convertArrowRecordBatchToGPURecordBatch(
|
|
265
|
-
device,
|
|
266
|
-
recordBatch,
|
|
267
|
-
batchSchema,
|
|
268
|
-
{sourceBatchIndex, sourceRowIndexOffset}
|
|
269
|
-
);
|
|
270
|
-
try {
|
|
265
|
+
let rowOffset = 0;
|
|
266
|
+
do {
|
|
271
267
|
signal?.throwIfAborted();
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
268
|
+
const batchSchema: ArrowGPUTableConversionSchema = {
|
|
269
|
+
columns: schema.columns.map(column => {
|
|
270
|
+
const origin = temporalOrigins.get(column.name);
|
|
271
|
+
return origin === undefined || column.temporal?.origin !== undefined
|
|
272
|
+
? column
|
|
273
|
+
: {...column, temporal: {...column.temporal, origin}};
|
|
274
|
+
})
|
|
275
|
+
};
|
|
276
|
+
let slice = rowOffset === 0 ? recordBatch : recordBatch.slice(rowOffset);
|
|
277
|
+
if (maxBatchPayloadBytes !== undefined || maxBatchGPUBytes !== undefined) {
|
|
278
|
+
while (true) {
|
|
279
|
+
const plan = planArrowTableGPUConversion(device, new Table([slice]), batchSchema);
|
|
280
|
+
const payload = plan.cost.targetByteLength;
|
|
281
|
+
const peak = plan.estimatedPeakGPUBytes;
|
|
282
|
+
const exceedsPayload =
|
|
283
|
+
maxBatchPayloadBytes !== undefined && payload > maxBatchPayloadBytes;
|
|
284
|
+
const exceedsPeak = maxBatchGPUBytes !== undefined && peak > maxBatchGPUBytes;
|
|
285
|
+
if (!exceedsPayload && !exceedsPeak) break;
|
|
286
|
+
if (!splitOversizedBatches || slice.numRows <= 1) {
|
|
287
|
+
const location = splitOversizedBatches ? ' at row ' + sourceRowIndexOffset : '';
|
|
288
|
+
const requirement = exceedsPayload
|
|
289
|
+
? payload + ' payload bytes, exceeding the ' + maxBatchPayloadBytes
|
|
290
|
+
: 'an estimated ' + peak + ' peak GPU bytes, exceeding the ' + maxBatchGPUBytes;
|
|
291
|
+
throw new Error(
|
|
292
|
+
'Arrow GPU stream batch ' +
|
|
293
|
+
sourceBatchIndex +
|
|
294
|
+
location +
|
|
295
|
+
' needs ' +
|
|
296
|
+
requirement +
|
|
297
|
+
' byte budget'
|
|
298
|
+
);
|
|
299
|
+
}
|
|
300
|
+
slice = recordBatch.slice(rowOffset, rowOffset + Math.floor(slice.numRows / 2));
|
|
278
301
|
}
|
|
279
|
-
formats.set(name, vector.format);
|
|
280
302
|
}
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
303
|
+
const prepared = await convertArrowRecordBatchToGPURecordBatch(device, slice, batchSchema, {
|
|
304
|
+
sourceBatchIndex,
|
|
305
|
+
sourceRowIndexOffset
|
|
306
|
+
});
|
|
307
|
+
try {
|
|
308
|
+
signal?.throwIfAborted();
|
|
309
|
+
for (const [name, vector] of Object.entries(prepared.vectors)) {
|
|
310
|
+
const expected = formats.get(name);
|
|
311
|
+
if (formats.has(name) && vector.format !== expected) {
|
|
312
|
+
throw new Error(
|
|
313
|
+
`Arrow stream column "${name}" format changed: ${expected} -> ${vector.format}`
|
|
314
|
+
);
|
|
315
|
+
}
|
|
316
|
+
formats.set(name, vector.format);
|
|
317
|
+
}
|
|
318
|
+
captureStreamingTemporalOrigins(slice, schema, prepared.batch, temporalOrigins);
|
|
319
|
+
} catch (error) {
|
|
320
|
+
prepared.destroy();
|
|
321
|
+
throw error;
|
|
322
|
+
}
|
|
323
|
+
yield prepared;
|
|
324
|
+
sourceRowIndexOffset += slice.numRows;
|
|
325
|
+
rowOffset += slice.numRows;
|
|
326
|
+
} while (rowOffset < recordBatch.numRows);
|
|
288
327
|
sourceBatchIndex++;
|
|
289
328
|
}
|
|
290
329
|
}
|
|
@@ -376,11 +415,25 @@ function captureStreamingTemporalOrigins(
|
|
|
376
415
|
}
|
|
377
416
|
}
|
|
378
417
|
|
|
418
|
+
/** Estimates peak bytes from previously retained outputs and one active column conversion. */
|
|
419
|
+
function estimatePeakGPUBytes(columns: ArrowGPUTableConversionPlan['columns']): number {
|
|
420
|
+
let retained = 0;
|
|
421
|
+
let peak = 0;
|
|
422
|
+
for (const {plan} of columns) {
|
|
423
|
+
if (!plan.cost.allocatesGPUStorage) continue;
|
|
424
|
+
// Reserve padding and minimum-sized allocations for each destination chunk.
|
|
425
|
+
retained += plan.cost.targetByteLength + plan.chunkCount * 8;
|
|
426
|
+
peak = Math.max(peak, retained + plan.cost.temporaryGPUByteLength);
|
|
427
|
+
}
|
|
428
|
+
return peak;
|
|
429
|
+
}
|
|
430
|
+
|
|
379
431
|
function sumConversionCosts(costs: readonly ArrowGPUConversionCost[]): ArrowGPUConversionCost {
|
|
380
432
|
return costs.reduce<ArrowGPUConversionCost>(
|
|
381
433
|
(sum, cost) => ({
|
|
382
434
|
sourceByteLength: sum.sourceByteLength + cost.sourceByteLength,
|
|
383
435
|
targetByteLength: sum.targetByteLength + cost.targetByteLength,
|
|
436
|
+
temporaryGPUByteLength: sum.temporaryGPUByteLength + cost.temporaryGPUByteLength,
|
|
384
437
|
uploadCount: sum.uploadCount + cost.uploadCount,
|
|
385
438
|
cpuPassCount: sum.cpuPassCount + cost.cpuPassCount,
|
|
386
439
|
gpuPassCount: sum.gpuPassCount + cost.gpuPassCount,
|
|
@@ -389,6 +442,7 @@ function sumConversionCosts(costs: readonly ArrowGPUConversionCost[]): ArrowGPUC
|
|
|
389
442
|
{
|
|
390
443
|
sourceByteLength: 0,
|
|
391
444
|
targetByteLength: 0,
|
|
445
|
+
temporaryGPUByteLength: 0,
|
|
392
446
|
uploadCount: 0,
|
|
393
447
|
cpuPassCount: 0,
|
|
394
448
|
gpuPassCount: 0,
|
|
@@ -95,6 +95,8 @@ export type ArrowGPUConversionCost = {
|
|
|
95
95
|
sourceByteLength: number;
|
|
96
96
|
/** Bytes expected in the prepared GPU payload, excluding auxiliary metadata. */
|
|
97
97
|
targetByteLength: number;
|
|
98
|
+
/** Estimated transient GPU source and configuration storage during conversion. */
|
|
99
|
+
temporaryGPUByteLength: number;
|
|
98
100
|
/** Number of Arrow chunks that must be uploaded. */
|
|
99
101
|
uploadCount: number;
|
|
100
102
|
/** Number of CPU transformation passes over source values. */
|
|
@@ -201,6 +203,8 @@ export function planArrowGPUConversion(
|
|
|
201
203
|
validateConversionNullability(source, semantic);
|
|
202
204
|
|
|
203
205
|
const chunkCount = getSourceChunkCount(source);
|
|
206
|
+
const temporalInfo =
|
|
207
|
+
semantic === 'temporal' ? getArrowTemporalVectorInfo(source, options.field) : undefined;
|
|
204
208
|
const sourceByteLength = getSourceByteLength(source);
|
|
205
209
|
const backend = resolveConversionBackend(device, strategy, source, options.policy ?? 'auto');
|
|
206
210
|
const targetByteLength =
|
|
@@ -208,6 +212,16 @@ export function planArrowGPUConversion(
|
|
|
208
212
|
(backend === 'webgpu' && source instanceof Vector && isArrowFloat64NumericType(source.type)
|
|
209
213
|
? 2
|
|
210
214
|
: 1);
|
|
215
|
+
const temporarySourceBytes =
|
|
216
|
+
temporalInfo && source instanceof Vector
|
|
217
|
+
? source.data.reduce((total, chunk) => {
|
|
218
|
+
const offsets = DataType.isList(chunk.type)
|
|
219
|
+
? (chunk.valueOffsets as Int32Array)
|
|
220
|
+
: undefined;
|
|
221
|
+
const values = offsets ? offsets[chunk.length] - offsets[0] : chunk.length;
|
|
222
|
+
return total + Math.max(4, (values * temporalInfo.bitWidth) / 8);
|
|
223
|
+
}, 0)
|
|
224
|
+
: Math.max(sourceByteLength, chunkCount * Float64Array.BYTES_PER_ELEMENT);
|
|
211
225
|
const transforms = strategy.startsWith('convert-');
|
|
212
226
|
const sourceIsArrow = source instanceof Vector;
|
|
213
227
|
const uploadCount = sourceIsArrow ? chunkCount : 0;
|
|
@@ -226,6 +240,11 @@ export function planArrowGPUConversion(
|
|
|
226
240
|
cost: {
|
|
227
241
|
sourceByteLength,
|
|
228
242
|
targetByteLength,
|
|
243
|
+
temporaryGPUByteLength:
|
|
244
|
+
sourceIsArrow && backend === 'webgpu'
|
|
245
|
+
? temporarySourceBytes +
|
|
246
|
+
(strategy === 'convert-temporal' ? chunkCount * 3 * Uint32Array.BYTES_PER_ELEMENT : 0)
|
|
247
|
+
: 0,
|
|
229
248
|
uploadCount,
|
|
230
249
|
cpuPassCount: transforms && backend === 'cpu' ? 1 : 0,
|
|
231
250
|
gpuPassCount: transforms && (backend === 'webgpu' || backend === 'webgl') ? 1 : 0,
|
|
@@ -716,8 +716,8 @@ function getArrowTemporalScalarDataBufferSource(
|
|
|
716
716
|
if (!values) {
|
|
717
717
|
return data.type.ArrayType === BigInt64Array ? new BigInt64Array(0) : new Int32Array(0);
|
|
718
718
|
}
|
|
719
|
-
|
|
720
|
-
return values.subarray(
|
|
719
|
+
// Arrow slices fixed-width values directly; the row offset still applies to the null bitmap.
|
|
720
|
+
return values.subarray(0, data.length) as Int32Array | BigInt64Array;
|
|
721
721
|
}
|
|
722
722
|
|
|
723
723
|
function getNormalizedArrowValueOffsets(data: Data<List<any>>): Int32Array {
|
|
@@ -123,9 +123,29 @@ export class GPUCommandGraphExecutionBudgetController {
|
|
|
123
123
|
/** Budget used to create the immutable execution that produced this step. */
|
|
124
124
|
executionBudget: Readonly<GPUCommandGraphExecutionBudget> = this.currentBudget
|
|
125
125
|
): GPUCommandGraphExecutionBudgetObservation {
|
|
126
|
-
validatePositiveNumber(durationMilliseconds, 'durationMilliseconds');
|
|
127
126
|
validateExecutionBudget(executionBudget);
|
|
128
|
-
|
|
127
|
+
return this.observeSaturation(getBudgetSaturation(step, executionBudget), durationMilliseconds);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/** Calibrates an application-sized dispatch using GPU time and its observed invocation count. */
|
|
131
|
+
observeInvocations(
|
|
132
|
+
invocationCount: number,
|
|
133
|
+
durationMilliseconds: number,
|
|
134
|
+
executionBudget: Readonly<GPUCommandGraphExecutionBudget> = this.currentBudget
|
|
135
|
+
): GPUCommandGraphExecutionBudgetObservation {
|
|
136
|
+
validateExecutionBudget(executionBudget);
|
|
137
|
+
return this.observeSaturation(
|
|
138
|
+
invocationCount / executionBudget.maximumInvocationCount,
|
|
139
|
+
durationMilliseconds
|
|
140
|
+
);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/** Updates the next execution budget from one completed workload observation. */
|
|
144
|
+
private observeSaturation(
|
|
145
|
+
saturation: number,
|
|
146
|
+
durationMilliseconds: number
|
|
147
|
+
): GPUCommandGraphExecutionBudgetObservation {
|
|
148
|
+
validatePositiveNumber(durationMilliseconds, 'durationMilliseconds');
|
|
129
149
|
if (saturation > 0) {
|
|
130
150
|
const desiredAdjustment =
|
|
131
151
|
(this.targetStepMilliseconds * Math.min(saturation, 1)) / durationMilliseconds;
|
|
@@ -58,6 +58,8 @@ type GPUGroupAggregationBaseProps = {
|
|
|
58
58
|
keys: GPUGroupAggregationKeys;
|
|
59
59
|
/** Optional nonzero/zero selection with the same logical length as `keys`; chunk boundaries may differ. */
|
|
60
60
|
mask?: GPUGroupAggregationMask;
|
|
61
|
+
/** Upper bound on mean count scratch, in bytes. Partitions the output key domain. */
|
|
62
|
+
maxMeanScratchBytes?: number;
|
|
61
63
|
};
|
|
62
64
|
|
|
63
65
|
/** Properties for graph-native dense group aggregation. */
|
|
@@ -102,6 +104,8 @@ export class GPUGroupAggregation {
|
|
|
102
104
|
readonly mask?: GPUGroupAggregationMask;
|
|
103
105
|
/** Group statistic computed by this aggregation. */
|
|
104
106
|
readonly operation: GPUGroupAggregationOperation;
|
|
107
|
+
/** Maximum number of groups using one shared count scratch buffer. */
|
|
108
|
+
readonly meanPartitionSize: number;
|
|
105
109
|
|
|
106
110
|
/** Creates and validates a dense group-aggregation description. */
|
|
107
111
|
constructor(props: GPUGroupAggregationProps) {
|
|
@@ -111,6 +115,11 @@ export class GPUGroupAggregation {
|
|
|
111
115
|
this.output = props.output;
|
|
112
116
|
this.mask = props.mask;
|
|
113
117
|
this.operation = props.operation ?? 'count';
|
|
118
|
+
const budget = props.maxMeanScratchBytes;
|
|
119
|
+
if (budget !== undefined && (!Number.isSafeInteger(budget) || budget < 4)) {
|
|
120
|
+
throw new Error(`${this.id} mean scratch budget requires at least four bytes`);
|
|
121
|
+
}
|
|
122
|
+
this.meanPartitionSize = Math.min(this.output.length, Math.floor((budget ?? Infinity) / 4));
|
|
114
123
|
|
|
115
124
|
for (const [chunkIndex, chunk] of getGroupChunks(this.keys).entries()) {
|
|
116
125
|
validateScalarInputView(chunk, 'uint32', `${this.id} keys chunk ${chunkIndex}`);
|
|
@@ -219,37 +228,64 @@ export class GPUGroupAggregation {
|
|
|
219
228
|
|
|
220
229
|
const output = this.output as GraphDataView<'float32'>;
|
|
221
230
|
const operation = this.operation;
|
|
222
|
-
|
|
231
|
+
/** Number of domain keys processed together under the configured mean budget. */
|
|
232
|
+
const partitionSize = operation === 'mean' ? this.meanPartitionSize : output.length;
|
|
233
|
+
/** Scratch reused from initialization through finalization for each key range. */
|
|
234
|
+
const countScratch =
|
|
223
235
|
operation === 'mean'
|
|
224
|
-
? createTransientView(graph,
|
|
236
|
+
? createTransientView(graph, this.id + '-counts', 'uint32', partitionSize)
|
|
225
237
|
: undefined;
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
const
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
238
|
+
for (let firstGroup = 0; firstGroup < output.length; firstGroup += partitionSize) {
|
|
239
|
+
/** Final partitions may be smaller than the configured range. */
|
|
240
|
+
const length = Math.min(partitionSize, output.length - firstGroup);
|
|
241
|
+
/** Writable subview of the final output for the current key range. */
|
|
242
|
+
const partition =
|
|
243
|
+
firstGroup === 0 && length === output.length
|
|
244
|
+
? output
|
|
245
|
+
: graph.createDataView(output.buffer, {
|
|
246
|
+
format: 'float32',
|
|
247
|
+
length,
|
|
248
|
+
byteOffset: output.byteOffset + firstGroup * 4
|
|
249
|
+
});
|
|
250
|
+
/** The active prefix of the shared count buffer for this partition. */
|
|
251
|
+
const counts =
|
|
252
|
+
countScratch && length !== countScratch.length
|
|
253
|
+
? graph.createDataView(countScratch.buffer, {
|
|
254
|
+
format: 'uint32',
|
|
255
|
+
length,
|
|
256
|
+
byteOffset: countScratch.byteOffset
|
|
257
|
+
})
|
|
258
|
+
: countScratch;
|
|
259
|
+
/** Distinguishes partition command IDs while preserving existing single-pass IDs. */
|
|
260
|
+
const id = partitionSize === output.length ? this.id : this.id + '-partition-' + firstGroup;
|
|
261
|
+
nodes.push(...addInitializeGroupStatisticsPass(graph, id, partition, operation, counts));
|
|
262
|
+
for (let chunkIndex = 0; chunkIndex < keyChunks.length; chunkIndex++) {
|
|
263
|
+
const keys = keyChunks[chunkIndex];
|
|
264
|
+
if (keys.length === 0) continue;
|
|
265
|
+
nodes.push(
|
|
266
|
+
...addGroupStatisticPass(graph, {
|
|
267
|
+
id:
|
|
268
|
+
this.keys instanceof GraphVectorView || keyChunks.length > 1
|
|
269
|
+
? id + '-chunk-' + chunkIndex
|
|
270
|
+
: id,
|
|
271
|
+
keys,
|
|
272
|
+
values: valueChunks![chunkIndex],
|
|
273
|
+
mask: maskChunks?.[chunkIndex],
|
|
274
|
+
output: partition,
|
|
275
|
+
operation,
|
|
276
|
+
counts,
|
|
277
|
+
firstGroup,
|
|
278
|
+
dispatchLayout: getGPUGroupAggregationDispatchLayout(
|
|
279
|
+
keys.length,
|
|
280
|
+
graph.device.limits.maxComputeWorkgroupsPerDimension
|
|
281
|
+
)
|
|
282
|
+
})
|
|
283
|
+
);
|
|
284
|
+
}
|
|
285
|
+
if (operation !== 'sum') {
|
|
286
|
+
nodes.push(...addFinalizeGroupStatisticsPass(graph, id, partition, operation, counts));
|
|
287
|
+
}
|
|
251
288
|
}
|
|
252
|
-
|
|
253
289
|
return nodes;
|
|
254
290
|
}
|
|
255
291
|
}
|
|
@@ -488,6 +524,7 @@ function addGroupStatisticPass<Parameters>(
|
|
|
488
524
|
output: GraphDataView<'float32'>;
|
|
489
525
|
operation: Exclude<GPUGroupAggregationOperation, 'count'>;
|
|
490
526
|
counts?: GraphDataView<'uint32'>;
|
|
527
|
+
firstGroup: number;
|
|
491
528
|
dispatchLayout: GPUGroupAggregationDispatchLayout;
|
|
492
529
|
}
|
|
493
530
|
): readonly GPUCommandNode<Parameters>[] {
|
|
@@ -539,10 +576,11 @@ ${useSubgroups ? getSubgroupBallotHelpersWGSL() : ''}
|
|
|
539
576
|
var groupIndex = 0u;
|
|
540
577
|
var value = 0.0;
|
|
541
578
|
if (index < ELEMENT_COUNT && ${maskCondition}) {
|
|
542
|
-
|
|
579
|
+
let key = groupKeys[KEYS_OFFSET + index * KEYS_STRIDE];
|
|
580
|
+
groupIndex = key - ${props.firstGroup}u;
|
|
543
581
|
value = inputValues[VALUES_OFFSET + index * VALUES_STRIDE];
|
|
544
582
|
let finiteValue = value == value && abs(value) <= 3.402823466e+38;
|
|
545
|
-
accepted = groupIndex < GROUP_COUNT && finiteValue;
|
|
583
|
+
accepted = key >= ${props.firstGroup}u && groupIndex < GROUP_COUNT && finiteValue;
|
|
546
584
|
}
|
|
547
585
|
${accumulation}
|
|
548
586
|
}`;
|
|
@@ -46,6 +46,8 @@ type GPUGlobalMetricState = {
|
|
|
46
46
|
sanitized: Map<string, GraphVectorView<GPUAnalyticsScalarFormat>>;
|
|
47
47
|
};
|
|
48
48
|
|
|
49
|
+
import {prepareGPUJoinAggregation, type GPUAggregateJoin} from './gpu-join-compiler';
|
|
50
|
+
|
|
49
51
|
/** One-row GPU-resident global aggregation with source-aligned selection and explicit validity. */
|
|
50
52
|
export class CompiledGPUDataFrameAggregation<
|
|
51
53
|
T extends GPUTypeMap = GPUTypeMap
|
|
@@ -62,7 +64,8 @@ export function compileGPUDataFrameAggregation<
|
|
|
62
64
|
selectedColumns: readonly (keyof Selection & string)[],
|
|
63
65
|
derivedColumns: readonly GPUDataFrameDerivedColumn[],
|
|
64
66
|
definitions: readonly GPUDataFrameAggregationDefinition[],
|
|
65
|
-
graph: GPUCommandGraph<GPUDataFrameQueryParameters
|
|
67
|
+
graph: GPUCommandGraph<GPUDataFrameQueryParameters>,
|
|
68
|
+
join?: GPUAggregateJoin
|
|
66
69
|
): CompiledGPUDataFrameAggregation<Result> {
|
|
67
70
|
validateGPUAnalyticsSource(
|
|
68
71
|
source,
|
|
@@ -76,7 +79,11 @@ export function compileGPUDataFrameAggregation<
|
|
|
76
79
|
Result,
|
|
77
80
|
CompiledGPUDataFrameAggregation<Result>
|
|
78
81
|
>(source, predicates, selectedColumns, graph, derivedColumns, {
|
|
79
|
-
prepare: context =>
|
|
82
|
+
prepare: context => {
|
|
83
|
+
const prepare = (input: typeof context) =>
|
|
84
|
+
addGPUGlobalAggregationsToGraph<Selection, Result>(input, definitions);
|
|
85
|
+
return join ? prepareGPUJoinAggregation(source, context, join, prepare) : prepare(context);
|
|
86
|
+
}
|
|
80
87
|
});
|
|
81
88
|
}
|
|
82
89
|
|