MayaFlux 1.0.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches

◆ run_windowed_kernel() [1/2]

std::vector< float > MayaFlux::Yantra::run_windowed_kernel ( ShaderExecutionContext<> & context,
const GpuComputeConfig & config,
const WindowedKernelShape & shape,
std::span< const WindowedInput > inputs,
uint32_t window_length,
uint32_t window_count,
uint32_t outputs,
std::span< const float > parameters )
inlinenodiscard

Run a windowed kernel over every window of one or more sequences.

Parameters
contextContext built with config and windowed_kernel_layout(shape).
configThe config the context was built from.
shapeThe shape the config was built for.
inputsOne entry per input of the shape. Every window must lie inside its input.
window_lengthSamples in each window, the same for every input.
window_countWindows to run.
outputsResults per window.
parametersFloats the kernel reads from the parameters binding.
Returns
window_count * outputs floats, window major, empty when there is nothing to run.
Exceptions
std::invalid_argumentwhen the number of inputs does not match the shape.

Definition at line 263 of file WindowedKernelAnalyzer.hpp.

267{
268 if (inputs.size() != shape.inputs) {
270 std::source_location::current(), "A kernel of {} inputs was given {}", shape.inputs, inputs.size());
271 }
272 if (window_count == 0 || outputs == 0) {
273 return {};
274 }
275
276 std::vector<uint32_t> push { window_length, inputs[0].stride, inputs[0].offset, window_count, outputs };
277 for (size_t input = 1; input < inputs.size(); ++input) {
278 push.push_back(inputs[input].stride);
279 push.push_back(inputs[input].offset);
280 }
281 const size_t result_bytes = static_cast<size_t>(window_count) * outputs * sizeof(float);
282 const float none = 0.0F;
283 const std::vector<WindowedInput> staged(inputs.begin(), inputs.end());
284
286 .config = config,
287 .stage_fn = [staged, parameters, &none, result_bytes, push, shape](GpuDispatchCore& core) {
288 for (size_t input = 0; input < staged.size(); ++input) {
289 if (!staged[input].resident) {
290 core.set_binding_data(input, staged[input].samples);
291 }
292 }
293 core.set_binding_data(shape.parameters_binding(), parameters.empty() ? std::span<const float>(&none, 1) : parameters);
294 core.set_output_size(shape.results_binding(), result_bytes);
295 core.set_push_constants(push.data(), push.size() * sizeof(uint32_t));
296 },
297 .explicit_groups = std::array<uint32_t, 3> { shape.groups(window_count), 1U, 1U },
298 } });
299
300 std::vector<float> results(static_cast<size_t>(window_count) * outputs);
301 context.download_binding(shape.results_binding(), results.data(), result_bytes);
302 return results;
303}
void download_binding(size_t index, void *dest, size_t byte_size)
Read back a specific binding into a caller-provided destination.
void record_stages(const std::vector< DependencyStage > &stages)
Stage and record each stage in order, one dispatch per stage.
Non-template base that owns all type-independent GPU dispatch logic.
@ ComputeMatrix
Compute operations (Yantra - algorithms, matrices, DSP).
@ Yantra
DSP algorithms, computational units, matrix operations, Grammar.
One stage in a record_stages call.
uint32_t groups(uint32_t windows) const noexcept

References MayaFlux::Journal::ComputeMatrix, MayaFlux::Yantra::GpuDispatchCore::download_binding(), MayaFlux::Yantra::WindowedKernelShape::groups(), MayaFlux::Yantra::WindowedKernelShape::inputs, MayaFlux::Yantra::WindowedKernelShape::parameters_binding(), MayaFlux::Yantra::GpuDispatchCore::record_stages(), MayaFlux::Yantra::WindowedKernelShape::results_binding(), and MayaFlux::Journal::Yantra.

Referenced by MayaFlux::Yantra::WaveformAnalyzer< std::vector< Kakshya::DataVariant >, Eigen::MatrixXd >::measure_chunk_native(), MayaFlux::Yantra::WindowedKernelAnalyzer< std::vector< Kakshya::DataVariant >, Eigen::MatrixXd >::run_chunk(), and run_windowed_kernel().

Here is the call graph for this function:
Here is the caller graph for this function: