diff mbox series

Move std::search into algobase.h

Message ID 01f2b9e7-14e8-12a7-c275-7e48e3bd94df@gmail.com
State New
Headers show
Series Move std::search into algobase.h | expand

Commit Message

François Dumont May 31, 2023, 5:39 p.m. UTC
libstdc++: Reduce <functional> inclusion to <stl_algobase.h>


Move the std::search definition from stl_algo.h to stl_algobase.h and use
the later in <functional>.

For consistency also move std::__parallel::search and associated helpers 
from
<parallel/stl_algo.h> to <parallel/stl_algobase.h> so that 
std::__parallel::search
is accessible along with std::search.

libstdc++-v3/ChangeLog:

             * include/bits/stl_algo.h
             (std::__search, std::search(_FwdIt1, _FwdIt1, _FwdIt2, 
_FwdIt2, _BinPred)): Move...
             * include/bits/stl_algobase.h: ...here.
             * include/std/functional: Replace <stl_algo.h> include by 
<stl_algobase.h>.
             * include/parallel/algo.h (std::__parallel::search<_FIt1, 
_FIt2, _BinaryPred>)
             (std::__parallel::__search_switch<_FIt1, _FIt2, 
_BinaryPred, _ItTag1, _ItTag2>):
             Move...
             * include/parallel/algobase.h: ...here.
             * include/std/functional: Remove <bits/stl_algo.h> and 
<parallel/algorithm>
             includes. Include <bits/stl_algobase.h>.

Tested under Linux x86_64.

Ok to commit ?

François

Comments

Jonathan Wakely May 31, 2023, 5:55 p.m. UTC | #1
On Wed, 31 May 2023 at 18:39, François Dumont via Libstdc++ <
libstdc++@gcc.gnu.org> wrote:

> libstdc++: Reduce <functional> inclusion to <stl_algobase.h>
>
>
> Move the std::search definition from stl_algo.h to stl_algobase.h and use
> the later in <functional>.
>
> For consistency also move std::__parallel::search and associated helpers
> from
> <parallel/stl_algo.h> to <parallel/stl_algobase.h> so that
> std::__parallel::search
> is accessible along with std::search.
>
> libstdc++-v3/ChangeLog:
>
>              * include/bits/stl_algo.h
>              (std::__search, std::search(_FwdIt1, _FwdIt1, _FwdIt2,
> _FwdIt2, _BinPred)): Move...
>              * include/bits/stl_algobase.h: ...here.
>              * include/std/functional: Replace <stl_algo.h> include by
> <stl_algobase.h>.
>              * include/parallel/algo.h (std::__parallel::search<_FIt1,
> _FIt2, _BinaryPred>)
>              (std::__parallel::__search_switch<_FIt1, _FIt2,
> _BinaryPred, _ItTag1, _ItTag2>):
>              Move...
>              * include/parallel/algobase.h: ...here.
>              * include/std/functional: Remove <bits/stl_algo.h> and
> <parallel/algorithm>
>              includes. Include <bits/stl_algobase.h>.
>
> Tested under Linux x86_64.
>
> Ok to commit ?
>

OK
Rainer Orth June 1, 2023, 11:52 a.m. UTC | #2
Jonathan Wakely via Gcc-patches <gcc-patches@gcc.gnu.org> writes:

> On Wed, 31 May 2023 at 18:39, François Dumont via Libstdc++ <
> libstdc++@gcc.gnu.org> wrote:
>
>> libstdc++: Reduce <functional> inclusion to <stl_algobase.h>
>>
>>
>> Move the std::search definition from stl_algo.h to stl_algobase.h and use
>> the later in <functional>.
>>
>> For consistency also move std::__parallel::search and associated helpers
>> from
>> <parallel/stl_algo.h> to <parallel/stl_algobase.h> so that
>> std::__parallel::search
>> is accessible along with std::search.
>>
>> libstdc++-v3/ChangeLog:
>>
>>              * include/bits/stl_algo.h
>>              (std::__search, std::search(_FwdIt1, _FwdIt1, _FwdIt2,
>> _FwdIt2, _BinPred)): Move...
>>              * include/bits/stl_algobase.h: ...here.
>>              * include/std/functional: Replace <stl_algo.h> include by
>> <stl_algobase.h>.
>>              * include/parallel/algo.h (std::__parallel::search<_FIt1,
>> _FIt2, _BinaryPred>)
>>              (std::__parallel::__search_switch<_FIt1, _FIt2,
>> _BinaryPred, _ItTag1, _ItTag2>):
>>              Move...
>>              * include/parallel/algobase.h: ...here.
>>              * include/std/functional: Remove <bits/stl_algo.h> and
>> <parallel/algorithm>
>>              includes. Include <bits/stl_algobase.h>.
>>
>> Tested under Linux x86_64.
>>
>> Ok to commit ?
>>
>
> OK

This seems to have caused

+FAIL: 17_intro/headers/c++2011/parallel_mode.cc (test for excess errors)
+FAIL: 17_intro/headers/c++2014/parallel_mode.cc (test for excess errors)

on i386-pc-solaris2.11:

Excess errors:
/var/gcc/regression/master/11.4-gcc-gas/build/i386-pc-solaris2.11/libstdc++-v3/include/parallel/algobase.h:496: error: '__search_template' is not a member of '__gnu_parallel'; did you mean '__find_template'?

	Rainer
Jonathan Wakely June 1, 2023, 12:05 p.m. UTC | #3
On Thu, 1 Jun 2023 at 12:52, Rainer Orth <ro@cebitec.uni-bielefeld.de>
wrote:

> Jonathan Wakely via Gcc-patches <gcc-patches@gcc.gnu.org> writes:
>
> > On Wed, 31 May 2023 at 18:39, François Dumont via Libstdc++ <
> > libstdc++@gcc.gnu.org> wrote:
> >
> >> libstdc++: Reduce <functional> inclusion to <stl_algobase.h>
> >>
> >>
> >> Move the std::search definition from stl_algo.h to stl_algobase.h and
> use
> >> the later in <functional>.
> >>
> >> For consistency also move std::__parallel::search and associated helpers
> >> from
> >> <parallel/stl_algo.h> to <parallel/stl_algobase.h> so that
> >> std::__parallel::search
> >> is accessible along with std::search.
> >>
> >> libstdc++-v3/ChangeLog:
> >>
> >>              * include/bits/stl_algo.h
> >>              (std::__search, std::search(_FwdIt1, _FwdIt1, _FwdIt2,
> >> _FwdIt2, _BinPred)): Move...
> >>              * include/bits/stl_algobase.h: ...here.
> >>              * include/std/functional: Replace <stl_algo.h> include by
> >> <stl_algobase.h>.
> >>              * include/parallel/algo.h (std::__parallel::search<_FIt1,
> >> _FIt2, _BinaryPred>)
> >>              (std::__parallel::__search_switch<_FIt1, _FIt2,
> >> _BinaryPred, _ItTag1, _ItTag2>):
> >>              Move...
> >>              * include/parallel/algobase.h: ...here.
> >>              * include/std/functional: Remove <bits/stl_algo.h> and
> >> <parallel/algorithm>
> >>              includes. Include <bits/stl_algobase.h>.
> >>
> >> Tested under Linux x86_64.
> >>
> >> Ok to commit ?
> >>
> >
> > OK
>
> This seems to have caused
>
> +FAIL: 17_intro/headers/c++2011/parallel_mode.cc (test for excess errors)
> +FAIL: 17_intro/headers/c++2014/parallel_mode.cc (test for excess errors)
>
> on i386-pc-solaris2.11:
>

I think it affects all targets.


>
> Excess errors:
> /var/gcc/regression/master/11.4-gcc-gas/build/i386-pc-solaris2.11/libstdc++-v3/include/parallel/algobase.h:496:
> error: '__search_template' is not a member of '__gnu_parallel'; did you
> mean '__find_template'?
>
>         Rainer
>
> --
>
> -----------------------------------------------------------------------------
> Rainer Orth, Center for Biotechnology, Bielefeld University
>
>
François Dumont June 1, 2023, 1:50 p.m. UTC | #4
Sorry, I had fully tested the move from bits/stl_algo.h to
bits/stl_algobase.h.

But it appears that the script I used to run the tests after the other move
has not done what I expected.

I'll provide the patch shortly.


Le jeu. 1 juin 2023 à 14:06, Jonathan Wakely <jwakely@redhat.com> a écrit :

>
>
> On Thu, 1 Jun 2023 at 12:52, Rainer Orth <ro@cebitec.uni-bielefeld.de>
> wrote:
>
>> Jonathan Wakely via Gcc-patches <gcc-patches@gcc.gnu.org> writes:
>>
>> > On Wed, 31 May 2023 at 18:39, François Dumont via Libstdc++ <
>> > libstdc++@gcc.gnu.org> wrote:
>> >
>> >> libstdc++: Reduce <functional> inclusion to <stl_algobase.h>
>> >>
>> >>
>> >> Move the std::search definition from stl_algo.h to stl_algobase.h and
>> use
>> >> the later in <functional>.
>> >>
>> >> For consistency also move std::__parallel::search and associated
>> helpers
>> >> from
>> >> <parallel/stl_algo.h> to <parallel/stl_algobase.h> so that
>> >> std::__parallel::search
>> >> is accessible along with std::search.
>> >>
>> >> libstdc++-v3/ChangeLog:
>> >>
>> >>              * include/bits/stl_algo.h
>> >>              (std::__search, std::search(_FwdIt1, _FwdIt1, _FwdIt2,
>> >> _FwdIt2, _BinPred)): Move...
>> >>              * include/bits/stl_algobase.h: ...here.
>> >>              * include/std/functional: Replace <stl_algo.h> include by
>> >> <stl_algobase.h>.
>> >>              * include/parallel/algo.h (std::__parallel::search<_FIt1,
>> >> _FIt2, _BinaryPred>)
>> >>              (std::__parallel::__search_switch<_FIt1, _FIt2,
>> >> _BinaryPred, _ItTag1, _ItTag2>):
>> >>              Move...
>> >>              * include/parallel/algobase.h: ...here.
>> >>              * include/std/functional: Remove <bits/stl_algo.h> and
>> >> <parallel/algorithm>
>> >>              includes. Include <bits/stl_algobase.h>.
>> >>
>> >> Tested under Linux x86_64.
>> >>
>> >> Ok to commit ?
>> >>
>> >
>> > OK
>>
>> This seems to have caused
>>
>> +FAIL: 17_intro/headers/c++2011/parallel_mode.cc (test for excess errors)
>> +FAIL: 17_intro/headers/c++2014/parallel_mode.cc (test for excess errors)
>>
>> on i386-pc-solaris2.11:
>>
>
> I think it affects all targets.
>
>
>>
>> Excess errors:
>> /var/gcc/regression/master/11.4-gcc-gas/build/i386-pc-solaris2.11/libstdc++-v3/include/parallel/algobase.h:496:
>> error: '__search_template' is not a member of '__gnu_parallel'; did you
>> mean '__find_template'?
>>
>>         Rainer
>>
>> --
>>
>> -----------------------------------------------------------------------------
>> Rainer Orth, Center for Biotechnology, Bielefeld University
>>
>>
François Dumont June 1, 2023, 8:36 p.m. UTC | #5
It's of course not as easy as I thought.

I would never have detected this problem on my system because I'm 
missing omp.h.

I've implemented and added a:

// { dg-require-effective-target omp }

so that now those tests are UNRESOLVED rather than PASS.

Now I've install OMP and try to rebuild lib to reproduce the failure.

To be continued tomorrow...

On 01/06/2023 14:05, Jonathan Wakely wrote:
>
>
> On Thu, 1 Jun 2023 at 12:52, Rainer Orth <ro@cebitec.uni-bielefeld.de> 
> wrote:
>
>     Jonathan Wakely via Gcc-patches <gcc-patches@gcc.gnu.org> writes:
>
>     > On Wed, 31 May 2023 at 18:39, François Dumont via Libstdc++ <
>     > libstdc++@gcc.gnu.org <mailto:libstdc%2B%2B@gcc.gnu.org>> wrote:
>     >
>     >> libstdc++: Reduce <functional> inclusion to <stl_algobase.h>
>     >>
>     >>
>     >> Move the std::search definition from stl_algo.h to
>     stl_algobase.h and use
>     >> the later in <functional>.
>     >>
>     >> For consistency also move std::__parallel::search and
>     associated helpers
>     >> from
>     >> <parallel/stl_algo.h> to <parallel/stl_algobase.h> so that
>     >> std::__parallel::search
>     >> is accessible along with std::search.
>     >>
>     >> libstdc++-v3/ChangeLog:
>     >>
>     >>              * include/bits/stl_algo.h
>     >>              (std::__search, std::search(_FwdIt1, _FwdIt1, _FwdIt2,
>     >> _FwdIt2, _BinPred)): Move...
>     >>              * include/bits/stl_algobase.h: ...here.
>     >>              * include/std/functional: Replace <stl_algo.h>
>     include by
>     >> <stl_algobase.h>.
>     >>              * include/parallel/algo.h
>     (std::__parallel::search<_FIt1,
>     >> _FIt2, _BinaryPred>)
>     >> (std::__parallel::__search_switch<_FIt1, _FIt2,
>     >> _BinaryPred, _ItTag1, _ItTag2>):
>     >>              Move...
>     >>              * include/parallel/algobase.h: ...here.
>     >>              * include/std/functional: Remove <bits/stl_algo.h> and
>     >> <parallel/algorithm>
>     >>              includes. Include <bits/stl_algobase.h>.
>     >>
>     >> Tested under Linux x86_64.
>     >>
>     >> Ok to commit ?
>     >>
>     >
>     > OK
>
>     This seems to have caused
>
>     +FAIL: 17_intro/headers/c++2011/parallel_mode.cc (test for excess
>     errors)
>     +FAIL: 17_intro/headers/c++2014/parallel_mode.cc (test for excess
>     errors)
>
>     on i386-pc-solaris2.11:
>
>
> I think it affects all targets.
>
>
>     Excess errors:
>     /var/gcc/regression/master/11.4-gcc-gas/build/i386-pc-solaris2.11/libstdc++-v3/include/parallel/algobase.h:496:
>     error: '__search_template' is not a member of '__gnu_parallel';
>     did you mean '__find_template'?
>
>             Rainer
>
>     -- 
>     -----------------------------------------------------------------------------
>     Rainer Orth, Center for Biotechnology, Bielefeld University
>
Jonathan Wakely June 1, 2023, 9:57 p.m. UTC | #6
On Thu, 1 Jun 2023, 21:37 François Dumont via Libstdc++, <
libstdc++@gcc.gnu.org> wrote:

> It's of course not as easy as I thought.
>
> I would never have detected this problem on my system because I'm
> missing omp.h.
>
> I've implemented and added a:
>
> // { dg-require-effective-target omp }
>
> so that now those tests are UNRESOLVED rather than PASS.
>
> Now I've install OMP and try to rebuild lib to reproduce the failure.
>

You shouldn't need to install anything, just build gcc and don't configure
it with --disable-libgomp




> To be continued tomorrow...
>
> On 01/06/2023 14:05, Jonathan Wakely wrote:
> >
> >
> > On Thu, 1 Jun 2023 at 12:52, Rainer Orth <ro@cebitec.uni-bielefeld.de>
> > wrote:
> >
> >     Jonathan Wakely via Gcc-patches <gcc-patches@gcc.gnu.org> writes:
> >
> >     > On Wed, 31 May 2023 at 18:39, François Dumont via Libstdc++ <
> >     > libstdc++@gcc.gnu.org <mailto:libstdc%2B%2B@gcc.gnu.org>> wrote:
> >     >
> >     >> libstdc++: Reduce <functional> inclusion to <stl_algobase.h>
> >     >>
> >     >>
> >     >> Move the std::search definition from stl_algo.h to
> >     stl_algobase.h and use
> >     >> the later in <functional>.
> >     >>
> >     >> For consistency also move std::__parallel::search and
> >     associated helpers
> >     >> from
> >     >> <parallel/stl_algo.h> to <parallel/stl_algobase.h> so that
> >     >> std::__parallel::search
> >     >> is accessible along with std::search.
> >     >>
> >     >> libstdc++-v3/ChangeLog:
> >     >>
> >     >>              * include/bits/stl_algo.h
> >     >>              (std::__search, std::search(_FwdIt1, _FwdIt1,
> _FwdIt2,
> >     >> _FwdIt2, _BinPred)): Move...
> >     >>              * include/bits/stl_algobase.h: ...here.
> >     >>              * include/std/functional: Replace <stl_algo.h>
> >     include by
> >     >> <stl_algobase.h>.
> >     >>              * include/parallel/algo.h
> >     (std::__parallel::search<_FIt1,
> >     >> _FIt2, _BinaryPred>)
> >     >> (std::__parallel::__search_switch<_FIt1, _FIt2,
> >     >> _BinaryPred, _ItTag1, _ItTag2>):
> >     >>              Move...
> >     >>              * include/parallel/algobase.h: ...here.
> >     >>              * include/std/functional: Remove <bits/stl_algo.h>
> and
> >     >> <parallel/algorithm>
> >     >>              includes. Include <bits/stl_algobase.h>.
> >     >>
> >     >> Tested under Linux x86_64.
> >     >>
> >     >> Ok to commit ?
> >     >>
> >     >
> >     > OK
> >
> >     This seems to have caused
> >
> >     +FAIL: 17_intro/headers/c++2011/parallel_mode.cc (test for excess
> >     errors)
> >     +FAIL: 17_intro/headers/c++2014/parallel_mode.cc (test for excess
> >     errors)
> >
> >     on i386-pc-solaris2.11:
> >
> >
> > I think it affects all targets.
> >
> >
> >     Excess errors:
> >
>  /var/gcc/regression/master/11.4-gcc-gas/build/i386-pc-solaris2.11/libstdc++-v3/include/parallel/algobase.h:496:
> >     error: '__search_template' is not a member of '__gnu_parallel';
> >     did you mean '__find_template'?
> >
> >             Rainer
> >
> >     --
> >
>  -----------------------------------------------------------------------------
> >     Rainer Orth, Center for Biotechnology, Bielefeld University
> >
>
François Dumont June 2, 2023, 7:33 a.m. UTC | #7
I haven't been able to reproduce so far.

Here is however a patch that I think will fix the problem. At least 
failing tests are UNRESOLVED on my system.

     libstdc++: Fix broken _GLIBCXX_PARALLEL mode

     Add missing <parallel/search.h> include in <parallel/algobase.h>.

     Detect availability of <omp.h> in tests needing it to make them 
UNSUPPORTED
     rather than PASS when header is missing.

     libstdc++-v3/ChangeLog:

             * include/parallel/algobase.h: Include <parallel/search.h>.
             * testsuite/lib/libstdc++.exp (check_effective_target_omp): 
New.
             * testsuite/17_intro/headers/c++2011/parallel_mode.cc:
             Add { dg-require-effective-target omp }.
             * testsuite/17_intro/headers/c++2014/parallel_mode.cc: 
Likewise.
             * testsuite/17_intro/headers/c++2017/parallel_mode.cc: 
Likewise.

Ok to commit ?


On 01/06/2023 23:57, Jonathan Wakely wrote:
>
>
> On Thu, 1 Jun 2023, 21:37 François Dumont via Libstdc++, 
> <libstdc++@gcc.gnu.org <mailto:libstdc%2B%2B@gcc.gnu.org>> wrote:
>
>     It's of course not as easy as I thought.
>
>     I would never have detected this problem on my system because I'm
>     missing omp.h.
>
>     I've implemented and added a:
>
>     // { dg-require-effective-target omp }
>
>     so that now those tests are UNRESOLVED rather than PASS.
>
>     Now I've install OMP and try to rebuild lib to reproduce the failure.
>
>
> You shouldn't need to install anything, just build gcc and don't 
> configure it with --disable-libgomp
>
I haven't used --disable-libgomp. But maybe when I run configure the 1st 
time it tried to detect OMP install and failed to find it as I just 
installed it.

I'll tried to rebuild everything to see if I can eventually have those 
tests PASS.

François
Jonathan Wakely June 2, 2023, 7:43 a.m. UTC | #8
On Fri, 2 Jun 2023 at 08:33, François Dumont wrote:

> I haven't been able to reproduce so far.
>
> Here is however a patch that I think will fix the problem. At least
> failing tests are UNRESOLVED on my system.
>
>     libstdc++: Fix broken _GLIBCXX_PARALLEL mode
>
>     Add missing <parallel/search.h> include in <parallel/algobase.h>.
>

This fixes the broken parallel mode.


>
>     Detect availability of <omp.h> in tests needing it to make them
> UNSUPPORTED
>     rather than PASS when header is missing.
>
>     libstdc++-v3/ChangeLog:
>
>             * include/parallel/algobase.h: Include <parallel/search.h>.
>             * testsuite/lib/libstdc++.exp (check_effective_target_omp):
> New.
>             * testsuite/17_intro/headers/c++2011/parallel_mode.cc:
>             Add { dg-require-effective-target omp }.
>             * testsuite/17_intro/headers/c++2014/parallel_mode.cc:
> Likewise.
>             * testsuite/17_intro/headers/c++2017/parallel_mode.cc:
> Likewise.
>
> Ok to commit ?
>

Please just add the #include to parallel/algobase.h for now.

The effective-target keyword seems reasonable, but "omp" is not a good
name. And if we add that dg-require-effective-target to those tests then
they don't need to repeat the check in the test itself:
#if __has_include(<omp.h>)

So please just add the #include and then we can revisit the
effective-target separately.



>
> On 01/06/2023 23:57, Jonathan Wakely wrote:
>
> On Thu, 1 Jun 2023, 21:37 François Dumont via Libstdc++, <
> libstdc++@gcc.gnu.org> wrote:
>
>> Now I've install OMP and try to rebuild lib to reproduce the failure.
>>
>
> You shouldn't need to install anything, just build gcc and don't configure
> it with --disable-libgomp
>
> I haven't used --disable-libgomp. But maybe when I run configure the 1st
> time it tried to detect OMP install and failed to find it as I just
> installed it.
>

I don't know what you mean, because GCC doesn't depend on "OMP". GCC
includes its own OpenMP implementation, and installs its own libgomp
runtime library to support the -fopenmp flag. It doesn't depend on anything
else.

Which OS are you testing on?
François Dumont June 2, 2023, 9:47 a.m. UTC | #9
Ok, push done.

Even after full rebuild those tests are still UNRESOLVED on my system.

Yes, I also noticed that I could remove this check. I'll propose it later.

François

On 02/06/2023 09:43, Jonathan Wakely wrote:
> On Fri, 2 Jun 2023 at 08:33, François Dumont wrote:
>
>     I haven't been able to reproduce so far.
>
>     Here is however a patch that I think will fix the problem. At
>     least failing tests are UNRESOLVED on my system.
>
>         libstdc++: Fix broken _GLIBCXX_PARALLEL mode
>
>         Add missing <parallel/search.h> include in <parallel/algobase.h>.
>
>
> This fixes the broken parallel mode.
>
>
>         Detect availability of <omp.h> in tests needing it to make
>     them UNSUPPORTED
>         rather than PASS when header is missing.
>
>         libstdc++-v3/ChangeLog:
>
>                 * include/parallel/algobase.h: Include
>     <parallel/search.h>.
>                 * testsuite/lib/libstdc++.exp
>     (check_effective_target_omp): New.
>                 * testsuite/17_intro/headers/c++2011/parallel_mode.cc:
>                 Add { dg-require-effective-target omp }.
>                 * testsuite/17_intro/headers/c++2014/parallel_mode.cc:
>     Likewise.
>                 * testsuite/17_intro/headers/c++2017/parallel_mode.cc:
>     Likewise.
>
>     Ok to commit ?
>
>
> Please just add the #include to parallel/algobase.h for now.
>
> The effective-target keyword seems reasonable, but "omp" is not a good 
> name. And if we add that dg-require-effective-target to those tests 
> then they don't need to repeat the check in the test itself:
> #if __has_include(<omp.h>)
>
> So please just add the #include and then we can revisit the 
> effective-target separately.
>
>
>
>     On 01/06/2023 23:57, Jonathan Wakely wrote:
>>     On Thu, 1 Jun 2023, 21:37 François Dumont via Libstdc++,
>>     <libstdc++@gcc.gnu.org <mailto:libstdc%2B%2B@gcc.gnu.org>> wrote:
>>
>>         Now I've install OMP and try to rebuild lib to reproduce the
>>         failure.
>>
>>
>>     You shouldn't need to install anything, just build gcc and don't
>>     configure it with --disable-libgomp
>>
>     I haven't used --disable-libgomp. But maybe when I run configure
>     the 1st time it tried to detect OMP install and failed to find it
>     as I just installed it.
>
>
> I don't know what you mean, because GCC doesn't depend on "OMP". GCC 
> includes its own OpenMP implementation, and installs its own libgomp 
> runtime library to support the -fopenmp flag. It doesn't depend on 
> anything else.
>
> Which OS are you testing on?
>
Jonathan Wakely June 2, 2023, 11:30 a.m. UTC | #10
On Fri, 2 Jun 2023 at 10:47, François Dumont <frs.dumont@gmail.com> wrote:

> Ok, push done.
>

Thanks.


> Even after full rebuild those tests are still UNRESOLVED on my system.
>
What is the error in the log?

What is your system? How and where did you install "OMP"?

Does the libgomp directory exist in the GCC build tree, at the same level
as libstdc++-v3?

e.g. in $objdir/x86_64-pc-linux-gnu/libgomp or equivalent?

That directory should contain omp.h and .libs/libgomp.* which will be used
by the libstdc++ testsuite for the check-parallel target (see the
libgomp_flags variable which sets the paths to find libgomp in the build
tree).

But because that test only runs for normal mode (not parallel mode) it
doesn't use libgomp_flags, and so it will only find omp.h if it already
exists in the compiler's default include paths, which will happen if you've
already run "make install" on the GCC built with libgomp enabled.

If you haven't enabled libgomp, or you haven't installed the new GCC yet,
then the __has_include(<omp.h>) should fail, and so the test does nothing
and so should just PASS. If it's UNRESOLVED for you then that implies it's
finding an <omp.h> header, but probably not the one from GCC, so it fails
to compile. I think that's due to how you've installed "OMP" (whatever that
means ... I don't think you've installed libgomp and so I don't think you
should have done that ... maybe you installed Clang's libomp headers
instead and GCC is finding those somehow?)
Jonathan Wakely June 2, 2023, 12:34 p.m. UTC | #11
On Fri, 2 Jun 2023 at 12:30, Jonathan Wakely <jwakely@redhat.com> wrote:

>
>
> On Fri, 2 Jun 2023 at 10:47, François Dumont <frs.dumont@gmail.com> wrote:
>
>> Ok, push done.
>>
>
> Thanks.
>
>
>> Even after full rebuild those tests are still UNRESOLVED on my system.
>>
> What is the error in the log?
>
> What is your system? How and where did you install "OMP"?
>
> Does the libgomp directory exist in the GCC build tree, at the same level
> as libstdc++-v3?
>
> e.g. in $objdir/x86_64-pc-linux-gnu/libgomp or equivalent?
>
> That directory should contain omp.h and .libs/libgomp.* which will be used
> by the libstdc++ testsuite for the check-parallel target (see the
> libgomp_flags variable which sets the paths to find libgomp in the build
> tree).
>
> But because that test only runs for normal mode (not parallel mode) it
> doesn't use libgomp_flags, and so it will only find omp.h if it already
> exists in the compiler's default include paths, which will happen if you've
> already run "make install" on the GCC built with libgomp enabled.
>
> If you haven't enabled libgomp, or you haven't installed the new GCC yet,
> then the __has_include(<omp.h>) should fail, and so the test does nothing
> and so should just PASS. If it's UNRESOLVED for you then that implies it's
> finding an <omp.h> header, but probably not the one from GCC, so it fails
> to compile. I think that's due to how you've installed "OMP" (whatever that
> means ... I don't think you've installed libgomp and so I don't think you
> should have done that ... maybe you installed Clang's libomp headers
> instead and GCC is finding those somehow?)
>

Since we already have dg-require-parallel-mode that is used for most
parallel mode tests, I don't think it's worth adding a new "openmp"
effective-target just for these three tests. But it would be helpful if I
added this comment to them instead:

--- a/libstdc++-v3/testsuite/17_intro/headers/c++2014/parallel_mode.cc
+++ b/libstdc++-v3/testsuite/17_intro/headers/c++2014/parallel_mode.cc
@@ -19,6 +19,12 @@
// { dg-do compile { target c++14 } }
// { dg-require-normal-mode "" }

+// In order to improve coverage this test is run by the normal 'make check'
+// target, not only the infrequently-tested check-parallel target. That
means
+// the makefile variable $(libgomp_flags) is not used, so the libgomp files
+// in the build tree will not be found. The parallel mode headers will only
+// be able to include <omp.h> if libgomp has already been installed to the
+// $prefix of the GCC being tested, so use __has_include to fail
gracefully.
#if __has_include(<omp.h>)
# define _GLIBCXX_PARALLEL 1
# include <bits/extc++.h>

Or we could just remove those tests and ensure that somebody runs 'make
check-parallel' at least once every six months.

N.B. running 'make check-parallel' would have found the problem with the
missing #include in <parallel/algobase.h>, even without an installed
libgomp.
diff mbox series

Patch

diff --git a/libstdc++-v3/include/bits/stl_algo.h b/libstdc++-v3/include/bits/stl_algo.h
index 54695490166..2c52ed51402 100644
--- a/libstdc++-v3/include/bits/stl_algo.h
+++ b/libstdc++-v3/include/bits/stl_algo.h
@@ -140,54 +140,6 @@  _GLIBCXX_BEGIN_NAMESPACE_VERSION
   // count
   // count_if
   // search
-
-  template<typename _ForwardIterator1, typename _ForwardIterator2,
-	   typename _BinaryPredicate>
-    _GLIBCXX20_CONSTEXPR
-    _ForwardIterator1
-    __search(_ForwardIterator1 __first1, _ForwardIterator1 __last1,
-	     _ForwardIterator2 __first2, _ForwardIterator2 __last2,
-	     _BinaryPredicate  __predicate)
-    {
-      // Test for empty ranges
-      if (__first1 == __last1 || __first2 == __last2)
-	return __first1;
-
-      // Test for a pattern of length 1.
-      _ForwardIterator2 __p1(__first2);
-      if (++__p1 == __last2)
-	return std::__find_if(__first1, __last1,
-		__gnu_cxx::__ops::__iter_comp_iter(__predicate, __first2));
-
-      // General case.
-      _ForwardIterator1 __current = __first1;
-
-      for (;;)
-	{
-	  __first1 =
-	    std::__find_if(__first1, __last1,
-		__gnu_cxx::__ops::__iter_comp_iter(__predicate, __first2));
-
-	  if (__first1 == __last1)
-	    return __last1;
-
-	  _ForwardIterator2 __p = __p1;
-	  __current = __first1;
-	  if (++__current == __last1)
-	    return __last1;
-
-	  while (__predicate(__current, __p))
-	    {
-	      if (++__p == __last2)
-		return __first1;
-	      if (++__current == __last1)
-		return __last1;
-	    }
-	  ++__first1;
-	}
-      return __first1;
-    }
-
   // search_n
 
   /**
@@ -4147,48 +4099,6 @@  _GLIBCXX_BEGIN_NAMESPACE_ALGO
 			   __gnu_cxx::__ops::__iter_equal_to_iter());
     }
 
-  /**
-   *  @brief Search a sequence for a matching sub-sequence using a predicate.
-   *  @ingroup non_mutating_algorithms
-   *  @param  __first1     A forward iterator.
-   *  @param  __last1      A forward iterator.
-   *  @param  __first2     A forward iterator.
-   *  @param  __last2      A forward iterator.
-   *  @param  __predicate  A binary predicate.
-   *  @return   The first iterator @c i in the range
-   *  @p [__first1,__last1-(__last2-__first2)) such that
-   *  @p __predicate(*(i+N),*(__first2+N)) is true for each @c N in the range
-   *  @p [0,__last2-__first2), or @p __last1 if no such iterator exists.
-   *
-   *  Searches the range @p [__first1,__last1) for a sub-sequence that
-   *  compares equal value-by-value with the sequence given by @p
-   *  [__first2,__last2), using @p __predicate to determine equality,
-   *  and returns an iterator to the first element of the
-   *  sub-sequence, or @p __last1 if no such iterator exists.
-   *
-   *  @see search(_ForwardIter1, _ForwardIter1, _ForwardIter2, _ForwardIter2)
-  */
-  template<typename _ForwardIterator1, typename _ForwardIterator2,
-	   typename _BinaryPredicate>
-    _GLIBCXX20_CONSTEXPR
-    inline _ForwardIterator1
-    search(_ForwardIterator1 __first1, _ForwardIterator1 __last1,
-	   _ForwardIterator2 __first2, _ForwardIterator2 __last2,
-	   _BinaryPredicate  __predicate)
-    {
-      // concept requirements
-      __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator1>)
-      __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator2>)
-      __glibcxx_function_requires(_BinaryPredicateConcept<_BinaryPredicate,
-	    typename iterator_traits<_ForwardIterator1>::value_type,
-	    typename iterator_traits<_ForwardIterator2>::value_type>)
-      __glibcxx_requires_valid_range(__first1, __last1);
-      __glibcxx_requires_valid_range(__first2, __last2);
-
-      return std::__search(__first1, __last1, __first2, __last2,
-			   __gnu_cxx::__ops::__iter_comp_iter(__predicate));
-    }
-
   /**
    *  @brief Search a sequence for a number of consecutive values.
    *  @ingroup non_mutating_algorithms
diff --git a/libstdc++-v3/include/bits/stl_algobase.h b/libstdc++-v3/include/bits/stl_algobase.h
index 4a6f8195d98..dd95e94f7e9 100644
--- a/libstdc++-v3/include/bits/stl_algobase.h
+++ b/libstdc++-v3/include/bits/stl_algobase.h
@@ -2150,6 +2150,53 @@  _GLIBCXX_END_NAMESPACE_ALGO
       return __result;
     }
 
+  template<typename _ForwardIterator1, typename _ForwardIterator2,
+	   typename _BinaryPredicate>
+    _GLIBCXX20_CONSTEXPR
+    _ForwardIterator1
+    __search(_ForwardIterator1 __first1, _ForwardIterator1 __last1,
+	     _ForwardIterator2 __first2, _ForwardIterator2 __last2,
+	     _BinaryPredicate  __predicate)
+    {
+      // Test for empty ranges
+      if (__first1 == __last1 || __first2 == __last2)
+	return __first1;
+
+      // Test for a pattern of length 1.
+      _ForwardIterator2 __p1(__first2);
+      if (++__p1 == __last2)
+	return std::__find_if(__first1, __last1,
+		__gnu_cxx::__ops::__iter_comp_iter(__predicate, __first2));
+
+      // General case.
+      _ForwardIterator1 __current = __first1;
+
+      for (;;)
+	{
+	  __first1 =
+	    std::__find_if(__first1, __last1,
+		__gnu_cxx::__ops::__iter_comp_iter(__predicate, __first2));
+
+	  if (__first1 == __last1)
+	    return __last1;
+
+	  _ForwardIterator2 __p = __p1;
+	  __current = __first1;
+	  if (++__current == __last1)
+	    return __last1;
+
+	  while (__predicate(__current, __p))
+	    {
+	      if (++__p == __last2)
+		return __first1;
+	      if (++__current == __last1)
+		return __last1;
+	    }
+	  ++__first1;
+	}
+      return __first1;
+    }
+
 #if __cplusplus >= 201103L
   template<typename _ForwardIterator1, typename _ForwardIterator2,
 	   typename _BinaryPredicate>
@@ -2220,6 +2267,51 @@  _GLIBCXX_END_NAMESPACE_ALGO
     }
 #endif // C++11
 
+_GLIBCXX_BEGIN_NAMESPACE_ALGO
+
+  /**
+   *  @brief Search a sequence for a matching sub-sequence using a predicate.
+   *  @ingroup non_mutating_algorithms
+   *  @param  __first1     A forward iterator.
+   *  @param  __last1      A forward iterator.
+   *  @param  __first2     A forward iterator.
+   *  @param  __last2      A forward iterator.
+   *  @param  __predicate  A binary predicate.
+   *  @return   The first iterator @c i in the range
+   *  @p [__first1,__last1-(__last2-__first2)) such that
+   *  @p __predicate(*(i+N),*(__first2+N)) is true for each @c N in the range
+   *  @p [0,__last2-__first2), or @p __last1 if no such iterator exists.
+   *
+   *  Searches the range @p [__first1,__last1) for a sub-sequence that
+   *  compares equal value-by-value with the sequence given by @p
+   *  [__first2,__last2), using @p __predicate to determine equality,
+   *  and returns an iterator to the first element of the
+   *  sub-sequence, or @p __last1 if no such iterator exists.
+   *
+   *  @see search(_ForwardIter1, _ForwardIter1, _ForwardIter2, _ForwardIter2)
+  */
+  template<typename _ForwardIterator1, typename _ForwardIterator2,
+	   typename _BinaryPredicate>
+    _GLIBCXX20_CONSTEXPR
+    inline _ForwardIterator1
+    search(_ForwardIterator1 __first1, _ForwardIterator1 __last1,
+	   _ForwardIterator2 __first2, _ForwardIterator2 __last2,
+	   _BinaryPredicate  __predicate)
+    {
+      // concept requirements
+      __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator1>)
+      __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator2>)
+      __glibcxx_function_requires(_BinaryPredicateConcept<_BinaryPredicate,
+	    typename iterator_traits<_ForwardIterator1>::value_type,
+	    typename iterator_traits<_ForwardIterator2>::value_type>)
+      __glibcxx_requires_valid_range(__first1, __last1);
+      __glibcxx_requires_valid_range(__first2, __last2);
+
+      return std::__search(__first1, __last1, __first2, __last2,
+			   __gnu_cxx::__ops::__iter_comp_iter(__predicate));
+    }
+
+_GLIBCXX_END_NAMESPACE_ALGO
 _GLIBCXX_END_NAMESPACE_VERSION
 } // namespace std
 
diff --git a/libstdc++-v3/include/experimental/functional b/libstdc++-v3/include/experimental/functional
index ce9d4e0fece..26b8dd51aec 100644
--- a/libstdc++-v3/include/experimental/functional
+++ b/libstdc++-v3/include/experimental/functional
@@ -42,10 +42,7 @@ 
 #include <unordered_map>
 #include <vector>
 #include <array>
-#include <bits/stl_algo.h>
-#ifdef _GLIBCXX_PARALLEL
-# include <parallel/algorithm> // For std::__parallel::search
-#endif
+#include <bits/stl_algobase.h> // std::max, std::search
 #include <experimental/bits/lfts_config.h>
 
 namespace std _GLIBCXX_VISIBILITY(default)
diff --git a/libstdc++-v3/include/parallel/algo.h b/libstdc++-v3/include/parallel/algo.h
index 43ed6c558ee..13ae7622aa6 100644
--- a/libstdc++-v3/include/parallel/algo.h
+++ b/libstdc++-v3/include/parallel/algo.h
@@ -996,59 +996,6 @@  namespace __parallel
 			     std::__iterator_category(__begin2));
     }
 
-  // Public interface.
-  template<typename _FIterator1, typename _FIterator2,
-	   typename _BinaryPredicate>
-    inline _FIterator1
-    search(_FIterator1 __begin1, _FIterator1 __end1,
-	   _FIterator2 __begin2, _FIterator2 __end2,
-	   _BinaryPredicate __pred, __gnu_parallel::sequential_tag)
-    { return _GLIBCXX_STD_A::search(
-			       __begin1, __end1, __begin2, __end2, __pred); }
-
-  // Parallel algorithm for random access iterator.
-  template<typename _RAIter1, typename _RAIter2,
-	   typename _BinaryPredicate>
-    _RAIter1
-    __search_switch(_RAIter1 __begin1, _RAIter1 __end1,
-		    _RAIter2 __begin2, _RAIter2 __end2,
-		    _BinaryPredicate __pred,
-		    random_access_iterator_tag, random_access_iterator_tag)
-    {
-      if (_GLIBCXX_PARALLEL_CONDITION(
-		static_cast<__gnu_parallel::_SequenceIndex>(__end1 - __begin1)
-	    >= __gnu_parallel::_Settings::get().search_minimal_n))
-	return __gnu_parallel::__search_template(__begin1, __end1,
-					       __begin2, __end2, __pred);
-      else
-	return search(__begin1, __end1, __begin2, __end2, __pred,
-		      __gnu_parallel::sequential_tag());
-    }
-
-  // Sequential fallback for input iterator case
-  template<typename _FIterator1, typename _FIterator2,
-	   typename _BinaryPredicate, typename _IteratorTag1,
-	   typename _IteratorTag2>
-    inline _FIterator1
-    __search_switch(_FIterator1 __begin1, _FIterator1 __end1,
-		    _FIterator2 __begin2, _FIterator2 __end2,
-		    _BinaryPredicate __pred, _IteratorTag1, _IteratorTag2)
-    { return search(__begin1, __end1, __begin2, __end2, __pred,
-		    __gnu_parallel::sequential_tag()); }
-
-  // Public interface
-  template<typename _FIterator1, typename _FIterator2,
-	   typename _BinaryPredicate>
-    inline _FIterator1
-    search(_FIterator1 __begin1, _FIterator1 __end1,
-	   _FIterator2 __begin2, _FIterator2 __end2,
-	   _BinaryPredicate  __pred)
-    {
-      return __search_switch(__begin1, __end1, __begin2, __end2, __pred,
-			     std::__iterator_category(__begin1),
-			     std::__iterator_category(__begin2));
-    }
-
 #if __cplusplus >= 201703L
   /** @brief Search a sequence using a Searcher object.
    *
diff --git a/libstdc++-v3/include/parallel/algobase.h b/libstdc++-v3/include/parallel/algobase.h
index 0bc25a69f8a..4e4cc0fa0f2 100644
--- a/libstdc++-v3/include/parallel/algobase.h
+++ b/libstdc++-v3/include/parallel/algobase.h
@@ -470,7 +470,60 @@  namespace __parallel
 #if __cpp_lib_three_way_comparison
   using _GLIBCXX_STD_A::lexicographical_compare_three_way;
 #endif
-} // end namespace
-} // end namespace
+
+  // Public interface.
+  template<typename _FIterator1, typename _FIterator2,
+	   typename _BinaryPredicate>
+    inline _FIterator1
+    search(_FIterator1 __begin1, _FIterator1 __end1,
+	   _FIterator2 __begin2, _FIterator2 __end2,
+	   _BinaryPredicate __pred, __gnu_parallel::sequential_tag)
+    { return _GLIBCXX_STD_A::search(
+			       __begin1, __end1, __begin2, __end2, __pred); }
+
+  // Parallel algorithm for random access iterator.
+  template<typename _RAIter1, typename _RAIter2,
+	   typename _BinaryPredicate>
+    _RAIter1
+    __search_switch(_RAIter1 __begin1, _RAIter1 __end1,
+		    _RAIter2 __begin2, _RAIter2 __end2,
+		    _BinaryPredicate __pred,
+		    random_access_iterator_tag, random_access_iterator_tag)
+    {
+      if (_GLIBCXX_PARALLEL_CONDITION(
+		static_cast<__gnu_parallel::_SequenceIndex>(__end1 - __begin1)
+	    >= __gnu_parallel::_Settings::get().search_minimal_n))
+	return __gnu_parallel::__search_template(__begin1, __end1,
+					       __begin2, __end2, __pred);
+      else
+	return search(__begin1, __end1, __begin2, __end2, __pred,
+		      __gnu_parallel::sequential_tag());
+    }
+
+  // Sequential fallback for input iterator case
+  template<typename _FIterator1, typename _FIterator2,
+	   typename _BinaryPredicate, typename _IteratorTag1,
+	   typename _IteratorTag2>
+    inline _FIterator1
+    __search_switch(_FIterator1 __begin1, _FIterator1 __end1,
+		    _FIterator2 __begin2, _FIterator2 __end2,
+		    _BinaryPredicate __pred, _IteratorTag1, _IteratorTag2)
+    { return search(__begin1, __end1, __begin2, __end2, __pred,
+		    __gnu_parallel::sequential_tag()); }
+
+  // Public interface
+  template<typename _FIterator1, typename _FIterator2,
+	   typename _BinaryPredicate>
+    inline _FIterator1
+    search(_FIterator1 __begin1, _FIterator1 __end1,
+	   _FIterator2 __begin2, _FIterator2 __end2,
+	   _BinaryPredicate  __pred)
+    {
+      return __search_switch(__begin1, __end1, __begin2, __end2, __pred,
+			     std::__iterator_category(__begin1),
+			     std::__iterator_category(__begin2));
+    }
+} // end namespace __parallel
+} // end namespace std
 
 #endif /* _GLIBCXX_PARALLEL_ALGOBASE_H */
diff --git a/libstdc++-v3/include/std/functional b/libstdc++-v3/include/std/functional
index c7c6a5a7924..4a4b8b2b2e6 100644
--- a/libstdc++-v3/include/std/functional
+++ b/libstdc++-v3/include/std/functional
@@ -64,7 +64,7 @@ 
 #  include <vector>
 #  include <array>
 # endif
-# include <bits/stl_algo.h> // std::search
+# include <bits/stl_algobase.h> // std::search
 #endif
 #if __cplusplus >= 202002L
 # include <bits/ranges_cmp.h> // std::identity, ranges::equal_to etc.