Dispatch through mruby-gpu-narray's dispatch_pipeline() - #2
Open
yujiteshima wants to merge 2 commits into
Open
yujiteshima wants to merge 2 commits into
yujiteshima wants to merge 2 commits into
Conversation
- map2 / GPU.kernel { |x, y| }: a second input array (LAYOUT_3BUF), arity
taken from the block or given as arity: 2; size mismatch is ArgumentError
- sum { |x| ... }, dot(b), GPU.kernel(reduce: :sum | :min | :max): the
expression and a shared-memory tree reduction in one shader, partials
combined on the host in double (same arrangement as narray's #sum)
- where(cond, a, b), comparisons > < >= <= == != and & | ! on Expr; a
condition used as a number (or vice versa) is a TypeError before glslang
- iterate(init, count) { |acc, i| } emits a real GLSL for loop via a small
statement-emitting Codegen; loops nest; count must be an Integer at trace
time. Ruby loops with a known count are simply unrolled (documented)
- one-input shaders are byte-identical to before; 58/58 tests
Merge note: dispatch_kernel() in src/gpu_kernel.c now takes a layout and 2 or
3 buffers. The deferred-submit branch replaces that function with narray's
dispatch_pipeline(); when merging, keep the layout/3-buffer call sites here
and drop the local dispatch body in favour of the upstream entry point.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Drops the private copy of the dispatch routine. A traced kernel -- one or
two inputs, element-wise or reduction -- is now recorded into the base gem's
deferred batch like any built-in operator, so a.map { ... } queues one
dispatch and nothing is submitted until a result is read. For reductions,
mapping the partials is what flushes the batch.
examples/kernel_dsl.rb times the operator chain three ways (a wait per
operator, one batch, one traced kernel), because under deferred submission
the old loop measured recording rather than execution.
Needs a mruby-gpu-narray that exports dispatch_pipeline() (its
deferred-submit branch, PR #4). Stacked on dsl-control-flow (PR #1).
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Drops the private copy of the dispatch routine. A traced kernel — one or two inputs, element-wise or reduction — is now recorded into the base gem's deferred batch like any built-in operator:
a.map { ... }queues one dispatch, and nothing is submitted until a result is read (GPU.pendingcounts it,GPU.syncflushes it). Reductions keep their host-side combine; mapping the partials is what flushes the batch.examples/kernel_dsl.rbnow times the operator chain three ways — a wait per operator (GPU.sync_mode = :eager), one batch, one traced kernel — because under deferred submission the old loop measured recording rather than execution:Depends on
dispatch_pipeline()and theGpuBuffer **dispatch signature. Until that is merged, this branch builds only against a local checkout of that branch, listed before this gem inbuild_config.rb.mainon purpose, so that merging cannot land it on a side branch.)Tests
58/58 against mruby-gpu-narray
deferred-submit; the base gem's 59 tests also pass with this gem in the build.examples/kernel_dsl_2.rb(map2,sum { },where,iterate) runs inside a batch.🤖 Generated with Claude Code