Skip to content

RFC for zip_view implementation, for oneDPL C++20 #1931

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

Open
wants to merge 37 commits into
base: main
Choose a base branch
from

Conversation

MikeDvorskiy
Copy link
Contributor

@MikeDvorskiy MikeDvorskiy commented Nov 4, 2024

The proposal to implement zip_view in oneDPL. A part of the general RFC discussion #1944 about implementing useful C++23 views.

@MikeDvorskiy MikeDvorskiy marked this pull request as draft November 4, 2024 16:54
@MikeDvorskiy MikeDvorskiy marked this pull request as ready for review November 19, 2024 17:06
Copy link
Contributor

@dmitriy-sobolev dmitriy-sobolev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is one question regarding the conversions of the iterators. The rest are minor stylistic and wording corrections.

MikeDvorskiy and others added 4 commits December 17, 2024 16:23
Co-authored-by: Dmitriy Sobolev <Dmitriy.Sobolev@intel.com>
Co-authored-by: Dmitriy Sobolev <Dmitriy.Sobolev@intel.com>
Co-authored-by: Dmitriy Sobolev <Dmitriy.Sobolev@intel.com>
Co-authored-by: Dmitriy Sobolev <Dmitriy.Sobolev@intel.com>
MikeDvorskiy and others added 2 commits December 17, 2024 16:46
Co-authored-by: Dmitriy Sobolev <Dmitriy.Sobolev@intel.com>
Co-authored-by: Dmitriy Sobolev <Dmitriy.Sobolev@intel.com>
MikeDvorskiy and others added 2 commits December 17, 2024 17:41
Co-authored-by: Dmitriy Sobolev <Dmitriy.Sobolev@intel.com>
Co-authored-by: Dmitriy Sobolev <Dmitriy.Sobolev@intel.com>
akukanov
akukanov previously approved these changes Dec 19, 2024
Copy link
Contributor

@akukanov akukanov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I approve the proposal for implementation as an experimental feature.

The questions currently open in the review can be addressed later; just keep track of them please (for example, add to a special section at the end of the document).

Copy link
Contributor

@dmitriy-sobolev dmitriy-sobolev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The RFC also looks good to me.

My additional recommendation is to express the criteria for the feature to become fully supported. I believe, it can be done at a later stage, e.g. when the experimental feature is implemented or thoroughly reviewed for a better grasp of the context.

This class encapsulates a tuple-like type to keep a combination of two or more ranges.
- The implementation provides all necessary operators to satisfy 'random accessible view' requirement.
- To ensure device copyability, `oneapi::dpl::__internal::tuple` is proposed as a tuple-like type for underlying elements.
- To provide a value-swappable requirement `oneapi::dpl::__internal::tuple` is proposed as a dereferenced value for
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When it comes to the specification, this will need to be described as an unspecified tuple which satisfies some set of requirements, unless we want to make the move to specify our internal tuple and make it public (which I doubt we want to do).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the context of this, I was looking at the specification for our current zip_iterator, and noticed a couple of discrepancies as compared to our implementation with regard to std::tuple vs our unspecified internal tuple type. I believe that our implementation is intentional and the "correct" thing here and the spec should be changed, because of issues with device copyability when composing types from zip_iterators. std::tuple is not trivially copyable but our internal tuple is.

uxlfoundation/oneAPI-spec#605

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are moving towards specifying the tuple-like type better, most likely as a type that satisfies certain concepts / requirements. That should be done in an new proposal though.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes.. I've mentioned it in the RFC document update.

- compilable with C++20 version (minimum)
- API-compliant with `std::ranges::zip_view`
- in case of a device usage: a device copyable view if the all "underlying" views are device copyable views.
- To provide a transitive device copyability oneDPL tuple-like type underhood is proposed - `oneapi::dpl::__internal::tuple`.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think which tuple to use is an implementation detail. What we really want is that our zip_view is trivially copyable if all the underlying views are - this is the way to have transitive device copyability for view pipelines.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I think "to have transitive device copyability for view pipelines" - very strong argument to want that our zip_view is trivially copyable.
BTW, the proposed implementation has such property. The relevant test also was added.

Comment on lines +31 to +32
- `oneapi::dpl::ranges::zip_view` is based on oneDPL tuple-like type oneapi::dpl::__internal::tuple instead of std::tuple.
- `oneapi::dpl::ranges::zip_view::iterator::value_type` is oneDPL tuple-like type oneapi::dpl::__internal::tuple instead of std::tuple.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think here we mean that the API of zip_view and its iterator may use a oneDPL tuple-like type instead of std::tuple.
The details like oneapi::dpl::__internal::tuple are already mentioned in the implementation section below.

- To provide a transitive device copyability oneDPL tuple-like type underhood is proposed - `oneapi::dpl::__internal::tuple`.

`oneapi::dpl::ranges::zip_view::iterator` should be:
- value-swappable (https://en.cppreference.com/w/cpp/named_req/ValueSwappable)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps we should explicitly add indirectly_writable as well.

@akukanov akukanov added this to the 2022.10.0 milestone Apr 8, 2025
MikeDvorskiy and others added 2 commits April 10, 2025 12:48
Co-authored-by: Alexey Kukanov <alexey.kukanov@intel.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants