Add timing print-outs to FAST.Farm#3378
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds an optional, compile-time timing instrumentation mode for FAST.Farm to support coarse-grained profiling (function-level timing and a final summary), enabled via a new CMake option. It also expands NWTC console line-length limits to reduce truncation of timing output.
Changes:
- Add
FASTFARM_TIMING_PRINTSCMake option and wire it to Fortran compilation viaFF_TIMING_PRINTS. - Instrument FAST.Farm driver + subsystems (including AWAE) with timing accumulation and live/summary printouts.
- Increase NWTC
WrScrmaximum line length from 98 to 256 characters across multiple platform-specificSysSubsimplementations.
Reviewed changes
Copilot reviewed 15 out of 15 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| modules/nwtc-library/src/SysMatlabWindows.f90 | Increase WrScr max line length for Windows Matlab environment. |
| modules/nwtc-library/src/SysMatlabLinuxIntel.f90 | Increase WrScr max line length for Intel Fortran Linux Matlab environment. |
| modules/nwtc-library/src/SysMatlabLinuxGnu.f90 | Increase WrScr max line length for GNU Fortran Linux Matlab environment. |
| modules/nwtc-library/src/SysIVF.f90 | Increase WrScr max line length for Intel Visual Fortran Windows environment. |
| modules/nwtc-library/src/SysIVF_Labview.f90 | Increase WrScr max line length for IVF LabVIEW environment. |
| modules/nwtc-library/src/SysIFL.f90 | Increase WrScr max line length for Intel Fortran Linux environment. |
| modules/nwtc-library/src/SysGnuWin.f90 | Increase WrScr max line length for GNU Fortran Windows environment. |
| modules/nwtc-library/src/SysGnuLinux.f90 | Increase WrScr max line length for GNU Fortran Linux environment. |
| modules/nwtc-library/src/SysFlangLinux.f90 | Increase WrScr max line length for Flang Linux environment. |
| modules/awae/src/AWAE.f90 | Add AWAE timing accumulators + staged timing hooks in UpdateStates/CalcOutput. |
| modules/awae/CMakeLists.txt | Add build flag wiring for AWAE timing instrumentation. |
| glue-codes/fast-farm/src/FAST_Farm.f90 | Add top-level stage timing around major driver calls and print summary at end. |
| glue-codes/fast-farm/src/FAST_Farm_Subs.f90 | Implement timing accumulation, live events, AWAE detail draining, and summary formatting. |
| glue-codes/fast-farm/CMakeLists.txt | Add FF_TIMING_PRINTS compile definition when FASTFARM_TIMING_PRINTS is enabled. |
| CMakeLists.txt | Introduce top-level FASTFARM_TIMING_PRINTS option. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| INTEGER, PARAMETER :: ConRecL = 120 ! The record length for console output. | ||
| INTEGER, PUBLIC :: CU = 6 ! The I/O unit for the console (Can be changed with SetConsoleUnit subroutine) | ||
| INTEGER, PARAMETER :: MaxWrScrLen = 98 ! The maximum number of characters allowed to be written to a line in WrScr | ||
| INTEGER, PARAMETER :: MaxWrScrLen = 256 ! The maximum number of characters allowed to be written to a line in WrScr |
| integer(IntKi), save :: AWAE_TimingCount = 0 | ||
| character(128), save :: AWAE_TimingLabel(AWAE_MaxTimingEntries) | ||
| real(DbKi), save :: AWAE_TimingSerial(AWAE_MaxTimingEntries) = 0.0_DbKi | ||
| real(DbKi), save :: AWAE_TimingPar(AWAE_MaxTimingEntries) = 0.0_DbKi | ||
| character(64), save :: AWAE_TimingPrefix = '' |
There was a problem hiding this comment.
We generally do not allow save variables. These tend to break things when multiple instances are run simultaneously since it is not threadsafe.
In this context it is ok, but in general we discourage it.
Extract all FarmTiming_* subroutines and module variables from FAST_Farm_Subs.f90 into a new FAST_Farm_timings.f90 module. The new file has no #ifdef FF_TIMING_PRINTS guards (it is conditionally compiled via CMakeLists.txt). FAST_Farm_Subs conditionally USEs the module. Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com> Co-authored-by: GitHub Copilot <noreply@github.com>
Extract all AWAE timing subroutines and module variables from AWAE.f90 into a new AWAE_timings.f90 module. The new file has no #ifdef FF_TIMING_PRINTS guards (it is conditionally compiled via CMakeLists.txt). AWAE conditionally USEs the module and re-exports the public symbols. Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com> Co-authored-by: GitHub Copilot <noreply@github.com>
Expand the indent format specifier in WrScr from I2 to I3 (and Frm from CHARACTER(10) to CHARACTER(11)) to support indent values up to 999. With MaxWrScrLen increased to 256, the previous I2 format could overflow for indent > 99, producing invalid format strings. Fixes issue raised in: https://github.com/OpenFAST/openfast/pull/3378/changes#r3539678079 Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com> Co-authored-by: GitHub Copilot <noreply@github.com>
Feature or improvement description
Add timing capability to FAST.Farm for profiling. Manual timing is helpful when we want to time certain function calls in its entirety and do not need per-thread information given by classic profiler (e.g. vtune). Option is enabled by the
FASTFARM_TIMING_PRINTSoption in cmake.Impacted areas of the software
Mostly FAST.Farm. Small changes to NWTC library to support a longer screen output (from 98 to 256)
Additional supporting information
Live timing of major functions are added directly to the output file. Simple to be parsed afterwards. A summary is printed at the end of a simulation. An example output file is provided -- log.fastfarm.seed0.txt. The timing strings do indeed pollute the output, but keep in mind that it can (and should) be turned off unless the user is explicitly looking for it. I have not done any assessment on the effect of the actual timing measurements and print statements on the runtime.
Generative AI usage
I had AI come up with the structure of the timing so it's clean and not many lines are added before/after where I want to time. AI also wrote the cmake-related entries for the extra flag that is now available. Everything else (where the timings go, their strings, what I want timed, etc) was done by myself.
Co-authored-by: Anthropic Claude claude@anthropic.com
Note: not up to speed with rc-5.0.1, but there seems to have no merge conflicts.