21 #ifndef __TBB_parallel_for_H 22 #define __TBB_parallel_for_H 33 namespace interface9 {
42 template<
typename Range,
typename Body,
typename Partitioner>
56 start_for(
const Range& range,
const Body& body, Partitioner& partitioner ) :
84 static void run(
const Range& range,
const Body& body, Partitioner& partitioner ) {
85 if( !range.empty() ) {
86 #if !__TBB_TASK_GROUP_CONTEXT || TBB_JOIN_OUTER_TASK_GROUP 101 #if __TBB_TASK_GROUP_CONTEXT 103 if( !range.empty() ) {
115 fgt_alg_begin_body( tbb::internal::PARALLEL_FOR_TASK, (
void *)const_cast<Body*>(&(this->my_body)), (
void*)
this );
121 void offer_work(
typename Partitioner::split_type& split_obj) {
140 template<
typename Range,
typename Body,
typename Partitioner>
142 my_partition.check_being_stolen( *
this );
143 my_partition.
execute(*
this, my_range);
155 template<
typename Function,
typename Index>
173 #if __TBB_ASSERT_ON_VECTORIZATION_FAILURE 174 #pragma vector always assert 177 for ( Index i = b; i < e; ++i, k += ms ) {
200 template<
typename Range,
typename Body>
207 template<
typename Range,
typename Body>
214 template<
typename Range,
typename Body>
221 template<
typename Range,
typename Body>
228 template<
typename Range,
typename Body>
233 #if __TBB_TASK_GROUP_CONTEXT 236 template<
typename Range,
typename Body>
243 template<
typename Range,
typename Body>
250 template<
typename Range,
typename Body>
257 template<
typename Range,
typename Body>
264 template<
typename Range,
typename Body>
271 namespace strict_ppl {
274 template <
typename Index,
typename Function,
typename Partitioner>
281 Index
end = (
last -
first - Index(1)) / step + Index(1);
283 internal::parallel_for_body<Function, Index> body(f,
first, step);
289 template <
typename Index,
typename Function>
294 template <
typename Index,
typename Function>
296 parallel_for_impl<Index,Function,const simple_partitioner>(
first,
last, step, f, partitioner);
299 template <
typename Index,
typename Function>
301 parallel_for_impl<Index,Function,const auto_partitioner>(
first,
last, step, f, partitioner);
304 template <
typename Index,
typename Function>
306 parallel_for_impl<Index,Function,const static_partitioner>(
first,
last, step, f, partitioner);
309 template <
typename Index,
typename Function>
315 template <
typename Index,
typename Function>
320 template <
typename Index,
typename Function>
322 parallel_for_impl<Index,Function,const simple_partitioner>(
first,
last, static_cast<Index>(1), f, partitioner);
325 template <
typename Index,
typename Function>
327 parallel_for_impl<Index,Function,const auto_partitioner>(
first,
last, static_cast<Index>(1), f, partitioner);
330 template <
typename Index,
typename Function>
332 parallel_for_impl<Index,Function,const static_partitioner>(
first,
last, static_cast<Index>(1), f, partitioner);
335 template <
typename Index,
typename Function>
340 #if __TBB_TASK_GROUP_CONTEXT 341 template <
typename Index,
typename Function,
typename Partitioner>
348 Index
end = (
last -
first - Index(1)) / step + Index(1);
350 internal::parallel_for_body<Function, Index> body(f,
first, step);
356 template <
typename Index,
typename Function>
361 template <
typename Index,
typename Function>
363 parallel_for_impl<Index,Function,const simple_partitioner>(
first,
last, step, f, partitioner, context);
366 template <
typename Index,
typename Function>
368 parallel_for_impl<Index,Function,const auto_partitioner>(
first,
last, step, f, partitioner, context);
371 template <
typename Index,
typename Function>
373 parallel_for_impl<Index,Function,const static_partitioner>(
first,
last, step, f, partitioner, context);
376 template <
typename Index,
typename Function>
383 template <
typename Index,
typename Function>
385 parallel_for_impl<Index,Function,const auto_partitioner>(
first,
last, static_cast<Index>(1), f,
auto_partitioner(), context);
388 template <
typename Index,
typename Function>
390 parallel_for_impl<Index,Function,const simple_partitioner>(
first,
last, static_cast<Index>(1), f, partitioner, context);
393 template <
typename Index,
typename Function>
395 parallel_for_impl<Index,Function,const auto_partitioner>(
first,
last, static_cast<Index>(1), f, partitioner, context);
398 template <
typename Index,
typename Function>
400 parallel_for_impl<Index,Function,const static_partitioner>(
first,
last, static_cast<Index>(1), f, partitioner, context);
403 template <
typename Index,
typename Function>
417 #if TBB_PREVIEW_SERIAL_SUBSET 418 #define __TBB_NORMAL_EXECUTION 419 #include "../serial/tbb/parallel_for.h" 420 #undef __TBB_NORMAL_EXECUTION 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
const_iterator begin() const
Beginning of range.
internal::allocate_child_proxy & allocate_child()
Returns proxy for overloaded new that allocates a child task of *this.
Calls the function with values from range [begin, end) with a step provided.
static void fgt_alg_begin_body(string_index, void *, void *)
void note_affinity(affinity_id id) __TBB_override
Update affinity info, if any.
A range over which to iterate.
virtual task * execute()=0
Should be overridden by derived classes.
auto first(Container &c) -> decltype(begin(c))
Used to form groups of tasks.
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
static void spawn_root_and_wait(task &root)
Spawn task allocated by allocate_root, wait for it to complete, and deallocate it.
void * allocate_sibling(task *start_for_task, size_t bytes)
allocate right task with new parent
Base class for user-defined tasks.
void set_parent(task *p)
sets parent task pointer to specified value
static void fgt_end_algorithm(void *)
void offer_work(const Range &r, depth_t d=0)
spawn right task, serves as callback for partitioner
void throw_exception(exception_id eid)
Versionless convenience wrapper for throw_exception_v4()
static void fgt_begin_algorithm(string_index, void *)
internal::affinity_id affinity_id
An id as used for specifying affinity.
auto last(Container &c) -> decltype(begin(c))
start_for(start_for &parent_, typename Partitioner::split_type &split_obj)
Splitting constructor used to generate children.
internal::allocate_continuation_proxy & allocate_continuation()
Returns proxy for overloaded new that allocates a continuation task of *this.
const_iterator end() const
One past last value in range.
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
Partitioner::task_partition_type my_partition
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.
Dummy type that distinguishes splitting constructor from copy constructor.
task * execute() __TBB_override
execute task for parallel_for
Task type used in parallel_for.
void parallel_for(const Range &range, const Body &body)
Parallel iteration over range with default partitioner.
static void run(const Range &range, const Body &body, Partitioner &partitioner)
static void fgt_alg_end_body(void *)
#define __TBB_DEFAULT_PARTITIONER
void operator()(const tbb::blocked_range< Index > &r) const
static void run(const Range &range, const Body &body, Partitioner &partitioner, task_group_context &context)
void set_ref_count(int count)
Set reference count.
parallel_for_body(const Function &_func, Index &_begin, Index &_step)
void offer_work(typename Partitioner::split_type &split_obj)
spawn right task, serves as callback for partitioner
task_group_context * context()
This method is deprecated and will be removed in the future.
static internal::allocate_root_proxy allocate_root()
Returns proxy for overloaded new that allocates a root task.
static void fgt_algorithm(string_index, void *, void *)
Join task node that contains shared flag for stealing feedback.
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...
start_for(start_for &parent_, const Range &r, depth_t d)
Construct right child from the given range as response to the demand.
void run_body(Range &r)
Run body for range, serves as callback for partitioner.
start_for(const Range &range, const Body &body, Partitioner &partitioner)
Constructor for root task.