Skip to content

IdModel: Step 4 of the loop promotion analysis#2003

Merged
naoyam merged 11 commits intomainfrom
idmodel_step4
Apr 3, 2024
Merged

IdModel: Step 4 of the loop promotion analysis#2003
naoyam merged 11 commits intomainfrom
idmodel_step4

Conversation

@naoyam
Copy link
Collaborator

@naoyam naoyam commented Mar 26, 2024

Step 4 of the loop promotion analysis. This is for fully propagating promotion mappings including partially inlined domains.

naoyam added 4 commits March 26, 2024 13:37
The loop promotion map generated at Step 3 is propagated through the IEL
graph. This is necessary for partially inlined domains.
@naoyam
Copy link
Collaborator Author

naoyam commented Mar 26, 2024

!build

@naoyam naoyam requested a review from zasdfgbnm March 26, 2024 22:41
@naoyam naoyam changed the title [WIP] IdModel: Step 4 of the loop promotion analysis IdModel: Step 4 of the loop promotion analysis Mar 26, 2024
Comment on lines +641 to +647
std::unordered_map<ValGroup, IterDomain*> final_iel_promotion_map;
propagatePromotionsInIELGraph(
iel_graph,
final_iel_promotion_map,
idGraph(IdMappingMode::LOOP),
loop_promotion_map,
true);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Does it make sense to do the following instead?:

for (auto entry : iel_promotion_map) {
  ValGroup iel_group = entry->first;
  ValGroup loop_group = idGraph(IdMappingMode::LOOP).toGroup(iel_group->front());
  auto it = loop_promotion_map.find(loop_group);
  if (it != loop_promotion_map.end()) {
    entry->second = it->second;
  }
}
propagatePromotionsInIELGraph(iel_graph, iel_promotion_map, require_loop_mapped_promotion=true);

I think my biggest problem with IdModel is this is so complicated that I can not fit it into my mind. IIUC, changing it to the above code is equivalent to the current approach, but the mental model will be easier.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is actually related to #2003 (comment).

Using the Step 3 results needs to consider the condition checked by hasUniqueInputLoopGraphs, so the suggested code would result in the double propagation. We could avoid that by selectively updating iel_promotion_map, but that would mean we would need to look at inputs and outputs and propagate loop_promotion_map only to outputs in some cases. I'd say that would be almost equally complicated as the current version.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I see, thanks for the explanation. Could you open an issue for #2003 (comment)?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Could you open an issue for #2003 (comment)?

What issue are you referring to? The broadcast forwarding?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yes

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Added: #2030

@naoyam
Copy link
Collaborator Author

naoyam commented Apr 3, 2024

!build

@naoyam naoyam merged commit fb1071f into main Apr 3, 2024
@naoyam naoyam deleted the idmodel_step4 branch April 3, 2024 15:55
@naoyam naoyam added the idmodel label Apr 3, 2024
protonu pushed a commit that referenced this pull request Apr 3, 2024
Step 4 of the loop promotion analysis. This is for fully propagating
promotion mappings including partially inlined domains.

---------

Co-authored-by: Gao, Xiang <qasdfgtyuiop@gmail.com>
naoyam added a commit that referenced this pull request May 10, 2024
This is the final step of the loop promotion analysis. The promotion map
is almost completed at Step 3, but some partially inlined domains need
one more propagation, which is done by Step 4 and Step 5. Step 5 is
mostly just a repeat of Step 3.

This basically concludes the loop promotion analysis, although there are
a couple of issues that were found while working on indexing (#2218).
Those issues will be addressed as further follow-up PRs.

- Step 1: #1650 
- Step 2: #1777 
- Step 3: #1830 
- Step 4: #2003
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants