]>
git.ipfire.org Git - thirdparty/gcc.git/blob - libstdc++-v3/testsuite/25_algorithms/headers/algorithm/parallel_algorithm_mixed2.cc
2 // { dg-require-parallel-mode "" }
3 // { dg-options "-fopenmp" { target *-*-* } }
5 // Copyright (C) 2007-2019 Free Software Foundation, Inc.
7 // This file is part of the GNU ISO C++ Library. This library is free
8 // software; you can redistribute it and/or modify it under the
9 // terms of the GNU General Public License as published by the
10 // Free Software Foundation; either version 3, or (at your option)
13 // This library is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 // GNU General Public License for more details.
18 // You should have received a copy of the GNU General Public License along
19 // with this library; see the file COPYING3. If not see
20 // <http://www.gnu.org/licenses/>.
22 // Make sure to test without _GLIBCXX_PARALLEL
23 #ifdef _GLIBCXX_PARALLEL
24 # undef _GLIBCXX_PARALLEL
27 #include <parallel/algorithm>
33 typedef unsigned short value_type
;
34 typedef std::vector
<value_type
> vector_type
;
36 const value_type
c(0);
38 vector_type
v(10), result(20);
40 std::equal(v
.begin(), v
.end(), v
.begin());
41 std::equal(v
.begin(), v
.end(), v
.begin(), std::equal_to
<value_type
>());
42 __gnu_parallel::equal(v
.begin(), v
.end(), v
.begin());
43 __gnu_parallel::equal(v
.begin(), v
.end(), v
.begin(),
44 std::equal_to
<value_type
>());
46 std::find(v
.begin(), v
.end(), c
);
47 __gnu_parallel::find(v
.begin(), v
.end(), c
);
49 std::find_first_of(v
.begin(), v
.end(), v
.begin(), v
.end());
50 std::find_first_of(v
.begin(), v
.end(), v
.begin(), v
.end(),
51 std::equal_to
<value_type
>());
52 __gnu_parallel::find_first_of(v
.begin(), v
.end(), v
.begin(), v
.end());
53 __gnu_parallel::find_first_of(v
.begin(), v
.end(), v
.begin(), v
.end(),
54 std::equal_to
<value_type
>());
56 std::search_n(v
.begin(), v
.end(), 5, value_type(1));
57 std::search_n(v
.begin(), v
.end(), 5, value_type(1),
58 std::equal_to
<value_type
>());
59 __gnu_parallel::search_n(v
.begin(), v
.end(), 5, value_type(1));
60 __gnu_parallel::search_n(v
.begin(), v
.end(), 5, value_type(1),
61 std::equal_to
<value_type
>());
63 std::merge(v
.begin(), v
.end(), v
.begin(), v
.end(), result
.begin());
64 std::merge(v
.begin(), v
.end(), v
.begin(), v
.end(), result
.begin(),
65 std::less
<value_type
>());
66 __gnu_parallel::merge(v
.begin(), v
.end(), v
.begin(), v
.end(),
68 __gnu_parallel::merge(v
.begin(), v
.end(), v
.begin(), v
.end(),
69 result
.begin(), std::less
<value_type
>());
71 std::nth_element(v
.begin(), v
.begin() + 5, v
.end());
72 std::nth_element(v
.begin(), v
.begin() + 5, v
.end(), std::less
<value_type
>());
73 __gnu_parallel::nth_element(v
.begin(), v
.begin() + 5, v
.end());
74 __gnu_parallel::nth_element(v
.begin(), v
.begin() + 5, v
.end(),
75 std::less
<value_type
>());
77 std::partial_sort(v
.begin(), v
.begin() + 5, v
.end());
78 std::partial_sort(v
.begin(), v
.begin() + 5, v
.end(),
79 std::less
<value_type
>());
80 __gnu_parallel::partial_sort(v
.begin(), v
.begin() + 5, v
.end());
81 __gnu_parallel::partial_sort(v
.begin(), v
.begin() + 5, v
.end(),
82 std::less
<value_type
>());
84 std::min_element(v
.begin(), v
.end());
85 std::min_element(v
.begin(), v
.end(), std::less
<value_type
>());
86 __gnu_parallel::min_element(v
.begin(), v
.end());
87 __gnu_parallel::min_element(v
.begin(), v
.end(), std::less
<value_type
>());
89 std::max_element(v
.begin(), v
.end());
90 std::max_element(v
.begin(), v
.end(), std::less
<value_type
>());
91 __gnu_parallel::max_element(v
.begin(), v
.end());
92 __gnu_parallel::max_element(v
.begin(), v
.end(), std::less
<value_type
>());