Skip to content

Branch shifting limiter terms#181

Open
AhmedSalih3d wants to merge 1 commit into
BeforeLidDrivenCavityExamplefrom
codex/replace-boolean-multiplication-with-branches
Open

Branch shifting limiter terms#181
AhmedSalih3d wants to merge 1 commit into
BeforeLidDrivenCavityExamplefrom
codex/replace-boolean-multiplication-with-branches

Conversation

@AhmedSalih3d

Copy link
Copy Markdown
Owner

Motivation

  • Avoid computing shift-related vector expressions for non-fluid interaction pairs because boolean-multiplied vector expressions can still perform expensive math even when the logical condition is false, so a branch can save work when many neighbours are boundary/non-fluid.
  • Microbenchmarking indicated the branched form is faster in a mixed fluid/boundary workload while producing identical results.

Description

  • Replace MotionLimiterCondition boolean scalar multiplication with an explicit if ParticleType[i] == Fluid && ParticleType[j] == Fluid branch in the kernel-output shifting path in src/SPHCellList.jl so Vᵢ and shift accumulations are only computed for fluid-fluid pairs.
  • Apply the same explicit fluid-fluid branch in the no-kernel-output shifting path in src/SPHCellList.jl to avoid computing unnecessary shift_c_acc and shift_r_acc terms for non-fluid pairs.
  • Commit contains only these branch replacements and associated minor reformatting in src/SPHCellList.jl.

Testing

  • Ran julia --project=. -e 'using Pkg; Pkg.test()', which errored in an existing time stepping test due to a preexisting MethodError: no method matching Δt(...) unrelated to this change (tests did not pass).
  • Ran julia --project=. -e 'using SPHExample; println("loaded")' which succeeded and precompiled the package.
  • Executed an ad-hoc automated microbenchmark comparing boolean-multiplication vs branched accumulation over 5,000,000 mixed pairs, which returned boolmul seconds=0.016947455, branched seconds=0.006823296, and identical numeric results (same=true).
  • Ran git diff --check (no whitespace/errors reported) as part of verification.

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.

1 participant