Home ⌂Doc Index ◂Up ▴
Intel(R) Threading Building Blocks Doxygen Documentation  version 4.2.3
parallel_for_each.h
Go to the documentation of this file.
1 /*
2  Copyright (c) 2005-2020 Intel Corporation
3 
4  Licensed under the Apache License, Version 2.0 (the "License");
5  you may not use this file except in compliance with the License.
6  You may obtain a copy of the License at
7 
8  http://www.apache.org/licenses/LICENSE-2.0
9 
10  Unless required by applicable law or agreed to in writing, software
11  distributed under the License is distributed on an "AS IS" BASIS,
12  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  See the License for the specific language governing permissions and
14  limitations under the License.
15 */
16 
17 #ifndef __TBB_parallel_for_each_H
18 #define __TBB_parallel_for_each_H
19 
20 #include "parallel_do.h"
21 #include "parallel_for.h"
22 
23 namespace tbb {
24 
26 namespace internal {
27  // The class calls user function in operator()
28  template <typename Function, typename Iterator>
30  const Function &my_func;
31  public:
32  parallel_for_each_body_do(const Function &_func) : my_func(_func) {}
33 
34  void operator()(typename std::iterator_traits<Iterator>::reference value) const {
35  my_func(value);
36  }
37  };
38 
39  // The class calls user function in operator()
40  template <typename Function, typename Iterator>
42  const Function &my_func;
43  public:
44  parallel_for_each_body_for(const Function &_func) : my_func(_func) {}
45 
47 #if __INTEL_COMPILER
48 #pragma ivdep
49 #endif
50  for(Iterator it = range.begin(), end = range.end(); it != end; ++it) {
51  my_func(*it);
52  }
53  }
54  };
55 
56  template<typename Iterator, typename Function, typename Generic>
58 #if __TBB_TASK_GROUP_CONTEXT
59  static void doit(Iterator first, Iterator last, const Function& f, task_group_context &context) {
61  tbb::parallel_do(first, last, body, context);
62  }
63 #endif
64  static void doit(Iterator first, Iterator last, const Function& f) {
66  tbb::parallel_do(first, last, body);
67  }
68  };
69  template<typename Iterator, typename Function>
70  struct parallel_for_each_impl<Iterator, Function, std::random_access_iterator_tag> {
71 #if __TBB_TASK_GROUP_CONTEXT
72  static void doit(Iterator first, Iterator last, const Function& f, task_group_context &context) {
75  }
76 #endif
77  static void doit(Iterator first, Iterator last, const Function& f) {
80  }
81  };
82 } // namespace internal
84 
88 
90 #if __TBB_TASK_GROUP_CONTEXT
91 template<typename Iterator, typename Function>
92 void parallel_for_each(Iterator first, Iterator last, const Function& f, task_group_context &context) {
94 }
95 
97 
98 template<typename Range, typename Function>
99 void parallel_for_each(Range& rng, const Function& f, task_group_context& context) {
101 }
102 
104 
105 template<typename Range, typename Function>
106 void parallel_for_each(const Range& rng, const Function& f, task_group_context& context) {
108 }
109 #endif /* __TBB_TASK_GROUP_CONTEXT */
110 
112 template<typename Iterator, typename Function>
113 void parallel_for_each(Iterator first, Iterator last, const Function& f) {
115 }
116 
118 template<typename Range, typename Function>
119 void parallel_for_each(Range& rng, const Function& f) {
121 }
122 
124 template<typename Range, typename Function>
125 void parallel_for_each(const Range& rng, const Function& f) {
127 }
128 
130 
131 } // namespace
132 
133 #endif /* __TBB_parallel_for_each_H */
void const char const char int ITT_FORMAT __itt_group_sync x void const char ITT_FORMAT __itt_group_sync s void ITT_FORMAT __itt_group_sync p void ITT_FORMAT p void ITT_FORMAT p no args __itt_suppress_mode_t unsigned int void size_t ITT_FORMAT d void ITT_FORMAT p void ITT_FORMAT p __itt_model_site __itt_model_site_instance ITT_FORMAT p __itt_model_task __itt_model_task_instance ITT_FORMAT p void ITT_FORMAT p void ITT_FORMAT p void size_t ITT_FORMAT d void ITT_FORMAT p const wchar_t ITT_FORMAT s const char ITT_FORMAT s const char ITT_FORMAT s const char ITT_FORMAT s no args void ITT_FORMAT p size_t ITT_FORMAT d no args const wchar_t const wchar_t ITT_FORMAT s __itt_heap_function void size_t int ITT_FORMAT d __itt_heap_function void ITT_FORMAT p __itt_heap_function void void size_t int ITT_FORMAT d no args no args unsigned int ITT_FORMAT u const __itt_domain __itt_id ITT_FORMAT lu const __itt_domain __itt_id __itt_id __itt_string_handle ITT_FORMAT p const __itt_domain __itt_id ITT_FORMAT p const __itt_domain __itt_id __itt_timestamp __itt_timestamp end
parallel_for_each_body_for(const Function &_func)
Used to form groups of tasks.
Definition: task.h:358
void operator()(tbb::blocked_range< Iterator > range) const
static void doit(Iterator first, Iterator last, const Function &f)
void parallel_for(const Range &range, const Body &body)
Parallel iteration over range with default partitioner.
Base class for types that should not be assigned.
Definition: tbb_stddef.h:322
static void doit(Iterator first, Iterator last, const Function &f, task_group_context &context)
parallel_for_each_body_do(const Function &_func)
auto last(Container &c) -> decltype(begin(c))
void parallel_for_each(Iterator first, Iterator last, const Function &f, task_group_context &context)
Calls function f for all items from [first, last) interval using user-supplied context.
const_iterator begin() const
Beginning of range.
Definition: blocked_range.h:69
static void doit(Iterator first, Iterator last, const Function &f, task_group_context &context)
void operator()(typename std::iterator_traits< Iterator >::reference value) const
auto first(Container &c) -> decltype(begin(c))
void parallel_do(Iterator first, Iterator last, const Body &body)
Parallel iteration over a range, with optional addition of more work.
Definition: parallel_do.h:497
A range over which to iterate.
Definition: blocked_range.h:45
const_iterator end() const
One past last value in range.
Definition: blocked_range.h:72
void const char const char int ITT_FORMAT __itt_group_sync x void const char ITT_FORMAT __itt_group_sync s void ITT_FORMAT __itt_group_sync p void ITT_FORMAT p void ITT_FORMAT p no args __itt_suppress_mode_t unsigned int void size_t ITT_FORMAT d void ITT_FORMAT p void ITT_FORMAT p __itt_model_site __itt_model_site_instance ITT_FORMAT p __itt_model_task __itt_model_task_instance ITT_FORMAT p void ITT_FORMAT p void ITT_FORMAT p void size_t ITT_FORMAT d void ITT_FORMAT p const wchar_t ITT_FORMAT s const char ITT_FORMAT s const char ITT_FORMAT s const char ITT_FORMAT s no args void ITT_FORMAT p size_t ITT_FORMAT d no args const wchar_t const wchar_t ITT_FORMAT s __itt_heap_function void size_t int ITT_FORMAT d __itt_heap_function void ITT_FORMAT p __itt_heap_function void void size_t int ITT_FORMAT d no args no args unsigned int ITT_FORMAT u const __itt_domain __itt_id ITT_FORMAT lu const __itt_domain __itt_id __itt_id __itt_string_handle ITT_FORMAT p const __itt_domain __itt_id ITT_FORMAT p const __itt_domain __itt_id __itt_timestamp __itt_timestamp ITT_FORMAT lu const __itt_domain __itt_id __itt_id __itt_string_handle ITT_FORMAT p const __itt_domain ITT_FORMAT p const __itt_domain __itt_string_handle unsigned long long value
The graph class.

Copyright © 2005-2020 Intel Corporation. All Rights Reserved.

Intel, Pentium, Intel Xeon, Itanium, Intel XScale and VTune are registered trademarks or trademarks of Intel Corporation or its subsidiaries in the United States and other countries.

* Other names and brands may be claimed as the property of others.