57 return assemble.ssbo(
"result", BindingDirection::Output, result)
88 size_t count, uint32_t workgroup = 256)
91 const std::array<uint32_t, 1> push {
static_cast<uint32_t
>(count) };
92 const uint32_t groups = std::max<uint32_t>(1U,
static_cast<uint32_t
>((count + workgroup - 1) / workgroup));
102 .explicit_groups = std::array<uint32_t, 3> { groups, 1U, 1U },
161 if (!operand.resident && operand.host.size() < count) {
163 std::source_location::current(),
164 "word_pair_map_stage: a host operand holds {} elements, {} are required", operand.host.size(), count);
173 stage.stage_fn = [&context, a, b, unary, count, resident = std::move(stage.stage_fn)](
GpuDispatchCore& core) {
208 std::span<const double> a, std::span<const double> b, uint32_t workgroup = 256)
211 const size_t count = unary ? a.size() : std::min(a.size(), b.size());
227 std::vector<float> out(count);
Runs a shader on doubles carried as two 32-bit words, with no fp64 on the device.
Assemble & ssbo(std::string name, BindingDirection direction, Kakshya::GpuDataFormat format, Kakshya::DataModality modality=Kakshya::DataModality::SCALAR_F32)
Declare an SSBO binding.
Assemble & tmpl(KernelTemplate t)
Set the kernel template.
Assemble & word_op(WordPairOp o)
Set the operation of a WordPairMap.
Fluent assembler producing a ShaderSpec.
void download_binding(size_t index, void *dest, size_t byte_size)
Read back a specific binding into a caller-provided destination.
void download_shared(uint32_t set, size_t binding_index, void *dest, size_t byte_size)
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.
Non-template base that owns all type-independent GPU dispatch logic.
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.
Shader context whose numeric input is staged as a uvec2 per double.
@ BufferProcessing
Buffer processing (Buffers::BufferManager, processing chains).
@ Yantra
DSP algorithms, computational units, matrix operations, Grammar.
@ VEC2_U32
glm::uvec2: a 64-bit value as low word (x) and high word (y), not a sampled image format
@ FLOAT32
32-bit float (standard GPU)
@ WordPairMap
Applies one IEEE double operation to word-pair doubles, one thread per element.
BindingDirection
Data flow direction for a shader binding slot.
WordPairOp
Operation applied by a WordPairMap kernel.
@ ToFloat32
float32(a) rounded to nearest even, with IEEE results for zeros, infinities, NaN, overflow and float ...
@ Sqrt
sqrt(a). Unary: no b binding.
DependencyStage word_pair_map_stage(WordPairExecutionContext &context, const GpuComputeConfig &config, Portal::Graphics::WordPairOp op, size_t count, uint32_t workgroup=256)
The stage that applies the operation to count elements whose operands are already on the device.
Portal::Graphics::ShaderSpec word_pair_map_spec(Portal::Graphics::WordPairOp op, uint32_t workgroup=256)
The spec of a WordPairMap kernel.
constexpr size_t word_pair_result_bytes(Portal::Graphics::WordPairOp op) noexcept
Bytes of one result element: a word pair, or a float32 for ToFloat32.
constexpr bool word_pair_unary(Portal::Graphics::WordPairOp op) noexcept
True for an operation that takes no second operand.
std::vector< float > read_float_results(WordPairExecutionContext &context, size_t count)
Read the float32 results of a ToFloat32 stage recorded on the context.
Plain-data description of the compute shader to dispatch.
Complete declarative description of a generated compute shader.
One stage in a record_stages call.
static WordPairOperand on_device()
The operand is already on the device.
WordPairOperand(const std::vector< double > &values)
WordPairOperand(std::span< const double > values)
std::span< const double > host
WordPairOperand()=default
Where one operand of a WordPairMap stage comes from.