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 1 commit into
base: maerhart-rtgtest-materializer
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
@maerhart maerhart marked this pull request as draft January 16, 2025 17:48
@maerhart
Copy link
Member Author

Temporarily converting to draft to evaluate the comments re std::variant in earlier PRs

@maerhart maerhart force-pushed the maerhart-rtg-elaboration-scfif branch from c387cd7 to d4fa31c Compare January 17, 2025 11:23
Base automatically changed from maerhart-rtg-elaboration-scfif to main January 17, 2025 11:51
@maerhart maerhart force-pushed the maerhart-rtg-elaboration-perf branch 2 times, most recently from 6f3896c to 4752232 Compare January 17, 2025 14:33
@maerhart maerhart marked this pull request as ready for review January 17, 2025 14:34
@maerhart maerhart force-pushed the maerhart-rtg-elaboration-perf branch from 4752232 to ff7069a Compare January 21, 2025 11:17
@maerhart maerhart changed the base branch from main to maerhart-rtgtest-materializer January 21, 2025 11:17
Copy link
Contributor

@darthscsi darthscsi left a comment

Choose a reason for hiding this comment

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

LGTM

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.

2 participants