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

DO NOT MERGE: Remove ineffective distribute-constants optimization #734

Closed
wants to merge 6 commits into from

Conversation

sjalander
Copy link
Collaborator

The distributed-constants optimization has no effect on the cycle count for the hls test suite. So, it is being removed.

@sjalander sjalander requested review from phate, haved and davidmetz January 9, 2025 18:38
@haved
Copy link
Collaborator

haved commented Jan 9, 2025

Woah, I tried replacing it with NodeReduction and got errors, I had not considered just downright removing it.

I think the reason there was a dedicated "move constants in" pass was to avoid buffers holding constant values being created, e.g. before thetas. Do we have any quick way of determining if this change has a drastic effect on the size of the HLS?

@sjalander
Copy link
Collaborator Author

I don't think we currently have any quick way of doing it. But I guess it wouldn't be difficult to count nodes and different types of nodes in the final graph and compare numbers.

@sjalander
Copy link
Collaborator Author

@haved Adding the NodeReduction before mem_sep_argument() causes an assert to be triggered similarly if it is placed before mem_queue(). I've not debugged these to find out what assumptions that break.
It is possible to add the NodeReduction after memstate_conv(), but without adding the statistics mentioned earlier, it's not that easy to say if it has a benefit.

The distributed-constants optimization has no effect on the cycle
count for the hls test suite. So, it is being removed.
Replaced in the main pipeline defined in rvsdg2rhls.cpp, but
unfortunately still part of the mem-conv.cpp. So the code has not
been removed completely.
@sjalander sjalander force-pushed the distribute-constants branch from 2dda309 to d99c18e Compare January 16, 2025 17:03
@sjalander
Copy link
Collaborator Author

@haved
I also replaced the unused state with llvm::InvariantValueRedirection.
Can you check with your new statistics option to see if this has an impact on the number of nodes.

I was not able to eliminate the code completely, as the remove_unused_state() is also used in the mem_conv() pass, and simply replacing it there caused logical faults.

Copy link

The execution time of dynamatic/kernel_2mm has changed
  Golden cycle time: 24621
  Simulated cycles: 24701

@sjalander sjalander changed the title Remove ineffective distribute-constants optimization DO NOT MERGE: Remove ineffective distribute-constants optimization Jan 16, 2025
Copy link

The execution time of dynamatic/kernel_2mm has changed
  Golden cycle time: 24621
  Simulated cycles: 24701

@haved
Copy link
Collaborator

haved commented Jan 17, 2025

@sjalander @phate
Among all 67 files in the hls test suite, the changes made in this PR only affects the node count in one of them: insertion_sort.c. The change is as follows:

Differences in file insertion_sort.txt:
Total change in node count: +3 (before 333)
HLS_BUF_P_10: +1 (before: 148)
HLS_BRANCH: +1 (before: 31)
HLS_SINK: +1 (before: 13)

@sjalander sjalander marked this pull request as draft January 17, 2025 16:49
This commit removes code that is not necessary and replaced by
InvariantValueRedirection.
Copy link

The execution time of base/test_return has changed
  Golden cycle time: 2
  Simulated cycles: 3

Copy link

The execution time of base/test_return has changed
  Golden cycle time: 2
  Simulated cycles: 3

@sjalander sjalander closed this Jan 30, 2025
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