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][ranges] support size limit for output for merge algorithm #1942

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

Conversation

MikeDvorskiy
Copy link
Contributor

@MikeDvorskiy MikeDvorskiy commented Nov 20, 2024

[oneDPL][ranges] support size limit for output for merge algorithm.
The change is according to https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2024/p3179r2.html#range_as_output

  1. serial pattern
  2. parallel pattern (tbb)
  3. parallel pattern (openMP)
  4. parallel pattern (serial backend)
  5. parallel pattern (DPCPP backend)

Update: Changes to draft status, causing faced to design issue, connected with different return types from the merge patterns - __result_and_scratch_storage/__result_and_scratch_storage_base. As an option - to have one common type of __result_and_scratch_storage for the all needs (ate least for pattern dpcpp merge patterns).
Update 2: the issue mentioned above has been resolved.

@MikeDvorskiy MikeDvorskiy marked this pull request as draft November 20, 2024 14:30
@MikeDvorskiy MikeDvorskiy force-pushed the dev/mdvorski/merge_sized_output branch 9 times, most recently from 33cd332 to d443dbe Compare November 27, 2024 12:03
@MikeDvorskiy MikeDvorskiy force-pushed the dev/mdvorski/merge_sized_output branch 4 times, most recently from 9ebcfb6 to 0066210 Compare November 28, 2024 11:55
@MikeDvorskiy MikeDvorskiy marked this pull request as ready for review November 28, 2024 15:24
@MikeDvorskiy MikeDvorskiy force-pushed the dev/mdvorski/merge_sized_output branch 7 times, most recently from 3f648a7 to 5b078ad Compare November 29, 2024 17:24
@MikeDvorskiy MikeDvorskiy force-pushed the dev/mdvorski/merge_sized_output branch from 98a7acb to c81b4c1 Compare December 23, 2024 13:50
@MikeDvorskiy MikeDvorskiy marked this pull request as draft December 29, 2024 10:00
@MikeDvorskiy MikeDvorskiy force-pushed the dev/mdvorski/merge_sized_output branch from 76c3c16 to c0c8ba4 Compare January 14, 2025 13:49
@MikeDvorskiy MikeDvorskiy marked this pull request as ready for review January 14, 2025 13:49
@MikeDvorskiy MikeDvorskiy force-pushed the dev/mdvorski/merge_sized_output branch from c0c8ba4 to ffea24a Compare January 14, 2025 13:51
@MikeDvorskiy MikeDvorskiy force-pushed the dev/mdvorski/merge_sized_output branch from 73e0bad to 6915343 Compare January 29, 2025 16:44
Comment on lines +2954 to +2955
__serial_merge_out_lim(_Iterator1 __x, _Iterator1 __x_e, _Iterator2 __y, _Iterator2 __y_e, _Iterator3 __i,
_Iterator3 __j, _Comp __comp)
Copy link
Contributor

Choose a reason for hiding this comment

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

A nitpick. I suggest renaming __i to __out and _j to __out_e. I had to check how __serial_merge_out_lim is called to infer the meaning of these arguments.

include/oneapi/dpl/pstl/algorithm_impl.h Show resolved Hide resolved
Comment on lines +2971 to +2975
else if (std::invoke(__comp, *__x, *__y))
{
*__k = *__x;
++__x;
}
Copy link
Contributor

@dmitriy-sobolev dmitriy-sobolev Jan 29, 2025

Choose a reason for hiding this comment

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

Indeed, it is the reversed order... Let's add a test verifying stability (as we agreed) to make sure it is not mixed up.

@MikeDvorskiy MikeDvorskiy force-pushed the dev/mdvorski/merge_sized_output branch from 9780273 to 4002984 Compare January 29, 2025 17:25
@MikeDvorskiy MikeDvorskiy force-pushed the dev/mdvorski/merge_sized_output branch from 083c090 to d0dcc89 Compare January 30, 2025 18:10
Copy link
Contributor

@danhoeflinger danhoeflinger left a comment

Choose a reason for hiding this comment

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

All my feedback has been resolved, so LGTM. We have an agreement to target some change from #2003 for 2022.9.0.

I believe that some others (@SergeyKopienko @dmitriy-sobolev @mmichel11) may have been more involved in reviewing and looking at details in changes from their feedback recently, so I suggest getting approval also from one or more of them.

Finally, we should wait for green CI (other than the docs, looks like that is systemic and unrelated).

Comment on lines +3023 to +3027
___merge_path_out_lim(_Tag, _ExecutionPolicy&& __exec, _It1 __it_1, _Index1 __n_1, _It2 __it_2, _Index2 __n_2,
_OutIt __it_out, _Index3 __n_out, _Comp __comp)
{
return __serial_merge_out_lim(__it_1, __it_1 + __n_1, __it_2, __it_2 + __n_2, __it_out, __it_out + __n_out, __comp);
}
Copy link
Contributor

@akukanov akukanov Jan 30, 2025

Choose a reason for hiding this comment

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

This is funny :) @MikeDvorskiy you explained to me that using indexes as the parameters of this function is to avoid computing the indexes twice. But in the serial implementation you do not really use indexes but switch back to the iterators :) which only confirms my impression that ___merge_path_out_lim should use iterators as its parameters.

Comment on lines +2953 to +2954
//Serial version of ___merge_path_out_lim merges 1st sequience and 2nd sequience in "revert maner":
//the identical elements from 2nd sequience are being merged first.
Copy link
Contributor

@akukanov akukanov Jan 30, 2025

Choose a reason for hiding this comment

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

Suggested change
//Serial version of ___merge_path_out_lim merges 1st sequience and 2nd sequience in "revert maner":
//the identical elements from 2nd sequience are being merged first.
// Serial version of ___merge_path_out_lim merges the 1st sequence and the 2nd sequence in "reverse order":
// the identical elements from the 2nd sequence are merged first.

And by the way, I do not understand why this is done, so perhaps it is worth explaining in the comments. Or is it just an error that needs to be fixed?

Comment on lines +3031 to +3032
//Parallel version of ___merge_path_out_lim merges 1st sequience and 2nd sequience in "revert maner":
//the identical elements from 2nd sequience are being merged first.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
//Parallel version of ___merge_path_out_lim merges 1st sequience and 2nd sequience in "revert maner":
//the identical elements from 2nd sequience are being merged first.
// Parallel version of ___merge_path_out_lim merges the 1st sequence and the 2nd sequence in "reverse order":
// the identical elements from the 2nd sequence are merged first.

Comment on lines +474 to +476
//Parallel and serial versions of ___merge_path_out_lim merges 1st sequience and 2nd sequience in "revert maner":
//the identical elements from 2nd sequience are being merged first.
//So, the following call passes 1st sequience 2nd sequience in "a revert maner".
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
//Parallel and serial versions of ___merge_path_out_lim merges 1st sequience and 2nd sequience in "revert maner":
//the identical elements from 2nd sequience are being merged first.
//So, the following call passes 1st sequience 2nd sequience in "a revert maner".
// Parallel and serial versions of ___merge_path_out_lim merge the 1st sequence and the 2nd sequence in "reverse order":
// the identical elements from the 2nd sequence are merged first.
// So, the call to ___merge_path_out_lim swaps the order of sequences.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants