feat[next]: Compile time domains#2173
Conversation
… ir.makers and update tests
…nsform_get_domain
|
@havogt The case we discussed where a program does not create any temporaries, for which using static values for the domain has no benefits, but leads to unnecessary recompilation when changing the number of nodes, can not be easily detected in a way that would allow us to keep dynamic domain sizes. Such programs can only be identified after field operator fusion, which is after the replacement of the |
Note: required some merging
Note: required some merging
Note: required some merging
Note: required some merging
Note: required some merging
egparedes
left a comment
There was a problem hiding this comment.
Looks good. I have only a couple of minor questions and suggestions
| else: | ||
| nb_index = val.value # type: ignore[assignment] # assert above | ||
|
|
||
| accessed = connectivity.ndarray[start:stop, nb_index] |
There was a problem hiding this comment.
Is guaranteed at this point that the connectivity is well formed (i.e. 2d with the second axis being the neighbor dimension) or it should be asserted/checked?
There was a problem hiding this comment.
Good catch, when we wrote this I was actually not aware a Connectivity is not necessarily two dimensional with a regular and a local index. I test for NeighborConnectivity now.
src/gt4py/next/program_processors/runners/dace/workflow/translation.py
Outdated
Show resolved
Hide resolved
|
|
||
| # the float argument here is merely to test that static domains work for tuple arguments | ||
| # of inhomogeneous types | ||
| @gtx.program(backend=CaptureCompileTimeArgsBackend(), static_domains=True) |
There was a problem hiding this comment.
Should we add a test case for named collections or do you think it's not needed?
There was a problem hiding this comment.
Yes, it actually revealed a small but.
egparedes
left a comment
There was a problem hiding this comment.
LGTM. Please go ahead and merge once CI is green.
This PR adds support for domain sizes and domain inference at compile time. As a result temporary fields are only allocated on the domains that they are read on instead of everywhere.
Internally compile time domains are realized by the addition of a new argument descriptor
FieldDomainDescriptorwhich holds the domain of the corresponding field argument in the form of agtx.Domain. The output domains ofSetAtstatements are replaced with these static domains using theTransformGetDomainRangepass introduced in #2151. The domain inference is extended to use the actual values stored in the connectivity to deduce the required domain on which temporaries need to be computed. This domain is potentially non-contiguous and, since we only support contiguous domains, extended to the minimal contiguous domain. In case this extension leads to many unnecessary computations (default is 25% of the total size) a warning is emitted. The current default can be configured by settingNON_CONTIGUOUS_DOMAIN_WARNING_THRESHOLDingt4py.next.iterator.ir_utils.domain_utils. The old behavior to compute everywhere is still used in case either a) thestatic_domainoption isFalseor b) the backend is configured to compute everywhere by settinguse_max_domain_range_on_unstructured_shifttoTrueinGTFNTranslationSteporDaCeTranslator.Note that compile time domains are only supported in
jitmode right now, as we need to change thecompileinterface, which will happen in a later PR.