]> git.ipfire.org Git - thirdparty/gcc.git/blob - libstdc++-v3/testsuite/25_algorithms/headers/algorithm/parallel_algorithm_mixed2.cc
Update copyright years.
[thirdparty/gcc.git] / libstdc++-v3 / testsuite / 25_algorithms / headers / algorithm / parallel_algorithm_mixed2.cc
1 // { dg-do compile }
2 // { dg-require-parallel-mode "" }
3 // { dg-options "-fopenmp" { target *-*-* } }
4
5 // Copyright (C) 2007-2019 Free Software Foundation, Inc.
6 //
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)
11 // any later version.
12
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.
17
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/>.
21
22 // Make sure to test without _GLIBCXX_PARALLEL
23 #ifdef _GLIBCXX_PARALLEL
24 # undef _GLIBCXX_PARALLEL
25 #endif
26
27 #include <parallel/algorithm>
28 #include <vector>
29 #include <algorithm>
30
31 void test()
32 {
33 typedef unsigned short value_type;
34 typedef std::vector<value_type> vector_type;
35
36 const value_type c(0);
37
38 vector_type v(10), result(20);
39
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>());
45
46 std::find(v.begin(), v.end(), c);
47 __gnu_parallel::find(v.begin(), v.end(), c);
48
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>());
55
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>());
62
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(),
67 result.begin());
68 __gnu_parallel::merge(v.begin(), v.end(), v.begin(), v.end(),
69 result.begin(), std::less<value_type>());
70
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>());
76
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>());
83
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>());
88
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>());
93 }