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

Add a more thorough target slot analysis #526

Merged
merged 1 commit into from Mar 18, 2024

Conversation

j2kun
Copy link
Collaborator

@j2kun j2kun commented Mar 12, 2024

When running this in debug mode

bazel run --noallow_analysis_cache_discard //tools:heir-opt -- \
    --secretize=entry-function=box_blur --wrap-generic --canonicalize --cse \
    --full-loop-unroll --canonicalize --cse \
    --insert-rotate \
    $PWD/tests/simd/box_blur_4x4.mlir --debug --debug-only=insert-rotate

The logs show:

https://gist.github.com/j2kun/00d819fc79b7e1a24e29b8354c08537f

I believe this is sufficient to thread through the pass and achieve the optimal rotations, however, it will require giving up on the pattern-based implementation because I'm not aware of a way to have tablegen patterns use the results of an analysis pass. I will inquire about it though.

Copy link
Collaborator

@AlexanderViand-Intel AlexanderViand-Intel left a comment

Choose a reason for hiding this comment

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

I believe this is sufficient to thread through the pass and achieve the optimal rotations

Yes, this looks really good! Not only because the taget slots match for each of the ops in an unrolled iteration of the box_blur loop nest, but also because it doesn't seem to flag any "excessive" target slots in hamming_dist 👍

// values.
void visitOperation(Operation *op, ArrayRef<TargetSlotLattice *> operands,
ArrayRef<const TargetSlotLattice *> results) override;

Copy link
Collaborator

Choose a reason for hiding this comment

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

Less of a review comment, more a question for my own benefit/understanding of the analysis framework: what's going on here with these empty implementations?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I believe these hooks are for adding special behavior at control flow entry and exit points, where by default the framework would have no propagation through them. For something like a liveness analysis

https://github.com/llvm/llvm-project/blob/2a547f0f6c6b456342b9bfad38787f54f265fc96/mlir/lib/Analysis/DataFlow/LivenessAnalysis.cpp#L104-L106

I don't specifically know which arguments of the branch ops, for example, are "not forwarded" automatically. But for our purposes for now we're assuming there is no control flow.

@j2kun j2kun added the pull_ready Indicates whether a PR is ready to pull. The copybara worker will import for internal testing label Mar 15, 2024
@copybara-service copybara-service bot merged commit cb54c78 into google:main Mar 18, 2024
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pull_ready Indicates whether a PR is ready to pull. The copybara worker will import for internal testing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants