Skip to content

Cleanup flocking example to use composition - #254

Merged
catilac merged 1 commit into
neighbor-listsfrom
flocking-composition
Oct 5, 2026
Merged

catilac merged 1 commit into
neighbor-listsfrom
flocking-composition

Conversation

@tychedelia

@tychedelia tychedelia commented Sep 29, 2026 •

Copy link
Copy Markdown
Member

Flocking is now built from the generic ops, so the built-in flock goes.

  • Removed: p.flock(), particles_flock, particles_kernel_flock, the flock.wgsl kernel, and its FFI constructor.
  • flocking_gpu.py is now a recipe with no shader code: find neighbors, sum what each rule steers toward, apply steering with a mask for boids that have no neighbors, then add the force to velocity and limit the speed.

It's slower than the fused kernel: about 3.5 ms vs 1.6 ms at 20k boids, and 8 ms vs 4 ms at 100k. Most of that is the per-dispatch cost of ~30 passes, not GPU work, so batching submits is the next thing to look at. Anyone who needs the speed can still write a small kernel that reads neighbors directly.

@tychedelia
tychedelia added this pull request to stack #256 September 29, 2026 04:50
@tychedelia
tychedelia removed this pull request from stack #256 September 29, 2026 05:06
@tychedelia
tychedelia added this pull request to stack #258 September 29, 2026 05:06
@github-actions

github-actions Bot commented Sep 29, 2026 •

Copy link
Copy Markdown

Visual regression: 1 changed of 43 cases

case status detail
py_flocking_gpu ❌ changed 28.6% of pixels differ

If these changes are intentional, add the deliberate-rendering-change label.

baseline 496b5c8bd8 · adapter llvmpipe (LLVM 20.1.2, 256 bits) (Vulkan, Mesa 25.2.8-0ubuntu0.24.04.4 (LLVM 20.1.2))

Open the visual report · workflow run

@tychedelia
tychedelia force-pushed the flocking-composition branch 2 times, most recently from bc50b98 to 2a145c5 Compare September 29, 2026 18:45
@catilac
catilac force-pushed the flocking-composition branch from 2a145c5 to 67ca33b Compare October 5, 2026 14:35

@catilac catilac left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is really really cool, @tychedelia. I will play with this API after we get this all merged. This looks good though. It looks like flocking_gpu_flock.wesl and flocking_gpu_integrate.wesl can be deleted now?

@catilac
catilac merged commit 0b1a55d into main Oct 5, 2026
4 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants