36 uint32_t workgroup = 256)
49 if (geometry.
count == 0) {
52 stage(values, geometry);
56 return { result.begin(), result.end() };
Runs a shader on doubles carried as two 32-bit words, with no fp64 on the device.
Assemble & op(KernelOp o)
Set the named operation the emitter will lower to SPIR-V.
ShaderSpec build()
Finalise and return the ShaderSpec.
Assemble & pc(std::string name, Kakshya::GpuDataFormat format)
Declare a push constant field with explicit format.
Assemble & ssbo(std::string name, BindingDirection direction, Kakshya::GpuDataFormat format, Kakshya::DataModality modality=Kakshya::DataModality::SCALAR_F32)
Declare an SSBO binding.
Assemble & workgroup(uint32_t x, uint32_t y=1, uint32_t z=1)
Override workgroup size.
Assemble & tmpl(KernelTemplate t)
Set the kernel template.
Assemble & map(ReductionMap m)
Set the pointwise map of a SegmentedReduction.
Fluent assembler producing a ShaderSpec.
void set_output_size(size_t index, size_t byte_size)
Declare the byte capacity of an output binding independently of input data.
std::array< uint32_t, 3 > calculate_dispatch_size(size_t, const DataStructureInfo &) const override
One workgroup per segment.
std::vector< double > reduce(std::span< const double > values, const SegmentGeometry &geometry)
Reduce every segment.
SegmentedReductionContext(Portal::Graphics::KernelOp combine, Portal::Graphics::ReductionMap map=Portal::Graphics::ReductionMap::Identity, uint32_t workgroup=256)
void stage(std::span< const double > values, const SegmentGeometry &geometry)
Stage values and geometry for the next dispatch without running it.
void stage(const SegmentGeometry &geometry)
Stage the geometry for values that are already on the device.
static Portal::Graphics::ShaderSpec reduction_spec(Portal::Graphics::KernelOp combine, Portal::Graphics::ReductionMap map, uint32_t workgroup)
The spec of the template instance this context drives.
SegmentedReductionContext(const Portal::Graphics::ShaderSpec &spec)
ShaderExecutionContext & push(const T &data)
Set push constants from a trivially copyable struct or value.
output_type execute(const input_type &input, const ExecutionContext &ctx) override
Injects multipass configuration into the context before dispatch when set_multipass() has been called...
WordPairExecutionContext(GpuComputeConfig config, std::vector< GpuBufferBinding > bindings, bool order_key, std::string name="WordPairExecutionContext")
std::span< const double > primary_values() const noexcept
The primary output of the last dispatch decoded to doubles.
void stage_words(uint32_t binding, std::span< const double > values, size_t padded_count=0, bool complement=false)
Encode values and stage them as the data of a binding.
@ VEC2_U32
glm::uvec2: a 64-bit value as low word (x) and high word (y), not a sampled image format
@ SegmentedReduction
One workgroup per segment over word-pair doubles.
BindingDirection
Data flow direction for a shader binding slot.
ReductionMap
Pointwise map applied to each element before a SegmentedReduction combines it.
KernelOp
Named operation the SPIR-V emitter knows how to lower to opcodes.
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.
Complete declarative description of a generated compute shader.
Dimensions, modality, source type, and optional Composite field schema.
Input/Output container for computation pipeline data flow with structure preservation.
Context information controlling how a compute operation executes.
Where the windows of a GPU pass sit in the value array.