Skip to content

Commit

Permalink
feat(perf): Provide the uniqueID for calculationReset events
Browse files Browse the repository at this point in the history
This avoids each function called having to re-obtain the `uniqueID`.
  • Loading branch information
abensonca committed Sep 18, 2023
1 parent 6f74f91 commit 5d027ca
Show file tree
Hide file tree
Showing 49 changed files with 441 additions and 303 deletions.
17 changes: 10 additions & 7 deletions source/accretion.halo.Naoz_Barkana_2007.F90
Original file line number Diff line number Diff line change
Expand Up @@ -224,18 +224,21 @@ subroutine naozBarkana2007Destructor(self)
return
end subroutine naozBarkana2007Destructor

subroutine naozBarkana2007CalculationReset(self,node)
subroutine naozBarkana2007CalculationReset(self,node,uniqueID)
!!{
Reset the accretion rate calculation.
!!}
use :: Kind_Numbers, only : kind_int8
implicit none
class(accretionHaloNaozBarkana2007), intent(inout) :: self
type (treeNode ), intent(inout) :: node
class (accretionHaloNaozBarkana2007), intent(inout) :: self
type (treeNode ), intent(inout) :: node
integer(kind_int8 ), intent(in ) :: uniqueID
!$GLC attributes unused :: node

self%filteredFractionComputed =.false.
self%filteredFractionRateComputed=.false.
self%rateCorrectionComputed =.false.
self%lastUniqueID =node%uniqueID()
self%lastUniqueID =uniqueID
return
end subroutine naozBarkana2007CalculationReset

Expand Down Expand Up @@ -282,7 +285,7 @@ double precision function naozBarkana2007FilteredFraction(self,node)
double precision :: massFiltering, massHalo

! Check if node differs from previous one for which we performed calculations.
if (node%uniqueID() /= self%lastUniqueID) call self%calculationReset(node)
if (node%uniqueID() /= self%lastUniqueID) call self%calculationReset(node,node%uniqueID())
! Evaluate the filtering mass suppression fitting formula as defined by Naoz & Barkana (2007;
! http://adsabs.harvard.edu/abs/2007MNRAS.377..667N). We use a halo mass in this formula defined in the same way (∆=200) as in
! the original work by Gnedin (2000; http://adsabs.harvard.edu/abs/2000ApJ...542..535G) based on the discussion of halo
Expand Down Expand Up @@ -319,7 +322,7 @@ double precision function naozBarkana2007FilteredFractionRate(self,node)
double precision :: massFiltering, massHalo

! Check if node differs from previous one for which we performed calculations.
if (node%uniqueID() /= self%lastUniqueID) call self%calculationReset(node)
if (node%uniqueID() /= self%lastUniqueID) call self%calculationReset(node,node%uniqueID())
! Evaluate the rate of change of the filtering mass suppression fitting formula as defined by Naoz & Barkana (2007;
! http://adsabs.harvard.edu/abs/2007MNRAS.377..667N). We use a halo mass in this formula defined in the same way (∆=200) as in
! the original work by Gnedin (2000; http://adsabs.harvard.edu/abs/2000ApJ...542..535G) based on the discussion of halo
Expand Down Expand Up @@ -393,7 +396,7 @@ double precision function naozBarkana2007RateCorrection(self,node) result(rateCo
& growthRate

! Check if node differs from previous one for which we performed calculations.
if (node%uniqueID() /= self%lastUniqueID) call self%calculationReset(node)
if (node%uniqueID() /= self%lastUniqueID) call self%calculationReset(node,node%uniqueID())
if (.not.self%rateCorrectionComputed) then
hotHalo => node %hotHalo ( )
growthRate = +self %rateAdjust &
Expand Down
13 changes: 8 additions & 5 deletions source/accretion.halo.cold_mode.F90
Original file line number Diff line number Diff line change
Expand Up @@ -198,16 +198,19 @@ subroutine coldModeDestructor(self)
return
end subroutine coldModeDestructor

subroutine coldModeCalculationReset(self,node)
subroutine coldModeCalculationReset(self,node,uniqueID)
!!{
Reset the accretion rate calculation.
!!}
use :: Kind_Numbers, only : kind_int8
implicit none
class(accretionHaloColdMode), intent(inout) :: self
type (treeNode ), intent(inout) :: node
class (accretionHaloColdMode), intent(inout) :: self
type (treeNode ), intent(inout) :: node
integer(kind_int8 ), intent(in ) :: uniqueID
!$GLC attributes unused :: node

self%coldFractionComputed=.false.
self%lastUniqueID =node%uniqueID()
self%lastUniqueID =uniqueID
return
end subroutine coldModeCalculationReset

Expand Down Expand Up @@ -472,7 +475,7 @@ double precision function coldModeColdModeFraction(self,node,accretionMode)
coldModeColdModeFraction=1.0d0
case (accretionModeHot%ID,accretionModeCold%ID)
! Reset calculations if necessary.
if (node%uniqueID() /= self%lastUniqueID) call self%calculationReset(node)
if (node%uniqueID() /= self%lastUniqueID) call self%calculationReset(node,node%uniqueID())
! Compute cold fraction if not already computed.
if (.not.self%coldFractionComputed) then
! Get the basic component.
Expand Down
15 changes: 9 additions & 6 deletions source/cooling.cooling_radius.beta_profile.F90
Original file line number Diff line number Diff line change
Expand Up @@ -239,17 +239,20 @@ subroutine betaProfileDestructor(self)
return
end subroutine betaProfileDestructor

subroutine betaProfileCalculationReset(self,node)
subroutine betaProfileCalculationReset(self,node,uniqueID)
!!{
Reset the cooling radius calculation.
!!}
use :: Kind_Numbers, only : kind_int8
implicit none
class(coolingRadiusBetaProfile), intent(inout) :: self
type (treeNode ), intent(inout) :: node
class (coolingRadiusBetaProfile), intent(inout) :: self
type (treeNode ), intent(inout) :: node
integer(kind_int8 ), intent(in ) :: uniqueID
!$GLC attributes unused :: node

self%radiusComputed =.false.
self%radiusGrowthRateComputed=.false.
self%lastUniqueID =node%uniqueID()
self%lastUniqueID =uniqueID
return
end subroutine betaProfileCalculationReset

Expand All @@ -274,7 +277,7 @@ double precision function betaProfileRadiusGrowthRate(self,node)
type (chemicalAbundances ) :: chemicalFractions, chemicalMasses

! Check if node differs from previous one for which we performed calculations.
if (node%uniqueID() /= self%lastUniqueID) call self%calculationReset(node)
if (node%uniqueID() /= self%lastUniqueID) call self%calculationReset(node,node%uniqueID())

! Check if cooling radius growth rate is already computed.
if (.not.self%radiusGrowthRateComputed) then
Expand Down Expand Up @@ -352,7 +355,7 @@ double precision function betaProfileRadius(self,node)
type (chemicalAbundances ) :: chemicalFractions, chemicalMasses

! Check if node differs from previous one for which we performed calculations.
if (node%uniqueID() /= self%lastUniqueID) call self%calculationReset(node)
if (node%uniqueID() /= self%lastUniqueID) call self%calculationReset(node,node%uniqueID())
! Check if cooling radius is already computed.
if (.not.self%radiusComputed) then
! Get the time available for cooling in node.
Expand Down
15 changes: 9 additions & 6 deletions source/cooling.cooling_radius.isothermal_profile.F90
Original file line number Diff line number Diff line change
Expand Up @@ -228,17 +228,20 @@ subroutine isothermalDestructor(self)
return
end subroutine isothermalDestructor

subroutine isothermalCalculationReset(self,node)
subroutine isothermalCalculationReset(self,node,uniqueID)
!!{
Reset the cooling radius calculation.
!!}
use :: Kind_Numbers, only : kind_int8
implicit none
class(coolingRadiusIsothermal), intent(inout) :: self
type (treeNode ), intent(inout) :: node
class (coolingRadiusIsothermal), intent(inout) :: self
type (treeNode ), intent(inout) :: node
integer(kind_int8 ), intent(in ) :: uniqueID
!$GLC attributes unused :: node

self%radiusComputed =.false.
self%radiusGrowthRateComputed=.false.
self%lastUniqueID =node%uniqueID()
self%lastUniqueID =uniqueID
return
end subroutine isothermalCalculationReset

Expand All @@ -252,7 +255,7 @@ double precision function isothermalRadiusGrowthRate(self,node)
double precision :: radiusCooling, radiusVirial

! Check if node differs from previous one for which we performed calculations.
if (node%uniqueID() /= self%lastUniqueID) call self%calculationReset(node)
if (node%uniqueID() /= self%lastUniqueID) call self%calculationReset(node,node%uniqueID())

! Check if cooling radius growth rate is already computed.
if (.not.self%radiusGrowthRateComputed) then
Expand Down Expand Up @@ -298,7 +301,7 @@ double precision function isothermalRadius(self,node)
type (chemicalAbundances ) :: chemicalFractions, chemicalMasses

! Check if node differs from previous one for which we performed calculations.
if (node%uniqueID() /= self%lastUniqueID) call self%calculationReset(node)
if (node%uniqueID() /= self%lastUniqueID) call self%calculationReset(node,node%uniqueID())
! Check if cooling radius is already computed.
if (.not.self%radiusComputed) then
! Get the time available for cooling in node.
Expand Down
15 changes: 9 additions & 6 deletions source/cooling.cooling_radius.simple.F90
Original file line number Diff line number Diff line change
Expand Up @@ -228,17 +228,20 @@ subroutine simpleDestructor(self)
return
end subroutine simpleDestructor

subroutine simpleCalculationReset(self,node)
subroutine simpleCalculationReset(self,node,uniqueID)
!!{
Reset the cooling radius calculation.
!!}
use :: Kind_Numbers, only : kind_int8
implicit none
class(coolingRadiusSimple), intent(inout) :: self
type (treeNode ), intent(inout) :: node
class (coolingRadiusSimple), intent(inout) :: self
type (treeNode ), intent(inout) :: node
integer(kind_int8 ), intent(in ) :: uniqueID
!$GLC attributes unused :: node

self%radiusComputed =.false.
self%radiusGrowthRateComputed=.false.
self%lastUniqueID =node%uniqueID()
self%lastUniqueID =uniqueID
return
end subroutine simpleCalculationReset

Expand All @@ -259,7 +262,7 @@ double precision function simpleRadiusGrowthRate(self,node)
& temperature , temperatureLogSlope

! Check if node differs from previous one for which we performed calculations.
if (node%uniqueID() /= self%lastUniqueID) call self%calculationReset(node)
if (node%uniqueID() /= self%lastUniqueID) call self%calculationReset(node,node%uniqueID())
! Check if cooling radius growth rate is already computed.
if (.not.self%radiusGrowthRateComputed) then
! Flag that cooling radius is now computed.
Expand Down Expand Up @@ -324,7 +327,7 @@ double precision function simpleRadius(self,node)
& rootZero , rootOuter

! Check if node differs from previous one for which we performed calculations.
if (node%uniqueID() /= self%lastUniqueID) call self%calculationReset(node)
if (node%uniqueID() /= self%lastUniqueID) call self%calculationReset(node,node%uniqueID())
! Check if cooling radius is already computed.
if (.not.self%radiusComputed) then
! Flag that cooling radius is now computed.
Expand Down
13 changes: 8 additions & 5 deletions source/cooling.specific_angular_momentum.constant_rotation.F90
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ double precision function constantRotationAngularMomentumSpecific(self,node,radi
double precision :: angularMomentumSpecificMean, normalizationRotation

! Check if node differs from previous one for which we performed calculations.
if (node%uniqueID() /= self%lastUniqueID) call self%calculationReset(node)
if (node%uniqueID() /= self%lastUniqueID) call self%calculationReset(node,node%uniqueID())
! Check if specific angular momentum of cooling gas is already computed.
if (.not.self%angularMomentumSpecificComputed) then
! Flag that cooling radius is now computed.
Expand Down Expand Up @@ -274,15 +274,18 @@ double precision function constantRotationAngularMomentumSpecific(self,node,radi
return
end function constantRotationAngularMomentumSpecific

subroutine constantRotationCalculationReset(self,node)
subroutine constantRotationCalculationReset(self,node,uniqueID)
!!{
Reset the specific angular momentum of cooling gas calculation.
!!}
use :: Kind_Numbers, only : kind_int8
implicit none
class(coolingSpecificAngularMomentumConstantRotation), intent(inout) :: self
type (treeNode ), intent(inout) :: node
class (coolingSpecificAngularMomentumConstantRotation), intent(inout) :: self
type (treeNode ), intent(inout) :: node
integer(kind_int8 ), intent(in ) :: uniqueID
!$GLC attributes unused :: node

self%angularMomentumSpecificComputed=.false.
self%lastUniqueID =node%uniqueID()
self%lastUniqueID =uniqueID
return
end subroutine constantRotationCalculationReset
12 changes: 7 additions & 5 deletions source/dark_matter_halos.mass_accretion_history.Wechsler2002.F90
Original file line number Diff line number Diff line change
Expand Up @@ -173,17 +173,19 @@ subroutine wechsler2002Destructor(self)
return
end subroutine wechsler2002Destructor

subroutine wechsler2002CalculationReset(self,node)
subroutine wechsler2002CalculationReset(self,node,uniqueID)
!!{
Reset the cooling radius calculation.
!!}
implicit none
class(darkMatterHaloMassAccretionHistoryWechsler2002), intent(inout) :: self
type (treeNode ), intent(inout) :: node
class (darkMatterHaloMassAccretionHistoryWechsler2002), intent(inout) :: self
type (treeNode ), intent(inout) :: node
integer(kind_int8 ), intent(in ) :: uniqueID
!$GLC attributes unused :: node

self%timeFormationPrevious=-huge(0.0d0)
self%massPrevious =-huge(0.0d0)
self%lastUniqueID =node%uniqueID()
self%lastUniqueID =uniqueID
return
end subroutine wechsler2002CalculationReset

Expand All @@ -202,7 +204,7 @@ double precision function wechsler2002Time(self,node,mass)
& mergerTreeFormationExpansionFactor

! Check if node differs from previous one for which we performed calculations.
if (node%uniqueID() /= self%lastUniqueID) call self%calculationReset(node)
if (node%uniqueID() /= self%lastUniqueID) call self%calculationReset(node,node%uniqueID())
! Compute formation time if necessary.
if (self%massPrevious /= mass) then
basicBase => node%basic()
Expand Down
19 changes: 11 additions & 8 deletions source/dark_matter_halos.scales.virial_density_contrast.F90
Original file line number Diff line number Diff line change
Expand Up @@ -192,19 +192,22 @@ subroutine virialDensityContrastDefinitionDestructor(self)
return
end subroutine virialDensityContrastDefinitionDestructor

subroutine virialDensityContrastDefinitionCalculationReset(self,node)
subroutine virialDensityContrastDefinitionCalculationReset(self,node,uniqueID)
!!{
Reset the halo scales calculation.
!!}
use :: Kind_Numbers, only : kind_int8
implicit none
class(darkMatterHaloScaleVirialDensityContrastDefinition), intent(inout) :: self
type (treeNode ), intent(inout) :: node
class (darkMatterHaloScaleVirialDensityContrastDefinition), intent(inout) :: self
type (treeNode ), intent(inout) :: node
integer(kind_int8 ), intent(in ) :: uniqueID
!$GLC attributes unused :: node

self%radiusVirialComputed =.false.
self%temperatureVirialComputed =.false.
self%velocityVirialComputed =.false.
self%timescaleDynamicalComputed=.false.
self%lastUniqueID =node%uniqueID()
self%lastUniqueID =uniqueID
return
end subroutine virialDensityContrastDefinitionCalculationReset

Expand All @@ -224,7 +227,7 @@ double precision function virialDensityContrastDefinitionDynamicalTimescale(self
return
end if
! Check if node differs from previous one for which we performed calculations.
if (node%uniqueID() /= self%lastUniqueID) call self%calculationReset(node)
if (node%uniqueID() /= self%lastUniqueID) call self%calculationReset(node,node%uniqueID())
! Check if halo dynamical timescale is already computed. Compute and store if not.
if (.not.self%timescaleDynamicalComputed) then
self%timescaleDynamicalComputed= .true.
Expand Down Expand Up @@ -254,7 +257,7 @@ double precision function virialDensityContrastDefinitionVirialVelocity(self,nod
return
end if
! Check if node differs from previous one for which we performed calculations.
if (node%uniqueID() /= self%lastUniqueID) call self%calculationReset(node)
if (node%uniqueID() /= self%lastUniqueID) call self%calculationReset(node,node%uniqueID())
! Check if virial velocity is already computed. Compute and store if not.
if (.not.self%velocityVirialComputed) then
! Get the basic component.
Expand Down Expand Up @@ -317,7 +320,7 @@ double precision function virialDensityContrastDefinitionVirialTemperature(self,
return
end if
! Check if node differs from previous one for which we performed calculations.
if (node%uniqueID() /= self%lastUniqueID) call self%calculationReset(node)
if (node%uniqueID() /= self%lastUniqueID) call self%calculationReset(node,node%uniqueID())
! Check if virial temperature is already computed. Compute and store if not.
if (.not.self%temperatureVirialComputed) then
self%temperatureVirialComputed=.true.
Expand Down Expand Up @@ -347,7 +350,7 @@ double precision function virialDensityContrastDefinitionVirialRadius(self,node)
return
end if
! Check if node differs from previous one for which we performed calculations.
if (node%uniqueID() /= self%lastUniqueID) call self%calculationReset(node)
if (node%uniqueID() /= self%lastUniqueID) call self%calculationReset(node,node%uniqueID())
! Check if virial radius is already computed. Compute and store if not.
if (.not.self%radiusVirialComputed) then
! Get the basic component.
Expand Down
Loading

1 comment on commit 5d027ca

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Performance Alert ⚠️

Possible performance regression was detected for benchmark 'Milky Way model benchmarks'.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold 1.10.

Benchmark suite Current: 5d027ca Previous: c02ffb6 Ratio
Milky Way model - Likelihood - localGroupStellarMassHaloMassRelation 9.77158607413816 -logℒ 1.32204863767182 -logℒ 7.39

This comment was automatically generated by workflow using github-action-benchmark.

CC: @abensonca

Please sign in to comment.