Skip to content

Commit

Permalink
Add profiling inside ESMF_StateReconcileIsNoop().
Browse files Browse the repository at this point in the history
  • Loading branch information
theurich committed Sep 25, 2024
1 parent 12b4300 commit 491caf3
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions src/Superstructure/StateReconcile/src/ESMF_StateReconcile.F90
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,8 @@ subroutine ESMF_StateReconcileIsNoop(state, vm, isNoop, rc)
logical :: isNoopLoc
integer :: isNoopLocInt(1), isNoopInt(1)

logical, parameter :: profile = .true.

localrc = ESMF_RC_NOT_IMPL

isNoop = .false. ! assume reconcile is needed
Expand All @@ -345,19 +347,47 @@ subroutine ESMF_StateReconcileIsNoop(state, vm, isNoop, rc)

!call ESMF_VMIdLog(vmId, prefix="vmId: ", rc=rc)

if (profile) then
call ESMF_TraceRegionEnter("StateReconcileIsNoopLoc", rc=localrc)
if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, &
ESMF_CONTEXT, &
rcToReturn=rc)) return
endif

call StateReconcileIsNoopLoc(state, isNoopLoc=isNoopLoc, rc=localrc)
if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, ESMF_CONTEXT, &
rcToReturn=rc)) return

if (profile) then
call ESMF_TraceRegionExit("StateReconcileIsNoopLoc", rc=localrc)
if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, &
ESMF_CONTEXT, &
rcToReturn=rc)) return
endif

isNoopLocInt(1) = 0
if (isNoopLoc) isNoopLocInt(1) = 1

if (profile) then
call ESMF_TraceRegionEnter("ESMF_VMAllReduce", rc=localrc)
if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, &
ESMF_CONTEXT, &
rcToReturn=rc)) return
endif

! logical AND reduction, only 1 if all incoming 1
call ESMF_VMAllReduce(vm, isNoopLocInt, isNoopInt, 1, ESMF_REDUCE_MIN, &
rc=localrc)
if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, ESMF_CONTEXT, &
rcToReturn=rc)) return

if (profile) then
call ESMF_TraceRegionExit("ESMF_VMAllReduce", rc=localrc)
if (ESMF_LogFoundError(localrc, ESMF_ERR_PASSTHRU, &
ESMF_CONTEXT, &
rcToReturn=rc)) return
endif

if (isNoopInt(1)==1) isNoop = .true. ! found that Reconcile is a NOOP

! return successfully
Expand Down

0 comments on commit 491caf3

Please sign in to comment.