# [Blueline] Granule optimization <!-- Add the tag for the current cycle number in the top bar --> - Shaped by: - Appetite (FTEs, weeks): - Developers: <!-- Filled in at the betting table unless someone is specifically required here --> ## Problem This project covers all changes that are done in the user-code. In this cycle we prefer performance over readability (if we have to choose). Consider keeping (and testing) the more readable variants. The following changes could potentially improve performance: - Remove output fields that are only for debugging - Introduce field operator output fields with different domains - Probably minor: Replace copies for in/out fields by forwarding different fields if possible Any change that touches the shape/scope of programs should verify: - change actually results in better performance (maybe after tweaking DaCe optimizations) - change is verified in blueline for relveant experiments (to be defined) ## Appetite <!-- Explain how much time we want to spend and how that constrains the solution --> ## Solution ### Remove output fields that are only for debugging #### Dycore local: ``` ddt_vn_apc_ntl1 ddt_vn_apc_ntl2 ddt_w_adv_ntl1 ddt_w_adv_ntl2 mass_fl_e w_concorr_c vn_ie ``` #### Used in dycore and diffusion but no where else: ``` theta_v_ic diffu_type 5, smagorinsky, not our current code path but COULD be used in the future vt diffu_type 5, smagorinsky, not our current code path but COULD be used in the future ``` #### Used elswhere: ``` rho_ic used in AES physics for example exner_pr used in AES and NWP physics for example exner_dyn_incr used in NWP physics for example mass_flx_me tracer adv mass_flx_ic tracer adv vol_flx_ic tracer adv vn_traj tracer adv ``` #### Not output, should be removed from output and verify_field in blue line. ``` grf_tend_rho grf_tend_thv grf_tend_w ddt_exner_phy used in NWP physics for example ddt_vn_phy vn_incr rho_incr exner_incr grf_tend_vn ``` ### Introduce field operator output fields of varying dimensions ### Replace copies if possible TODO ## Rabbit holes ## No-gos ## Progress - [ ] Combine `compute_perturbed_quantities_and_interpolation` further by inlining the half level `nlevp1` fields `exner_at_cells_on_half_levels` and `perturbed_theta_v_at_cells_on_half_levels` which allows us to combine 4 field operators into one. - The 4 field operators are `_surface_computations`, `_compute_perturbed_quantities_and_interpolation`, `_interpolate_to_surface`, `_compute_first_and_second_vertical_derivative_of_exner` - The field operator `_set_theta_v_on_surface_level` also has a dependency on `perturbed_theta_v_at_cells_on_half_levels` on the last level, however, this can be fixed by inlining `_interpolate_to_surface` into it, which then results in a dependency on `perturbed_theta_v_at_cells_on_model_levels`, which is computed in the big new combined field operator (which we get by fusing the 4 mentioned above), so it is readily available - The open PR is here: https://github.com/C2SM/icon4py/pull/896