Skip to content
This repository was archived by the owner on Aug 28, 2024. It is now read-only.

Commit

Permalink
Added timers to help troubleshoot speed issues with the big productio…
Browse files Browse the repository at this point in the history
…n runs
  • Loading branch information
daminton committed Apr 25, 2023
1 parent 6dd5767 commit 012e05c
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 13 deletions.
22 changes: 20 additions & 2 deletions src/swiftest/swiftest_driver.f90
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ program swiftest_driver
integer(I4B) :: nout !! Current output step
integer(I4B) :: istep !! Current value of istep (used for time stretching)
type(walltimer) :: integration_timer !! Object used for computing elapsed wall time
type(walltimer) :: t1, t2, t3, t4

call swiftest_io_get_args(integrator, param_file_name, display_style)

Expand Down Expand Up @@ -105,7 +106,7 @@ program swiftest_driver
if (param%lcoarray .and. (this_image() < num_images())) sync images(this_image() + 1)

! Distribute test particles to the various images
call nbody_system%coarray_distribute(param)
if (param%lcoarray) call nbody_system%coarray_distribute(param)
#endif

! If this is a new run, compute energy initial conditions (if energy tracking is turned on) and write the initial conditions to file.
Expand All @@ -132,7 +133,9 @@ program swiftest_driver
nbody_system%t = t0 + iloop * dt

!> Evaluate any discards or collisional outcomes
call t1%start()
call nbody_system%discard(param)
call t1%stop()

!> If the loop counter is at the output cadence value, append the data file with a single frame
if (istep_out > 0) then
Expand All @@ -145,11 +148,17 @@ program swiftest_driver
istep = floor(istep_out * fstep_out**nout, kind=I4B)
end if

call t2%start()
call system_history%take_snapshot(param,nbody_system)
call t2%stop()

if (idump == dump_cadence) then
idump = 0
call t3%start()
call nbody_system%dump(param, system_history)
call t3%stop()
call t3%report(message="Dump", unit=display_unit)
call t3%reset()
end if
#ifdef COARRAY
if (this_image() == 1 .or. param%log_output) then
Expand All @@ -166,7 +175,16 @@ program swiftest_driver
if (param%lenergy) call nbody_system%conservation_report(param, lterminal=.true.)
#ifdef COARRAY
end if ! (this_image() == 1)
call nbody_system%coarray_balance(param)
call t4%start()
if (param%lcoarray) call nbody_system%coarray_balance(param)
call t4%stop()

call t1%report(message="Discard", unit=display_unit)
call t2%report(message="Snapshot", unit=display_unit)
call t4%report(message="Balance", unit=display_unit)
call t1%reset()
call t2%reset()
call t4%reset()
#endif
end if
end if
Expand Down
33 changes: 22 additions & 11 deletions src/swiftest/swiftest_io.f90
Original file line number Diff line number Diff line change
Expand Up @@ -228,16 +228,15 @@ module subroutine swiftest_io_display_run_information(self, param, integration_t
character(len=64) :: pbarmessage
character(*), parameter :: symbacompactfmt = '(";NPLM",ES22.15,$)'
#ifdef COARRAY
character(*), parameter :: statusfmt = '("Image: ",I4, "; Time = ", ES12.5, "; fraction done = ", F6.3, ' // &
character(*), parameter :: co_statusfmt = '("Image: ",I4, "; Time = ", ES12.5, "; fraction done = ", F6.3, ' // &
'"; Number of active pl, tp = ", I6, ", ", I6)'
character(*), parameter :: symbastatfmt = '("Image: ",I4, "; Image: Time = ", ES12.5, "; fraction done = ", F6.3, ' // &
character(*), parameter :: co_symbastatfmt = '("Image: ",I4, "; Image: Time = ", ES12.5, "; fraction done = ", F6.3, ' // &
'"; Number of active pl, plm, tp = ", I6, ", ", I6, ", ", I6)'
#else
#endif
character(*), parameter :: statusfmt = '("Time = ", ES12.5, "; fraction done = ", F6.3, ' // &
'"; Number of active pl, tp = ", I6, ", ", I6)'
character(*), parameter :: symbastatfmt = '("Time = ", ES12.5, "; fraction done = ", F6.3, ' // &
'"; Number of active pl, plm, tp = ", I6, ", ", I6, ", ", I6)'
#endif
character(*), parameter :: pbarfmt = '("Time = ", ES12.5," of ",ES12.5)'

! The following will syncronize the images so that they report in order, and only write to file one at at ime
Expand Down Expand Up @@ -292,15 +291,23 @@ module subroutine swiftest_io_display_run_information(self, param, integration_t

if (self%pl%nplm > 0) then
#ifdef COARRAY
write(param%display_unit, symbastatfmt) this_image(),self%t, tfrac, self%pl%nbody, self%pl%nplm, self%tp%nbody
#else
write(param%display_unit, symbastatfmt) self%t, tfrac, self%pl%nbody, self%pl%nplm, self%tp%nbody
if (param%lcoarray) then
write(param%display_unit, co_symbastatfmt) this_image(),self%t, tfrac, self%pl%nbody, self%pl%nplm, self%tp%nbody
else
#endif
write(param%display_unit, symbastatfmt) self%t, tfrac, self%pl%nbody, self%pl%nplm, self%tp%nbody
#ifdef COARRAY
end if
#endif
else
#ifdef COARRAY
write(param%display_unit, statusfmt) this_image(),self%t, tfrac, self%pl%nbody, self%tp%nbody
#else
write(param%display_unit, statusfmt) self%t, tfrac, self%pl%nbody, self%tp%nbody
if (param%lcoarray) then
write(param%display_unit, co_statusfmt) this_image(),self%t, tfrac, self%pl%nbody, self%tp%nbody
else
#endif
write(param%display_unit, statusfmt) self%t, tfrac, self%pl%nbody, self%tp%nbody
#ifdef COARRAY
end if
#endif
end if

Expand Down Expand Up @@ -3086,7 +3093,11 @@ module subroutine swiftest_io_set_display_param(self, display_style)
self%log_output = .false.
case ('COMPACT', 'PROGRESS')
#ifdef COARRAY
write(SWIFTEST_LOG_FILE,'("swiftest_coimage",I0.3,".log")') this_image()
if (self%lcoarray) then
write(SWIFTEST_LOG_FILE,'("swiftest_coimage",I0.3,".log")') this_image()
else
write(SWIFTEST_LOG_FILE,'("swiftest.log")')
end if
#endif
inquire(file=SWIFTEST_LOG_FILE, exist=fileExists)
if (self%lrestart.and.fileExists) then
Expand Down

0 comments on commit 012e05c

Please sign in to comment.