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

DaCe Orchestration for the Diffusion Granule #514

Open
wants to merge 185 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
185 commits
Select commit Hold shift + click to select a range
f5c5590
gt4py program to SDFGConvertible : WIP
kotsaloscv Feb 19, 2024
4f3651e
Merge branch 'main' into dace_driving_code
kotsaloscv Feb 19, 2024
9ec5cdd
gt4py program to SDFGConvertible : WIP
kotsaloscv Feb 19, 2024
9e61320
gt4py program to SDFGConvertible : WIP
kotsaloscv Feb 21, 2024
537c74b
gt4py program to SDFGConvertible : Diffusion module fully fused
kotsaloscv Mar 5, 2024
fbd73cb
Merge branch 'main' into dace_driving_code
kotsaloscv Mar 5, 2024
f12be1e
gt4py program to SDFGConvertible : Diffusion module fully fused
kotsaloscv Mar 5, 2024
b32aa67
Halo Exchange in Fused SDFG : WIP
kotsaloscv Mar 5, 2024
7205291
Merge branch 'main' into dace_driving_code
kotsaloscv Mar 13, 2024
69cb8b6
Halo Exchange in Fused SDFG : WIP
kotsaloscv Mar 14, 2024
efe9a1a
Halo Exchange in Fused SDFG : WIP
kotsaloscv Mar 15, 2024
6a5e294
Halo Exchange in Fused SDFG : WIP
kotsaloscv Mar 19, 2024
6a9a4f8
DaCe Orchestration - Diffusion : WIP
kotsaloscv Mar 19, 2024
e8cdc8c
DaCe Orchestration - Diffusion : WIP
kotsaloscv Mar 20, 2024
25fecbf
DaCe Orchestration - Diffusion : WIP
kotsaloscv Mar 22, 2024
a0d0c57
DaCe Orchestration - Diffusion : WIP
kotsaloscv Mar 22, 2024
4468656
DaCe Orchestration - Diffusion : WIP
kotsaloscv Mar 26, 2024
ac3c842
DaCe Orchestration - Diffusion : WIP
kotsaloscv Mar 26, 2024
322342c
DaCe Orchestration - Diffusion : WIP
kotsaloscv Mar 26, 2024
be73b5c
DaCe Orchestration - Diffusion : WIP
kotsaloscv Mar 26, 2024
4180edd
Merge branch 'main' into dace_driving_code
kotsaloscv Mar 27, 2024
9aceda5
DaCe Orchestration - Diffusion : WIP
kotsaloscv Mar 28, 2024
7f3ab7b
Merge branch 'main' into dace_driving_code
kotsaloscv Apr 3, 2024
2ccba96
DaCe Orchestration - Diffusion : WIP
kotsaloscv Apr 4, 2024
5497529
DaCe Orchestration - Diffusion : WIP
kotsaloscv Apr 4, 2024
c055edf
DaCe Orchestration - Diffusion : WIP
kotsaloscv Apr 4, 2024
b6d8ab5
DaCe Orchestration - Diffusion : WIP
kotsaloscv Apr 4, 2024
14d479f
DaCe Orchestration - Diffusion : WIP
kotsaloscv Apr 4, 2024
c99bdcb
DaCe Orchestration - Diffusion : WIP
kotsaloscv Apr 5, 2024
d8987e5
DaCe Orchestration - Diffusion : WIP
kotsaloscv Apr 5, 2024
bd91722
DaCe Orchestration - Diffusion : WIP
kotsaloscv Apr 8, 2024
148af6c
DaCe Orchestration - Diffusion : WIP
kotsaloscv Apr 8, 2024
4d60d84
merge main
kotsaloscv Apr 8, 2024
dd59bb0
Merge branch 'main' into dace_driving_code
kotsaloscv Apr 8, 2024
6a897de
Merge branch 'main' into dace_driving_code
kotsaloscv Apr 10, 2024
c60b072
DaCe Orchestration : WIP
kotsaloscv Apr 10, 2024
f1fdeec
DaCe Orchestration : WIP
kotsaloscv Apr 16, 2024
1878d57
DaCe Orchestration : WIP
kotsaloscv Apr 16, 2024
9d2101a
DaCe Orchestration : WIP
kotsaloscv Apr 23, 2024
99cd256
merge main
kotsaloscv Apr 23, 2024
e2eebb0
DaCe Orchestration : WIP
kotsaloscv Apr 23, 2024
e43a30c
DaCe Orchestration : WIP
kotsaloscv Apr 23, 2024
04548e8
DaCe Orchestration : WIP
kotsaloscv Apr 23, 2024
751028e
DaCe Orchestration : WIP
kotsaloscv Apr 26, 2024
be54236
DaCe Orchestration : WIP
kotsaloscv Apr 26, 2024
998e5c7
DaCe Orchestration : WIP
kotsaloscv Apr 26, 2024
407f1d5
DaCe Orchestration : WIP
kotsaloscv May 3, 2024
6055701
merge with main
kotsaloscv May 3, 2024
6ca14cf
DaCe Orchestration : WIP
kotsaloscv May 3, 2024
7c61ea2
merge main
kotsaloscv Jun 10, 2024
43c5e52
ghex related update
kotsaloscv Jun 10, 2024
d82ee66
Turn off caching because it breaks the SDFGConvertible interface : WI…
kotsaloscv Jun 10, 2024
795c481
Automatic Halo Updates : More optimizations (WIP)
kotsaloscv Jun 10, 2024
fe9c012
Automatic Halo Updates : More optimizations (WIP)
kotsaloscv Jun 11, 2024
6835d96
Automatic Halo Updates : More optimizations (WIP)
kotsaloscv Jun 12, 2024
cc16428
Insert halo exchange nodes (only if needed) in the fused SDFG : WIP
kotsaloscv Jun 12, 2024
7f712dd
Insert halo exchange nodes (only if needed) in the fused SDFG : WIP
kotsaloscv Jun 12, 2024
e119028
DaCe Orchestration : Diffusion Module [WIP]
kotsaloscv Jun 18, 2024
b951368
DaCe Orchestration : Diffusion Module [WIP]
kotsaloscv Jun 18, 2024
e81cbc8
DaCe Orchestration : Diffusion Module [WIP]
kotsaloscv Jun 19, 2024
35a2a72
DaCe Orchestration : Diffusion Module [WIP]
kotsaloscv Jun 26, 2024
b2ed55d
DaCe Orchestration : Diffusion Module [WIP]
kotsaloscv Jun 27, 2024
d02f88f
DaCe Orchestration : Diffusion Module [WIP]
kotsaloscv Jun 27, 2024
b9d72de
DaCe Orchestration : Diffusion Module [WIP]
kotsaloscv Jun 27, 2024
b0b274c
DaCe Orchestration : Diffusion Module [WIP]
kotsaloscv Jun 27, 2024
85506d5
DaCe Orchestration : Diffusion Module [WIP]
kotsaloscv Jun 27, 2024
bf78703
DaCe Orchestration : Diffusion Module [WIP]
kotsaloscv Jun 27, 2024
8505824
DaCe Orchestration : Diffusion Module [WIP]
kotsaloscv Jun 27, 2024
fb8e876
DaCe Orchestration : Diffusion Module [WIP]
kotsaloscv Jul 2, 2024
af2fe54
Merge branch 'main' into dace_driving_code
kotsaloscv Jul 2, 2024
4c68b8a
DaCe Orchestration : Diffusion Module [WIP]
kotsaloscv Jul 2, 2024
1594270
DaCe Orchestration : Diffusion Module [WIP]
kotsaloscv Jul 3, 2024
c56635c
DaCe Orchestration : Diffusion Module [WIP]
kotsaloscv Jul 3, 2024
3290115
DaCe Orchestration : Diffusion Module [WIP]
kotsaloscv Jul 3, 2024
dbbea80
DaCe Orchestration : Diffusion Module [WIP]
kotsaloscv Jul 3, 2024
e7ab402
DaCe Orchestration : Diffusion Module [WIP]
kotsaloscv Jul 3, 2024
e26360a
DaCe Orchestration : Diffusion Module [WIP]
kotsaloscv Jul 3, 2024
a25e98e
DaCe Orchestration : Diffusion Module [WIP]
kotsaloscv Jul 3, 2024
1c714ec
DaCe Orchestration : Diffusion Module [WIP]
kotsaloscv Jul 4, 2024
ce2f339
DaCe Orchestration : Diffusion Module [WIP]
kotsaloscv Jul 4, 2024
65fdc0c
DaCe Orchestration : Diffusion Module [WIP]
kotsaloscv Jul 4, 2024
18ff073
DaCe Orchestration : Diffusion Module [WIP]
kotsaloscv Jul 4, 2024
815f137
DaCe Orchestration : Diffusion Module [WIP]
kotsaloscv Jul 4, 2024
be9cc22
DaCe Orchestration : Diffusion Module [WIP]
kotsaloscv Jul 4, 2024
96ef1d8
DaCe Orchestration : Diffusion Module [WIP]
kotsaloscv Jul 4, 2024
1354ed2
DaCe Orchestration : Diffusion Module [WIP]
kotsaloscv Jul 4, 2024
669a567
DaCe Orchestration : Diffusion Module [WIP]
kotsaloscv Jul 5, 2024
8097cdd
DaCe Orchestration : Diffusion Module [WIP]
kotsaloscv Jul 5, 2024
924a4f3
DaCe Orchestration : Diffusion Module [WIP]
kotsaloscv Jul 5, 2024
1d62256
DaCe Orchestration : Diffusion Module [WIP]
kotsaloscv Jul 8, 2024
7a56921
DaCe Orchestration : Diffusion Module [WIP]
kotsaloscv Jul 8, 2024
d6601e1
DaCe Orchestration : Diffusion Module [WIP]
kotsaloscv Jul 9, 2024
f167dbd
DaCe Orchestration : Diffusion Module [WIP]
kotsaloscv Jul 11, 2024
941c82e
DaCe Orchestration : Diffusion Module [WIP]
kotsaloscv Jul 12, 2024
064bf98
DaCe Orchestration : Diffusion Module [WIP]
kotsaloscv Jul 19, 2024
eb6446c
Merge branch 'main' into dace_driving_code
kotsaloscv Jul 19, 2024
168717b
Merge branch 'main' into dace_driving_code
kotsaloscv Jul 19, 2024
5d7bf00
DaCe Orchestration : Diffusion Module [WIP]
kotsaloscv Jul 22, 2024
9421be1
DaCe Orchestration : Diffusion Module [WIP]
kotsaloscv Jul 22, 2024
1fa4b54
DaCe Orchestration : Diffusion Module [WIP]
kotsaloscv Jul 22, 2024
1337905
DaCe Orchestration : Diffusion Module [WIP]
kotsaloscv Jul 23, 2024
096e9b5
DaCe Orchestration : Diffusion Module [WIP]
kotsaloscv Jul 23, 2024
1330342
DaCe Orchestration : Diffusion Module [WIP]
kotsaloscv Jul 23, 2024
3ecaacc
DaCe Orchestration : Diffusion Module [WIP]
kotsaloscv Jul 24, 2024
07c259b
DaCe Orchestration : Diffusion Module [WIP]
kotsaloscv Jul 24, 2024
9be1155
DaCe Orchestration : Diffusion Module [WIP]
kotsaloscv Jul 24, 2024
7fa78ae
DaCe Orchestration : Diffusion Module [WIP]
kotsaloscv Jul 24, 2024
6934614
DaCe Orchestration : Diffusion Module [WIP]
kotsaloscv Jul 24, 2024
a333269
DaCe Orchestration : Diffusion Module [WIP]
kotsaloscv Jul 26, 2024
051e051
DaCe Orchestration : Diffusion Module [WIP]
kotsaloscv Jul 26, 2024
31aaf20
DaCe Orchestration : Diffusion Module [WIP]
kotsaloscv Jul 26, 2024
6fba75a
DaCe Orchestration : Diffusion Module [WIP]
kotsaloscv Jul 29, 2024
fd867c8
DaCe Orchestration : Diffusion Module [WIP]
kotsaloscv Jul 29, 2024
9cfecd1
DaCe Orchestration : Diffusion Module [WIP]
kotsaloscv Jul 29, 2024
dddf764
DaCe Orchestration : Diffusion Module [WIP]
kotsaloscv Jul 30, 2024
bc94607
DaCe Orchestration : Diffusion Module [WIP]
kotsaloscv Jul 30, 2024
36be951
DaCe Orchestration : Diffusion Module [WIP]
kotsaloscv Jul 30, 2024
67bc8ee
DaCe Orchestration : Diffusion Module [WIP]
kotsaloscv Jul 30, 2024
2f966d2
DaCe Orchestration : Diffusion Module [WIP]
kotsaloscv Jul 30, 2024
407e900
Merge branch 'main' into dace_driving_code
kotsaloscv Jul 30, 2024
df5bbb3
DaCe Orchestration : Diffusion Module [WIP]
kotsaloscv Aug 14, 2024
5c74a7b
Merge branch 'main' into dace_driving_code
kotsaloscv Aug 14, 2024
c06e859
DaCe Orchestration : Diffusion Module [WIP]
kotsaloscv Aug 14, 2024
9dc7492
DaCe Orchestration : Diffusion Module [WIP]
kotsaloscv Aug 20, 2024
439afe8
Merge branch 'main' into dace_driving_code
kotsaloscv Aug 20, 2024
772a7a2
DaCe Orchestration : Diffusion Module [WIP]
kotsaloscv Aug 20, 2024
9398922
DaCe Orchestration : Diffusion Module [WIP]
kotsaloscv Aug 20, 2024
a5992aa
DaCe Orchestration : Diffusion Module [WIP]
kotsaloscv Aug 20, 2024
35c70ec
DaCe Orchestration : Diffusion Module [WIP]
kotsaloscv Aug 20, 2024
9422e82
DaCe Orchestration : Diffusion Module [WIP]
kotsaloscv Sep 10, 2024
3e9181e
DaCe Orchestration : marge main
kotsaloscv Sep 10, 2024
76148f6
DaCe Orchestration : Diffusion Module [WIP]
kotsaloscv Sep 10, 2024
13628e3
DaCe Orchestration : Diffusion Module [WIP]
kotsaloscv Sep 11, 2024
395bbf6
DaCe Orchestration : Diffusion Module [WIP]
kotsaloscv Sep 11, 2024
accbc3d
Merge branch 'main' into dace_driving_code
kotsaloscv Sep 16, 2024
eb01c62
DaCe Orchestration : Diffusion Module [WIP]
kotsaloscv Sep 17, 2024
e666d90
Merge branch 'main' into dace_driving_code
kotsaloscv Sep 17, 2024
f41a5e5
DaCe Orchestration : Diffusion Module [WIP]
kotsaloscv Sep 17, 2024
b1dffd4
DaCe Orchestration : Diffusion Module [WIP]
kotsaloscv Sep 17, 2024
0b055fc
DaCe Orchestration : Diffusion Module [WIP]
kotsaloscv Sep 17, 2024
e7f5284
DaCe Orchestration : Diffusion Module
kotsaloscv Sep 18, 2024
b858de8
DaCe Orchestration : Diffusion Module
kotsaloscv Sep 19, 2024
e6841b9
Merge branch 'main' into dace_driving_code
kotsaloscv Sep 19, 2024
611f84b
DaCe Orchestration : Diffusion Module
kotsaloscv Sep 20, 2024
30aba22
Merge branch 'main' into dace_driving_code
kotsaloscv Sep 20, 2024
3e3ed33
DaCe Orchestration : Diffusion Module
kotsaloscv Sep 20, 2024
dece05f
DaCe Orchestration : Diffusion Module
kotsaloscv Sep 20, 2024
cf401c0
DaCe Orchestration : Diffusion Module
kotsaloscv Sep 20, 2024
334b349
DaCe Orchestration : Diffusion Module
kotsaloscv Sep 20, 2024
839bd87
Merge branch 'main' into dace_driving_code
kotsaloscv Sep 24, 2024
a36cbe8
DaCe Orchestration : Diffusion Module
kotsaloscv Sep 24, 2024
0569299
DaCe Orchestration : Diffusion Module
kotsaloscv Sep 25, 2024
b367a71
DaCe Orchestration : Diffusion Module
kotsaloscv Sep 26, 2024
64ff46f
DaCe Orchestration : Diffusion Module
kotsaloscv Sep 30, 2024
4369795
DaCe Orchestration : Diffusion Module
kotsaloscv Sep 30, 2024
b8f22a5
DaCe Orchestration : Diffusion Module
kotsaloscv Sep 30, 2024
218cdf1
DaCe Orchestration : Diffusion Module
kotsaloscv Oct 1, 2024
eb62b6b
DaCe Orchestration : Diffusion Module
kotsaloscv Oct 1, 2024
7f5b53d
DaCe Orchestration : Diffusion Module
kotsaloscv Oct 1, 2024
f4eabcc
DaCe Orchestration : Diffusion Module
kotsaloscv Oct 1, 2024
34a1771
DaCe Orchestration : Diffusion Module
kotsaloscv Oct 2, 2024
2e02c9b
DaCe Orchestration : Diffusion Module [WIP]
kotsaloscv Oct 2, 2024
86e1dd6
DaCe Orchestration : Diffusion Module [WIP]
kotsaloscv Oct 2, 2024
defeec6
DaCe Orchestration : Diffusion Module [WIP]
kotsaloscv Oct 2, 2024
00ff3b1
DaCe Orchestration : Diffusion Module
kotsaloscv Oct 2, 2024
11a5c9e
DaCe Orchestration : Diffusion Module
kotsaloscv Oct 3, 2024
9dcec01
DaCe Orchestration : Diffusion Module
kotsaloscv Oct 3, 2024
68d5daf
DaCe Orchestration : Diffusion Module
kotsaloscv Oct 3, 2024
64784ac
DaCe Orchestration : Diffusion Module
kotsaloscv Oct 3, 2024
83173ca
DaCe Orchestration : Diffusion Module
kotsaloscv Oct 3, 2024
ac102a5
DaCe Orchestration : Diffusion Module
kotsaloscv Oct 3, 2024
bd261cb
DaCe Orchestration : Diffusion Module
kotsaloscv Oct 3, 2024
34990f9
DaCe Orchestration : Diffusion Module
kotsaloscv Oct 3, 2024
5826d93
DaCe Orchestration : Diffusion Module
kotsaloscv Oct 3, 2024
be2dde3
DaCe Orchestration : Diffusion Module
kotsaloscv Oct 3, 2024
cf32448
DaCe Orchestration : Diffusion Module
kotsaloscv Oct 3, 2024
3113af1
DaCe Orchestration : Diffusion Module
kotsaloscv Oct 4, 2024
81dc23a
DaCe Orchestration : Diffusion Module
kotsaloscv Oct 4, 2024
1f51f3c
Merge branch 'main' into dace_driving_code
kotsaloscv Oct 4, 2024
cc29e68
DaCe Orchestration : Diffusion Module
kotsaloscv Oct 4, 2024
c0dc6f3
DaCe Orchestration : Diffusion Module
kotsaloscv Oct 4, 2024
5d35688
DaCe Orchestration : Diffusion Module
kotsaloscv Oct 5, 2024
847c849
DaCe Orchestration : Diffusion Module
kotsaloscv Oct 5, 2024
ed8c9ef
Merge branch 'main' into dace_driving_code
kotsaloscv Oct 14, 2024
f176bcb
DaCe Orchestration : Diffusion Module
kotsaloscv Oct 14, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions ci/dace.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,21 @@ test_model_stencils_x86_64:
test_model_stencils_aarch64:
extends: [.test_model_stencils, .test_template_aarch64]

.test_model_datatests:
stage: test
script:
- pip install dace==$DACE_VERSION
- tox -r -e run_model_tests -c model/ -- --backend=$BACKEND $DACE_ORCHESTRATION $COMPONENT --verbose
parallel:
matrix:
- COMPONENT: [atmosphere/diffusion/tests/diffusion_tests]
BACKEND: [dace_cpu_noopt]
DACE_ORCHESTRATION: ['--dace-orchestration=True', '']
test_model_datatests_x86_64:
extends: [.test_model_datatests, .test_template_x86_64]
test_model_datatests_aarch64:
extends: [.test_model_datatests, .test_template_aarch64]

.benchmark_model_stencils:
stage: benchmark
script:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
from typing import Final, Optional

import gt4py.next as gtx
from gt4py.next import int32

import icon4py.model.common.states.prognostic_state as prognostics
from icon4py.model.atmosphere.diffusion import diffusion_utils, diffusion_states
Expand Down Expand Up @@ -62,6 +63,9 @@
from icon4py.model.common.settings import xp
from icon4py.model.common.utils import gt4py_field_allocation as field_alloc

from icon4py.model.common.orchestration import decorator as dace_orchestration


"""
Diffusion module ported from ICON mo_nh_diffusion.f90.

Expand Down Expand Up @@ -351,6 +355,9 @@ def __init__(
self, exchange: decomposition.ExchangeRuntime = decomposition.SingleNodeExchange()
):
self._exchange = exchange
self.halo_exchange_wait = decomposition.create_halo_exchange_wait(
self._exchange
) # wait on a communication handle
self._initialized = False
self.rd_o_cvd: float = constants.GAS_CONSTANT_DRY_AIR / (
constants.CPD - constants.GAS_CONSTANT_DRY_AIR
Expand Down Expand Up @@ -447,6 +454,10 @@ def init(

self._determine_horizontal_domains()

self.compile_time_connectivities = dace_orchestration.build_compile_time_connectivities(
self.grid.offset_providers
)

self._initialized = True

@property
Expand Down Expand Up @@ -585,6 +596,7 @@ def _sync_cell_fields(self, prognostic_state):
)
log.debug("communication of prognostic cell fields: theta, w, exner - done")

@dace_orchestration.orchestrate
def _do_diffusion_step(
self,
diagnostic_state: diffusion_states.DiffusionDiagnosticState,
Expand All @@ -606,12 +618,13 @@ def _do_diffusion_step(
smag_offset:

"""
num_levels = self.grid.num_levels
# dtime dependent: enh_smag_factor,
scale_k(self.enh_smag_fac, dtime, self.diff_multfac_smag, offset_provider={})
scale_k.with_connectivities(self.compile_time_connectivities)(
halungge marked this conversation as resolved.
Show resolved Hide resolved
self.enh_smag_fac, dtime, self.diff_multfac_smag, offset_provider={}
)

log.debug("rbf interpolation 1: start")
mo_intp_rbf_rbf_vec_interpol_vertex(
mo_intp_rbf_rbf_vec_interpol_vertex.with_connectivities(self.compile_time_connectivities)(
p_e_in=prognostic_state.vn,
ptr_coeff_1=self.interpolation_state.rbf_coeff_1,
ptr_coeff_2=self.interpolation_state.rbf_coeff_2,
Expand All @@ -620,18 +633,20 @@ def _do_diffusion_step(
horizontal_start=self._vertex_start_lateral_boundary_level_2,
horizontal_end=self._vertex_end_local,
vertical_start=0,
vertical_end=num_levels,
vertical_end=self.grid.num_levels,
offset_provider=self.grid.offset_providers,
)
log.debug("rbf interpolation 1: end")

# 2. HALO EXCHANGE -- CALL sync_patch_array_mult u_vert and v_vert
log.debug("communication rbf extrapolation of vn - start")
self._exchange.exchange_and_wait(dims.VertexDim, self.u_vert, self.v_vert)
self._exchange(self.u_vert, self.v_vert, dim=dims.VertexDim, wait=True)
log.debug("communication rbf extrapolation of vn - end")

log.debug("running stencil 01(calculate_nabla2_and_smag_coefficients_for_vn): start")
calculate_nabla2_and_smag_coefficients_for_vn(
calculate_nabla2_and_smag_coefficients_for_vn.with_connectivities(
self.compile_time_connectivities
)(
diff_multfac_smag=self.diff_multfac_smag,
tangent_orientation=self.edge_params.tangent_orientation,
inv_primal_edge_length=self.edge_params.inverse_primal_edge_lengths,
Expand All @@ -651,7 +666,7 @@ def _do_diffusion_step(
horizontal_start=self._edge_start_lateral_boundary_level_5,
horizontal_end=self._edge_end_halo_level_2,
vertical_start=0,
vertical_end=num_levels,
vertical_end=self.grid.num_levels,
offset_provider=self.grid.offset_providers,
)
log.debug("running stencil 01 (calculate_nabla2_and_smag_coefficients_for_vn): end")
Expand All @@ -662,7 +677,9 @@ def _do_diffusion_step(
log.debug(
"running stencils 02 03 (calculate_diagnostic_quantities_for_turbulence): start"
)
calculate_diagnostic_quantities_for_turbulence(
calculate_diagnostic_quantities_for_turbulence.with_connectivities(
self.compile_time_connectivities
)(
kh_smag_ec=self.kh_smag_ec,
vn=prognostic_state.vn,
e_bln_c_s=self.interpolation_state.e_bln_c_s,
Expand All @@ -674,7 +691,7 @@ def _do_diffusion_step(
horizontal_start=self._cell_start_nudging,
horizontal_end=self._cell_end_local,
vertical_start=1,
vertical_end=num_levels,
vertical_end=self.grid.num_levels,
offset_provider=self.grid.offset_providers,
)
log.debug(
Expand All @@ -685,11 +702,11 @@ def _do_diffusion_step(
# TODO (magdalena) move this up and do asynchronous exchange
if self.config.type_vn_diffu > 1:
log.debug("communication rbf extrapolation of z_nable2_e - start")
self._exchange.exchange_and_wait(dims.EdgeDim, self.z_nabla2_e)
self._exchange(self.z_nabla2_e, dim=dims.EdgeDim, wait=True)
log.debug("communication rbf extrapolation of z_nable2_e - end")

log.debug("2nd rbf interpolation: start")
mo_intp_rbf_rbf_vec_interpol_vertex(
mo_intp_rbf_rbf_vec_interpol_vertex.with_connectivities(self.compile_time_connectivities)(
p_e_in=self.z_nabla2_e,
ptr_coeff_1=self.interpolation_state.rbf_coeff_1,
ptr_coeff_2=self.interpolation_state.rbf_coeff_2,
Expand All @@ -698,18 +715,18 @@ def _do_diffusion_step(
horizontal_start=self._vertex_start_lateral_boundary_level_2,
horizontal_end=self._vertex_end_local,
vertical_start=0,
vertical_end=num_levels,
vertical_end=self.grid.num_levels,
offset_provider=self.grid.offset_providers,
)
log.debug("2nd rbf interpolation: end")

# 6. HALO EXCHANGE -- CALL sync_patch_array_mult (Vertex Fields)
log.debug("communication rbf extrapolation of z_nable2_e - start")
self._exchange.exchange_and_wait(dims.VertexDim, self.u_vert, self.v_vert)
self._exchange(self.u_vert, self.v_vert, dim=dims.VertexDim, wait=True)
log.debug("communication rbf extrapolation of z_nable2_e - end")

log.debug("running stencils 04 05 06 (apply_diffusion_to_vn): start")
apply_diffusion_to_vn(
apply_diffusion_to_vn.with_connectivities(self.compile_time_connectivities)(
u_vert=self.u_vert,
v_vert=self.v_vert,
primal_normal_vert_v1=self.edge_params.primal_normal_vert[0],
Expand All @@ -730,42 +747,49 @@ def _do_diffusion_step(
horizontal_start=self._edge_start_lateral_boundary_level_5,
horizontal_end=self._edge_end_local,
vertical_start=0,
vertical_end=num_levels,
vertical_end=self.grid.num_levels,
offset_provider=self.grid.offset_providers,
)
log.debug("running stencils 04 05 06 (apply_diffusion_to_vn): end")

log.debug("communication of prognistic.vn : start")
handle_edge_comm = self._exchange.exchange(dims.EdgeDim, prognostic_state.vn)
handle_edge_comm = self._exchange(prognostic_state.vn, dim=dims.EdgeDim, wait=False)

log.debug(
"running stencils 07 08 09 10 (apply_diffusion_to_w_and_compute_horizontal_gradients_for_turbulence): start"
)
# TODO (magdalena) get rid of this copying. So far passing an empty buffer instead did not verify?
copy_field(prognostic_state.w, self.w_tmp, offset_provider={})
copy_field.with_connectivities(self.compile_time_connectivities)(
prognostic_state.w, self.w_tmp, offset_provider={}
)

apply_diffusion_to_w_and_compute_horizontal_gradients_for_turbulence(
apply_diffusion_to_w_and_compute_horizontal_gradients_for_turbulence.with_connectivities(
self.compile_time_connectivities
)(
area=self.cell_params.area,
geofac_n2s=self.interpolation_state.geofac_n2s,
geofac_grg_x=self.interpolation_state.geofac_grg_x,
geofac_grg_y=self.interpolation_state.geofac_grg_y,
w_old=self.w_tmp,
w=prognostic_state.w,
type_shear=gtx.int32(self.config.shear_type.value),
kotsaloscv marked this conversation as resolved.
Show resolved Hide resolved
type_shear=int32(
self.config.shear_type.value
), # DaCe parser peculiarity (does not work as gtx.int32)
dwdx=diagnostic_state.dwdx,
dwdy=diagnostic_state.dwdy,
diff_multfac_w=self.diff_multfac_w,
diff_multfac_n2w=self.diff_multfac_n2w,
k=self.vertical_index,
cell=self.horizontal_cell_index,
nrdmax=gtx.int32(
nrdmax=int32( # DaCe parser peculiarity (does not work as gtx.int32)
self.vertical_grid.end_index_of_damping_layer + 1
), # +1 since Fortran includes boundaries
interior_idx=self._cell_start_interior,
halo_idx=self._cell_end_local,
horizontal_start=self._horizontal_start_index_w_diffusion,
horizontal_end=self._cell_end_halo,
vertical_start=0,
vertical_end=num_levels,
vertical_end=self.grid.num_levels,
offset_provider=self.grid.offset_providers,
)
log.debug(
Expand All @@ -776,24 +800,26 @@ def _do_diffusion_step(
"running fused stencils 11 12 (calculate_enhanced_diffusion_coefficients_for_grid_point_cold_pools): start"
)

calculate_enhanced_diffusion_coefficients_for_grid_point_cold_pools(
calculate_enhanced_diffusion_coefficients_for_grid_point_cold_pools.with_connectivities(
self.compile_time_connectivities
)(
theta_v=prognostic_state.theta_v,
theta_ref_mc=self.metric_state.theta_ref_mc,
thresh_tdiff=self.thresh_tdiff,
smallest_vpfloat=constants.DBL_EPS,
kh_smag_e=self.kh_smag_e,
horizontal_start=self._edge_start_nudging,
horizontal_end=self._edge_end_halo,
vertical_start=(num_levels - 2),
vertical_end=num_levels,
vertical_start=(self.grid.num_levels - 2),
vertical_end=self.grid.num_levels,
offset_provider=self.grid.offset_providers,
)
log.debug(
"running stencils 11 12 (calculate_enhanced_diffusion_coefficients_for_grid_point_cold_pools): end"
)

log.debug("running stencils 13 14 (calculate_nabla2_for_theta): start")
calculate_nabla2_for_theta(
calculate_nabla2_for_theta.with_connectivities(self.compile_time_connectivities)(
kh_smag_e=self.kh_smag_e,
inv_dual_edge_length=self.edge_params.inverse_dual_edge_lengths,
theta_v=prognostic_state.theta_v,
Expand All @@ -802,15 +828,17 @@ def _do_diffusion_step(
horizontal_start=self._cell_start_nudging,
horizontal_end=self._cell_end_local,
vertical_start=0,
vertical_end=num_levels,
vertical_end=self.grid.num_levels,
offset_provider=self.grid.offset_providers,
)
log.debug("running stencils 13_14 (calculate_nabla2_for_theta): end")
log.debug(
"running stencil 15 (truly_horizontal_diffusion_nabla_of_theta_over_steep_points): start"
)
if self.config.apply_zdiffusion_t:
truly_horizontal_diffusion_nabla_of_theta_over_steep_points(
truly_horizontal_diffusion_nabla_of_theta_over_steep_points.with_connectivities(
self.compile_time_connectivities
)(
mask=self.metric_state.mask_hdiff,
zd_vertoffset=self.metric_state.zd_vertoffset,
zd_diffcoef=self.metric_state.zd_diffcoef,
Expand All @@ -822,15 +850,15 @@ def _do_diffusion_step(
horizontal_start=self._cell_start_nudging,
horizontal_end=self._cell_end_local,
vertical_start=0,
vertical_end=num_levels,
vertical_end=self.grid.num_levels,
offset_provider=self.grid.offset_providers,
)

log.debug(
"running fused stencil 15 (truly_horizontal_diffusion_nabla_of_theta_over_steep_points): end"
)
log.debug("running stencil 16 (update_theta_and_exner): start")
update_theta_and_exner(
update_theta_and_exner.with_connectivities(self.compile_time_connectivities)(
z_temp=self.z_temp,
area=self.cell_params.area,
theta_v=prognostic_state.theta_v,
Expand All @@ -839,9 +867,17 @@ def _do_diffusion_step(
horizontal_start=self._cell_start_nudging,
horizontal_end=self._cell_end_local,
vertical_start=0,
vertical_end=num_levels,
vertical_end=self.grid.num_levels,
offset_provider={},
)
log.debug("running stencil 16 (update_theta_and_exner): end")
handle_edge_comm.wait() # need to do this here, since we currently only use 1 communication object.

self.halo_exchange_wait(
handle_edge_comm
) # need to do this here, since we currently only use 1 communication object.
log.debug("communication of prognogistic.vn - end")

def orchestration_uid(self) -> str:
"""Unique id based on the runtime state of the Diffusion object. It is used for caching in DaCe Orchestration."""
# TODO (kotsaloscv): It is unsafe to set it as cached property -demands more testing-
return dace_orchestration.generate_orchestration_uid(self)
Loading
Loading