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

[RTG][Elaboration] Do not internalize primitive values #7997

Open
wants to merge 4 commits into
base: maerhart-rtg-elaboration-scfif
Choose a base branch
from

Conversation

maerhart
Copy link
Member

  • Refactor the pass to not internalize ElaboratorValue directly, but let it have a pointer to a storage which is internalized. This storage pointer can be used to directly store primitive values, thus avoiding internalization:
    • index type values
    • i1 type values
    • MLIR Attributes by storing their opaque pointer (because they are already internalized by MLIR)
  • Instead of the unique pointer trick, use a bump allocator in the internalization logic
  • I tested 3 possible implementation for the sets that store the internalized values:
    • DenseSet<StorageTy *> with a custom MapInfo that does actual value comparison instead of comparing pointers: performs very well when all values internalized are unique (i.e., no equivalent object is already in the set, ever), but not very well when the object is equivalent to an already internalized one most of the time
    • FoldingSet<StorageTy>: performs worse than the above in the first case, but considerably better when the object is already in the set, because it avoids unnecessary malloc+free
    • The approach in this PR: combines the advantages of the above two, i.e., performs best in all cases, and is also the approach taken in MLIRs StorageUniquer.cpp
  • Improves performance of the example in [RTG][Elaboration] Add support for 'scf.if' and 'scf.for' #7986 from ~5.4 sec to ~0.78 sec (~6.9x speedup)

@maerhart maerhart added the RTG Involving the `rtg` dialect label Dec 16, 2024
@maerhart maerhart force-pushed the maerhart-rtg-elaboration-perf branch from 2151aba to 2e5bedb Compare December 16, 2024 10:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
RTG Involving the `rtg` dialect
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant