Skip to content

[oneDPL][rfc][ranges][L1] the third portion of the range based API #2269

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 6 commits into
base: main
Choose a base branch
from

Conversation

MikeDvorskiy
Copy link
Contributor

[oneDPL][rfc][ranges][L1] the third portion of the range based API

The feature is proposed as the next step of range-based API support for oneDPL.

### Key Requirements
- The range-based signatures for the mentioned API should correspond to the [proposed specification](https://github.com/uxlfoundation/oneAPI-spec/pull/614)
Copy link
Contributor

@akukanov akukanov May 26, 2025

Choose a reason for hiding this comment

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

The specification should yet be updated; the link is to the previous patch.

Comment on lines +20 to +21
- The implementation is supposed to rely on existing range-based or iterator-based algorithm patterns, which are already
implemented in oneDPL.
Copy link
Contributor

Choose a reason for hiding this comment

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

Does it make sense to provide mapping of algorithms to the patterns, or is it always the same as for iterator-based overloads?
I am not trying to create extra work, but it would be good to make sure that no problems with the implementation are expected, since the proposed set is quite big,

Copy link
Contributor Author

@MikeDvorskiy MikeDvorskiy May 28, 2025

Choose a reason for hiding this comment

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

  1. For hetero impl - it is based on existing range based algo patterns.
  2. For host impl - it is based on existing iterator based algo patterns + std::ranges::begin, std::ranges::begin(..) + std::ranges::size();
  3. The "output size limit semantic" is on high level layer before call an algo pattern or a corresponding algo pattern has a few changes to support output size limit.

Comment on lines 22 to 23
- Several algorithms described in P3179 have slightly different semantics. To implement these, some existing algorithm patterns
might require modifications or new versions.
Copy link
Contributor

Choose a reason for hiding this comment

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

Perhaps this can be a bit more specific on both the patterns and the changes needed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually, this sentence is not relevant now and in this context and should be removed.

Comment on lines 24 to 25
- For the algorithms, which work with uninitialized memory (`uninitialized_*` and `destroy` form `<memory>`) an additional require is proposed: `oneapi:dpl::value_adressable`.
The require can be implemented via C++ concept: `template<typename R> concept value_adressable = requires { std::addressof(*std::ranges::iterator_t<R>{}); };`
Copy link
Contributor

Choose a reason for hiding this comment

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

It would be good to explain potential benefits of this idea.

Copy link
Contributor

Choose a reason for hiding this comment

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

It looks like the "nothrow" requirements for iterators/ranges used with uninitialized_* algorithms (https://en.cppreference.com/w/cpp/memory/ranges/nothrow_concepts.html) effectively cover the addressability.

template< class I >
concept no-throw-input-iterator =
    std::input_iterator<I> &&
    std::is_lvalue_reference_v<std::iter_reference_t<I>> &&
    std::same_as<std::remove_cvref_t<std::iter_reference_t<I>>, std::iter_value_t<I>>;

This concept requires that the result of dereferencing (std::iter_reference_t<I>) is an lvalue reference to the iterator value type.

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, it looks that no-throw-input-iterator is sufficient.

## Motivations
The feature is proposed as the next step of range-based API support for oneDPL.

### Key Requirements
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's add the feature testing macro update to the requirements, so that it is not forgotten again.

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.

2 participants