Repository navigation
Conversation
update_secondary_variables_state! passed the number of threads N, not the number of batches, to threaded_loop_minbatch, together with minbatch. With the default :batch thread type that is `@batch minbatch = minbatch for i in 1:N`, which Polyester runs on a single thread whenever N < 2 minbatch: the secondary variables were updated serially. Loop over the N_batches batches with threaded_loop instead, one contiguous batch per thread as before. The serial check also compared the function thread_type, not its value tt, with :serial. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
With one contiguous batch per thread, a model whose cost per entity varies with the state (e.g. a vertical-equilibrium model whose plume occupies a contiguous range of columns) gives one thread most of the work while the others wait. Use up to four batches per thread, thread t taking batches t, t + N, ..., so that each thread's share is spread over the entities. Results are unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Member
|
This was incorporated in #404 together with another option for secondary strides |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Secondary variables are updated in one contiguous batch per thread. When some cells cost much more than others, and these lie together (e.g. around a front), one thread gets most of the work while the others wait.
This PR splits the cells into up to four batches per thread and gives thread
tthe batchest, t + N, …, so each thread's work is spread over the grid. Results are unchanged.Trade-off: with uniform cost it is slightly slower. In an application with uneven cost, the secondary variables became 35 % faster, but the equations, which read them, about 12 % slower (likely cache locality); the total run time dropped 11 %. Builds on #384 (this branch includes its commit; I will rebase once #384 is merged).
Testing: test systems and
test/mesh.jlpass. Speed-up on 8 threads (100 × 100 grid): uniform cost 7.5× (#384) → 7.2×; one block of expensive cells 1.6× → 5.2×.Benchmark
As in #384, with
n = 1000 < i <= 3000 ? 4000 : 40sine evaluations per cell for the uneven case. Speed-ups against one serial pass in the same run (8 threads):main🤖 Generated with Claude Code