17 #ifndef __TBB_parallel_for_H 18 #define __TBB_parallel_for_H 29 namespace interface9 {
38 template<
typename Range,
typename Body,
typename Partitioner>
52 start_for(
const Range& range,
const Body& body, Partitioner& partitioner ) :
80 static void run(
const Range& range,
const Body& body, Partitioner& partitioner ) {
81 if( !range.empty() ) {
82 #if !__TBB_TASK_GROUP_CONTEXT || TBB_JOIN_OUTER_TASK_GROUP 97 #if __TBB_TASK_GROUP_CONTEXT 99 if( !range.empty() ) {
111 fgt_alg_begin_body( tbb::internal::PARALLEL_FOR_TASK, (
void *)const_cast<Body*>(&(this->my_body)), (
void*)
this );
117 void offer_work(
typename Partitioner::split_type& split_obj) {
136 template<
typename Range,
typename Body,
typename Partitioner>
138 my_partition.check_being_stolen( *
this );
139 my_partition.
execute(*
this, my_range);
151 template<
typename Function,
typename Index>
169 #if __TBB_ASSERT_ON_VECTORIZATION_FAILURE 170 #pragma vector always assert 173 for ( Index i = b; i < e; ++i, k += ms ) {
196 template<
typename Range,
typename Body>
203 template<
typename Range,
typename Body>
210 template<
typename Range,
typename Body>
217 template<
typename Range,
typename Body>
224 template<
typename Range,
typename Body>
229 #if __TBB_TASK_GROUP_CONTEXT 232 template<
typename Range,
typename Body>
239 template<
typename Range,
typename Body>
246 template<
typename Range,
typename Body>
253 template<
typename Range,
typename Body>
260 template<
typename Range,
typename Body>
267 namespace strict_ppl {
270 template <
typename Index,
typename Function,
typename Partitioner>
277 Index
end = (
last -
first - Index(1)) / step + Index(1);
279 internal::parallel_for_body<Function, Index> body(f,
first, step);
285 template <
typename Index,
typename Function>
290 template <
typename Index,
typename Function>
292 parallel_for_impl<Index,Function,const simple_partitioner>(
first,
last, step, f, partitioner);
295 template <
typename Index,
typename Function>
297 parallel_for_impl<Index,Function,const auto_partitioner>(
first,
last, step, f, partitioner);
300 template <
typename Index,
typename Function>
302 parallel_for_impl<Index,Function,const static_partitioner>(
first,
last, step, f, partitioner);
305 template <
typename Index,
typename Function>
311 template <
typename Index,
typename Function>
316 template <
typename Index,
typename Function>
318 parallel_for_impl<Index,Function,const simple_partitioner>(
first,
last, static_cast<Index>(1), f, partitioner);
321 template <
typename Index,
typename Function>
323 parallel_for_impl<Index,Function,const auto_partitioner>(
first,
last, static_cast<Index>(1), f, partitioner);
326 template <
typename Index,
typename Function>
328 parallel_for_impl<Index,Function,const static_partitioner>(
first,
last, static_cast<Index>(1), f, partitioner);
331 template <
typename Index,
typename Function>
336 #if __TBB_TASK_GROUP_CONTEXT 337 template <
typename Index,
typename Function,
typename Partitioner>
344 Index
end = (
last -
first - Index(1)) / step + Index(1);
346 internal::parallel_for_body<Function, Index> body(f,
first, step);
352 template <
typename Index,
typename Function>
357 template <
typename Index,
typename Function>
359 parallel_for_impl<Index,Function,const simple_partitioner>(
first,
last, step, f, partitioner, context);
362 template <
typename Index,
typename Function>
364 parallel_for_impl<Index,Function,const auto_partitioner>(
first,
last, step, f, partitioner, context);
367 template <
typename Index,
typename Function>
369 parallel_for_impl<Index,Function,const static_partitioner>(
first,
last, step, f, partitioner, context);
372 template <
typename Index,
typename Function>
379 template <
typename Index,
typename Function>
381 parallel_for_impl<Index,Function,const auto_partitioner>(
first,
last, static_cast<Index>(1), f,
auto_partitioner(), context);
384 template <
typename Index,
typename Function>
386 parallel_for_impl<Index,Function,const simple_partitioner>(
first,
last, static_cast<Index>(1), f, partitioner, context);
389 template <
typename Index,
typename Function>
391 parallel_for_impl<Index,Function,const auto_partitioner>(
first,
last, static_cast<Index>(1), f, partitioner, context);
394 template <
typename Index,
typename Function>
396 parallel_for_impl<Index,Function,const static_partitioner>(
first,
last, static_cast<Index>(1), f, partitioner, context);
399 template <
typename Index,
typename Function>
413 #if TBB_PREVIEW_SERIAL_SUBSET 414 #define __TBB_NORMAL_EXECUTION 415 #include "../serial/tbb/parallel_for.h" 416 #undef __TBB_NORMAL_EXECUTION void * allocate_sibling(task *start_for_task, size_t bytes)
allocate right task with new parent
void parallel_for(const Range &range, const Body &body)
Parallel iteration over range with default partitioner.
auto last(Container &c) -> decltype(begin(c))
const_iterator end() const
One past last value in range.
task_group_context * context()
This method is deprecated and will be removed in the future.
Calls the function with values from range [begin, end) with a step provided.
static void spawn_root_and_wait(task &root)
Spawn task allocated by allocate_root, wait for it to complete, and deallocate it.
parallel_for_body(const Function &_func, Index &_begin, Index &_step)
const_iterator begin() const
Beginning of range.
auto first(Container &c) -> decltype(begin(c))
static void fgt_alg_end_body(void *)
void parallel_for_impl(Index first, Index last, Index step, const Function &f, Partitioner &partitioner)
Implementation of parallel iteration over stepped range of integers with explicit step and partitione...
void run_body(Range &r)
Run body for range, serves as callback for partitioner.
Used to form groups of tasks.
void note_affinity(affinity_id id) __TBB_override
Update affinity info, if any.
static void fgt_algorithm(string_index, void *, void *)
internal::allocate_child_proxy & allocate_child()
Returns proxy for overloaded new that allocates a child task of *this.
static void run(const Range &range, const Body &body, Partitioner &partitioner)
static void run(const Range &range, const Body &body, Partitioner &partitioner, task_group_context &context)
Task type used in parallel_for.
static void fgt_begin_algorithm(string_index, void *)
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
start_for(const Range &range, const Body &body, Partitioner &partitioner)
Constructor for root task.
task * execute() __TBB_override
execute task for parallel_for
Partitioner::task_partition_type my_partition
void set_ref_count(int count)
Set reference count.
#define __TBB_DEFAULT_PARTITIONER
void offer_work(typename Partitioner::split_type &split_obj)
spawn right task, serves as callback for partitioner
internal::affinity_id affinity_id
An id as used for specifying affinity.
Base class for user-defined tasks.
void offer_work(const Range &r, depth_t d=0)
spawn right task, serves as callback for partitioner
internal::allocate_continuation_proxy & allocate_continuation()
Returns proxy for overloaded new that allocates a continuation task of *this.
static internal::allocate_root_proxy allocate_root()
Returns proxy for overloaded new that allocates a root task.
static void fgt_alg_begin_body(string_index, void *, void *)
virtual task * execute()=0
Should be overridden by derived classes.
A range over which to iterate.
void parallel_for(Index first, Index last, Index step, const Function &f)
Parallel iteration over a range of integers with a step provided and default partitioner.
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 * task
void set_parent(task *p)
sets parent task pointer to specified value
Join task node that contains shared flag for stealing feedback.
static void fgt_end_algorithm(void *)
void operator()(const tbb::blocked_range< Index > &r) const
start_for(start_for &parent_, typename Partitioner::split_type &split_obj)
Splitting constructor used to generate children.
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
start_for(start_for &parent_, const Range &r, depth_t d)
Construct right child from the given range as response to the demand.
void throw_exception(exception_id eid)
Versionless convenience wrapper for throw_exception_v4()
Dummy type that distinguishes splitting constructor from copy constructor.