Skip to content

Refactor the implementation logic of backtrack mapping#104

Merged
ShangkunLi merged 6 commits intocoredac:mainfrom
ShangkunLi:refactor-backtrack
Aug 8, 2025
Merged

Refactor the implementation logic of backtrack mapping#104
ShangkunLi merged 6 commits intocoredac:mainfrom
ShangkunLi:refactor-backtrack

Conversation

@ShangkunLi
Copy link
Copy Markdown
Collaborator

In this pr:

  • Refactor the backtrack mapping logic to enable real backtrack mapping
  • Specifically, the mapping logic for now is illustrated using an example below.

Suppose I want to map a simple DFG that has 3 operations, with the dependencies A->B->C.

  1. I first get 3 available candidate locations for A based on calculateAward, and I map the one with the highest award.
  2. Then I continue to get 2 available candidate locations for B based on calculateAward, and I also successfully map the one with the highest award.
  3. Then I find 3 available candidate locations for C, but none of them can be mapped legally, so I need to backtrack to B to try to select another available location of B for mapping, and then try C's 3 locations again (maybe not 3, it depends on the result of calculateAward), to see which one can succeed, at this time we define the backtracking depth as 1.
  4. If B's two locations also cannot work, we need to backtrack to A, try A's other locations, and then re-map B and C, at this time we define the backtracking depth as 2.
  5. If if the max backtracking depth is reached, and we still haven't found any legal mapping, it will return false and try next II

@ShangkunLi ShangkunLi marked this pull request as ready for review August 6, 2025 07:38
@tancheng
Copy link
Copy Markdown
Contributor

tancheng commented Aug 6, 2025

Plz explain the diff from existing code a little bit use your example.

@ShangkunLi
Copy link
Copy Markdown
Collaborator Author

Plz explain the diff from existing code a little bit use your example.

In current implementation,

for (int i = 0; i < locations_to_try; ++i) {

when p&r in current candidate location for C fails, it will restore to the mapping_state before mapping C and try different candidate locations for C

mappingstate_snapshot.restore(mapping_state);

But the backtracking_depth increases each time when I try new candidate locations for the current op. It is not correct, because when I try different locations for C, the backtracking depth should remain the same (In fact, this is not backtracking, because I just try different locations for C).

@tancheng
Copy link
Copy Markdown
Contributor

tancheng commented Aug 6, 2025

Plz explain the diff from existing code a little bit use your example.

In current implementation,

for (int i = 0; i < locations_to_try; ++i) {

when p&r in current candidate location for C fails, it will restore to the mapping_state before mapping C and try different candidate locations for C

mappingstate_snapshot.restore(mapping_state);

But the backtracking_depth increases each time when I try new candidate locations for the current op. It is not correct, because when I try different locations for C, the backtracking depth should remain the same (In fact, this is not backtracking, because I just try different locations for C).

This sounds if we increase the backtracking steps to N * locations_to_try, it would be the same as your current PR's backtracking steps of N?

@ShangkunLi
Copy link
Copy Markdown
Collaborator Author

Plz explain the diff from existing code a little bit use your example.

In current implementation,

for (int i = 0; i < locations_to_try; ++i) {

when p&r in current candidate location for C fails, it will restore to the mapping_state before mapping C and try different candidate locations for C

mappingstate_snapshot.restore(mapping_state);

But the backtracking_depth increases each time when I try new candidate locations for the current op. It is not correct, because when I try different locations for C, the backtracking depth should remain the same (In fact, this is not backtracking, because I just try different locations for C).

This sounds if we increase the backtracking steps to N * locations_to_try, it would be the same as your current PR's backtracking steps of N?

No, in the previous implementation, there is no backtracking. We just try different locations for C without restoring the state to before mapping B. And the number of locations to try is min(locations_to_try, max_backtracking_depth).

@ShangkunLi ShangkunLi merged commit 0307d5e into coredac:main Aug 8, 2025
1 check passed
ShangkunLi added a commit that referenced this pull request Mar 12, 2026
Refactor the implementation logic of backtrack mapping
ShangkunLi added a commit that referenced this pull request Mar 12, 2026
Refactor the implementation logic of backtrack mapping
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.

2 participants