Skip to content

Cleanup flocking example to use composition - #254

Open
tychedelia wants to merge 1 commit into
neighbor-listsfrom
flocking-composition
Open

tychedelia wants to merge 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.55% of pixels differ

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

baseline f4e69a80d4 · adapter llvmpipe (LLVM 20.1.2, 256 bits) (Vulkan, Mesa 25.2.8-0ubuntu0.24.04.2 (LLVM 20.1.2))

Open the visual report · workflow run

This branch has not been deployed

No deployments
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.

1 participant