Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove computational bottlenecks in hco_calc_mod.F90 #201

Merged
merged 4 commits into from
Apr 10, 2023

Conversation

yantosca
Copy link
Contributor

@yantosca yantosca commented Mar 14, 2023

Name and Institution (Required)

Name: Bob Yantosca
Institution: Harvard + GCST

Confirm you have reviewed the following documentation

Describe the update

This PR improves the performance of routine Get_Current_Emissions in src/Core/hco_calc_mod.F90. We have refactored code to remove several ELSE blocks following the "never-nesting" coding strategy (see this link for more info.

We have also abstracted some code in Get_Current_Emissions into separate routines both for clarity and for improved computational efficiency.

Expected changes

We have run profiling tests with TAU (Tuning and Analysis Utilities) on the GEOS-Chem carbon simulation using a single CH4 species. The reference simulation, based on 14.2.0-alpha.1, shows that the 2 parallel loops in Get_Current_Emissions are near the top of the list of routines taking the longest time to execute, taking about 22 seconds combined. (See hco_calc_mod_MOD_get_current_emissions_omp_fn.0 and hco_calc_mod_MOD_get_current_emissions_omp_fn.1 in the table below.)

ref

With the updates contained in this PR, we have managed to cut this time down to about 7 seconds:

dev2

src/Core/hco_calc_mod.F90
- Remove ELSE blocks by use of "never-nesting" technique
- Abstract reused code into subroutines
- Collapse parallel DO loops
- Add Dynamic scaling to DO loops where expedient

Signed-off-by: Bob Yantosca <[email protected]>
src/Core/hco_calc_mod.F90
- Fixed incorrect function calls to Get_Value_From_DataCont
- Added missing commas to arguments in Get_Value_From_DataCont
- Renamed return value to dataVal in Get_Value_From_DataCont
- Fixed incorrect data container names (BaseDct -> Dct)
  in Get_Value_From_DataCont

Signed-off-by: Bob Yantosca <[email protected]>
src/Core/hco_calc_mod.F90
- In routine Get_Current_Emissions
  - Renamed LOC -> thisLoc
  - Added whitespace to function calls for better readability
  - Edited comments for clarity
  - Replaced placeholder error messages with actual error messages
  - Indented code to proper indentation levels
  - Trimmed trailing whitespace
- In routine Get_Value_From_Datacont
  - Update comments and comment header
- In routine Apply_Scale_Factor
  - Update comments and comment header
- In routine Apply_Dilution_Factor
  - Update comments and comment header
- Routine Get_Current_Emisisons_B
  - Now removed, this was not used
@yantosca yantosca added the topic: Performance Related to HEMCO performance, parallelization, or memory issues label Mar 14, 2023
@yantosca yantosca requested a review from msulprizio March 14, 2023 17:53
@yantosca yantosca self-assigned this Mar 14, 2023
@yantosca
Copy link
Contributor Author

yantosca commented Mar 14, 2023

I forgot to mention that the above changes were shown to be zero-diff w/r/t 14.2.0-alpha.1:

Using configuration file rst.yml
... Printing totals and differences
... Only showing variables with |absolute difference| > 0.0
Variable               Ref=14.2.0-alpha.1       Dev=hco-cleanup          Dev - Ref

Integration tests are in progress.

@yantosca yantosca added this to the 3.7.0 milestone Mar 14, 2023
@yantosca yantosca added topic: Structural Modifications Related to HEMCO structural modifications (as opposed to scientific updates) no-diff-to-benchmark This update will have no impact on benchmark simulations labels Mar 14, 2023
CHANGELOG.md
- Added a sentence about the removal of computational bottlenecks
  from hco_calc_mod.F90 (PR #201)

Signed-off-by: Bob Yantosca <[email protected]>
@yantosca
Copy link
Contributor Author

The CHANGELOG.md has also been updated in abaff9a

@yantosca
Copy link
Contributor Author

All GEOS-Chem Classic integration tests have passed:

==============================================================================
GEOS-Chem Classic: Execution Test Results

GCClassic #c9de6c9 Merge 14.1.1 into dev/14.2.0
GEOS-Chem #d104cebfe Merge 14.1.1 into dev/14.2.0
HEMCO     #e5cf011 Further code cleanup in hco_calc_mod.F90

Using 24 OpenMP threads
Number of execution tests: 26

Submitted as SLURM job: 46051178
==============================================================================
 
Execution tests:
------------------------------------------------------------------------------
gc_05x0625_NA_47L_merra2_CH4........................Execute Simulation....PASS
gc_05x0625_NA_47L_merra2_fullchem...................Execute Simulation....PASS
gc_4x5_47L_merra2_fullchem..........................Execute Simulation....PASS
gc_4x5_47L_merra2_fullchem_TOMAS15..................Execute Simulation....PASS
gc_4x5_47L_merra2_fullchem_TOMAS40..................Execute Simulation....PASS
gc_4x5_merra2_aerosol...............................Execute Simulation....PASS
gc_4x5_merra2_carbon................................Execute Simulation....PASS
gc_4x5_merra2_CH4...................................Execute Simulation....PASS
gc_4x5_merra2_CO2...................................Execute Simulation....PASS
gc_4x5_merra2_fullchem..............................Execute Simulation....PASS
gc_4x5_merra2_fullchem_aciduptake...................Execute Simulation....PASS
gc_4x5_merra2_fullchem_APM..........................Execute Simulation....PASS
gc_4x5_merra2_fullchem_benchmark....................Execute Simulation....PASS
gc_4x5_merra2_fullchem_complexSOA...................Execute Simulation....PASS
gc_4x5_merra2_fullchem_complexSOA_SVPOA.............Execute Simulation....PASS
gc_4x5_merra2_fullchem_LuoWd........................Execute Simulation....PASS
gc_4x5_merra2_fullchem_marinePOA....................Execute Simulation....PASS
gc_4x5_merra2_fullchem_RRTMG........................Execute Simulation....PASS
gc_4x5_merra2_Hg....................................Execute Simulation....PASS
gc_4x5_merra2_metals................................Execute Simulation....PASS
gc_4x5_merra2_POPs_BaP..............................Execute Simulation....PASS
gc_4x5_merra2_tagCH4................................Execute Simulation....PASS
gc_4x5_merra2_tagCO.................................Execute Simulation....PASS
gc_4x5_merra2_tagO3.................................Execute Simulation....PASS
gc_4x5_merra2_TransportTracers......................Execute Simulation....PASS
gc_4x5_merra2_TransportTracers_LuoWd................Execute Simulation....PASS
 
Summary of test results:
------------------------------------------------------------------------------
Execution tests passed: 26
Execution tests failed: 0
Execution tests not yet completed: 0

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%  All execution tests passed!  %%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

@msulprizio msulprizio merged commit c007b1f into dev/3.7.0 Apr 10, 2023
@msulprizio msulprizio deleted the feature/hco-calc-mod-cleanup branch April 10, 2023 17:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
no-diff-to-benchmark This update will have no impact on benchmark simulations topic: Performance Related to HEMCO performance, parallelization, or memory issues topic: Structural Modifications Related to HEMCO structural modifications (as opposed to scientific updates)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants