Repository navigation
perf: evaluate a cable's line-wide channel values once per output row - #184
Merged
Merged
Conversation
Every Twist<L>N<J> channel of a finite-EI cable re-evaluated the twist of every element of the line (CD_HermiteCable_Dyn_Element_Twist, with the twist reference and its Hessian per element), and every Torq<L>N<J>, CurvX/CurvY and VIV amplitude channel re-evaluated its own line-wide array. On the coupled OpenFAST route the channels are evaluated in every CalcOutput (about two per step) and again for the committed-step row of the .CD.out, so a deck with a few twist channels spent most of its CalcOutput time on them. The channels of one output row now share these values: CD_ChannelRow (the former load-power row cache) also carries the torsion state, the element and end twists, the node torques, the section curvature and the VIV amplitude of a cable. The first channel of a row that needs a value evaluates it with the same call the channel made before, and the cable's other channels of the row read it, so every value is bit-identical. A row is valid for one state only: CD_AGG_EvalChannels (new) clears it at the start and the end of every row, the standalone routes per row. - CD_CalcOutput, its committed-step row and lin_eval evaluate the channels with CD_AGG_EvalChannels. A supercycled module's row takes the channels the same call has just evaluated on the committed state (the re-evaluation repeated them bit for bit). - The standalone mixed route (write_mixed_row), the multibody march and the cubic-Hermite writer pass the row through CD_Eval_Aggregate_Channel / eval_cable_channel. - A channel that fails still ends the row after the channels before it. On the IEA-15MW UMaine model with a 600-element lazy-wave cable restrained in torsion (nine Twist and nine BendMom channels, DT 0.01 s), CalcOutput takes 12.3 ms per step instead of 26.6 ms (channels 1.0 ms instead of 9.9 ms, the .CD.out row 0.6 ms instead of 5.1 ms). The coupled cases, restarts, linearization files, FAST.Farm and the example decks are bit-identical to dev. 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. 👍 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.
Summary
CalcOutputof the coupled route was dominated by the deck channels, not by the solve. EveryTwist<L>N<J>channel of a finite-EI cable re-evaluated the twist of every element of its line (CD_HermiteCable_Dyn_Element_Twist: the twist reference and its Hessian per element), and OpenFAST evaluates the channels in each of its ~2.1CalcOutputcalls per step and once more for the committed-step row of the.CD.out.The channels of one output row now share the line-wide values of a cable: they are evaluated once per row instead of once per channel. Every output is unchanged to the bit.
CD_ChannelRow(the former load-power row) also carries the torsion state, the element and end twists, the node torques, the section curvature (CurvX/CurvY) and the VIV amplitude. The first channel of a row that needs a value evaluates it with the call the channel made before; the cable's other channels of the row read it.CD_AGG_EvalChannels(new) clears the rows at the start and at the end of every row, so nothing is carried from one state to the next. The standalone routes clear them per output row.CD_CalcOutput, its committed-step.CD.outrow andlin_eval(OpenFAST and FAST.Farm);write_mixed_row), the multibody march and the cubic-Hermite writer.dtM > DT, the.CD.outrow takes the channels the same call has just evaluated on the committed state (the re-evaluation repeated them bit for bit).Profile
IEA-15MW UMaine (r-test
MD_Sharedturbine 1, pose reset),DT = 0.01 s, 1000 steps, SeaState JONSWAP waves withWaterKin SEASTATE, one thread,CABLEDYN_PROFILE=1. Deck: the three chains and the lazy-wave cable ofiea15mw_umaine_mixed_cabledyn.datrefined to 1 m elements (600 elements), restrained in torsion (GJ5e4 N m²,Irnfrom the sections, pinned ends, 90° pretwist), seabed friction 0.35, and 37 channels (nineTwist4N<J>, nineBendMom4N<J>,Twist4, twoTorq4N<J>, tensions, kinematics, point forces). Medians of three runs each, in ms per step:CalcOutput(2.1 calls per step).CD.outrowUpdateStatesCalcOutputof 24.9–29.2 ms; this PR's gave 12.1–12.5. The overlay, restore and step rows run unchanged code, so their differences are timing noise on a shared machine.CalcOutputcalls are all fresh (nsuper = 1).BendMom. It was already O(1) per channel: two element residuals, cached per element state. Its code is unchanged, and all 37 channels together now take 1.0 ms, so the old channel time was the twist channels.Not done: skipping the output-probe overlay at the committed kinematics
The overlay and restore of
CalcOutput(save, transfer, restore of the mirror; 8.2 ms per step above) are left as they are. Skipping them when a call's input carries exactly the kinematics of the last advance is not bit-identical in general, so it is not in this PR.How often it would apply. An instrumented build counted the calls whose input equals the committed input bit for bit. Under the OpenFAST glue (
ModCoupling 3,InterpOrder 2) this was the first call after the advance in 764 of 1000 steps; the others differ by at most 7e-15 (extrapolation round-off). Under the module driver and FAST.Farm it was every call.Why it is not exact. The overlay of the committed kinematics is not a no-op:
CD_HermiteCable_Dyn_Set_Torsion_Frames);prepare_parent_end).The restore also resets in-step copies that a skipped call would keep: the VIV phases at the evaluation point, the cached committed force and
a_restored(CD_HFMF_UnpackMirror).A measured counterexample. In an aggregate-level check (not part of this PR) with two clamped, torsion-restrained cables (one with
GJ|Kcoupling and an end spring), the overlay of the committed kinematics changedTorq2N1,Twist3N2,Torq3N1and both fairlead moments by one ulp at step 4 of 12, for example 6.7999987504996443E+02 against 6.7999987504996454E+02.The exact case is not worth the code. A skip that is provably exact needs a deck without end connections, torsion, friction, VIV, viscoelastic or Syrope lines, bodies, rods and failures. On such a deck (the UMaine chains) the overlay and restore cost 0.03 ms of a 0.27 ms
CalcOutput.The instrumented runs found no difference on the decks below. The counterexample is the reason the skip is still left out.
Bit-identity
Every output of the dev executables (
origin/dev5f1db71) is compared line by line with this branch's; only header lines carrying a date, a time or the version are skipped.Coupled OpenFAST, gfortran, double precision (r-test
MD_Sharedturbine 1;OutFmt ES24.15E3,DT_Outevery step):.out,.CD.out,.CD.static.outtors1crcNumCrctn = 1: every step rewinds and re-advanceslooseModCoupling = 1ckpt+ restart-restartto 4 slinLinearize,LinTimes 1.0, 2.5,LinInputs/LinOutputs2, still water (dYdu/dYdx differencelin_eval's channels).lin+ 3sciea15mw_umaine_mixed_cabledyn.datwithdtM = 0.05 s(nsuper = 5): the reused.CD.outrowei0CableDyn_UMaine.datchains,dtM = DTcd_settle,cd_harmonicof the OpenFAST tree, and the torsion deck under six-DOF platform motionMD_SharedwithMod_SharedMooring = 5, 10 sFarmCD.out,FarmCD.static.out,T1.out,T2.outSingle precision (
-DDOUBLE_PRECISION=OFF, the release executable'sReKi):tors1,crc,ckpt+ restart andlin(10.linfiles and its 3 outputs) are identical between dev and this PR.Standalone driver: all 63 example decks (191 output files) and all 52 test-data decks (150 files) are byte-identical, the decks that fail on purpose included.
Checkpoint files. The
.chkpfiles themselves cannot be compared: two runs of the same dev executable already differ in 8241 bytes (wall-clock strings, and uninitialised or pointer-valued words). Restarts are therefore compared by their outputs.Tests
channel_rowtest. A coupled deck has an EI = 0 line and two finite-EI cables restrained in torsion; one hasGJ|Kand a torsional end spring, and every fairlead surges and rolls. Its 29 channels mix twists, torques, bend moments, curvatures,CurvX/CurvY, tensions, kinematics and point forces. The test checks:CD_AGG_EvalChannels, the test fails (3 checks).Checks
OPENBLAS_CORETYPE=Prescott: 433/433 pass.-fcheck=all): the 19 tests that evaluate aggregate or cable channels pass:channel_row,openfast_aggregate,openfast_aggregate_touchdown;coupled_torsion,lin_torsion,control_torsion,torsion_one_end,torsion_deck;mixed_route_torsion,mixed_route_currents,two_moving_ends,coupled_cable_tolerance;point_seabed_contact,load_power_deck,viv_amplitude_deck,section_curvature;line_values_match_channels,step_allocations,memory_growth_aggregate.fprettifyleaves the changed sources unchanged.sphinx-build -W --keep-going -b html docpasses.[Unreleased]→ Changed. No input, option or output changes, so no doc pages change.