Repository navigation
perf: cheaper nodal-twist kernels (Hessians, frame-only transfer) - #187
Conversation
|
@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. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9da84fa58b
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
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".
The nodal twist evaluates every element's reference twist and holonomy, with their 12 x 12 Hessians on each tangent assembly. On a power cable with the nodal twist in a coupled OpenFAST run, these kernels are a large share of the cable step. A good part of that time went on run-time library calls and on Hessian entries nobody reads: - skew, outer, outer9 and identity3 used RESHAPE and SPREAD, which gfortran turns into calls into its run-time library (spread, reshape_r8) on every Gauss point and solid angle. They now set their entries one by one, with the same products. - The solid angle of a reference triangle formed its full 9 x 9 Hessian, while CD_HermiteTwist_Reference reads only the blocks between the triangle's free vertices (the node tangents; the committed tangents and end directors are fixed). With the new optional argument free, solid_angle forms those blocks alone, each entry with the same expression as before. - element_holonomy evaluated the shape derivatives twice per Gauss point (once directly, once inside element_ab). It also formed the two blocks of its 9 x 9 intermediate Hessian that are never read (rows of the unit tangent against the r' and r'' columns). - The finiteness checks of the reference vertices and of the Hessian are one rank-3 and one rank-2 test instead of 6 and 12 calls per element. Every entry is formed by the same floating-point operations in the same order, so the results are bit-identical. Signed-off-by: Jae Hoon Seo <jaehoon.seo@inha.ac.kr>
CD_HermiteCable_Dyn_Set_Torsion_Frames moves the committed torsion end frames without a step. The OpenFAST output probe calls it on every CalcOutput, and the checkpoint rebuild and the linearization call it as well. It re-based the twist reference of every element (tw_advance_reference), one twist_reference evaluation per element including the element holonomy. Yet the host writes only the end nodes, so the reference twist of every other element stays as it was. tw_advance_reference now forms the unit node tangents first. An interior element (not at a rigid end) whose two tangents equal the reference tangents, bit for bit, keeps its reference twist without the evaluation. Its transport solid angles are then exactly the reference terms they are differenced against, so twist_reference returns tw_beta(e) + tw_wrap(0) + 0; that sum is formed directly. The directors are carried as before. A frame-only transfer therefore evaluates only the elements at a rigid end, or at a node whose tangent the host turned. The commit of a step evaluates every element whose tangents moved. A zero tangent handle keeps a zero tangent in the scratch, so its elements are still evaluated and report it. The results are bit-identical. Signed-off-by: Jae Hoon Seo <jaehoon.seo@inha.ac.kr>
The frame-only shortcut of tw_advance_reference kept an element's reference twist when its two unit node tangents were the reference's. That was enough for the value: the reference twist depends on the element only through those tangents. It was not enough for the checks, though. twist_reference also checks the element's shape (the holonomy's fold and handle checks). Suppose a host translates an elastically restrained end past its neighbouring node without turning the end tangent. The end element then folds while both of its tangents are unchanged, and the q_check pass of CD_HermiteCable_Dyn_Set_Torsion_Frames accepted it. So CD_HFMF_SetCoupledKinematics wrote the boundary before the following assembly found the fold, which broke its all-or-nothing update. The committed reference now records the configuration it was formed at (tw_rq, set by tw_commit_reference from the configuration tw_advance_reference re-based at). An element keeps its reference twist only when its 12 DOFs are those, bit for bit, as well as its tangents. It then passed every check of twist_reference at that very shape. A reference that comes from a mirror, a snapshot or tw_init carries no configuration (tw_rq_ok = .FALSE.), so every element is evaluated until the next commit. The results stay bit-identical. Signed-off-by: Jae Hoon Seo <jaehoon.seo@inha.ac.kr>
9da84fa to
0742970
Compare
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 0742970893
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
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".
…nd drops it with the lengths The reference-twist shortcut of tw_advance_reference keeps an element's reference twist only at the configuration tw_rq, at which every element passed every check. Two problems with how tw_rq was kept: - It was re-recorded at every reference commit, a frame-only transfer's included, and dropped by every mirror reload (tw_unpack). In the OpenFAST shell the output probe moves the coupled end, commits the reference at that pose and is then reloaded from the mirror. So the shortcut was off for the probe of the following call, which cost the speed-up this change is for. tw_rq is now recorded only by the commit of a step (tw_commit_reference without frames_only). A frame-only transfer moves no element DOF but the end nodes', and keeps it. A reload keeps it as well: tw_rq is a configuration this model evaluated, and the shortcut still requires the element's unit node tangents to be those of the present reference, so a reloaded reference is used only where it matches. - A change of the unstretched lengths (active line control, rebuild_length_caches) did not drop it. The element shape depends on its reference length: a 0.5 m element with unit tangent handles folds at 2 m with the same DOFs, so its checks no longer hold. tw_rq_ok is now cleared there. Gate F of test_nodal_twist_dynamic gains the length case: a step records the configuration, a length change drops it, and the next step records it again. Results stay bit-identical. Signed-off-by: Jae Hoon Seo <jaehoon.seo@inha.ac.kr>
|
@codex review |
|
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". |
Summary
A finite-EI cable with the nodal twist (torsion with polar inertia
Irn) evaluates, for every element, a reference twist and an element holonomy. On a tangent assembly it also forms their 12 x 12 Hessians. In a coupled OpenFAST run of a lazy-wave power cable these kernels were the largest single part of the cable step.This PR makes them cheaper in two commits, each measured separately, plus two review fixes to the second. Both are bit-identical: every output,
.CD.outrow and restart is unchanged to the bit.1. Cheaper reference and holonomy Hessians (
CableDyn_HermiteTorsion)skew,outer,outer9andidentity3usedRESHAPEandSPREAD, which gfortran compiles into calls into its run-time library (_gfortran_spread,_gfortran_reshape_r8) on every Gauss point and solid angle. They now set their entries one at a time, with the same products.CD_HermiteTwist_Referencereads only the blocks between the triangle's free vertices: the node tangents, not the committed tangents or end directors. A new optional argumentfreemakessolid_angleform those blocks alone, each entry with the same expression.element_holonomyevaluated the shape derivatives twice per Gauss point (once directly, once insideelement_ab). It also formed two blocks of its 9 x 9 intermediate Hessian that nothing reads.2. A frame-only twist transfer re-bases only the elements that moved (
tw_advance_reference)CD_HermiteCable_Dyn_Set_Torsion_Framesmoves the committed torsion end frames without a step. The OpenFAST output probe calls it on everyCalcOutput, and the checkpoint rebuild and linearization call it too. It re-based the reference of every element. The host, however, writes only the end nodes.tw_advance_referencenow forms the unit node tangents first. An interior element (not at a rigid end) keeps its reference twist without the evaluation when its 12 DOFs are those of the last committed step (tw_rq, recorded by the step'stw_commit_reference) and its unit node tangents are those of the present reference, bit for bit. Its transport solid angles are then exactly the reference terms they are differenced against, sotwist_referencewould returntw_beta(e) + tw_wrap(0) + 0, and that sum is formed directly. The element also passed every check oftwist_referenceat that very shape.Matching the tangents alone is not enough for the checks (commit 3, from review): a host that translates an elastically restrained end past its neighbour without turning its tangent folds the end element while both tangents are unchanged. Commit 4, also from review, refines this:
tw_rqis recorded only by the commit of a step. A frame-only transfer moves no element DOF but the end nodes', so it keepstw_rq.tw_rqas well: it is a configuration this model evaluated, and the tangent condition admits a reloaded reference only where it matches. In the first version, a reload dropped it, so the shortcut was off for the next output probe.rebuild_length_caches, active line control) dropstw_rq, because the element shape depends on the reference length. The same happens before the first step and attw_init.A frame-only transfer therefore evaluates only the elements at a rigid end, or at a node whose tangent the host turned. The commit of a step still evaluates every element whose tangents moved. A zero tangent handle keeps a zero tangent in the scratch, so its elements are still evaluated and report it.
Tests
OpenFAST coupled runs: IEA-15 MW VolturnUS-S with three chains and a lazy-wave power cable (nodal twist, clamped hang-off), 300 s, one thread. The
.outand.CD.outof each build are compared with the build without this PR:DT0.02 s.outand.CD.outbyte-identicalDT0.025 stests/test_nodal_twist_dynamic.f90(new gate F) covers the review case. A bending-pinned line, elastic in torsion, is marched. Its coupled end is then written 0.8 m back along the line, past its neighbour, with the tangent unchanged. The write is refused before anything is written, both after the march and after a frame-only transfer of the committed pose. The gate also checks that a step records the configuration, that a length change drops it, and that the next step records it again.Checkpoint restart (checkpoint at 50 s of a 100 s run, compared with the continuous run): the
.CD.out(2000 rows) and.out(1000 rows) after 50 s are identical to the continuous run, which is itself byte-identical to the build without this PR.Full
ctest(including the slow tier) on the default OpenBLAS kernel and withOPENBLAS_CORETYPE=Prescott: 433 of 433 passed on each.Cost
This is the simulation CPU time of the 300 s runs, scaled to one simulated hour:
DT0.02 sDT0.025 sFinal head (ed43f45) against dev (5d97bde), measured interleaved (dev, branch, dev, branch) on a busier machine, so the absolute values sit about 10 % above the table:
DT0.02 sDT0.025 sThe
.outand.CD.outfiles of these runs are byte-identical to dev.