Skip to content

LANDISDisp: optional OpenMP threads for the spiral scan - #256

Open
eliotmcintire wants to merge 8 commits into
developmentfrom
perf/dispersal-openmp
Open

eliotmcintire wants to merge 8 commits into
developmentfrom
perf/dispersal-openmp

Conversation

@eliotmcintire

@eliotmcintire eliotmcintire commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

Seed dispersal can now use several processor cores for its slowest step, making it about twice as fast with 4 cores. Results are identical no matter how many cores are used, and the default is still one core.

Affects: run time only, and only when more cores are turned on.

Technical details

The receiver scan in spiralLoopCpp (src/spiralSeedDispersal.cpp) is the one serial part that uses no RNG, so it now runs under OpenMP when options(LandR.LANDISDisp.threads = n) is above 1 (default 1) and a step has at least 20000 active receivers. It uses a static schedule with one hit buffer per thread, joined in thread order, so the receiver order matches the serial loop. The uniform draws, success test and compaction stay serial on the main thread, so output is bit-identical for any thread count and to useCpp = FALSE. OpenMP is guarded with #ifdef _OPENMP, and src/Makevars and src/Makevars.win add $(SHLIB_OPENMP_CXXFLAGS).

Verified with a new test-LANDISDisp-threads.R (expect_identical for threads 1, 2, 4 and the R reference, skipped without OpenMP), plus the parity, seedLocked (LANDR_SLOW_TESTS=1), wardScreen and pgv tests, all passing.

Timing on the xxxlarge fixture (9M cells, pgv supplied, verbose 0, median of 5): the whole LANDISDisp call takes 0.72 s on #255 and 0.63 s, 0.39 s and 0.35 s here with 1, 2 and 4 threads, so about twice as fast at 4 threads. The threshold made no measurable difference at 5000, 20000 or 100000, so 20000 is kept. An earlier version of this description reported a smaller gain; its benchmark timed spiralLoopCpp with a nested system.time(), whose default gcFirst = TRUE added a full garbage collection (~0.55 s) to every whole-call time.

🤖 Generated with Claude Code

https://claude.ai/code/session_01CwcjqqK59FmTJscyi7xUqv

…ers, fork safety)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CwcjqqK59FmTJscyi7xUqv
eliotmcintire added a commit that referenced this pull request Oct 1, 2026
LANDISDisp: optional OpenMP threads for the spiral scan

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CwcjqqK59FmTJscyi7xUqv
achubaty and others added 2 commits October 1, 2026 21:04
NEWS only: keep both sides' entries.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Brings a86df7b, the R reference fix that makes the R/C++ parity tests pass on macOS.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
eliotmcintire added a commit that referenced this pull request Oct 3, 2026
LANDISDisp: optional OpenMP threads for the spiral scan

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@eliotmcintire eliotmcintire added enhancement New feature or request backwards compatible Existing code and results keep working unchanged labels Oct 6, 2026
eliotmcintire and others added 4 commits October 12, 2026 17:56
NEWS.md was the only conflict; both entries kept.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CwcjqqK59FmTJscyi7xUqv
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CwcjqqK59FmTJscyi7xUqv
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CwcjqqK59FmTJscyi7xUqv
NEWS: keep both sides.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014G18Mik3fH4z5M5CyMSUS6
@eliotmcintire
eliotmcintire marked this pull request as ready for review October 16, 2026 00:08
eliotmcintire added a commit that referenced this pull request Oct 16, 2026
LANDISDisp: optional OpenMP threads for the spiral scan

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014G18Mik3fH4z5M5CyMSUS6

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

backwards compatible Existing code and results keep working unchanged enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants