Skip to content

Conversation

@SF-N
Copy link
Contributor

@SF-N SF-N commented Jul 24, 2025

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.

@gtx.program(static_domains=True)
def testee(...):
        ...

Internally compile time domains are realized by the addition of a new argument descriptor FieldDomainDescriptor which holds the domain of the corresponding field argument in the form of a gtx.Domain. The output domains of SetAt statements are replaced with these static domains using the TransformGetDomainRange pass 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 setting NON_CONTIGUOUS_DOMAIN_WARNING_THRESHOLD in gt4py.next.iterator.ir_utils.domain_utils. The old behavior to compute everywhere is still used in case either a) the static_domain option is False or b) the backend is configured to compute everywhere by setting use_max_domain_range_on_unstructured_shift to True in GTFNTranslationStep or DaCeTranslator.

Note that compile time domains are only supported in jit mode right now, as we need to change the compile interface, which will happen in a later PR.

@SF-N SF-N requested a review from tehrengruber July 24, 2025 16:03
tehrengruber and others added 12 commits October 8, 2025 11:38
…mains_of_temporaries

# Conflicts:
#	tests/next_tests/integration_tests/feature_tests/ffront_tests/test_compiled_program.py
…of_temporaries' into infer_unstructured_domains_of_temporaries
…mains_of_temporaries

# Conflicts:
#	src/gt4py/next/iterator/transforms/pass_manager.py
#	tests/next_tests/integration_tests/feature_tests/ffront_tests/test_compiled_program.py
#	tests/next_tests/unit_tests/program_processor_tests/runners_tests/dace_tests/test_dace_translation.py
…mains_of_temporaries

# Conflicts:
#	src/gt4py/next/ffront/past_to_itir.py
#	tests/next_tests/unit_tests/program_processor_tests/runners_tests/dace_tests/test_dace_domain.py
#	tests/next_tests/unit_tests/program_processor_tests/runners_tests/dace_tests/test_gtir_to_sdfg.py
tehrengruber added a commit to tehrengruber/gt4py that referenced this pull request Nov 13, 2025
…mains_of_temporaries

# Conflicts:
#	src/gt4py/next/ffront/decorator.py
#	src/gt4py/next/ffront/past_to_itir.py
tehrengruber added a commit to tehrengruber/gt4py that referenced this pull request Nov 13, 2025
tehrengruber added a commit to tehrengruber/gt4py that referenced this pull request Nov 13, 2025
def _process_symbolic_domains_option(
ir: itir.Program,
offset_provider: common.OffsetProvider | common.OffsetProviderType,
symbolic_domain_sizes: Optional[dict[str, str | itir.Expr]],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
symbolic_domain_sizes: Optional[dict[str, str | itir.Expr]],
symbolic_domain_sizes: Optional[dict[str, itir.Expr]],

Try if this is possible everywhere with low effort.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still open?

@tehrengruber
Copy link
Contributor

tehrengruber commented Nov 26, 2025

@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 get_domain_range calls and domain inference. As soon as we introduce symbolic domain operations (e.g. union, intersection) we can keep the domain inference symbolic and only after operator fusion make everything static. As such I would postpone working on this case and stay with the workaround of the user selectively using static_domains to avoid unnecessary recompilation. Most likely this is anyway only important for PMAP-GO where we have a good amount of small operators without temporaries.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants