Skip to content

Commit 75429fd

Browse files
committed
fix: keep the profiled run's execution and count steps when committed
A third review found four more points. The finite-EI step counters are process-global, so with them armed the aggregate of the mixed EI = 0 + finite-EI route stepped its cables one after another; the profile now arms them only on the routes that step their cables in turn anyway, and on the mixed route reports that the cable steps are not counted, so the profiled run executes as an unprofiled one. The Hermite and the objects-only marches entered the output phase before checking the step status, so a failed step's time went to the outputs; they now check first. Committed steps were counted in the progress report after the outputs, so a step whose output failed was missed; every march now counts a step when it has passed its checks, before its outputs. Signed-off-by: Jae Hoon Seo <jaehoon.seo@inha.ac.kr>
1 parent 758cd97 commit 75429fd

4 files changed

Lines changed: 35 additions & 14 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,10 @@ All notable changes to CableDyn are recorded in this file. The format follows
1515
between input parsing, initialisation and statics, and the dynamic march. The march is split
1616
into the fluid sampled by the driver, the line, cable and object steps, the checks, the
1717
outputs, and the progress report. The profile also gives the committed steps and the time per
18-
step, the tension-only line steps and their Newton iterations, and the finite-EI cable steps
19-
with their residual, tangent and solve counts and times. Every output file is the same with
20-
and without it. See the manual's command-line page (Run-time profile).
18+
step, the tension-only line steps and their Newton iterations, and (outside the mixed
19+
`EI = 0` + finite-EI route) the finite-EI cable steps with their residual, tangent and solve
20+
counts and times. Every output file is the same with and without it. See the manual's
21+
command-line page (Run-time profile).
2122

2223
### Changed
2324

‎app/cabledyn.f90‎

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ PROGRAM cabledyn
6262
INTEGER :: nargs, ErrStat, n_ei0, n_finite_ei, iarg
6363
REAL(wp) :: dtM, tmax
6464
LOGICAL :: converged, has_dtm, has_tmax, has_motion_file, has_line_outputs, has_objects
65+
! the run-time profile includes the finite-EI cable step counters (not on the mixed route)
66+
LOGICAL :: profile_cable_detail = .FALSE.
6567
! Sized for the aggregate and deck-driver messages it relays (512-character buffers
6668
! plus deck-line context), so no diagnostic is cut short.
6769
CHARACTER(1024) :: ErrMsg
@@ -124,17 +126,23 @@ PROGRAM cabledyn
124126
! process's own.
125127
CALL CD_Fatal_Report_Install()
126128
! Opt-in run-time profile (environment variable CABLEDYN_PROFILE), printed before the last
127-
! stdout line. It also arms the finite-EI cable step counters.
129+
! stdout line.
128130
IF (CD_Profile_Requested()) THEN
129131
CALL CD_Profile_Arm()
130-
CALL CD_HermiteCable_Dyn_Reset_Profile()
131132
CALL CD_HermiteCable_Dyn_Recovery_Reset()
132133
WRITE (output_unit, '(A)') ' Run-time profile armed by CABLEDYN_PROFILE.'
133134
END IF
134135
CALL CD_Deck_Query_dtM(TRIM(deck_path), dtM, has_dtm, ErrStat, ErrMsg, tmax=tmax, &
135136
has_tmax=has_tmax, n_ei0=n_ei0, n_finite_ei=n_finite_ei, &
136137
has_motion_file=has_motion_file, standalone_scan=.TRUE., &
137138
has_line_outputs=has_line_outputs, input_files=input_files, has_objects=has_objects)
139+
IF (ErrStat == CD_DECKDRV_OK .AND. CD_Profile_Armed()) THEN
140+
! The finite-EI step counters are process-global, so the aggregate of the mixed route steps
141+
! its cables one after another while they are armed. That route keeps its cables concurrent
142+
! and reports no finite-EI step detail; every other route steps its cables in turn anyway.
143+
profile_cable_detail = .NOT. (n_ei0 > 0 .AND. n_finite_ei > 0 .AND. .NOT. has_objects)
144+
IF (profile_cable_detail) CALL CD_HermiteCable_Dyn_Reset_Profile()
145+
END IF
138146
IF (ErrStat == CD_DECKDRV_OK) THEN
139147
DO iarg = 1, SIZE(input_files)
140148
CALL check_input_not_output(TRIM(input_files(iarg)), TRIM(out_root), root_native, 'input file')
@@ -598,6 +606,8 @@ SUBROUTINE run_mixed_held_deck(deck, root, dt, has_dt, run_time, has_run_time, h
598606
ELSE
599607
consecutive_miss = 0
600608
END IF
609+
! a committed step: count it, then its outputs
610+
CALL CD_Profile_Step()
601611
CALL CD_Profile_Enter(CD_PROF_OUTPUT)
602612
CALL CD_AGG_CalcOutput(aggregate, es, em)
603613
IF (es /= CD_AGG_OK) THEN
@@ -821,7 +831,6 @@ SUBROUTINE update_standalone_progress(progress, step, simulated_time)
821831
INTEGER(int64) :: now
822832
REAL(wp) :: elapsed, remaining, percent
823833
CHARACTER(16) :: elapsed_text, remaining_text
824-
CALL CD_Profile_Step()
825834
! Every committed step: the time an abnormal end of the process reports.
826835
CALL CD_Fatal_Report_Time(simulated_time)
827836
IF (step >= progress%nstep .OR. MOD(step, progress%stride) == 0) THEN
@@ -888,6 +897,9 @@ SUBROUTINE print_profile()
888897
', tangent ', fixed(t_tan, 3), ', effective matrix ', fixed(t_eff, 3), ', linear solve ', &
889898
fixed(t_solve, 3), ', added mass ', fixed(t_am, 3), ', other ', &
890899
fixed(MAX(0.0_wp, t_step - (t_resid + t_tan + t_eff + t_solve + t_am)), 3), '.'
900+
ELSE IF (.NOT. profile_cable_detail .AND. n_finite_ei > 0) THEN
901+
WRITE (output_unit, '(A)') ' Finite-EI cable steps: not counted on the mixed EI = 0 + finite-EI route, '// &
902+
'whose cables step concurrently.'
891903
END IF
892904
FLUSH (output_unit)
893905
END SUBROUTINE print_profile

‎doc/cli.rst‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -203,10 +203,9 @@ when it starts.
203203
The profile only reads the clock and never changes a result: every output file is identical
204204
with and without it. Its cost is a few clock reads per step.
205205

206-
On the mixed ``EI = 0`` + finite-EI route, the cables of a profiled run are stepped one after
207-
another rather than concurrently, so that their counts stay exact. Without OpenMP, which
208-
includes the release executable, this changes nothing; with OpenMP, compare wall times of
209-
profiled runs only with other profiled runs.
206+
On the mixed ``EI = 0`` + finite-EI route the cables step concurrently, so the profile does not
207+
count the finite-EI cable steps there. It says so in their place, and leaves that route's
208+
execution exactly as in an unprofiled run.
210209

211210
``openfast.exe`` reads the same variable for its own module profile (see :doc:`faq`).
212211

‎src/CableDyn_DeckDriver.f90‎

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14382,6 +14382,7 @@ SUBROUTINE write_dynamic_out(out_root, channels, lines, points, opts, models, co
1438214382
ErrMsg = TRIM(ErrMsg)//INSPECTION_NOTE
1438314383
RETURN
1438414384
END IF
14385+
CALL CD_Profile_Step()
1438514386
CALL CD_Profile_Enter(CD_PROF_OUTPUT)
1438614387
IF (opts%has_motion_file) THEN
1438714388
CALL write_model_row(unit, t, channels, lines, points, models, output_work, ErrStat, ErrMsg, motion, step + 1)
@@ -14547,6 +14548,7 @@ SUBROUTINE write_system_dynamic_out(out_root, channels, lines, points, opts, sys
1454714548
RETURN
1454814549
END IF
1454914550
END IF
14551+
CALL CD_Profile_Step()
1455014552
CALL CD_Profile_Enter(CD_PROF_OUTPUT)
1455114553
CALL write_system_model_row(unit, t, channels, lines, points, system, output_work, ErrStat, ErrMsg)
1455214554
IF (ErrStat /= CD_DECKDRV_OK) THEN
@@ -14924,6 +14926,7 @@ SUBROUTINE write_rigid6_dynamic_out(out_root, channels, bodies, lines, points, o
1492414926
RETURN
1492514927
END IF
1492614928
END IF
14929+
CALL CD_Profile_Step()
1492714930
CALL CD_Profile_Enter(CD_PROF_OUTPUT)
1492814931
CALL write_system_model_row(unit, t, channels, lines, points, system, output_work, ErrStat, ErrMsg, &
1492914932
rigid=rigid, opts=opts, bathymetry=bathymetry)
@@ -15103,6 +15106,7 @@ SUBROUTINE write_rod_dynamic_out(out_root, channels, rod_types, rods, lines, poi
1510315106
converged = .FALSE.
1510415107
RETURN
1510515108
END IF
15109+
CALL CD_Profile_Step()
1510615110
CALL CD_Profile_Enter(CD_PROF_OUTPUT)
1510715111
CALL write_system_model_row(unit, t, channels, lines, points, system, output_work, ErrStat, ErrMsg, &
1510815112
rods=rod_state, opts=opts, bathymetry=bathymetry)
@@ -16137,8 +16141,11 @@ SUBROUTINE write_objects_dynamic_out(out_root, channels, bodies, rod_types, rods
1613716141
CALL pin_rod(rst(k))
1613816142
END DO
1613916143
END IF
16140-
CALL CD_Profile_Enter(CD_PROF_OUTPUT)
16141-
IF (ErrStat == CD_DECKDRV_OK) CALL write_row(t)
16144+
IF (ErrStat == CD_DECKDRV_OK) THEN
16145+
CALL CD_Profile_Step()
16146+
CALL CD_Profile_Enter(CD_PROF_OUTPUT)
16147+
CALL write_row(t)
16148+
END IF
1614216149
IF (ErrStat /= CD_DECKDRV_OK) THEN
1614316150
converged = .FALSE.
1614416151
CLOSE (unit)
@@ -16599,6 +16606,7 @@ SUBROUTINE write_multibody_dynamic_out(deck_path, out_root, channels, types, bod
1659916606
GOTO 800
1660016607
END IF
1660116608
END IF
16609+
CALL CD_Profile_Step()
1660216610
CALL CD_Profile_Enter(CD_PROF_OUTPUT)
1660316611
CALL mb_outputs(t)
1660416612
IF (ErrStat /= CD_DECKDRV_OK) GOTO 800
@@ -23764,8 +23772,9 @@ SUBROUTINE write_hermite_dynamic_out(out_root, channels, lines, points, opts, ca
2376423772
ErrMsg = 'CableDyn_DeckDriver: Hermite standalone step failed: '//TRIM(em); EXIT
2376523773
END IF
2376623774
END DO
23767-
CALL CD_Profile_Enter(CD_PROF_OUTPUT)
2376823775
IF (ErrStat /= CD_DECKDRV_OK) EXIT
23776+
CALL CD_Profile_Step()
23777+
CALL CD_Profile_Enter(CD_PROF_OUTPUT)
2376923778
CALL write_hermite_model_row(unit, t, channels, lines, points, cables, ErrStat, ErrMsg, &
2377023779
motion=motion, motion_time_index=MERGE(step + 1, 0, opts%has_motion_file), &
2377123780
has_motion=opts%has_motion_file, ranges=ranges)
@@ -24396,6 +24405,7 @@ SUBROUTINE write_finite_dynamic_out(out_root, channels, lines, points, opts, mod
2439624405
converged, ErrStat, ErrMsg)
2439724406
RETURN
2439824407
END IF
24408+
CALL CD_Profile_Step()
2439924409
CALL CD_Profile_Enter(CD_PROF_OUTPUT)
2440024410
IF (opts%has_motion_file) THEN
2440124411
CALL write_finite_model_row(unit, t, channels, lines, points, models, output_work, ErrStat, ErrMsg, &
@@ -25854,7 +25864,6 @@ SUBROUTINE update_driver_progress(progress, step, simulated_time)
2585425864
REAL(wp) :: elapsed, remaining, percent
2585525865
CHARACTER(16) :: elapsed_text, remaining_text
2585625866

25857-
CALL CD_Profile_Step()
2585825867
! Every committed step: the time an abnormal end of the process reports.
2585925868
CALL CD_Fatal_Report_Time(simulated_time)
2586025869
IF (progress%nstep > 0 .AND. step > 0 .AND. &

0 commit comments

Comments
 (0)