-
Notifications
You must be signed in to change notification settings - Fork 113
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
Add workaround to parallel merge in TBB backend not to use input iterators default constructor #1346
base: main
Are you sure you want to change the base?
Add workaround to parallel merge in TBB backend not to use input iterators default constructor #1346
Conversation
I think we are able to fix this issue without changes in |
What about the code // Using callable object instead of lambda here to ensure transform iterator would be
// default constructible, that is part of the Forward Iterator requirements in the C++ standard.
struct NoTransform
{
ValueType operator()(const ValueType& val) const
{
return val;
}
}; Should we use lambda now in
|
I would prefer to keep this test as-is because, as I mentioned this fix is not a 100% guarantee that merge with transform_iterator with lambda body would work. |
ok |
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.
LGTM
Should the patch also be done in PSTL upstream? |
__ym = __ys + (__size_y / 2); | ||
__xm = std::upper_bound(__xs, __xe, *__ym, __comp); | ||
_RandomAccessIterator2 __ym = __ys + (__size_y / 2); | ||
__make_parallel_merge_leaf_tasks(::std::upper_bound(__xs, __xe, *__ym, __comp), |
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.
Recently, we came to conclusion that we should not write ::
operator before std::
in new code, at least.
I guess, yes it should. |
Add workaround to implementation of __parallel_merge function for the following use case:
The first input iterator in
merge
algorithm isdpl::transform_iterator<vector_it, lambda>
. Since lambda is not default constructible, this use case results in the compilation error while trying to default construct iterator inside TBB backend.From the C++ Standard perspective, it is not an issue, because default constructability is part of ForwardIterator requirements, but after the short offline discussion, it was decided to workaround this place in parallel backend TBB to make things better for our fancy iterators.
There is still no 100% guarantee, that no issues would be present for transform iterator with lambda body, because some algorithms we use from the C++ Standard Library are still allowed to call default constructor on the input iterator, e.g.
std::upper_bound
). This PR was tested together with libstdc++ and no issues was found.