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.
[oneDPL] Indirectly Device Accessible Iterator Customization Point and Public Trait #620
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
base: main
Are you sure you want to change the base?
[oneDPL] Indirectly Device Accessible Iterator Customization Point and Public Trait #620
Changes from 23 commits
d90682b
24b879d
ff940e8
0c0804b
8cff3e4
a36a006
cb102cb
bc32ce2
e7ffb99
913d555
29e209f
180a500
a852f0f
41b9828
96b1b45
dd71fdf
21b8d0f
7c76593
250aed2
696d925
b250e77
8928a06
1fff43d
59c147a
0fe3101
1d44b35
a918a45
25edb0b
b4aeaf0
4967f43
583fd52
b8a6018
311f2cb
8676878
ef67c3d
0f64be0
780f501
a57c7d7
6114c2c
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
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.
adjusted all of these "are" -> "is" [a]
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.
"Always" word seems redundant to me. The same comment is applicable for the iterators below.
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.
removed all instances of this.
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 think it's not true for a generic case. As I mentioned, I believe
std::conjunction
is an important use case. However,std::conjunction
might not havestd::true_type
orstd::false_type
characteristics at all.I believe that this sentence about characteristics has a perfect fit to where you describe
is_device_accessible_content_iterator
trait itself instead of the current wording, which is "... evaluates to a type...". I would just say "...has characteristics ofstd::true_type
..."Here we need something else. Don't have immediate suggestions, though
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.
If it is used with
true_type
/false_type
or derivatives, it will:And that's exactly our goal I believe.
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 suppose I don't know exactly what we mean by "characteristics of
std::true_type
" if astd::conjunction
or similar types will not qualify.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.
conjunction
,disjunction
and possiblynegation
(though, I am not sure) are the only exceptions I am aware of. All other traits have characteristics of eithertrue_type
orfalse_type
because they inherit frombool_constant
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 wording "with a base characteristic of" is used in a few places in the C++ standard, for example in https://eel.is/c++draft/meta.unary:
My understanding of this wording is: even though it is not a true_type or false_type, it has all the same characteristics as these types and can be used as such. Practically it means that the trait class inherits either true_type or false_type (maybe indirectly).
In my comment above, I say that
std::conjunction
also falls into this category if the chosen template parameter does. Though the standard does not prohibit to use other types withstd::conjunction
, typical arguments it is used with will be traits etc. classes that inheritbool_constant
. Therefore requiring that the return type of our ADL customization function should have these characteristics does not preclude the use ofstd::conjunction
, but limits what types can be passed to it.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.
Actually, it's even more strict - the standard requires public inheritance, see https://eel.is/c++draft/meta.rqmts#:Cpp17UnaryTypeTrait:
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.
Is see, thanks for the clarification. I think I agree that our current formulation makes sense then, with a small tweak to the language perhaps to follow the example language you provided.
Unless we have a compelling example to allow
conjunction
disjunction
negation
which use something other than types with the base characteristic of abool_constant
, I think simplicity is 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.
To follow up here, I've adjusted the language slightly, but think this simple version is best without making it more broad. I've not been able to come up with any real compelling case for
conjunction
ordisjunction
of anintegral_constant
which is not abool_constant
worth making this language more complex.However, I think a valid implementation could easily accommodate arbitrary usage of
conjunction
anddisjunction
, ensuring that the public trait is always abool_constant
.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.
This sentence sounds a bit awkward to me. ADL last letter already means lookup. Also, "valid search locations" is a sort of unusual. How about this:
You may leave this part, if you think it's useful: "... , which includes the
namespace of the definition of the iterator type
IteratorT
" but it also might be removed, I think. They choice is yours.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.
Taken, I removed the second part. It doesn't really make sense after the edit. Its more something for the documentation than the spec.
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.
Not sure if it's important. I would probably remove it.
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.
Well, it justifies the technical reason that "Overloads may be provided as forward declarations only,...", but perhaps its just enough to say that. I've removed it.
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.
Yes, but the thing about
decltype
is that it makes allowed use-cases broader. So, users are allowed to provide both declarations andconstexpr
definitions. If it would narrow the use-cases It would have made a perfect sense to me.With the current design I am glad that you decided to remove it.
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 don't think I understand this most recent comment. As it stands, users are able to provide either declarations or full definitions. As we discussed offline previously, return type must be knowable at compile-time regardless of what is marked as
constexpr
or not, so any implementation for which that isn't the case will have errors anyway.I'm not understanding why knowing the
decltype
thing actually changes anything other than "Overloads may be provided as forward declarations only...", other than giving some insight into why that is the case technically.Can you help me understand with an example of something allowed for a user in with this
decltype
knowledge which isn't allowed with the current language?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.
Is it ever a case?
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.
In practice, with a good amount of certainty with some compilers, yes. However, its a good question if its worth mentioning in the specification, since it is not always knowable (and not 100% knowable I believe).
uxlfoundation/oneDPL#1438 (comment)
uxlfoundation/oneDPL#1438 (comment)
How it looks in the oneDPL's implementation currently:
https://github.com/uxlfoundation/oneDPL/blob/1625f6a2dcc981a537c65fdc3b40951cb63b7326/include/oneapi/dpl/pstl/hetero/dpcpp/sycl_iterator.h#L154-L179
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.
Think of that as of specification, not as of documentation.
If we want to require that
std::vector
with USM allocators is used without excessive copying, then it is a part of the spec. Otherwise, it can be mentioned as an implementation-specific or completely omitted.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.
In practice, oneDPL's implementation is relying upon standard library implementation details which are not part of the C++ standard library specification of
std::vector::iterator
to enable handling of usm allocator vector iterators when it can confidently guess that the allocator type is knowable from the iterator type. From purely the C++ standard specification, I don't think it is possible to definitively know anything about the allocator from the type of astd::vector::iterator
.In practice, it would be quite unlikely that a standard library implementation could / would have a
std::vector::iterator
type which "tricks" the current oneDPL implementation's detection of a knowable "USM shared allocator", but I do think you could technically contrive such an implementation if you really wanted to.From a specification perspective, it doesn't belong, I think.
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've removed the line for now, but I'm open to discussion of course.
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.
Yeah, if we speak about
Allocator
we should write an iterator type slightly differently:std::vector<T, Allocator>::iterator
.As you can see
Allocator
is a part of specializedvector
type, not aniterator
type. I don't know a way in C++ do deduce a outer type by inner type: in this concrete example: deducevector<T, Allocator>
type from nestediterator
typeThere 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.
If we re-introduce something like this, we can describe it with
std::vector<T,Allocator>::iterator
, but I think its not a requirement that makes a lot of sense in the specification, because I don't can't be achieved for a generic implementation of the standard library with 100% certainty.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.
naming suggestions to consider
is_passed_directly_to_device
(perhaps obsolete)is_device_accessible_iterator
is_indirectly_device_accessible
For the last one it might be
is_device_indirectly_accessible
; not sure what is more accurate from English perspective. But the last proposed option (by me) is my favorite, so far. It also corelates with several C++20 concepts, e.g.,indirectly_writable
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 don't really like
is_device_accessible_iterator
because I think there is a difference between the iterator being accessible and its content it refers to being accessible. However,is_indirectly_device_accessible
is more clear and concise than what is currently in the PR.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 fine with
is_indirectly_device_accessible
, but we need to get feedback from the customers (that applies to any name(s) we eventually propose).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 was also thinking that
is_device_accessible_iterator
partially reflects the purpose. On the other hand we pass iterators to eventually get data from it, right? :)That's how the idea about
is_indirectly_device_accessible
comes to my mind. Since three of us like it we should probably reach customers to get feedback (as Alexey suggested). Whether we should change "device accessible content iterators", I am not sure. Perhaps, we should (if we agree on the new name) but I don't have a very strong preferenceThere 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 adjusted the name here in the spec.
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.
Still don't like this style of writing after a template name because it confuses (probably experienced) C++ users. Is the any chance we will define the API properly?
Something like
and then the descriptive part.
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.
Adjusted to be close to your proposal.
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.
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.
fixed.