-
Notifications
You must be signed in to change notification settings - Fork 424
Change e_pin_type to enum class #3250
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
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am just curious, why use an int8 here instead of leaving it unspecified?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One of the hot structs in rr-graph used e_pin_type::OPEN as default value so I thought making it smaller would make a difference. Halfway through the changes I realized it was actually not OPEN but simply -1. Reverted that change but the int8_t remained. I could remove this if think it'll be better.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
About UNDEFINED in vpr vs the other constants in libarchfpga and librrgraph, yeah I'm also not sure. I made each project have it's own UNDEFINED which is not ideal because of the reasons you mentioned but also to do otherwise we'll need a project wide constant. If you know a good place for that constant I'll be more than happy to unify all the different -1s.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not 100% sure what the compiler will do in this case. If you leave it unspecified it will use the default
int
type. This is whatever bitwidth of integer that the CPU finds the most convenient (which I think will be the size of a register). When you use a smaller type (likeint8_t
in this case), the compiler will still have to put the enum variable in a register which will certainly be larger so it may have to add the appropriate masking to the register so it only grabs the part that represents the enum. This can be slower, but honestly its probably so little its not worth worrying about. Also I suspect compilers are smart enough to recognize this behavior.The only benefit in my opinion on using a smaller int type for this would be if you are storing a large array of enums; but if we are not doing that, its probably cleaner just to leave as "int"; but I have seen people fight online about this (they claim that forcing the type helps protect people who are running on different machines, but I doubt that will be a problem in this case).
Honestly, up to you if you want to change it. If you are making any other changes to this PR, maybe change it back. But thats why I say it does not really matter. It is super interesting though in my opinion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Regarding UNDEFINED, I agree. I also do not think there is a good central place for it. Ideally we would use more modern std::optional syntax when we can; but that is far too much for this PR. Do not let it block it.