From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2066) id DB3BD3954C76; Tue, 12 May 2020 07:33:26 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org DB3BD3954C76 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1589268806; bh=FS7JaLetvn+CGdbHrMvmZXy+q+Aelbh5WaqloQXAny8=; h=From:To:Subject:Date:From; b=uicA/L9lMld0B/gHFGPFwuPeGfJuChUQpKSSh7FY5ZDqtYKBpdKc11ABYLTYHJn7M Y8a9AynocAqj0NMOvH3ARjqwmLyT4eSSg9MW5/EUe1hDEd0oxk29l6QoVCwZoaAhkE qGLVWap66KkCyBxrHu+OQyM4cnd1FrsWL+SdeLOs= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Jiu Fu Guo To: gcc-cvs@gcc.gnu.org, libstdc++-cvs@gcc.gnu.org Subject: [gcc(refs/users/guojiufu/heads/personal-branch)] libstdc++: Fix some C++20 algorithms to work in parallel mode X-Act-Checkin: gcc X-Git-Author: Jonathan Wakely X-Git-Refname: refs/users/guojiufu/heads/personal-branch X-Git-Oldrev: 4cbc9d8b346b932f34828a51e8822881413951b7 X-Git-Newrev: 9c24e97a97aaad4ad0500170cbae4f387d82ddd6 Message-Id: <20200512073326.DB3BD3954C76@sourceware.org> Date: Tue, 12 May 2020 07:33:26 +0000 (GMT) X-BeenThere: libstdc++-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libstdc++-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 12 May 2020 07:33:27 -0000 https://gcc.gnu.org/g:9c24e97a97aaad4ad0500170cbae4f387d82ddd6 commit 9c24e97a97aaad4ad0500170cbae4f387d82ddd6 Author: Jonathan Wakely Date: Thu May 7 21:43:49 2020 +0100 libstdc++: Fix some C++20 algorithms to work in parallel mode Some new algorithms need to use _GLIBCXX_STD_A to refer to the "normal" version of the algorithm, to workaround the namespace dance done for parallel mode. PR libstdc++/94971 (partial) * include/bits/ranges_algo.h (ranges::__sample_fn): Qualify std::sample using macro to work in parallel mode. (__sort_fn): Likewise for std::sort. (ranges::__nth_element_fn): Likewise for std::nth_element. * include/bits/stl_algobase.h (lexicographical_compare_three_way): Likewise for std::__min_cmp. * include/parallel/algobase.h (lexicographical_compare_three_way): Add to namespace std::__parallel. Diff: --- libstdc++-v3/ChangeLog | 34 +++++++++++++++++++++----------- libstdc++-v3/include/bits/ranges_algo.h | 14 +++++++------ libstdc++-v3/include/bits/stl_algobase.h | 10 +++++----- libstdc++-v3/include/parallel/algobase.h | 4 ++++ 4 files changed, 39 insertions(+), 23 deletions(-) diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index d0751909dd2..3b8e6d94f87 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,25 @@ +2020-05-07 Jonathan Wakely + + PR libstdc++/94971 (partial) + * include/bits/ranges_algo.h (ranges::__sample_fn): Qualify + std::sample using macro to work in parallel mode. + (__sort_fn): Likewise for std::sort. + (ranges::__nth_element_fn): Likewise for std::nth_element. + * include/bits/stl_algobase.h (lexicographical_compare_three_way): + Likewise for std::__min_cmp. + * include/parallel/algobase.h (lexicographical_compare_three_way): + Add to namespace std::__parallel. + + PR c/92472 + * include/parallel/multiway_merge.h (_GuardedIterator::operator*) + (_GuardedIterator::operator _RAIter, _UnguardedIterator::operator*) + (_UnguardedIterator::operator _RAIter): Add const qualifier. + (operator<(_GuardedIterator&, _GuardedIterator&) + (operator<=(_GuardedIterator&, _GuardedIterator&) + (operator<(_UnguardedIterator&, _UnguardedIterator&) + (operator<=(_UnguardedIterator&, _UnguardedIterator&): Change + parameters to const references. + 2020-05-07 Eric Botcazou * config/abi/post/sparc64-linux-gnu/baseline_symbols.txt: Update. @@ -27,18 +49,6 @@ * config/abi/post/sparc-solaris/sparcv9/baseline_symbols.txt: Likewise. -2020-05-07 Jonathan Wakely - - PR c/92472 - * include/parallel/multiway_merge.h (_GuardedIterator::operator*) - (_GuardedIterator::operator _RAIter, _UnguardedIterator::operator*) - (_UnguardedIterator::operator _RAIter): Add const qualifier. - (operator<(_GuardedIterator&, _GuardedIterator&) - (operator<=(_GuardedIterator&, _GuardedIterator&) - (operator<(_UnguardedIterator&, _UnguardedIterator&) - (operator<=(_UnguardedIterator&, _UnguardedIterator&): Change - parameters to const references. - 2020-05-06 Martin Liska Revert: diff --git a/libstdc++-v3/include/bits/ranges_algo.h b/libstdc++-v3/include/bits/ranges_algo.h index aa07cb97ea6..c038a505afa 100644 --- a/libstdc++-v3/include/bits/ranges_algo.h +++ b/libstdc++-v3/include/bits/ranges_algo.h @@ -1758,8 +1758,9 @@ namespace ranges // FIXME: Forwarding to std::sample here requires computing __lasti // which may take linear time. auto __lasti = ranges::next(__first, __last); - return std::sample(std::move(__first), std::move(__lasti), - std::move(__out), __n, std::forward<_Gen>(__g)); + return _GLIBCXX_STD_A:: + sample(std::move(__first), std::move(__lasti), std::move(__out), + __n, std::forward<_Gen>(__g)); } else { @@ -2018,8 +2019,8 @@ namespace ranges _Comp __comp = {}, _Proj __proj = {}) const { auto __lasti = ranges::next(__first, __last); - std::sort(std::move(__first), __lasti, - __detail::__make_comp_proj(__comp, __proj)); + _GLIBCXX_STD_A::sort(std::move(__first), __lasti, + __detail::__make_comp_proj(__comp, __proj)); return __lasti; } @@ -2262,8 +2263,9 @@ namespace ranges _Comp __comp = {}, _Proj __proj = {}) const { auto __lasti = ranges::next(__first, __last); - std::nth_element(std::move(__first), std::move(__nth), __lasti, - __detail::__make_comp_proj(__comp, __proj)); + _GLIBCXX_STD_A::nth_element(std::move(__first), std::move(__nth), + __lasti, + __detail::__make_comp_proj(__comp, __proj)); return __lasti; } diff --git a/libstdc++-v3/include/bits/stl_algobase.h b/libstdc++-v3/include/bits/stl_algobase.h index 089ec2903f6..0a0e29923b8 100644 --- a/libstdc++-v3/include/bits/stl_algobase.h +++ b/libstdc++-v3/include/bits/stl_algobase.h @@ -1706,8 +1706,8 @@ _GLIBCXX_BEGIN_NAMESPACE_ALGO if constexpr (__is_byte_iter<_InputIter1>) if constexpr (__is_byte_iter<_InputIter2>) { - const auto [__len, __lencmp] - = std::__min_cmp(__last1 - __first1, __last2 - __first2); + const auto [__len, __lencmp] = _GLIBCXX_STD_A:: + __min_cmp(__last1 - __first1, __last2 - __first2); if (__len) { const auto __c @@ -1737,9 +1737,9 @@ _GLIBCXX_BEGIN_NAMESPACE_ALGO _InputIter2 __first2, _InputIter2 __last2) { - return std::lexicographical_compare_three_way(__first1, __last1, - __first2, __last2, - compare_three_way{}); + return _GLIBCXX_STD_A:: + lexicographical_compare_three_way(__first1, __last1, __first2, __last2, + compare_three_way{}); } #endif // three_way_comparison diff --git a/libstdc++-v3/include/parallel/algobase.h b/libstdc++-v3/include/parallel/algobase.h index 06b1f3e3b5a..7e6fdd6e062 100644 --- a/libstdc++-v3/include/parallel/algobase.h +++ b/libstdc++-v3/include/parallel/algobase.h @@ -466,6 +466,10 @@ namespace __parallel __begin1, __end1, __begin2, __end2, __pred, _IteratorCategory1(), _IteratorCategory2()); } + +#if __cpp_lib_three_way_comparison + using _GLIBCXX_STD_A::lexicographical_compare_three_way; +#endif } // end namespace } // end namespace