Skip to content

Commit

Permalink
Added an option to help clarify the timing of CHEMISTRY children, whi…
Browse files Browse the repository at this point in the history
…ch would ordinarily be skewed against children that include parallel gather operators
  • Loading branch information
mmanyin committed Dec 26, 2023
1 parent 6436e3a commit cccee35
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 2 deletions.
48 changes: 46 additions & 2 deletions GEOS_ChemGridComp.F90
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ module GEOS_ChemGridCompMod
LOGICAL :: enable_TR
LOGICAL :: enable_DNA
LOGICAL :: enable_HEMCO
LOGICAL :: strict_child_timing ! Call a barrier before and after each child is run
! Only use this to test timings, not operationally
INTEGER :: AERO_PROVIDER
INTEGER :: RATS_PROVIDER ! WARNING: May be multiple RATS_PROVIDERs
END TYPE GEOS_ChemGridComp
Expand Down Expand Up @@ -230,6 +232,8 @@ subroutine SetServices ( GC, RC )
call ESMF_ConfigGetAttribute(myCF, myState%enable_DNA, Default=.FALSE., Label="ENABLE_DNA:", __RC__ )
call ESMF_ConfigGetAttribute(myCF, myState%enable_HEMCO, Default=.FALSE., Label="ENABLE_HEMCO:", __RC__ )

call ESMF_ConfigGetAttribute(myCF, myState%strict_child_timing, Default=.FALSE., Label="strict_child_timing:", __RC__ )

!ALT: valgrind flagged a memory leak. myState%CF => myCF ! save for later
call ESMF_ConfigDestroy(myCF, __RC__)

Expand Down Expand Up @@ -1095,6 +1099,9 @@ subroutine Run1 ( GC, IMPORT, EXPORT, CLOCK, RC )
integer :: userRC
character(len=ESMF_MAXSTR) :: CHILD_NAME
real, pointer :: th(:,:,:) => NULL()
type (GEOS_ChemGridComp), pointer :: myState ! private, that is
type (GEOS_ChemGridComp_Wrap) :: wrap
type (ESMF_VM) :: VM

!=============================================================================

Expand All @@ -1109,6 +1116,12 @@ subroutine Run1 ( GC, IMPORT, EXPORT, CLOCK, RC )
call MAPL_Get(MAPL, RUNALARM = ALARM, RC=STATUS )
VERIFY_(STATUS)

! Get my internal state
! ---------------------
call ESMF_UserCompGetInternalState(GC, 'GEOSchem_GridComp_State', WRAP, STATUS)
VERIFY_(STATUS)
myState => wrap%ptr

! Start timers
! ------------
call MAPL_TimerOn( MAPL, "TOTAL")
Expand Down Expand Up @@ -1158,6 +1171,12 @@ subroutine Run1 ( GC, IMPORT, EXPORT, CLOCK, RC )
! exists. Also updated MAPL_Get to accept the output
! argument NumRunPhases (ckeller, 09/10/2014)
! --------------------------------------------------------

IF ( myState%strict_child_timing ) THEN
call ESMF_VMGetCurrent ( VM=VM, __RC__ )
call ESMF_VMBarrier(VM, __RC__ )
END IF

do I=1,NCHLD
call ESMF_GridCompGet( GCS(I), NAME=CHILD_NAME, __RC__ )
call MAPL_GetObjectFromGC(GCS(I), CHLD, __RC__ )
Expand All @@ -1171,7 +1190,12 @@ subroutine Run1 ( GC, IMPORT, EXPORT, CLOCK, RC )
phase = IPHASE, &
userRC = userRC, &
__RC__ )
_ASSERT(userRC==ESMF_SUCCESS,'needs informative message')
_ASSERT(userRC==ESMF_SUCCESS,'Failed running the CHEM child '//trim(CHILD_NAME))

IF ( myState%strict_child_timing ) THEN
call ESMF_VMBarrier(VM, __RC__ )
END IF

call MAPL_TimerOff(MAPL,trim(CHILD_NAME))
endif
enddo !I
Expand Down Expand Up @@ -1243,6 +1267,9 @@ subroutine Run2 ( GC, IMPORT, EXPORT, CLOCK, RC )
integer :: NPHASE, IPHASE
integer :: userRC
character(len=ESMF_MAXSTR) :: CHILD_NAME
type (GEOS_ChemGridComp), pointer :: myState ! private, that is
type (GEOS_ChemGridComp_Wrap) :: wrap
type (ESMF_VM) :: VM
!-------------------------------------------------------------------
! Begin...

Expand All @@ -1254,6 +1281,12 @@ subroutine Run2 ( GC, IMPORT, EXPORT, CLOCK, RC )
VERIFY_(STATUS)
call MAPL_Get(MAPL, RUNALARM = ALARM, __RC__ )

! Get my internal state
! ---------------------
call ESMF_UserCompGetInternalState(GC, 'GEOSchem_GridComp_State', WRAP, STATUS)
VERIFY_(STATUS)
myState => wrap%ptr

! Start timers
! ------------
call MAPL_TimerOn( MAPL, "TOTAL")
Expand Down Expand Up @@ -1289,6 +1322,12 @@ subroutine Run2 ( GC, IMPORT, EXPORT, CLOCK, RC )
! do for every child: get child state, determine number of
! run phases and phase to call, execute.
! --------------------------------------------------------

IF ( myState%strict_child_timing ) THEN
call ESMF_VMGetCurrent ( VM=VM, __RC__ )
call ESMF_VMBarrier(VM, __RC__ )
END IF

do I=1,NCHLD
call MAPL_GetObjectFromGC(GCS(I), CHLD, __RC__ )
call ESMF_GridCompGet( GCS(I), NAME=CHILD_NAME, __RC__ )
Expand All @@ -1307,7 +1346,12 @@ subroutine Run2 ( GC, IMPORT, EXPORT, CLOCK, RC )
phase = IPHASE, &
userRC = userRC, &
__RC__ )
_ASSERT(userRC==ESMF_SUCCESS,'needs informative message')
_ASSERT(userRC==ESMF_SUCCESS,'Failed running the CHEM child '//trim(CHILD_NAME))

IF ( myState%strict_child_timing ) THEN
call ESMF_VMBarrier(VM, __RC__ )
END IF

call MAPL_TimerOff(MAPL,trim(CHILD_NAME))
enddo !I
endif
Expand Down
4 changes: 4 additions & 0 deletions GEOS_ChemGridComp.rc
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,7 @@
ENABLE_TR: .TRUE.
ENABLE_DNA: .FALSE.
ENABLE_HEMCO: .TRUE.

# Use only for diagnostic timing tests:
# --------------------------------------------------
strict_child_timing: .FALSE.

0 comments on commit cccee35

Please sign in to comment.