The stage that selects the largest value of every segment of values already on the device.
The values are whatever binding 0 resolves to: a shared buffer of the context, or one imported from another context with import_shared, for instance the result of a LaggedPair pass recorded earlier on the same recording. Nothing is staged from the host.
select.set_recording(recording);
Shader context whose numeric input is staged as a uvec2 per double.
std::vector< ArgMaxResult > read_argmax(WordPairExecutionContext &context, size_t segments)
Read the selections of the segments of the last recorded stage.
DependencyStage segmented_argmax_stage(WordPairExecutionContext &context, const GpuComputeConfig &config, const SegmentGeometry &geometry)
The stage that selects the largest value of every segment of values already on the device.
GpuComputeConfig config_from_spec(const Portal::Graphics::ShaderSpec &spec)
Derive a GpuComputeConfig from a ShaderSpec.
std::vector< GpuBufferBinding > bindings_from_spec(const Portal::Graphics::ShaderSpec &spec)
Derive a GpuBufferBinding list from a ShaderSpec.
Portal::Graphics::ShaderSpec segmented_argmax_spec(uint32_t workgroup=256)
The spec of a SegmentedArgMax kernel.
- Parameters
-
| context | Context built with config. |
| config | Config of the spec the context was built from. |
| geometry | Segment length, stride, first offset and count. Every segment must lie inside the values. |
Definition at line 81 of file SegmentedArgMax.hpp.
83{
84 const std::array<uint32_t, 3> push { geometry.
length, geometry.
stride, geometry.
offset };
85 const size_t result_bytes =
static_cast<size_t>(geometry.
count) * 2U *
sizeof(uint64_t);
86
87 return DependencyStage {
88 .config = config,
89 .stage_fn = [&context, result_bytes, push](GpuDispatchCore&) {
92 }
94 },
95 .explicit_groups = std::array<uint32_t, 3> { geometry.
count, 1U, 1U },
96 };
97}
std::optional< SharedBufferInfo > shared_buffer_info(uint32_t set, size_t binding_index) const
What the shared buffer at (set, binding_index) declares, or nothing when absent.
void set_output_size(size_t index, size_t byte_size)
Declare the byte capacity of an output binding independently of input data.
void set_push_constants(const void *data, size_t bytes)
Set push constant data from a raw byte pointer.
References MayaFlux::Yantra::SegmentGeometry::count, MayaFlux::Yantra::SegmentGeometry::length, MayaFlux::Yantra::SegmentGeometry::offset, MayaFlux::Yantra::GpuDispatchCore::set_output_size(), MayaFlux::Yantra::GpuDispatchCore::set_push_constants(), MayaFlux::Yantra::GpuDispatchCore::shared_buffer_info(), and MayaFlux::Yantra::SegmentGeometry::stride.
Referenced by MayaFlux::Yantra::WaveformAnalyzer< std::vector< Kakshya::DataVariant >, Eigen::MatrixXd >::measure_chunk(), and segmented_argmax_stage().