@luma.gl/graph 10.0.0-alpha.14 → 10.0.0-alpha.15
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-column-gpu-vector.cjs +27 -8
- package/dist/arrow/gpu/arrow-column-gpu-vector.d.ts +11 -1
- package/dist/arrow/gpu/arrow-column-gpu-vector.d.ts.map +1 -1
- package/dist/arrow/gpu/arrow-column-gpu-vector.js +33 -8
- package/dist/arrow/gpu/arrow-column-gpu-vector.js.map +1 -1
- package/dist/arrow/index.cjs +2 -0
- package/dist/arrow/index.cjs.map +1 -1
- package/dist/arrow/index.d.ts +1 -1
- package/dist/arrow/index.d.ts.map +1 -1
- package/dist/arrow/index.js +1 -1
- package/dist/arrow/index.js.map +1 -1
- package/dist/dist.dev.js +79 -39
- package/dist/dist.min.js +61 -61
- package/dist/experimental/index.cjs.map +1 -1
- package/dist/experimental/simulation/index.cjs.map +1 -1
- package/dist/geospatial/gpu-point-spatial-query.cjs +2 -15
- package/dist/geospatial/gpu-point-spatial-query.d.ts.map +1 -1
- package/dist/geospatial/gpu-point-spatial-query.js +2 -15
- package/dist/geospatial/gpu-point-spatial-query.js.map +1 -1
- package/dist/geospatial/index.cjs.map +2 -2
- package/dist/gpu-a5/index.cjs.map +1 -1
- package/dist/gpu-core/gpu-command-graph-compiler.cjs +11 -2
- package/dist/gpu-core/gpu-command-graph-compiler.d.ts +2 -1
- package/dist/gpu-core/gpu-command-graph-compiler.d.ts.map +1 -1
- package/dist/gpu-core/gpu-command-graph-compiler.js +13 -2
- package/dist/gpu-core/gpu-command-graph-compiler.js.map +1 -1
- package/dist/gpu-core/gpu-command-graph-types.d.ts +16 -1
- package/dist/gpu-core/gpu-command-graph-types.d.ts.map +1 -1
- package/dist/gpu-core/gpu-command-graph-types.js.map +1 -1
- package/dist/gpu-core/gpu-command-graph.cjs +6 -4
- package/dist/gpu-core/gpu-command-graph.d.ts +4 -4
- package/dist/gpu-core/gpu-command-graph.d.ts.map +1 -1
- package/dist/gpu-core/gpu-command-graph.js +6 -4
- package/dist/gpu-core/gpu-command-graph.js.map +1 -1
- package/dist/gpu-core/gpu-dispatch-utils.cjs +7 -3
- package/dist/gpu-core/gpu-dispatch-utils.d.ts +2 -0
- package/dist/gpu-core/gpu-dispatch-utils.d.ts.map +1 -1
- package/dist/gpu-core/gpu-dispatch-utils.js +4 -1
- package/dist/gpu-core/gpu-dispatch-utils.js.map +1 -1
- package/dist/gpu-core/gpu-grid-aggregation.cjs +2 -5
- package/dist/gpu-core/gpu-grid-aggregation.d.ts.map +1 -1
- package/dist/gpu-core/gpu-grid-aggregation.js +2 -5
- package/dist/gpu-core/gpu-grid-aggregation.js.map +1 -1
- package/dist/gpu-core/gpu-grid-binning.cjs +2 -5
- package/dist/gpu-core/gpu-grid-binning.d.ts.map +1 -1
- package/dist/gpu-core/gpu-grid-binning.js +2 -5
- package/dist/gpu-core/gpu-grid-binning.js.map +1 -1
- package/dist/gpu-core/gpu-grid-coordinate.cjs +41 -0
- package/dist/gpu-core/gpu-grid-coordinate.d.ts +7 -0
- package/dist/gpu-core/gpu-grid-coordinate.d.ts.map +1 -0
- package/dist/gpu-core/gpu-grid-coordinate.js +24 -0
- package/dist/gpu-core/gpu-grid-coordinate.js.map +1 -0
- package/dist/gpu-core/gpu-grid-index-internals.cjs +2 -15
- package/dist/gpu-core/gpu-grid-index-internals.d.ts.map +1 -1
- package/dist/gpu-core/gpu-grid-index-internals.js +2 -15
- package/dist/gpu-core/gpu-grid-index-internals.js.map +1 -1
- package/dist/gpu-core/gpu-grid-index-query.cjs +2 -16
- package/dist/gpu-core/gpu-grid-index-query.d.ts.map +1 -1
- package/dist/gpu-core/gpu-grid-index-query.js +2 -16
- package/dist/gpu-core/gpu-grid-index-query.js.map +1 -1
- package/dist/gpu-core/gpu-scan.cjs +46 -32
- package/dist/gpu-core/gpu-scan.d.ts.map +1 -1
- package/dist/gpu-core/gpu-scan.js +56 -44
- package/dist/gpu-core/gpu-scan.js.map +1 -1
- package/dist/gpu-core/gpu-segmented-reduction.cjs +12 -9
- package/dist/gpu-core/gpu-segmented-reduction.d.ts +1 -1
- package/dist/gpu-core/gpu-segmented-reduction.d.ts.map +1 -1
- package/dist/gpu-core/gpu-segmented-reduction.js +12 -9
- package/dist/gpu-core/gpu-segmented-reduction.js.map +1 -1
- package/dist/gpu-core/gpu-segmented-scan.cjs +73 -16
- package/dist/gpu-core/gpu-segmented-scan.d.ts.map +1 -1
- package/dist/gpu-core/gpu-segmented-scan.js +73 -16
- package/dist/gpu-core/gpu-segmented-scan.js.map +1 -1
- package/dist/gpu-core/index.cjs +18 -0
- package/dist/gpu-core/index.cjs.map +3 -3
- package/dist/gpu-core/index.d.ts +13 -1
- package/dist/gpu-core/index.d.ts.map +1 -1
- package/dist/gpu-core/index.js +6 -0
- package/dist/gpu-core/index.js.map +1 -1
- package/dist/gpu-data/gpu-vector-wgsl-layout.cjs +50 -0
- package/dist/gpu-data/gpu-vector-wgsl-layout.d.ts +41 -0
- package/dist/gpu-data/gpu-vector-wgsl-layout.d.ts.map +1 -0
- package/dist/gpu-data/gpu-vector-wgsl-layout.js +45 -0
- package/dist/gpu-data/gpu-vector-wgsl-layout.js.map +1 -0
- package/dist/gpu-data/index.cjs +3 -0
- package/dist/gpu-data/index.cjs.map +2 -2
- package/dist/gpu-data/index.d.ts +1 -0
- package/dist/gpu-data/index.d.ts.map +1 -1
- package/dist/gpu-data/index.js +1 -0
- package/dist/gpu-data/index.js.map +1 -1
- package/dist/gpu-dataframe/gpu-data-frame-query.cjs +1 -16
- package/dist/gpu-dataframe/gpu-data-frame-query.d.ts.map +1 -1
- package/dist/gpu-dataframe/gpu-data-frame-query.js +1 -23
- package/dist/gpu-dataframe/gpu-data-frame-query.js.map +1 -1
- package/dist/gpu-dataframe/gpu-expression.cjs +91 -2
- package/dist/gpu-dataframe/gpu-expression.d.ts +37 -0
- package/dist/gpu-dataframe/gpu-expression.d.ts.map +1 -1
- package/dist/gpu-dataframe/gpu-expression.js +106 -0
- package/dist/gpu-dataframe/gpu-expression.js.map +1 -1
- package/dist/gpu-dataframe/index.cjs +12 -2
- package/dist/gpu-dataframe/index.cjs.map +3 -3
- package/dist/gpu-dataframe/index.d.ts +4 -0
- package/dist/gpu-dataframe/index.d.ts.map +1 -1
- package/dist/gpu-dataframe/index.js +2 -0
- package/dist/gpu-dataframe/index.js.map +1 -1
- package/dist/gpu-dataframe/portable-expression.cjs +103 -0
- package/dist/gpu-dataframe/portable-expression.d.ts +19 -0
- package/dist/gpu-dataframe/portable-expression.d.ts.map +1 -0
- package/dist/gpu-dataframe/portable-expression.js +98 -0
- package/dist/gpu-dataframe/portable-expression.js.map +1 -0
- package/dist/gpu-dggs/benchmarks.cjs.map +1 -1
- package/dist/gpu-dggs/index.cjs.map +1 -1
- package/dist/gpu-geometry/index.cjs.map +1 -1
- 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-spatial-force-layout-internals.cjs +2 -15
- package/dist/gpu-graph-algorithms/gpu-graph-spatial-force-layout-internals.d.ts.map +1 -1
- package/dist/gpu-graph-algorithms/gpu-graph-spatial-force-layout-internals.js +2 -15
- package/dist/gpu-graph-algorithms/gpu-graph-spatial-force-layout-internals.js.map +1 -1
- package/dist/gpu-graph-algorithms/index.cjs.map +2 -2
- package/dist/gpu-h3/index.cjs.map +1 -1
- package/dist/gpu-physics/gpu-rigid-body-world.cjs +3 -1
- package/dist/gpu-physics/gpu-rigid-body-world.d.ts +4 -0
- package/dist/gpu-physics/gpu-rigid-body-world.d.ts.map +1 -1
- package/dist/gpu-physics/gpu-rigid-body-world.js +3 -1
- package/dist/gpu-physics/gpu-rigid-body-world.js.map +1 -1
- package/dist/gpu-physics/index.cjs.map +1 -1
- package/dist/gpu-physics/rigid-body-parallel-shaders.cjs +24 -9
- package/dist/gpu-physics/rigid-body-parallel-shaders.d.ts +1 -1
- package/dist/gpu-physics/rigid-body-parallel-shaders.d.ts.map +1 -1
- package/dist/gpu-physics/rigid-body-parallel-shaders.js +28 -9
- package/dist/gpu-physics/rigid-body-parallel-shaders.js.map +1 -1
- package/dist/gpu-physics/rigid-body-shaders.cjs +2 -2
- package/dist/gpu-physics/rigid-body-shaders.d.ts +1 -1
- package/dist/gpu-physics/rigid-body-shaders.d.ts.map +1 -1
- package/dist/gpu-physics/rigid-body-shaders.js +2 -2
- package/dist/gpu-physics/rigid-body-shaders.js.map +1 -1
- package/dist/gpu-pointcloud/index.cjs.map +1 -1
- package/dist/gpu-project/graph.cjs.map +1 -1
- package/dist/gpu-simple-graph/index.cjs.map +1 -1
- package/dist/gpu-sql/gpu-sql.cjs +97 -4
- package/dist/gpu-sql/gpu-sql.d.ts.map +1 -1
- package/dist/gpu-sql/gpu-sql.js +100 -5
- package/dist/gpu-sql/gpu-sql.js.map +1 -1
- package/dist/gpu-sql/index.cjs.map +2 -2
- package/dist/gpu-timeseries/index.cjs.map +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +8 -8
- package/src/arrow/gpu/arrow-column-gpu-vector.ts +67 -14
- package/src/arrow/index.ts +2 -0
- package/src/geospatial/gpu-point-spatial-query.ts +2 -15
- package/src/gpu-core/gpu-command-graph-compiler.ts +25 -2
- package/src/gpu-core/gpu-command-graph-types.ts +20 -0
- package/src/gpu-core/gpu-command-graph.ts +11 -4
- package/src/gpu-core/gpu-dispatch-utils.ts +13 -1
- package/src/gpu-core/gpu-grid-aggregation.ts +2 -5
- package/src/gpu-core/gpu-grid-binning.ts +2 -5
- package/src/gpu-core/gpu-grid-coordinate.ts +24 -0
- package/src/gpu-core/gpu-grid-index-internals.ts +2 -15
- package/src/gpu-core/gpu-grid-index-query.ts +2 -16
- package/src/gpu-core/gpu-scan.ts +59 -45
- package/src/gpu-core/gpu-segmented-reduction.ts +20 -10
- package/src/gpu-core/gpu-segmented-scan.ts +82 -17
- package/src/gpu-core/index.ts +21 -0
- package/src/gpu-data/gpu-vector-wgsl-layout.ts +79 -0
- package/src/gpu-data/index.ts +7 -0
- package/src/gpu-dataframe/gpu-data-frame-query.ts +6 -26
- package/src/gpu-dataframe/gpu-expression.ts +135 -0
- package/src/gpu-dataframe/index.ts +11 -0
- package/src/gpu-dataframe/portable-expression.ts +117 -0
- package/src/gpu-graph-algorithms/gpu-graph-spatial-force-layout-internals.ts +2 -15
- package/src/gpu-physics/gpu-rigid-body-world.ts +8 -1
- package/src/gpu-physics/rigid-body-parallel-shaders.ts +32 -9
- package/src/gpu-physics/rigid-body-shaders.ts +3 -2
- package/src/gpu-sql/gpu-sql.ts +105 -5
- package/src/index.ts +2 -0
package/src/gpu-core/gpu-scan.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
import {setGPUComputeDispatchWorkgroups} from './gpu-command-dispatch-metadata';
|
|
6
6
|
import {type GPUCommandNode, createGPUComputeCommandNode} from './gpu-command-node';
|
|
7
|
-
import {type Binding, type Device} from '@luma.gl/core';
|
|
7
|
+
import {type Binding, type Device, type ComputeShaderLayout} from '@luma.gl/core';
|
|
8
8
|
import {Kernel} from '../execution/compute/kernel';
|
|
9
9
|
import {GPUCommandGraph, type GraphDataView, GraphVectorView} from './gpu-command-graph';
|
|
10
10
|
import {
|
|
@@ -602,9 +602,39 @@ ${props.segmentFlags ? `var<workgroup> segmentScratch: array<u32, ${SCAN_WORKGRO
|
|
|
602
602
|
? getSubgroupBlockScanSource(props, sumOutput, sumBinding)
|
|
603
603
|
: portableSource;
|
|
604
604
|
|
|
605
|
+
const shaderLayout: ComputeShaderLayout = {
|
|
606
|
+
bindings: [
|
|
607
|
+
{name: 'inputValues', type: 'storage', group: 0, location: 0},
|
|
608
|
+
{name: 'outputValues', type: 'storage', group: 0, location: 1},
|
|
609
|
+
...(sumOutput ? [{name: 'sumValues', type: 'storage' as const, group: 0, location: 2}] : []),
|
|
610
|
+
...(props.segmentFlags
|
|
611
|
+
? [{name: 'segmentFlags', type: 'storage' as const, group: 0, location: 3}]
|
|
612
|
+
: []),
|
|
613
|
+
...(props.segmentPrefixes
|
|
614
|
+
? [{name: 'segmentPrefixes', type: 'storage' as const, group: 0, location: 4}]
|
|
615
|
+
: []),
|
|
616
|
+
...(segmentFlagOutput
|
|
617
|
+
? [
|
|
618
|
+
{
|
|
619
|
+
name: 'summarySegmentFlags',
|
|
620
|
+
type: 'storage' as const,
|
|
621
|
+
group: 0,
|
|
622
|
+
location: 5
|
|
623
|
+
}
|
|
624
|
+
]
|
|
625
|
+
: [])
|
|
626
|
+
]
|
|
627
|
+
};
|
|
628
|
+
|
|
605
629
|
nodes.push(
|
|
606
630
|
createGPUComputeCommandNode<Parameters>({
|
|
607
631
|
id: props.id,
|
|
632
|
+
kernel: {
|
|
633
|
+
entryPoint: 'main',
|
|
634
|
+
workgroupSize: [SCAN_WORKGROUP_SIZE, 1, 1],
|
|
635
|
+
bindings: shaderLayout.bindings,
|
|
636
|
+
source
|
|
637
|
+
},
|
|
608
638
|
workload: {
|
|
609
639
|
operation: 'GPUScan',
|
|
610
640
|
variant: strategy,
|
|
@@ -637,31 +667,7 @@ ${props.segmentFlags ? `var<workgroup> segmentScratch: array<u32, ${SCAN_WORKGRO
|
|
|
637
667
|
const kernel = new Kernel(device, {
|
|
638
668
|
id: props.id,
|
|
639
669
|
source,
|
|
640
|
-
shaderLayout
|
|
641
|
-
bindings: [
|
|
642
|
-
{name: 'inputValues', type: 'storage', group: 0, location: 0},
|
|
643
|
-
{name: 'outputValues', type: 'storage', group: 0, location: 1},
|
|
644
|
-
...(sumOutput
|
|
645
|
-
? [{name: 'sumValues', type: 'storage' as const, group: 0, location: 2}]
|
|
646
|
-
: []),
|
|
647
|
-
...(props.segmentFlags
|
|
648
|
-
? [{name: 'segmentFlags', type: 'storage' as const, group: 0, location: 3}]
|
|
649
|
-
: []),
|
|
650
|
-
...(props.segmentPrefixes
|
|
651
|
-
? [{name: 'segmentPrefixes', type: 'storage' as const, group: 0, location: 4}]
|
|
652
|
-
: []),
|
|
653
|
-
...(segmentFlagOutput
|
|
654
|
-
? [
|
|
655
|
-
{
|
|
656
|
-
name: 'summarySegmentFlags',
|
|
657
|
-
type: 'storage' as const,
|
|
658
|
-
group: 0,
|
|
659
|
-
location: 5
|
|
660
|
-
}
|
|
661
|
-
]
|
|
662
|
-
: [])
|
|
663
|
-
]
|
|
664
|
-
}
|
|
670
|
+
shaderLayout
|
|
665
671
|
});
|
|
666
672
|
return {
|
|
667
673
|
encode: ({computePass, getBuffer}) => {
|
|
@@ -854,9 +860,35 @@ ${props.offsetSegmentPrefixes ? '@group(0) @binding(3) var<storage, read> offset
|
|
|
854
860
|
${props.segmentPrefixes && props.offsetSegmentPrefixes ? 'segmentPrefixes[SEGMENT_PREFIXES_OFFSET + index] = segmentPrefix | offsetSegmentPrefix;' : ''}
|
|
855
861
|
}
|
|
856
862
|
}`;
|
|
863
|
+
const shaderLayout: ComputeShaderLayout = {
|
|
864
|
+
bindings: [
|
|
865
|
+
{name: 'outputValues', type: 'storage', group: 0, location: 0},
|
|
866
|
+
{name: 'offsets', type: 'storage', group: 0, location: 1},
|
|
867
|
+
...(props.segmentPrefixes
|
|
868
|
+
? [{name: 'segmentPrefixes', type: 'storage' as const, group: 0, location: 2}]
|
|
869
|
+
: []),
|
|
870
|
+
...(props.offsetSegmentPrefixes
|
|
871
|
+
? [
|
|
872
|
+
{
|
|
873
|
+
name: 'offsetSegmentPrefixes',
|
|
874
|
+
type: 'storage' as const,
|
|
875
|
+
group: 0,
|
|
876
|
+
location: 3
|
|
877
|
+
}
|
|
878
|
+
]
|
|
879
|
+
: [])
|
|
880
|
+
]
|
|
881
|
+
};
|
|
882
|
+
|
|
857
883
|
nodes.push(
|
|
858
884
|
createGPUComputeCommandNode<Parameters>({
|
|
859
885
|
id: props.id,
|
|
886
|
+
kernel: {
|
|
887
|
+
entryPoint: 'main',
|
|
888
|
+
workgroupSize: [SCAN_WORKGROUP_SIZE, 1, 1],
|
|
889
|
+
bindings: shaderLayout.bindings,
|
|
890
|
+
source
|
|
891
|
+
},
|
|
860
892
|
workload: {
|
|
861
893
|
operation: 'GPUScan',
|
|
862
894
|
commandCount: 1,
|
|
@@ -889,25 +921,7 @@ ${props.offsetSegmentPrefixes ? '@group(0) @binding(3) var<storage, read> offset
|
|
|
889
921
|
const kernel = new Kernel(device, {
|
|
890
922
|
id: props.id,
|
|
891
923
|
source,
|
|
892
|
-
shaderLayout
|
|
893
|
-
bindings: [
|
|
894
|
-
{name: 'outputValues', type: 'storage', group: 0, location: 0},
|
|
895
|
-
{name: 'offsets', type: 'storage', group: 0, location: 1},
|
|
896
|
-
...(props.segmentPrefixes
|
|
897
|
-
? [{name: 'segmentPrefixes', type: 'storage' as const, group: 0, location: 2}]
|
|
898
|
-
: []),
|
|
899
|
-
...(props.offsetSegmentPrefixes
|
|
900
|
-
? [
|
|
901
|
-
{
|
|
902
|
-
name: 'offsetSegmentPrefixes',
|
|
903
|
-
type: 'storage' as const,
|
|
904
|
-
group: 0,
|
|
905
|
-
location: 3
|
|
906
|
-
}
|
|
907
|
-
]
|
|
908
|
-
: [])
|
|
909
|
-
]
|
|
910
|
-
}
|
|
924
|
+
shaderLayout
|
|
911
925
|
});
|
|
912
926
|
return {
|
|
913
927
|
encode: ({computePass, getBuffer}) => {
|
|
@@ -6,6 +6,7 @@ import {type GPUCommandNode, createGPUComputeCommandNode} from './gpu-command-no
|
|
|
6
6
|
import type {Binding} from '@luma.gl/core';
|
|
7
7
|
import {Kernel} from '../execution/compute/kernel';
|
|
8
8
|
import {GPUCommandGraph, type GraphDataView} from './gpu-command-graph';
|
|
9
|
+
import {getBoundedWorkgroupLayout, type GPUBoundedDispatchLayout} from './gpu-dispatch-utils';
|
|
9
10
|
import {
|
|
10
11
|
getViewBinding,
|
|
11
12
|
getViewElementOffset,
|
|
@@ -22,7 +23,7 @@ export type GPUSegmentedReductionOperation = 'sum' | 'min' | 'max';
|
|
|
22
23
|
export type GPUSegmentedReductionProps<T extends GPUScalarFormat = GPUScalarFormat> = {
|
|
23
24
|
id?: string;
|
|
24
25
|
input: GraphDataView<T>;
|
|
25
|
-
/**
|
|
26
|
+
/** Nondecreasing element offsets relative to input. Length must equal output.length + 1. */
|
|
26
27
|
segmentOffsets: GraphDataView<'uint32'>;
|
|
27
28
|
output: GraphDataView<T>;
|
|
28
29
|
operation: GPUSegmentedReductionOperation;
|
|
@@ -73,15 +74,20 @@ export class GPUSegmentedReduction<T extends GPUScalarFormat = GPUScalarFormat>
|
|
|
73
74
|
}
|
|
74
75
|
if (this.output.length === 0) return nodes;
|
|
75
76
|
|
|
76
|
-
const
|
|
77
|
+
const dispatch = getBoundedWorkgroupLayout(
|
|
78
|
+
this.id,
|
|
79
|
+
this.output.length,
|
|
80
|
+
graph.device.limits.maxComputeWorkgroupsPerDimension
|
|
81
|
+
);
|
|
82
|
+
const source = makeShaderSource(this, dispatch);
|
|
77
83
|
nodes.push(
|
|
78
84
|
createGPUComputeCommandNode<Parameters>({
|
|
79
85
|
id: this.id,
|
|
80
86
|
workload: {
|
|
81
87
|
operation: 'GPUSegmentedReduction',
|
|
82
88
|
commandCount: 1,
|
|
83
|
-
maximumWorkgroupCount:
|
|
84
|
-
maximumInvocationCount:
|
|
89
|
+
maximumWorkgroupCount: dispatch.x * dispatch.y * dispatch.z,
|
|
90
|
+
maximumInvocationCount: dispatch.x * dispatch.y * dispatch.z * WORKGROUP_SIZE,
|
|
85
91
|
readByteLength: this.input.length * 4 + this.segmentOffsets.length * 4,
|
|
86
92
|
writeByteLength: this.output.length * 4
|
|
87
93
|
},
|
|
@@ -110,7 +116,7 @@ export class GPUSegmentedReduction<T extends GPUScalarFormat = GPUScalarFormat>
|
|
|
110
116
|
outputValues: getViewBinding(this.output, getBuffer)
|
|
111
117
|
};
|
|
112
118
|
|
|
113
|
-
kernel.dispatch(computePass, {bindings,
|
|
119
|
+
kernel.dispatch(computePass, {bindings, ...dispatch});
|
|
114
120
|
},
|
|
115
121
|
destroy: () => kernel.destroy()
|
|
116
122
|
};
|
|
@@ -122,7 +128,10 @@ export class GPUSegmentedReduction<T extends GPUScalarFormat = GPUScalarFormat>
|
|
|
122
128
|
}
|
|
123
129
|
}
|
|
124
130
|
|
|
125
|
-
function makeShaderSource(
|
|
131
|
+
function makeShaderSource(
|
|
132
|
+
reduction: GPUSegmentedReduction,
|
|
133
|
+
dispatch: GPUBoundedDispatchLayout
|
|
134
|
+
): string {
|
|
126
135
|
const type =
|
|
127
136
|
reduction.input.format === 'uint32'
|
|
128
137
|
? 'u32'
|
|
@@ -161,9 +170,10 @@ var<workgroup> scratch: array<${type}, ${WORKGROUP_SIZE}>;
|
|
|
161
170
|
fn combine(a: ${type}, b: ${type}) -> ${type} { return ${combine}; }
|
|
162
171
|
@compute @workgroup_size(${WORKGROUP_SIZE})
|
|
163
172
|
fn main(@builtin(workgroup_id) wg: vec3u, @builtin(local_invocation_index) lane: u32) {
|
|
164
|
-
let segment = wg.x;
|
|
165
|
-
|
|
166
|
-
let
|
|
173
|
+
let segment = (wg.z * ${dispatch.y}u + wg.y) * ${dispatch.x}u + wg.x;
|
|
174
|
+
if (segment >= ${reduction.output.length}u) { return; }
|
|
175
|
+
let begin = min(segmentOffsets[SEGMENT_OFFSET + segment], ${reduction.input.length}u);
|
|
176
|
+
let end = min(segmentOffsets[SEGMENT_OFFSET + segment + 1u], ${reduction.input.length}u);
|
|
167
177
|
var value: ${type} = ${identity};
|
|
168
178
|
var i = begin + lane;
|
|
169
179
|
loop {
|
|
@@ -181,7 +191,7 @@ fn main(@builtin(workgroup_id) wg: vec3u, @builtin(local_invocation_index) lane:
|
|
|
181
191
|
stride = stride / 2u;
|
|
182
192
|
}
|
|
183
193
|
if (lane == 0u) {
|
|
184
|
-
outputValues[OUTPUT_OFFSET + segment] = select(scratch[0], ${type}(
|
|
194
|
+
outputValues[OUTPUT_OFFSET + segment] = select(scratch[0], ${type}(0), begin >= end);
|
|
185
195
|
}
|
|
186
196
|
}`;
|
|
187
197
|
}
|
|
@@ -3,9 +3,10 @@
|
|
|
3
3
|
// SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
|
|
4
4
|
|
|
5
5
|
import {type GPUCommandNode, createGPUComputeCommandNode} from './gpu-command-node';
|
|
6
|
-
import type {Binding} from '@luma.gl/core';
|
|
6
|
+
import type {Binding, ComputeShaderLayout} from '@luma.gl/core';
|
|
7
7
|
import {Kernel} from '../execution/compute/kernel';
|
|
8
8
|
import {GPUCommandGraph, type GraphDataView} from './gpu-command-graph';
|
|
9
|
+
import {getBoundedWorkgroupLayout, type GPUBoundedDispatchLayout} from './gpu-dispatch-utils';
|
|
9
10
|
import {
|
|
10
11
|
getViewBinding,
|
|
11
12
|
getViewElementOffset,
|
|
@@ -66,16 +67,35 @@ export class GPUSegmentedScan {
|
|
|
66
67
|
throw new Error(`${this.id} views must belong to target graph`);
|
|
67
68
|
}
|
|
68
69
|
const segmentCount = this.segmentOffsets.length - 1;
|
|
69
|
-
if (segmentCount === 0) return nodes;
|
|
70
|
-
const
|
|
70
|
+
if (segmentCount === 0 || this.input.length === 0) return nodes;
|
|
71
|
+
const dispatch = getBoundedWorkgroupLayout(
|
|
72
|
+
this.id,
|
|
73
|
+
segmentCount,
|
|
74
|
+
graph.device.limits.maxComputeWorkgroupsPerDimension
|
|
75
|
+
);
|
|
76
|
+
const workgroupCount = dispatch.x * dispatch.y * dispatch.z;
|
|
77
|
+
const source = makeShaderSource(this, dispatch, segmentCount);
|
|
78
|
+
const shaderLayout: ComputeShaderLayout = {
|
|
79
|
+
bindings: [
|
|
80
|
+
{name: 'inputValues', type: 'read-only-storage', group: 0, location: 0},
|
|
81
|
+
{name: 'segmentOffsets', type: 'read-only-storage', group: 0, location: 1},
|
|
82
|
+
{name: 'outputValues', type: 'storage', group: 0, location: 2}
|
|
83
|
+
]
|
|
84
|
+
};
|
|
71
85
|
nodes.push(
|
|
72
86
|
createGPUComputeCommandNode<Parameters>({
|
|
73
87
|
id: this.id,
|
|
88
|
+
kernel: {
|
|
89
|
+
entryPoint: 'main',
|
|
90
|
+
workgroupSize: [WORKGROUP_SIZE, 1, 1],
|
|
91
|
+
bindings: shaderLayout.bindings,
|
|
92
|
+
source
|
|
93
|
+
},
|
|
74
94
|
workload: {
|
|
75
95
|
operation: 'GPUSegmentedScan',
|
|
76
96
|
commandCount: 1,
|
|
77
|
-
maximumWorkgroupCount:
|
|
78
|
-
maximumInvocationCount:
|
|
97
|
+
maximumWorkgroupCount: workgroupCount,
|
|
98
|
+
maximumInvocationCount: workgroupCount * WORKGROUP_SIZE,
|
|
79
99
|
readByteLength: this.input.length * 4 + this.segmentOffsets.length * 4,
|
|
80
100
|
writeByteLength: this.output.length * 4
|
|
81
101
|
},
|
|
@@ -88,13 +108,7 @@ export class GPUSegmentedScan {
|
|
|
88
108
|
const kernel = new Kernel(device, {
|
|
89
109
|
id: this.id,
|
|
90
110
|
source,
|
|
91
|
-
shaderLayout
|
|
92
|
-
bindings: [
|
|
93
|
-
{name: 'inputValues', type: 'read-only-storage', group: 0, location: 0},
|
|
94
|
-
{name: 'segmentOffsets', type: 'read-only-storage', group: 0, location: 1},
|
|
95
|
-
{name: 'outputValues', type: 'storage', group: 0, location: 2}
|
|
96
|
-
]
|
|
97
|
-
}
|
|
111
|
+
shaderLayout
|
|
98
112
|
});
|
|
99
113
|
return {
|
|
100
114
|
encode: ({computePass, getBuffer}) => {
|
|
@@ -104,7 +118,7 @@ export class GPUSegmentedScan {
|
|
|
104
118
|
outputValues: getViewBinding(this.output, getBuffer)
|
|
105
119
|
};
|
|
106
120
|
|
|
107
|
-
kernel.dispatch(computePass, {bindings,
|
|
121
|
+
kernel.dispatch(computePass, {bindings, ...dispatch});
|
|
108
122
|
},
|
|
109
123
|
destroy: () => kernel.destroy()
|
|
110
124
|
};
|
|
@@ -116,8 +130,59 @@ export class GPUSegmentedScan {
|
|
|
116
130
|
}
|
|
117
131
|
}
|
|
118
132
|
|
|
119
|
-
function makeShaderSource(
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
133
|
+
function makeShaderSource(
|
|
134
|
+
scan: GPUSegmentedScan,
|
|
135
|
+
dispatch: GPUBoundedDispatchLayout,
|
|
136
|
+
segmentCount: number
|
|
137
|
+
): string {
|
|
138
|
+
return `const INPUT_OFFSET: u32 = ${getViewElementOffset(scan.input)}u;
|
|
139
|
+
const SEGMENT_OFFSET: u32 = ${getViewElementOffset(scan.segmentOffsets)}u;
|
|
140
|
+
const OUTPUT_OFFSET: u32 = ${getViewElementOffset(scan.output)}u;
|
|
141
|
+
const INPUT_LENGTH: u32 = ${scan.input.length}u;
|
|
142
|
+
@group(0) @binding(0) var<storage, read> inputValues: array<u32>;
|
|
143
|
+
@group(0) @binding(1) var<storage, read> segmentOffsets: array<u32>;
|
|
144
|
+
@group(0) @binding(2) var<storage, read_write> outputValues: array<u32>;
|
|
145
|
+
var<workgroup> prefixes: array<u32, ${WORKGROUP_SIZE}>;
|
|
146
|
+
var<workgroup> segmentBounds: array<u32, 2>;
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
@compute @workgroup_size(${WORKGROUP_SIZE})
|
|
150
|
+
fn main(
|
|
151
|
+
@builtin(workgroup_id) workgroup: vec3u,
|
|
152
|
+
@builtin(local_invocation_index) lane: u32
|
|
153
|
+
) {
|
|
154
|
+
let segment = (workgroup.z * ${dispatch.y}u + workgroup.y) * ${dispatch.x}u + workgroup.x;
|
|
155
|
+
if (segment >= ${segmentCount}u) { return; }
|
|
156
|
+
if (lane == 0u) {
|
|
157
|
+
segmentBounds[0] = min(segmentOffsets[SEGMENT_OFFSET + segment], INPUT_LENGTH);
|
|
158
|
+
segmentBounds[1] = min(segmentOffsets[SEGMENT_OFFSET + segment + 1u], INPUT_LENGTH);
|
|
159
|
+
}
|
|
160
|
+
let begin = workgroupUniformLoad(&segmentBounds[0]);
|
|
161
|
+
let end = workgroupUniformLoad(&segmentBounds[1]);
|
|
162
|
+
var carry = 0u;
|
|
163
|
+
for (var tile = begin; tile < end;) {
|
|
164
|
+
let tileLength = min(end - tile, ${WORKGROUP_SIZE}u);
|
|
165
|
+
var value = 0u;
|
|
166
|
+
if (lane < tileLength) {
|
|
167
|
+
value = inputValues[INPUT_OFFSET + tile + lane];
|
|
168
|
+
}
|
|
169
|
+
prefixes[lane] = value;
|
|
170
|
+
workgroupBarrier();
|
|
171
|
+
|
|
172
|
+
for (var stride = 1u; stride < ${WORKGROUP_SIZE}u; stride *= 2u) {
|
|
173
|
+
var previous = 0u;
|
|
174
|
+
if (lane >= stride) { previous = prefixes[lane - stride]; }
|
|
175
|
+
workgroupBarrier();
|
|
176
|
+
prefixes[lane] += previous;
|
|
177
|
+
workgroupBarrier();
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
if (lane < tileLength) {
|
|
181
|
+
outputValues[OUTPUT_OFFSET + tile + lane] = carry + prefixes[lane]${scan.mode === 'exclusive' ? ' - value' : ''};
|
|
182
|
+
}
|
|
183
|
+
carry += prefixes[${WORKGROUP_SIZE - 1}u];
|
|
184
|
+
workgroupBarrier();
|
|
185
|
+
tile += tileLength;
|
|
186
|
+
}
|
|
187
|
+
}`;
|
|
123
188
|
}
|
package/src/gpu-core/index.ts
CHANGED
|
@@ -46,6 +46,8 @@ export type {
|
|
|
46
46
|
GPUCommandGraphNodeTiming,
|
|
47
47
|
GPUCommandGraphNodeType,
|
|
48
48
|
GPUCommandGraphNodePreflight,
|
|
49
|
+
GPUCommandGraphCompileOptions,
|
|
50
|
+
GPUCommandGraphKernelMetadata,
|
|
49
51
|
GPUCommandGraphResourceSummary,
|
|
50
52
|
GPUCommandGraphNodePublication,
|
|
51
53
|
GPUCommandGraphNodeWorkloadEstimate,
|
|
@@ -140,6 +142,8 @@ export {GPUByteRangeGather} from './gpu-byte-range-gather';
|
|
|
140
142
|
export type {GPUByteRangeGatherProps} from './gpu-byte-range-gather';
|
|
141
143
|
export {GPUGather} from './gpu-gather';
|
|
142
144
|
export type {GPUGatherFormat, GPUGatherProps} from './gpu-gather';
|
|
145
|
+
export {GPUScatter} from './gpu-scatter';
|
|
146
|
+
export type {GPUScatterFormat, GPUScatterProps} from './gpu-scatter';
|
|
143
147
|
export {
|
|
144
148
|
GPULZByteDecompressor,
|
|
145
149
|
GPU_LZ_BYTE_DESCRIPTOR_WORDS,
|
|
@@ -177,6 +181,15 @@ export type {
|
|
|
177
181
|
GPUWorkgroupReductionBenchmarkReport,
|
|
178
182
|
GPUWorkgroupReductionBenchmarkStrategy
|
|
179
183
|
} from './gpu-workgroup-reduction-benchmark';
|
|
184
|
+
export {GPUSegmentedScan} from './gpu-segmented-scan';
|
|
185
|
+
export type {GPUSegmentedScanMode, GPUSegmentedScanProps} from './gpu-segmented-scan';
|
|
186
|
+
|
|
187
|
+
export {GPUSegmentedReduction} from './gpu-segmented-reduction';
|
|
188
|
+
export type {
|
|
189
|
+
GPUSegmentedReductionOperation,
|
|
190
|
+
GPUSegmentedReductionProps
|
|
191
|
+
} from './gpu-segmented-reduction';
|
|
192
|
+
|
|
180
193
|
export {GPUSegmentedSort} from './gpu-segmented-sort';
|
|
181
194
|
export type {GPUSegmentedSortProps, GPUSortSegment} from './gpu-segmented-sort';
|
|
182
195
|
export {GPUCompaction} from './gpu-compaction';
|
|
@@ -392,6 +405,8 @@ export type {
|
|
|
392
405
|
GPUHistogramProps
|
|
393
406
|
} from './gpu-histogram';
|
|
394
407
|
|
|
408
|
+
export {GPU_GRID_COORDINATE_WGSL} from './gpu-grid-coordinate';
|
|
409
|
+
|
|
395
410
|
export {GPUGridBinning} from './gpu-grid-binning';
|
|
396
411
|
export type {
|
|
397
412
|
GPUGridBinningBounds,
|
|
@@ -637,6 +652,12 @@ export {GPUGraphDotProduct, GPUGraphVectorMADD} from './gpu-semantic-vector-oper
|
|
|
637
652
|
export {GPUGraphCSRMatrix, GPUGraphSpMV} from './gpu-semantic-spmv';
|
|
638
653
|
export {createGPUConjugateGradientGraph} from './gpu-conjugate-gradient-program';
|
|
639
654
|
|
|
655
|
+
export {GPUAdaptiveSpMV} from './gpu-adaptive-spmv';
|
|
656
|
+
export type {GPUAdaptiveSpMVProps} from './gpu-adaptive-spmv';
|
|
657
|
+
export type {GPUSpMVRowStatistics, GPUSpMVStrategyId} from './gpu-spmv-strategy';
|
|
658
|
+
export {GPUJacobiPCG} from './gpu-pcg';
|
|
659
|
+
export type {GPUJacobiPCGProps, GPUJacobiPCGResult} from './gpu-pcg';
|
|
660
|
+
|
|
640
661
|
export {GPUCOOToCSR} from './gpu-coo-to-csr';
|
|
641
662
|
export type {GPUCOOToCSRProps} from './gpu-coo-to-csr';
|
|
642
663
|
export {GPURunLengthEncode, GPUUnique} from './gpu-run-length-encode';
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
// luma.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
5
|
+
import {getLeafLayoutInfo, makeShaderBlockLayout} from '@luma.gl/shaders/types';
|
|
6
|
+
import {getGPUVectorFormatInfo} from './gpu-vector-format';
|
|
7
|
+
|
|
8
|
+
/** Scalar formats with matching 32-bit WGSL component representations. */
|
|
9
|
+
export type GPUVectorWGSLScalarFormat = 'float32' | 'sint32' | 'uint32';
|
|
10
|
+
|
|
11
|
+
/** Packed 32-bit numeric formats with a corresponding WGSL value type. */
|
|
12
|
+
export type GPUVectorWGSLFormat =
|
|
13
|
+
| GPUVectorWGSLScalarFormat
|
|
14
|
+
| `${GPUVectorWGSLScalarFormat}x${2 | 3 | 4}`;
|
|
15
|
+
|
|
16
|
+
/** Packed row metadata and the layout of the corresponding native WGSL storage value. */
|
|
17
|
+
export type GPUVectorWGSLLayout = {
|
|
18
|
+
/** The packed GPUVector format. */
|
|
19
|
+
format: GPUVectorWGSLFormat;
|
|
20
|
+
/** Number of scalar components in a row. */
|
|
21
|
+
components: 1 | 2 | 3 | 4;
|
|
22
|
+
/** GPUVector format of an individual component. */
|
|
23
|
+
componentType: GPUVectorWGSLScalarFormat;
|
|
24
|
+
/** WGSL type of an individual component. */
|
|
25
|
+
scalarType: 'f32' | 'i32' | 'u32';
|
|
26
|
+
/** WGSL scalar or vector type for one row. */
|
|
27
|
+
shaderType: 'f32' | 'i32' | 'u32' | `vec${2 | 3 | 4}<${'f32' | 'i32' | 'u32'}>`;
|
|
28
|
+
/** Number of bytes occupied by the components of one row. */
|
|
29
|
+
byteLength: number;
|
|
30
|
+
/** Distance in bytes between rows in a tightly packed GPUVector. */
|
|
31
|
+
packedByteStride: number;
|
|
32
|
+
/** Required byte alignment of the value in a native WGSL storage buffer. */
|
|
33
|
+
storageAlignment: number;
|
|
34
|
+
/** Distance in bytes between elements in a native WGSL storage array of this value type. */
|
|
35
|
+
nativeArrayByteStride: number;
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Describes packed GPUVector rows and the corresponding native WGSL storage array.
|
|
40
|
+
*
|
|
41
|
+
* @param format - Packed 32-bit scalar or vector format.
|
|
42
|
+
* @returns Layout metadata in bytes. The helper does not allocate or modify storage.
|
|
43
|
+
* @throws If the format has no supported 32-bit WGSL representation.
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* ```ts
|
|
47
|
+
* const layout = getGPUVectorWGSLLayout('float32x3');
|
|
48
|
+
* layout.packedByteStride; // 12
|
|
49
|
+
* layout.nativeArrayByteStride; // 16
|
|
50
|
+
* ```
|
|
51
|
+
*/
|
|
52
|
+
export function getGPUVectorWGSLLayout(format: GPUVectorWGSLFormat): GPUVectorWGSLLayout {
|
|
53
|
+
const {components, signedDataType, primitiveType, byteLength, elementFormat, normalized} =
|
|
54
|
+
getGPUVectorFormatInfo(format);
|
|
55
|
+
if (
|
|
56
|
+
normalized ||
|
|
57
|
+
elementFormat !== format ||
|
|
58
|
+
(signedDataType !== 'float32' && signedDataType !== 'sint32' && signedDataType !== 'uint32') ||
|
|
59
|
+
primitiveType === 'f16'
|
|
60
|
+
) {
|
|
61
|
+
throw new Error('Expected a packed 32-bit numeric vector format');
|
|
62
|
+
}
|
|
63
|
+
const scalarType = primitiveType;
|
|
64
|
+
const shaderType = components === 1 ? scalarType : (`vec${components}<${scalarType}>` as const);
|
|
65
|
+
const layout = 'wgsl-storage';
|
|
66
|
+
const {alignment} = getLeafLayoutInfo(shaderType, layout);
|
|
67
|
+
const arrayLayout = makeShaderBlockLayout({values: [shaderType, 2]}, {layout});
|
|
68
|
+
return {
|
|
69
|
+
format,
|
|
70
|
+
components,
|
|
71
|
+
componentType: signedDataType,
|
|
72
|
+
scalarType,
|
|
73
|
+
shaderType,
|
|
74
|
+
byteLength,
|
|
75
|
+
packedByteStride: byteLength,
|
|
76
|
+
storageAlignment: alignment * Uint32Array.BYTES_PER_ELEMENT,
|
|
77
|
+
nativeArrayByteStride: arrayLayout.byteLength / 2
|
|
78
|
+
};
|
|
79
|
+
}
|
package/src/gpu-data/index.ts
CHANGED
|
@@ -74,5 +74,12 @@ export {CPUVector, type CPUVectorProps} from './cpu-vector';
|
|
|
74
74
|
|
|
75
75
|
export {makeGPUVectorFromCPUVector, makeCPUVectorFromGPUVector} from './cpu-gpu-vector-transfer';
|
|
76
76
|
|
|
77
|
+
export {
|
|
78
|
+
getGPUVectorWGSLLayout,
|
|
79
|
+
type GPUVectorWGSLFormat,
|
|
80
|
+
type GPUVectorWGSLLayout,
|
|
81
|
+
type GPUVectorWGSLScalarFormat
|
|
82
|
+
} from './gpu-vector-wgsl-layout';
|
|
83
|
+
|
|
77
84
|
export {convertCPUColors, resolveColorOutputFormat} from './color-conversion';
|
|
78
85
|
export type {ColorOutputFormat, ColorConversionOptions} from './color-conversion';
|
|
@@ -6,7 +6,12 @@
|
|
|
6
6
|
import type {GPUTypeMap} from '@luma.gl/graph/gpu-tables';
|
|
7
7
|
import type {GPUCommandGraph} from '@luma.gl/graph/gpu-core';
|
|
8
8
|
import type {GPUDataFrame} from './gpu-data-frame';
|
|
9
|
-
import {
|
|
9
|
+
import {
|
|
10
|
+
getGPUExpressionColumnNames,
|
|
11
|
+
GPUExpression,
|
|
12
|
+
isBooleanExpressionNode,
|
|
13
|
+
type GPUExpressionNode
|
|
14
|
+
} from './gpu-expression';
|
|
10
15
|
import {
|
|
11
16
|
GPUDataFrameAggregationQuery,
|
|
12
17
|
type GPUDataFrameGlobalAggregationDefinitions,
|
|
@@ -434,28 +439,3 @@ function isNumericExpressionNode(node: GPUExpressionNode): boolean {
|
|
|
434
439
|
return false;
|
|
435
440
|
}
|
|
436
441
|
}
|
|
437
|
-
|
|
438
|
-
function isBooleanExpressionNode(node: GPUExpressionNode): boolean {
|
|
439
|
-
switch (node.kind) {
|
|
440
|
-
case 'column':
|
|
441
|
-
return false;
|
|
442
|
-
case 'literal':
|
|
443
|
-
case 'parameter':
|
|
444
|
-
return typeof node.value === 'boolean';
|
|
445
|
-
case 'unary':
|
|
446
|
-
return node.operator === 'not' || node.operator === 'is-valid' || node.operator === 'is-null';
|
|
447
|
-
case 'binary':
|
|
448
|
-
return (
|
|
449
|
-
node.operator === 'equal' ||
|
|
450
|
-
node.operator === 'not-equal' ||
|
|
451
|
-
node.operator === 'greater-than' ||
|
|
452
|
-
node.operator === 'greater-than-or-equal' ||
|
|
453
|
-
node.operator === 'less-than' ||
|
|
454
|
-
node.operator === 'less-than-or-equal' ||
|
|
455
|
-
node.operator === 'and' ||
|
|
456
|
-
node.operator === 'or'
|
|
457
|
-
);
|
|
458
|
-
default:
|
|
459
|
-
return false;
|
|
460
|
-
}
|
|
461
|
-
}
|