Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,14 @@ All notable changes to CableDyn are recorded in this file. The format follows

## [Unreleased]

### Added

- The run-time profile (`CABLEDYN_PROFILE=1`, standalone driver and OpenFAST) splits the steps
of `EI = 0` lines into residual-only evaluations, residual and tangent evaluations, LU
factorisations and back-substitutions, with their counts and times, and separates the
factorisations of finite-EI cables from their back-substitutions (which now include the
force-blend correction that ends each step). Results do not change.

## [0.2.0] - 2026-10-20

### Added
Expand Down
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2047,15 +2047,15 @@ add_test(
-DDRIVER=$<TARGET_FILE:cabledyn>
-DDECK=${CMAKE_CURRENT_SOURCE_DIR}/examples/dynamic_chain_waves.dat
-DOUTPUT_ROOT=${CMAKE_CURRENT_BINARY_DIR}/driver_profile_ei0
"-DEXPECT=\n EI = 0 line steps: [1-9][0-9]* \\(substeps and retries included\\), Newton iterations: [1-9]"
"-DEXPECT=\n EI = 0 line steps: [1-9][0-9]* \\(substeps and retries included\\), Newton iterations: [1-9][^\n]*\n EI = 0 line step kernels: residual [0-9]+ \\([0-9.]+ s\\), residual and tangent [1-9][0-9]* \\([0-9.]+ s\\), factorisation [1-9][0-9]* \\([0-9.]+ s\\), back-substitution [1-9][0-9]* \\([0-9.]+ s\\)\\."
-P ${CMAKE_CURRENT_SOURCE_DIR}/tests/check_driver_profile.cmake)
add_test(
NAME driver_profile_finite_ei
COMMAND ${CMAKE_COMMAND}
-DDRIVER=$<TARGET_FILE:cabledyn>
-DDECK=${CMAKE_CURRENT_SOURCE_DIR}/tests/data/held_start_gomex80_power_cable.dat
-DOUTPUT_ROOT=${CMAKE_CURRENT_BINARY_DIR}/driver_profile_finite_ei
"-DEXPECT=\n Finite-EI cable steps: [1-9][0-9]*, residual evaluations: [1-9]"
"-DEXPECT=\n Finite-EI cable steps: [1-9][0-9]*, residual evaluations: [1-9][0-9]*, tangent assemblies: [1-9][0-9]*, factorisations: [1-9][0-9]*, linear solves: [1-9][0-9]*, force-blend corrections: [0-9]+[^\n]*\n Finite-EI cable step time \\(s\\): residual [0-9.]+, tangent [0-9.]+, effective matrix [0-9.]+, factorisation [0-9.]+, back-substitution [0-9.]+, added mass [0-9.]+, other [0-9.]+\\."
-P ${CMAKE_CURRENT_SOURCE_DIR}/tests/check_driver_profile.cmake)
add_test(
NAME driver_profile_failure
Expand Down
33 changes: 22 additions & 11 deletions app/cabledyn.f90
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ PROGRAM cabledyn
USE CableDyn_Profile, ONLY: CD_Profile_Requested, CD_Profile_Arm, CD_Profile_Armed, CD_Profile_Enter, &
CD_Profile_Flush, CD_Profile_Step, CD_Profile_Seconds, CD_Profile_Counts, &
CD_PROF_INPUT, CD_PROF_INIT, CD_PROF_FLUID, CD_PROF_SOLVE, CD_PROF_CHECK, &
CD_PROF_OUTPUT, CD_PROF_PROGRESS, CD_PROF_FINAL, CD_PROF_NPHASE
CD_PROF_OUTPUT, CD_PROF_PROGRESS, CD_PROF_FINAL, CD_PROF_NPHASE, &
CD_Profile_Kernels, CD_PROF_K_RESIDUAL, CD_PROF_K_TANGENT, CD_PROF_K_FACTOR, &
CD_PROF_K_SOLVE, CD_PROF_NKERNEL
USE CableDyn_HermiteCableDynamic, ONLY: CD_HermiteCable_Dyn_Reset_Profile, CD_HermiteCable_Dyn_Get_Profile, &
CD_HermiteCable_Dyn_Recovery_Reset, CD_HermiteCable_Dyn_Recovery_Count
USE, INTRINSIC :: ISO_FORTRAN_ENV, ONLY: error_unit, output_unit, int64
Expand Down Expand Up @@ -857,9 +859,10 @@ SUBROUTINE print_profile()
!! of each phase of the run, the step counts and the Newton iterations, and the interior of
!! the finite-EI cable steps. Printed once, on stdout, at the end of the run.
LOGICAL, SAVE :: printed = .FALSE.
REAL(wp) :: seconds(CD_PROF_NPHASE), total, march, t_step, t_resid, t_eff, t_solve, t_am, t_tan
INTEGER(int64) :: march_steps, line_steps, line_iterations
INTEGER :: line_max_iterations, n_step, n_resid, n_solve, n_am, n_alloc, n_tan, k
REAL(wp) :: seconds(CD_PROF_NPHASE), total, march, t_step, t_resid, t_eff, t_solve, t_am, t_tan, t_factor
REAL(wp) :: kernel_seconds(CD_PROF_NKERNEL)
INTEGER(int64) :: march_steps, line_steps, line_iterations, kernel_calls(CD_PROF_NKERNEL)
INTEGER :: line_max_iterations, n_step, n_resid, n_solve, n_am, n_alloc, n_tan, n_factor, n_correct, k
IF (printed .OR. .NOT. CD_Profile_Armed()) RETURN
printed = .TRUE.
! the running phase up to now: the finalisation of a completed run, or the phase in which a
Expand Down Expand Up @@ -887,16 +890,24 @@ SUBROUTINE print_profile()
IF (line_steps > 0_int64) WRITE (output_unit, '(A,I0,A,I0,A,A,A,I0,A)') ' EI = 0 line steps: ', &
line_steps, ' (substeps and retries included), Newton iterations: ', line_iterations, ' (', &
fixed(REAL(line_iterations, wp)/REAL(line_steps, wp), 3), ' per line step, at most ', line_max_iterations, ').'
CALL CD_Profile_Kernels(kernel_calls, kernel_seconds)
IF (line_steps > 0_int64) WRITE (output_unit, '(A,I0,3A,I0,3A,I0,3A,I0,3A)') &
' EI = 0 line step kernels: residual ', kernel_calls(CD_PROF_K_RESIDUAL), ' (', &
fixed(kernel_seconds(CD_PROF_K_RESIDUAL), 3), ' s), residual and tangent ', kernel_calls(CD_PROF_K_TANGENT), &
' (', fixed(kernel_seconds(CD_PROF_K_TANGENT), 3), ' s), factorisation ', kernel_calls(CD_PROF_K_FACTOR), &
' (', fixed(kernel_seconds(CD_PROF_K_FACTOR), 3), ' s), back-substitution ', kernel_calls(CD_PROF_K_SOLVE), &
' (', fixed(kernel_seconds(CD_PROF_K_SOLVE), 3), ' s).'
CALL CD_HermiteCable_Dyn_Get_Profile(n_step, n_resid, n_solve, n_am, n_alloc, t_step, t_resid, t_eff, &
t_solve, t_am, n_tan, t_tan)
t_solve, t_am, n_tan, t_tan, n_factor, t_factor, n_correct)
IF (n_step > 0) THEN
WRITE (output_unit, '(A,I0,A,I0,A,I0,A,I0,A,I0,A)') ' Finite-EI cable steps: ', n_step, &
', residual evaluations: ', n_resid, ', tangent assemblies: ', n_tan, ', linear solves: ', n_solve, &
WRITE (output_unit, '(A,I0,A,I0,A,I0,A,I0,A,I0,A,I0,A,I0,A)') ' Finite-EI cable steps: ', n_step, &
', residual evaluations: ', n_resid, ', tangent assemblies: ', n_tan, ', factorisations: ', n_factor, &
', linear solves: ', n_solve, ', force-blend corrections: ', n_correct, &
', intervals recovered by substeps: ', CD_HermiteCable_Dyn_Recovery_Count(), '.'
WRITE (output_unit, '(13A)') ' Finite-EI cable step time (s): residual ', fixed(t_resid, 3), &
', tangent ', fixed(t_tan, 3), ', effective matrix ', fixed(t_eff, 3), ', linear solve ', &
fixed(t_solve, 3), ', added mass ', fixed(t_am, 3), ', other ', &
fixed(MAX(0.0_wp, t_step - (t_resid + t_tan + t_eff + t_solve + t_am)), 3), '.'
WRITE (output_unit, '(15A)') ' Finite-EI cable step time (s): residual ', fixed(t_resid, 3), &
', tangent ', fixed(t_tan, 3), ', effective matrix ', fixed(t_eff, 3), ', factorisation ', &
fixed(t_factor, 3), ', back-substitution ', fixed(t_solve, 3), ', added mass ', fixed(t_am, 3), ', other ', &
fixed(MAX(0.0_wp, t_step - (t_resid + t_tan + t_eff + t_factor + t_solve + t_am)), 3), '.'
ELSE IF (.NOT. profile_cable_detail .AND. n_finite_ei > 0) THEN
WRITE (output_unit, '(A)') ' Finite-EI cable steps: not counted on the mixed EI = 0 + finite-EI route, '// &
'whose cables step concurrently.'
Expand Down
36 changes: 23 additions & 13 deletions doc/cli.rst
Original file line number Diff line number Diff line change
Expand Up @@ -157,20 +157,21 @@ breakdown such as:
.. code-block:: text

Run-time profile (CABLEDYN_PROFILE), wall-clock time:
input parsing 0.002 s 0.0 %
initialisation and statics 0.233 s 3.1 %
dynamic march 7.232 s 96.8 %
fluid sampled by the driver 0.050 s 0.7 %
line, cable and object steps 7.168 s 96.0 %
checks and line failures 0.001 s 0.0 %
outputs 0.013 s 0.2 %
input parsing 0.002 s 0.1 %
initialisation and statics 0.237 s 8.8 %
dynamic march 2.444 s 91.1 %
fluid sampled by the driver 0.050 s 1.9 %
line, cable and object steps 2.379 s 88.6 %
checks and line failures 0.002 s 0.1 %
outputs 0.012 s 0.5 %
progress and bookkeeping 0.000 s 0.0 %
finalisation 0.000 s 0.0 %
total 7.467 s 100.0 %
March: 600 committed step(s), 12.0528 ms per step.
EI = 0 line steps: 3621 (substeps and retries included), Newton iterations: 4661 (1.287 per line step, at most 2).
Finite-EI cable steps: 4849, residual evaluations: 21255, tangent assemblies: 10391, linear solves: 10391, intervals recovered by substeps: 0.
Finite-EI cable step time (s): residual 1.416, tangent 2.674, effective matrix 0.136, linear solve 0.943, added mass 0.167, other 0.457.
total 2.684 s 100.0 %
March: 600 committed step(s), 4.0735 ms per step.
EI = 0 line steps: 3621 (substeps and retries included), Newton iterations: 4739 (1.309 per line step, at most 2).
EI = 0 line step kernels: residual 6947 (0.039 s), residual and tangent 3322 (0.064 s), factorisation 3322 (0.013 s), back-substitution 5126 (0.009 s).
Finite-EI cable steps: 1423, residual evaluations: 6140, tangent assemblies: 2914, factorisations: 2914, linear solves: 2914, force-blend corrections: 1423, intervals recovered by substeps: 0.
Finite-EI cable step time (s): residual 0.412, tangent 0.883, effective matrix 0.039, factorisation 0.211, back-substitution 0.075, added mass 0.049, other 0.085.

The phases add up to the total, which runs from the start of the deck parse to the report. If the
run stops with an error, the time up to the stop counts to the phase in which it stopped, and
Expand All @@ -193,9 +194,18 @@ The counts follow the march:
* **EI = 0 line steps** counts every step of every tension-only line, including recovery
substeps, retries and, on the body marches, each re-step of a line within the body
iterations. **Newton iterations** is their total.
* **EI = 0 line step kernels** splits the work inside those steps: the residual-only
evaluations (predictor tests and line-search trials), the evaluations that also assemble the
effective tangent, the LU factorisations of that tangent, and the back-substitutions with it
(Newton updates, a reused factor and the end tangent of a body junction). Each count is
followed by its time, summed over the lines: it can exceed the wall time when lines step
concurrently, so set ``OMP_NUM_THREADS=1`` to compare it with the phase rows.
* **Finite-EI cable steps** counts the same for the cubic-Hermite cables. A cable clamped to a
body is re-stepped in every body iteration, so the count can exceed the number of march
steps.
steps. Its step time is split into the residual and tangent assemblies, the effective
matrix, the factorisations, the back-substitutions (of the Newton solves and of the
force-blend correction that ends each step), the added mass and the rest; the rarely used
torsion and consistent-acceleration solves count to the rest.

An unset or empty variable, or ``0``, leaves the profile off. The driver reads the variable once,
when it starts.
Expand Down
6 changes: 4 additions & 2 deletions doc/faq.rst
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,10 @@ OpenFAST coupling
benchmark does **not** imply a fast coupled run: OpenFAST may call ``CalcOutput`` several times
per physical step with different trial kinematics. Set the environment variable
``CABLEDYN_PROFILE=1`` before running ``openfast.exe`` to separate CableDyn solve, SeaState
sampling, output-probe, and native-I/O time; the standalone driver reads the same variable
and prints its own breakdown (:ref:`cli-profile`). Keep ``ModCoupling`` fixed while
sampling, output-probe, and native-I/O time, and to split the steps of ``EI = 0`` lines and
finite-EI cables into residual, tangent, factorisation and back-substitution time (with
``OMP_NUM_THREADS=1`` the line times add up to the solve time); the standalone driver reads
the same variable and prints its own breakdown (:ref:`cli-profile`). Keep ``ModCoupling`` fixed while
comparing configurations. Do not switch to loose coupling merely to meet a wall-clock target; on
the IEA-15MW reference model it materially changed platform and tension responses. Test
``OMP_NUM_THREADS=1`` as well as the intended threaded setting: three short lines can be too
Expand Down
37 changes: 36 additions & 1 deletion src/CableDyn_Dynamic.f90
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ MODULE CableDyn_Dynamic
CD_Cable_Free_Bandwidth
USE CableDyn_Linalg, ONLY: CD_Factor_Banded, CD_Solve_Banded, CD_Solve_Dense_As_Banded, &
CD_Solve_Factored_Banded
USE CableDyn_Profile, ONLY: CD_Profile_Kernel_Begin, CD_Profile_Kernel_End, CD_PROF_K_RESIDUAL, &
CD_PROF_K_TANGENT, CD_PROF_K_FACTOR, CD_PROF_K_SOLVE
USE, INTRINSIC :: ISO_FORTRAN_ENV, ONLY: int64
IMPLICIT NONE
PRIVATE

Expand Down Expand Up @@ -755,6 +758,8 @@ SUBROUTINE CD_Cable_Gen_Alpha_Step(q, v, a, elem_conn, l0, ea, rho_a, tension_on
LOGICAL :: accepted, has_load_proc, has_load_band_proc, has_added_mass_proc, has_added_mass_band_proc
LOGICAL :: has_load_force_proc
LOGICAL :: has_prescribed, direct_banded, have_eff, tangent_fresh, use_element_mass_band
! clock at the start of a profiled kernel (CABLEDYN_PROFILE; zero when not profiling)
INTEGER(int64) :: prof_k0
LOGICAL :: factored_now, guess_used, prev_end_ok, reuse_factor, reused, warm_call, r_at_qk
LOGICAL :: scales_stale, trial_is_iterate
INTEGER :: es
Expand Down Expand Up @@ -1239,8 +1244,10 @@ SUBROUTINE CD_Cable_Gen_Alpha_Step(q, v, a, elem_conn, l0, ea, rho_a, tension_on
END DO
! eval_dynamic has just checked this band finite when a banded load or added-mass
! callback contributes to it; the factorization then skips repeating that scan.
CALL CD_Profile_Kernel_Begin(prof_k0)
CALL CD_Factor_Banded(eff_band, kl, ku, ipiv, es, em, &
matrix_validated=has_load_band_proc .OR. has_added_mass_band_proc)
CALL CD_Profile_Kernel_End(CD_PROF_K_FACTOR, prof_k0)
factored_now = es == 0
work%step_factor = factored_now .AND. work%end_request
IF (es /= 0) THEN
Expand All @@ -1256,10 +1263,15 @@ SUBROUTINE CD_Cable_Gen_Alpha_Step(q, v, a, elem_conn, l0, ea, rho_a, tension_on
IF (direct_banded) THEN
! A tangent factored in this iteration is the finite LU CD_Factor_Banded returned; a
! reused one keeps the full check.
CALL CD_Profile_Kernel_Begin(prof_k0)
CALL CD_Solve_Factored_Banded(eff_band, kl, ku, ipiv, dq, es, em, factor_validated=tangent_fresh)
CALL CD_Profile_Kernel_End(CD_PROF_K_SOLVE, prof_k0)
ELSE
eff_free = eff(free, free)
! the dense path factors and solves in one call: profiled as a factorisation
CALL CD_Profile_Kernel_Begin(prof_k0)
CALL CD_Solve_Dense_As_Banded(eff_free, dq, es, em)
CALL CD_Profile_Kernel_End(CD_PROF_K_FACTOR, prof_k0)
END IF
IF (es /= 0 .OR. .NOT. CD_All_Finite(dq)) THEN
ErrStat = CD_DYN_SINGULAR
Expand Down Expand Up @@ -1497,7 +1509,9 @@ SUBROUTINE end_junction_data()
eff_band_unfactored(i, j) = eff_band(i, j)
END DO
END DO
CALL CD_Profile_Kernel_Begin(prof_k0)
CALL CD_Factor_Banded(eff_band, kl, ku, ipiv, es2, em2)
CALL CD_Profile_Kernel_End(CD_PROF_K_FACTOR, prof_k0)
END IF
work%step_factor = es2 == 0
IF (es2 /= 0) THEN
Expand Down Expand Up @@ -1539,7 +1553,9 @@ SUBROUTINE end_junction_data()
DO i = 1, nfx
work%end_k(i, j) = (R_trial(fixed(i)) - R(fixed(i)))/h
END DO
CALL CD_Profile_Kernel_Begin(prof_k0)
CALL CD_Solve_Factored_Banded(eff_band, kl, ku, ipiv, dq, es2, em2)
CALL CD_Profile_Kernel_End(CD_PROF_K_SOLVE, prof_k0)
IF (es2 /= 0 .OR. .NOT. CD_All_Finite(dq)) THEN
ErrStat = CD_DYN_SINGULAR
ErrMsg = 'CableDyn_Dynamic: junction end tangent back-solve failed: '//TRIM(em2)
Expand Down Expand Up @@ -1912,6 +1928,25 @@ SUBROUTINE form_trial(stp)
END SUBROUTINE form_trial

SUBROUTINE eval_dynamic(q_eval, Rout, es_e, em_e, effout, effbandout)
!! eval_dynamic_core, timed by the run-time profile (CABLEDYN_PROFILE) as a residual-only
!! evaluation or, with an effective tangent requested, as a residual and tangent one.
REAL(wp), INTENT(IN) :: q_eval(:)
REAL(wp), INTENT(OUT) :: Rout(:)
INTEGER, INTENT(OUT) :: es_e
CHARACTER(*), INTENT(OUT) :: em_e
REAL(wp), INTENT(OUT), OPTIONAL :: effout(:, :)
REAL(wp), INTENT(OUT), OPTIONAL :: effbandout(:, :)
INTEGER(int64) :: clock0
CALL CD_Profile_Kernel_Begin(clock0)
CALL eval_dynamic_core(q_eval, Rout, es_e, em_e, effout, effbandout)
IF (PRESENT(effout) .OR. PRESENT(effbandout)) THEN
CALL CD_Profile_Kernel_End(CD_PROF_K_TANGENT, clock0)
ELSE
CALL CD_Profile_Kernel_End(CD_PROF_K_RESIDUAL, clock0)
END IF
END SUBROUTINE eval_dynamic

SUBROUTINE eval_dynamic_core(q_eval, Rout, es_e, em_e, effout, effbandout)
!! R = M a_alpha + (1-af) r(q_eval, v_eval) + af r(q_n, v_n) with the force blend, else
!! M a_alpha + f_int(q_alpha) - f_ext - load(q_alpha, v_alpha) (f_ext constant). When
!! the OPTIONAL effout is present it also returns the effective tangent
Expand Down Expand Up @@ -2150,7 +2185,7 @@ SUBROUTINE eval_dynamic(q_eval, Rout, es_e, em_e, effout, effbandout)
CALL apply_release_cap(q_eval, Rout)
END IF
END IF
END SUBROUTINE eval_dynamic
END SUBROUTINE eval_dynamic_core

SUBROUTINE structural_inertia(Rout)
!! Rout = M a_alpha with the element consistent mass (of mass_l0 when present, the lengths
Expand Down
Loading
Loading