Skip to content

[WIP] Derive a scope's symbol table once per scope - #2519

Draft
ThrudPrimrose wants to merge 1 commit into
mainfrom
perf/scope-symbol-table
Draft

[WIP] Derive a scope's symbol table once per scope#2519
ThrudPrimrose wants to merge 1 commit into
mainfrom
perf/scope-symbol-table

Conversation

@ThrudPrimrose

@ThrudPrimrose ThrudPrimrose commented Aug 23, 2026

Copy link
Copy Markdown
Collaborator

symbols_defined_at walks every descriptor in the SDFG, and propagate_memlet derived it once per
memlet, so building a program cost O(scopes x descriptors) sympy work -- on a 2000-line generated
kernel, 8845 walks over 2082 descriptors, 81% of a 183 s parse. Callers propagating several memlets
through one scope node now derive it once, Data.free_symbols is memoized behind the property
setter that is the only way its sources can change, and the descriptor scan reads s.name instead
of printing the symbol.

tests/corpus/cloudsc, build_cloudsc_sdfg(simplify=False)   -- this branch vs main
  before  872.6 s      after  800.3 s      (6342 blocks, 2687 descriptors)

warpx_field_gather (hpcagent_bench, 2000 lines), to_sdfg(simplify=False)
  before  182.6 s      after   38.4 s      (7269 blocks, 2948 descriptors)

The second kernel is measured on the extended branch: it needs a data-dependent shape main's
frontend refuses, so main cannot parse it either way.

… edge

symbols_defined_at walks every descriptor in the SDFG. propagate_memlet derived it per memlet, so
building a program cost O(scopes x descriptors) sympy work: on a 2000-line generated kernel, 8845
walks over 2082 descriptors, 81% of a 183s parse.

Callers that propagate several memlets through one scope node now derive it once and pass it down;
Data.free_symbols is memoized, invalidated by the property setter that is the only way its sources
can change (they are tuples and sympy expressions, so none can be edited in place); and the scan
reads a symbol's name rather than printing it through sympy. Same parse: 38s.
@ThrudPrimrose

Copy link
Copy Markdown
Collaborator Author

Holding this on the extended branch for now: the win is large on generated kernels and small on the cloudsc corpus, so it wants more evidence before landing on main.

@ThrudPrimrose
ThrudPrimrose deleted the perf/scope-symbol-table branch August 23, 2026 13:19
@ThrudPrimrose
ThrudPrimrose restored the perf/scope-symbol-table branch August 23, 2026 13:20
@ThrudPrimrose ThrudPrimrose reopened this Aug 23, 2026
@ThrudPrimrose

Copy link
Copy Markdown
Collaborator Author

Reopened -- keeping it as a draft. The change is running on the extended branch meanwhile, which is where the generated-kernel numbers come from.

@ThrudPrimrose ThrudPrimrose changed the title [WIP] Derive a scope's symbol table once per scope, not once per propagated edge [WIP] Derive a scope's symbol table once per scope Aug 23, 2026
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.

1 participant