]> git.ipfire.org Git - thirdparty/gcc.git/blame - libstdc++-v3/include/parallel/for_each.h
Update copyright years.
[thirdparty/gcc.git] / libstdc++-v3 / include / parallel / for_each.h
CommitLineData
c2ba9709
JS
1// -*- C++ -*-
2
85ec4feb 3// Copyright (C) 2007-2018 Free Software Foundation, Inc.
c2ba9709
JS
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
748086b7 8// Foundation; either version 3, or (at your option) any later
c2ba9709
JS
9// version.
10
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.
15
748086b7
JJ
16// Under Section 7 of GPL version 3, you are granted additional
17// permissions described in the GCC Runtime Library Exception, version
18// 3.1, as published by the Free Software Foundation.
19
20// You should have received a copy of the GNU General Public License and
21// a copy of the GCC Runtime Library Exception along with this program;
22// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
23// <http://www.gnu.org/licenses/>.
c2ba9709
JS
24
25/** @file parallel/for_each.h
a3e6b31a 26 * @brief Main interface for embarrassingly parallel functions.
c2ba9709
JS
27 *
28 * The explicit implementation are in other header files, like
29 * workstealing.h, par_loop.h, omp_loop.h, and omp_loop_static.h.
30 * This file is a GNU parallel extension to the Standard C++ Library.
31 */
32
33// Written by Felix Putze.
34
35#ifndef _GLIBCXX_PARALLEL_FOR_EACH_H
36#define _GLIBCXX_PARALLEL_FOR_EACH_H 1
37
38#include <parallel/settings.h>
39#include <parallel/par_loop.h>
40#include <parallel/omp_loop.h>
41#include <parallel/workstealing.h>
42
43namespace __gnu_parallel
44{
8e32aa11 45 /** @brief Chose the desired algorithm by evaluating @c __parallelism_tag.
1acba85b
JS
46 * @param __begin Begin iterator of input sequence.
47 * @param __end End iterator of input sequence.
48 * @param __user_op A user-specified functor (comparator, predicate,
c2ba9709 49 * associative operator,...)
2a60a9f6 50 * @param __functionality functor to @a process an element with
1acba85b 51 * __user_op (depends on desired functionality, e. g. accumulate,
c2ba9709 52 * for_each,...
1acba85b
JS
53 * @param __reduction Reduction functor.
54 * @param __reduction_start Initial value for reduction.
55 * @param __output Output iterator.
56 * @param __bound Maximum number of elements processed.
57 * @param __parallelism_tag Parallelization method */
58 template<typename _IIter, typename _UserOp,
15ac3c72 59 typename _Functionality, typename _Red, typename _Result>
1acba85b
JS
60 _UserOp
61 __for_each_template_random_access(_IIter __begin, _IIter __end,
15ac3c72
JS
62 _UserOp __user_op,
63 _Functionality& __functionality,
64 _Red __reduction,
65 _Result __reduction_start,
66 _Result& __output, typename
67 std::iterator_traits<_IIter>::
68 difference_type __bound,
69 _Parallelism __parallelism_tag)
531898c3 70 {
1acba85b 71 if (__parallelism_tag == parallel_unbalanced)
77d16198
PC
72 return __for_each_template_random_access_ed
73 (__begin, __end, __user_op, __functionality, __reduction,
74 __reduction_start, __output, __bound);
1acba85b 75 else if (__parallelism_tag == parallel_omp_loop)
77d16198
PC
76 return __for_each_template_random_access_omp_loop
77 (__begin, __end, __user_op, __functionality, __reduction,
78 __reduction_start, __output, __bound);
1acba85b 79 else if (__parallelism_tag == parallel_omp_loop_static)
77d16198
PC
80 return __for_each_template_random_access_omp_loop
81 (__begin, __end, __user_op, __functionality, __reduction,
82 __reduction_start, __output, __bound);
15ac3c72 83 else //e. g. parallel_balanced
77d16198
PC
84 return __for_each_template_random_access_workstealing
85 (__begin, __end, __user_op, __functionality, __reduction,
86 __reduction_start, __output, __bound);
c2ba9709
JS
87 }
88}
89
cbcd1e45 90#endif /* _GLIBCXX_PARALLEL_FOR_EACH_H */