Open havogt opened 2 months ago
Does a) work in icon4py?
Probably broken in https://github.com/C2SM/icon4py/blob/1acfb78134f09d254457ea97ae81423da54c28bb/model/atmosphere/dycore/src/icon4py/model/atmosphere/dycore/compute_hydrostatic_correction_term.py#L38 where we compute a single output level, but access multiple levels with an as_offset shift.
Sketch for domain inference:
field(as_offset(Ioff, offset_field))
is intersection(domain(field), domain(offset_field))
. If the input IR does not have any Out-Of-Bounds memory accesses so does direct execution of the resulting IR here (since we only compute values were the input is defined).as_fieldop(dynamic_shift_stencil, forward_inferred_domain)
we can either
as_fieldop
. Since the domains of the inputs are inferred already by the forward propagation all domains are inferred and we can execute as usual, but might compute (way) too much. This is trivial to implement.offset_field
. Given the domain where the as_fieldop
is read, let's call it accessed_domain
, the resulting domain is intersection(forward_inferred_domain, extend(accessed_domain, max_relative_offset))
intersection(forward_inferred_domain, domain(min(offset_field_with_absolute_indices), max(offset_field_with_absolute_indices))
.
lowers to
How can we compute the domain that is needed for
compute_k_field
?a) take the out_domain: probably wrong in some cases (e.g. between k and khalf) b)
take the domain of(this is the same as a), as the domain ofk_offset
k_offset
is taken fromout_domain
c) user has to annotate the domain explicitly (either explicit (requires to pass in the domain bounds -> ugly) or relative to a domain or field; both introduce slicing-like syntax and requires clear concept definition) d) inline everything below for now and find a better way to express the patternNote: in icon4py all as_offsets are in the vertical