Skip to content

Conversation

@AhmedSalih3d
Copy link
Owner

Motivation

  • Reduce synchronization and per-thread reduction overhead by accumulating interaction contributions locally per particle instead of writing into threaded reduction buffers.
  • Avoid repeated zeroing/reset of large reduction arrays between neighbor loops by writing each particle once after its local accumulation.
  • Keep kernel-output and shifting behavior optional and zero-cost when disabled via SimulationMetaData dispatch.
  • Improve cache locality and simplify the simulation loop by moving accumulation into the per-particle traversal.

Description

  • Added construct_full_stencil and a KernelOutputLocal! pair to support per-particle local accumulation of kernel outputs when requested.
  • Implemented NeighborLoopPerParticle! overloads (with and without shifting) that iterate per particle, locally accumulate dρdt, acceleration, kernel values, and shifting terms, and write them once per particle.
  • Implemented ComputeInteractionsPerParticle! variants that compute pair contributions and return local increments instead of mutating threaded reduction arrays.
  • Switched SimulationLoop / RunSimulation to use the new per-particle neighbor loop and removed the intermediate threaded reduction/reset calls and the SimThreadedArrays reduction steps for the main interaction pass.

Testing

  • Ran julia --project=. -e 'using Pkg; Pkg.test()', which was attempted but precompilation stalled during CSV/UnicodePlots precompilation and the run was interrupted.
  • Per AGENTS.md, the repository currently lacks a test directory so Pkg.test() will report an error until tests are added, and full automated tests were therefore not completed.
  • No additional automated test suite was available to validate numerical equivalence after the change, so manual/bench testing is recommended before production use.
  • Command(s) executed: julia --project=. -e 'using Pkg; Pkg.test()' (precompilation stalled/interrupted).

Codex Task

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants