-
Notifications
You must be signed in to change notification settings - Fork 769
[SYCL] Unify compile/run-time properties more #12245
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
Closed
Closed
Changes from all commits
Commits
Show all changes
4 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
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.
You can see here that the definition of a typical runtime property expanded from 5 lines to about 12. However, the description of the PR says that a goal is to simplify the implementation. What is getting simplified? It seems like the definition of a runtime property is more complex, not less.
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.
The main motivation is to simplify has_property and get_property. I'm worried that if/when properties are getting used a lot, that the current implementation will be bad for compilation speed. Currently we store the properties as a sorted list of values in the template argument of
properties
. And because not all have the same form (compile-time are of the formproperty_value<key, ...>
and runtime are their own type) we have to iterate over the whole list every time.With this change all property have the same form of
property_value<key, ...>
. This turns the sorted list into a sorted map. And with that efficient map lookup with mp_map_find (doc, impl) is possible.If we don't like this change we could instead change the storage inside the template argument to a sorted set of runtime properties and a sorted map of compile-time properties (doesn't require any spec changes). Both would have fast lookup. We would just need to split the properties in the two group prior to sorting whenever we sort.
A 2nd motivation was to reduce where we need to distinguish between the two groups of properties in the implementation. With the alternative implementation this would become more not less.
For the spec we could allow both implementation strategies (runtime property values are of the form
property_value<key, ...>
or runtime property values/keys the same type). Then this becomes purely a quality of implementation question.The
property_value<key, ...>
form allows a runtime property value to store some of its values as compile-time values. And those values can be queried at compile time. I'm not aware of use-cases for properties which have both runtime values (members) and also compile-time values (template args). So I don't know whether this is an advantage.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 created a prototype of what I think a better implementation should roughly look like: https://godbolt.org/z/PvaWzTnnW. For the PRs I was trying to break the changes into incremental steps to help with review. But hopefully this shows what is possible after all changes. In my view it makes the implementation of the properties class much shorter and also easier to define both runtime and compile-time properties. This implementation currently isn't conformant, because the spec contains several implementation details which aren't valid for this strategy. To make it conformant we would need to remove (or change):
get_property
(simplifies implementation, we don't have any use case of non-device copyable properties)None of the changes are necessary. We could do none or only some and still simplify the implementation. It just that each of them make it simpler to either implement the properties class or add new properties.
I would be interested in any feedback regarding:
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 prefer multiple incremental PRs, personally, and I don't think we should specify anything about implementation that we don't have to.