scanWGSL¶
Overview¶
A template that performs a scan operation using workgroup memory on a single workgroup (one value per thread).
@author Jonathan Olson <jonathan.olson@colorado.edu>
Type scanWGSLOptions¶
- value: WGSLVariableName
the "input" and "output" variable name - scratch: WGSLVariableName
name for var<workgroup> array<T, workgroupSize> TODO: consider abstracting, so we could run multiple reduces TODO: concurrently - direction?: "left" | "right"
The direction of the scan. For instance, a left inclusive scan of [ 1, 2, 3, 4 ] is [ 1, 3, 6, 10 ], but a right incluive scan is [ 10, 9, 7, 4 ] (just scans in the other direction) - binaryOp: BinaryOp<T>
- mapScratchIndex?: ( index: WGSLExpressionU32 ) => WGSLExpressionU32
allows overriding the index used for the scratch array, so that we can run multiple smaller loads in the same workgroup - exclusive?: boolean
boolean (whether the scan should be exclusive - otherwise it is inclusive). e.g. an inclusive left scan of [ 1, 2, 3, 4 ] is [ 1, 3, 6, 10 ], whereas an exclusive left scan is [ 0, 1, 3, 6 ] - needsValidScratch?: boolean
if the scratch value doesn't need to be accurate, we can skip this - scratchPreloaded?: boolean
TODO: some of this is duplicated with reduce.wgsl, how can we factor it out? If true, we won't need to load the value INTO the scratch array - valuePreloaded?: boolean
If true, we won't need to load the value FROM the scratch array - & WorkgroupSizable & LocalIndexable
Source Code¶
See the source for scanWGSL.ts in the alpenglow repository.