re PR target/37283 (Cannot build crtbegin.o for ARM)
[official-gcc.git] / libstdc++-v3 / include / parallel / for_each.h
blobdf9d4f338a1a03786f527241eb0d5b0cdca9cf37
1 // -*- C++ -*-
3 // Copyright (C) 2007, 2008 Free Software Foundation, Inc.
4 //
5 // This file is part of the GNU ISO C++ Library. This library is free
6 // software; you can redistribute it and/or modify it under the terms
7 // of the GNU General Public License as published by the Free Software
8 // Foundation; either version 2, or (at your option) any later
9 // version.
11 // This library is distributed in the hope that it will be useful, but
12 // WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // General Public License for more details.
16 // You should have received a copy of the GNU General Public License
17 // along with this library; see the file COPYING. If not, write to
18 // the Free Software Foundation, 59 Temple Place - Suite 330, Boston,
19 // MA 02111-1307, USA.
21 // As a special exception, you may use this file as part of a free
22 // software library without restriction. Specifically, if other files
23 // instantiate templates or use macros or inline functions from this
24 // file, or you compile this file and link it with other files to
25 // produce an executable, this file does not by itself cause the
26 // resulting executable to be covered by the GNU General Public
27 // License. This exception does not however invalidate any other
28 // reasons why the executable file might be covered by the GNU General
29 // Public License.
31 /** @file parallel/for_each.h
32 * @brief Main interface for embarrassingly parallel functions.
34 * The explicit implementation are in other header files, like
35 * workstealing.h, par_loop.h, omp_loop.h, and omp_loop_static.h.
36 * This file is a GNU parallel extension to the Standard C++ Library.
39 // Written by Felix Putze.
41 #ifndef _GLIBCXX_PARALLEL_FOR_EACH_H
42 #define _GLIBCXX_PARALLEL_FOR_EACH_H 1
44 #include <parallel/settings.h>
45 #include <parallel/par_loop.h>
46 #include <parallel/omp_loop.h>
47 #include <parallel/workstealing.h>
49 namespace __gnu_parallel
51 /** @brief Chose the desired algorithm by evaluating @c parallelism_tag.
52 * @param begin Begin iterator of input sequence.
53 * @param end End iterator of input sequence.
54 * @param user_op A user-specified functor (comparator, predicate,
55 * associative operator,...)
56 * @param functionality functor to "process" an element with
57 * user_op (depends on desired functionality, e. g. accumulate,
58 * for_each,...
59 * @param reduction Reduction functor.
60 * @param reduction_start Initial value for reduction.
61 * @param output Output iterator.
62 * @param bound Maximum number of elements processed.
63 * @param parallelism_tag Parallelization method */
64 template<typename InputIterator, typename UserOp,
65 typename Functionality, typename Red, typename Result>
66 UserOp
67 for_each_template_random_access(InputIterator begin, InputIterator end,
68 UserOp user_op,
69 Functionality& functionality,
70 Red reduction, Result reduction_start,
71 Result& output, typename
72 std::iterator_traits<InputIterator>::
73 difference_type bound,
74 _Parallelism parallelism_tag)
76 if (parallelism_tag == parallel_unbalanced)
77 return for_each_template_random_access_ed(begin, end, user_op,
78 functionality, reduction,
79 reduction_start,
80 output, bound);
81 else if (parallelism_tag == parallel_omp_loop)
82 return for_each_template_random_access_omp_loop(begin, end, user_op,
83 functionality,
84 reduction,
85 reduction_start,
86 output, bound);
87 else if (parallelism_tag == parallel_omp_loop_static)
88 return for_each_template_random_access_omp_loop(begin, end, user_op,
89 functionality,
90 reduction,
91 reduction_start,
92 output, bound);
93 else //e. g. parallel_balanced
94 return for_each_template_random_access_workstealing(begin, end,
95 user_op,
96 functionality,
97 reduction,
98 reduction_start,
99 output, bound);
103 #endif /* _GLIBCXX_PARALLEL_FOR_EACH_H */