21 #ifndef __TBB_SERIAL_parallel_for_H 22 #define __TBB_SERIAL_parallel_for_H 26 #ifndef __TBB_NORMAL_EXECUTION 31 #if TBB_USE_EXCEPTIONS 41 namespace interface9 {
45 template<
typename Range,
typename Body,
typename Partitioner >
53 start_for(
const Range& range,
const Body& body, Partitioner& partitioner ) :
70 static void run(
const Range& range,
const Body& body, Partitioner& partitioner ) {
71 if( !range.empty() ) {
72 ANNOTATE_SITE_BEGIN( tbb_parallel_for );
77 ANNOTATE_SITE_END( tbb_parallel_for );
82 template<
typename Range,
typename Body,
typename Partitioner >
84 if( !my_range.is_divisible() || !my_partition.is_divisible() ) {
85 ANNOTATE_TASK_BEGIN( tbb_parallel_for_range );
89 ANNOTATE_TASK_END( tbb_parallel_for_range );
91 typename Partitioner::split_type split_obj;
100 template<
typename Range,
typename Body>
107 template<
typename Range,
typename Body>
114 template<
typename Range,
typename Body>
121 template<
typename Range,
typename Body>
128 template<
typename Range,
typename Body>
134 template <
typename Index,
typename Function,
typename Partitioner>
137 #if TBB_USE_EXCEPTIONS 138 throw std::invalid_argument(
"nonpositive_step" );
140 std::cerr <<
"nonpositive step in a call to parallel_for" << std::endl;
145 ANNOTATE_SITE_BEGIN( tbb_parallel_for );
146 for( Index i =
first; i <
last; i = i + step ) {
147 ANNOTATE_TASK_BEGIN( tbb_parallel_for_iteration );
149 ANNOTATE_TASK_END( tbb_parallel_for_iteration );
151 ANNOTATE_SITE_END( tbb_parallel_for );
156 template <
typename Index,
typename Function>
161 template <
typename Index,
typename Function>
163 parallel_for_impl<Index,Function,const simple_partitioner>(
first,
last, step, f,
p);
166 template <
typename Index,
typename Function>
168 parallel_for_impl<Index,Function,const auto_partitioner>(
first,
last, step, f,
p);
171 template <
typename Index,
typename Function>
173 parallel_for_impl<Index,Function,const static_partitioner>(
first,
last, step, f,
p);
176 template <
typename Index,
typename Function>
182 template <
typename Index,
typename Function>
187 template <
typename Index,
typename Function>
189 parallel_for_impl<Index,Function,const simple_partitioner>(
first,
last, static_cast<Index>(1), f,
p);
192 template <
typename Index,
typename Function>
194 parallel_for_impl<Index,Function,const auto_partitioner>(
first,
last, static_cast<Index>(1), f,
p);
197 template <
typename Index,
typename Function>
199 parallel_for_impl<Index,Function,const static_partitioner>(
first,
last, static_cast<Index>(1), f,
p);
202 template <
typename Index,
typename Function>
213 #ifndef __TBB_NORMAL_EXECUTION Partitioner::task_partition_type my_partition
auto first(Container &c) -> decltype(begin(c))
Base class for types that should not be copied or assigned.
void const char const char int ITT_FORMAT __itt_group_sync p
auto last(Container &c) -> decltype(begin(c))
start_for(const Range &range, const Body &body, Partitioner &partitioner)
Constructor for root task.
static void run(const Range &range, const Body &body, Partitioner &partitioner)
void parallel_for_impl(Index first, Index last, Index step, const Function &f, Partitioner &)
Implementation of parallel iteration over stepped range of integers with explicit step and partitione...
start_for(start_for &parent_, typename Partitioner::split_type &split_obj)
Splitting constructor used to generate children.
#define __TBB_DEFAULT_PARTITIONER
void parallel_for(const Range &range, const Body &body)
Parallel iteration over range with default partitioner.