Repository navigation
perf(hermite): evaluate each element kernel once for load and tangent (bit-identical) - #119
Merged
Merged
Conversation
… and tangent The first Newton iteration of a finite-EI dynamic step assembles its tangent at the predictor, the state its residual evaluation has just assembled, so every element kernel ran twice there. The predictor evaluation now runs each kernel once for its load and its tangent (evaluate_tangent_element with forces, in the same threshold-gated OpenMP loop as the tangent assembly), adds the loads to the residual serially in the element and phase order of the residual-only assembly, and keeps the element tangent blocks. The tangent assembly that follows at bitwise the same configuration, velocity and time scatters those blocks instead of evaluating the kernels again; every other assembly drops them. The refresh evaluation of modified Newton and cross-step reuse, which its tangent also follows, does the same. Every kernel forms its load by the same statements with or without its tangent, so the residual is bit-for-bit that of the residual-only assembly, and the scattered blocks are those the tangent assembly would evaluate. If an element evaluation fails (a tangent can overflow where the load stays finite), the evaluation assembles the residual-only way and keeps nothing, so every result and message is unchanged. A step that converges at its predictor needs no tangent: the next predictor then evaluates residual-only. Signed-off-by: Jae Hoon Seo <jaehoon.seo@inha.ac.kr>
An accepted line-search trial that the iteration goes on from assembles its tangent at the trial's own state, which the trial's residual evaluation has just assembled. In full Newton the full step (the first trial) of a line search now keeps its element tangents while the step's line searches have assembled fewer tangents than those of the previous step, and the line-search tangent assembly scatters them. The predictor keeps its element tangents when the previous step made a solve, in place of a flag that recorded whether it converged at its predictor. These rules only choose where the element kernels run: kept tangents are used only at bitwise the state they were evaluated at, so every result is unchanged. A trial that is rejected or converges keeps tangents that are not used. Signed-off-by: Jae Hoon Seo <jaehoon.seo@inha.ac.kr>
Owner
Author
|
@codex review |
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex Review: Didn't find any major issues. Chef's kiss. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
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.
Where a tangent follows the residual at the same state, the finite-EI dynamic step now evaluates each element kernel once for both. Each kernel already computes its load with the same statements whether or not it also returns its tangent.
Change
evaluate_tangent_element: gains an optionalforces(12,6)output with the structural, damping, drag, VIV and Froude–Krylov loads from the call that forms the tangent blocks.assemble_residual(stash_tangent):assemble_residual(use_stash):Error behaviour: if a kernel fails in a keeping pass, that pass recomputes the residual the plain way and keeps nothing. Errors and messages stay identical.
Where blocks are kept:
These choices decide only where kernels run, never a result.
Evidence
All 54 examples are bit-identical to the base, comparing every output byte for byte, in each of these runs:
OMP_NUM_THREADS=4, compared with the one-thread outputs;modified_newton True.Timings, median of 5, one thread:
lazy_wave_vessel_raolazy_wave_vessel_motionbuoy_clamped_cablelazy_wave_bend_stiffenerTests
-fcheck=all: 366/366.doc/cli.rstnow says that kept kernel time is counted as residual time inCABLEDYN_PROFILE.