Skip to content
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

[oneDPL] Sort By Key APIs #564

Merged
merged 23 commits into from
Sep 4, 2024
Merged
Changes from 5 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
4c2ae27
[oneDPL] Sort By Key APIs
dmitriy-sobolev Aug 14, 2024
21dcdfc
[oneDPL] Sort By Key APIs
dmitriy-sobolev Aug 14, 2024
8c689b0
Minor improvements
dmitriy-sobolev Aug 15, 2024
7b8211f
Minor improvements
dmitriy-sobolev Aug 15, 2024
6ee3677
Change :code: with double backquotes
dmitriy-sobolev Aug 17, 2024
ef9f079
Clarify the assosition between keys and values
dmitriy-sobolev Sep 2, 2024
b607ceb
Describe comparator
dmitriy-sobolev Sep 2, 2024
898d626
Improve the summaries of sort functions
dmitriy-sobolev Sep 2, 2024
11f0755
Refer to C++ standard sort for comp objects
dmitriy-sobolev Sep 2, 2024
70b4635
Clarify sort stability
dmitriy-sobolev Sep 2, 2024
bb18eed
Improve the algorithm signatures
dmitriy-sobolev Sep 2, 2024
e12dea9
Return a sentence with std::less, minor fixes
dmitriy-sobolev Sep 2, 2024
aab5a3b
Minor correction
dmitriy-sobolev Sep 2, 2024
a422221
Align std::less construction with the rest algorithms
dmitriy-sobolev Sep 2, 2024
f08b420
Add ValueSwappable requirement
dmitriy-sobolev Sep 2, 2024
e71236c
Use double back quotes
dmitriy-sobolev Sep 2, 2024
2084732
Apply suggestions: reorganize the wording
dmitriy-sobolev Sep 3, 2024
060ca50
InputKeyIt -> KeyIt, InputValueIt -> ValueIt
dmitriy-sobolev Sep 3, 2024
fcd1561
Addition sentence for key-value pairs association during sort
dmitriy-sobolev Sep 3, 2024
a21e7e2
InputIt -> KeyIt
dmitriy-sobolev Sep 3, 2024
13dbb96
Remove unnecessary commas
dmitriy-sobolev Sep 3, 2024
1beadb7
Merge branch 'main' into dpl-sort-by-key
dmitriy-sobolev Sep 4, 2024
159ff01
Remove extra line
dmitriy-sobolev Sep 4, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions source/elements/oneDPL/source/parallel_api.rst
danhoeflinger marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -688,5 +688,39 @@ than an element in the range being searched.

The elements e of [start, end) must be partitioned with respect to the comparator used.

.. code:: cpp

template<typename Policy, typename InputKeyIt, typename InputValueIt,
akukanov marked this conversation as resolved.
Show resolved Hide resolved
typename Comparator =
std::less<typename std::iterator_traits<InputIt>::value_type>>
void
sort_by_key(Policy&& policy, InputKeyIt keys_first, InputKeyIt keys_last,
InputValueIt values_first, Comparator comp =
std::less<typename std::iterator_traits<InputKeyIt>::value_type>());
akukanov marked this conversation as resolved.
Show resolved Hide resolved
dmitriy-sobolev marked this conversation as resolved.
Show resolved Hide resolved

``oneapi::dpl::sort_by_key`` sorts a sequence of keys in the range ``[keys_first, keys_last)``,
and permutes a sequence of values in the range
danhoeflinger marked this conversation as resolved.
Show resolved Hide resolved
``[values_first, values_first + distance(keys_first, keys_last))`` to match the order of the sorted keys.
The order of equal keys is not guaranteed to be preserved.
akukanov marked this conversation as resolved.
Show resolved Hide resolved

If no comparator is provided, the keys are sorted with respect to ``std::less{}``.
danhoeflinger marked this conversation as resolved.
Show resolved Hide resolved

.. code:: cpp

template<typename Policy, typename InputKeyIt, typename InputValueIt,
typename Comparator =
std::less<typename std::iterator_traits<InputIt>::value_type>>
void
stable_sort_by_key(Policy&& policy, InputKeyIt keys_first, InputKeyIt keys_last,
InputValueIt values_first, Comparator comp =
std::less<typename std::iterator_traits<InputKeyIt>::value_type>());
dmitriy-sobolev marked this conversation as resolved.
Show resolved Hide resolved

``oneapi::dpl::stable_sort_by_key`` sorts a sequence of keys in the range ``[keys_first, keys_last)``,
and permutes a sequence of values in the range
``[values_first, values_first + distance(keys_first, keys_last))`` to match the order of the sorted keys.
The order of equal keys is preserved.
dmitriy-sobolev marked this conversation as resolved.
Show resolved Hide resolved

If no comparator is provided, the keys are sorted with respect to ``std::less{}``.

.. _`C++ Standard`: https://isocpp.org/std/the-standard
.. _`SYCL`: https://registry.khronos.org/SYCL/specs/sycl-2020/html/sycl-2020.html