parallel_for_each.h
Go to the documentation of this file.
/*
Copyright (c) 2005-2020 Intel Corporation
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
#ifndef __TBB_parallel_for_each_H
#define __TBB_parallel_for_each_H
#include "parallel_do.h"
#include "parallel_for.h"
namespace tbb {
namespace internal {
// The class calls user function in operator()
template <typename Function, typename Iterator>
class parallel_for_each_body_do : internal::no_assign {
const Function &my_func;
public:
parallel_for_each_body_do(const Function &_func) : my_func(_func) {}
void operator()(typename std::iterator_traits<Iterator>::reference value) const {
my_func(value);
}
};
// The class calls user function in operator()
template <typename Function, typename Iterator>
class parallel_for_each_body_for : internal::no_assign {
const Function &my_func;
public:
parallel_for_each_body_for(const Function &_func) : my_func(_func) {}
void operator()(tbb::blocked_range<Iterator> range) const {
#if __INTEL_COMPILER
#pragma ivdep
#endif
for(Iterator it = range.begin(), end = range.end(); it != end; ++it) {
my_func(*it);
}
}
};
template<typename Iterator, typename Function, typename Generic>
struct parallel_for_each_impl {
#if __TBB_TASK_GROUP_CONTEXT
static void doit(Iterator first, Iterator last, const Function& f, task_group_context &context) {
internal::parallel_for_each_body_do<Function, Iterator> body(f);
tbb::parallel_do(first, last, body, context);
}
#endif
static void doit(Iterator first, Iterator last, const Function& f) {
internal::parallel_for_each_body_do<Function, Iterator> body(f);
tbb::parallel_do(first, last, body);
}
};
template<typename Iterator, typename Function>
struct parallel_for_each_impl<Iterator, Function, std::random_access_iterator_tag> {
#if __TBB_TASK_GROUP_CONTEXT
static void doit(Iterator first, Iterator last, const Function& f, task_group_context &context) {
internal::parallel_for_each_body_for<Function, Iterator> body(f);
tbb::parallel_for(tbb::blocked_range<Iterator>(first, last), body, context);
}
#endif
static void doit(Iterator first, Iterator last, const Function& f) {
internal::parallel_for_each_body_for<Function, Iterator> body(f);
tbb::parallel_for(tbb::blocked_range<Iterator>(first, last), body);
}
};
} // namespace internal
#if __TBB_TASK_GROUP_CONTEXT
template<typename Iterator, typename Function>
void parallel_for_each(Iterator first, Iterator last, const Function& f, task_group_context &context) {
internal::parallel_for_each_impl<Iterator, Function, typename std::iterator_traits<Iterator>::iterator_category>::doit(first, last, f, context);
}
template<typename Range, typename Function>
void parallel_for_each(Range& rng, const Function& f, task_group_context& context) {
parallel_for_each(tbb::internal::first(rng), tbb::internal::last(rng), f, context);
}
template<typename Range, typename Function>
void parallel_for_each(const Range& rng, const Function& f, task_group_context& context) {
parallel_for_each(tbb::internal::first(rng), tbb::internal::last(rng), f, context);
}
#endif /* __TBB_TASK_GROUP_CONTEXT */
template<typename Iterator, typename Function>
void parallel_for_each(Iterator first, Iterator last, const Function& f) {
internal::parallel_for_each_impl<Iterator, Function, typename std::iterator_traits<Iterator>::iterator_category>::doit(first, last, f);
}
template<typename Range, typename Function>
void parallel_for_each(Range& rng, const Function& f) {
parallel_for_each(tbb::internal::first(rng), tbb::internal::last(rng), f);
}
template<typename Range, typename Function>
void parallel_for_each(const Range& rng, const Function& f) {
parallel_for_each(tbb::internal::first(rng), tbb::internal::last(rng), f);
}
} // namespace
#endif /* __TBB_parallel_for_each_H */
parallel_do.h
end
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
Definition: ittnotify_static.h:182
value
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
Definition: ittnotify_static.h:192
tbb::parallel_do
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
tbb::parallel_for
void parallel_for(const Range &range, const Body &body)
Parallel iteration over range with default partitioner.
Definition: tbb/parallel_for.h:200
tbb::parallel_for_each
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.
Definition: parallel_for_each.h:92
tbb
The graph class.
Definition: serial/tbb/parallel_for.h:46
tbb::internal::last
auto last(Container &c) -> decltype(begin(c))
Definition: _range_iterator.h:40
tbb::internal::first
auto first(Container &c) -> decltype(begin(c))
Definition: _range_iterator.h:34
internal
Definition: _flow_graph_async_msg_impl.h:24
tbb::blocked_range
A range over which to iterate.
Definition: blocked_range.h:45
tbb::blocked_range::begin
const_iterator begin() const
Beginning of range.
Definition: blocked_range.h:69
tbb::blocked_range::end
const_iterator end() const
One past last value in range.
Definition: blocked_range.h:72
tbb::internal::parallel_for_each_body_do
Definition: parallel_for_each.h:29
tbb::internal::parallel_for_each_body_do::operator()
void operator()(typename std::iterator_traits< Iterator >::reference value) const
Definition: parallel_for_each.h:34
tbb::internal::parallel_for_each_body_do::parallel_for_each_body_do
parallel_for_each_body_do(const Function &_func)
Definition: parallel_for_each.h:32
tbb::internal::parallel_for_each_body_do::my_func
const Function & my_func
Definition: parallel_for_each.h:30
tbb::internal::parallel_for_each_body_for
Definition: parallel_for_each.h:41
tbb::internal::parallel_for_each_body_for::parallel_for_each_body_for
parallel_for_each_body_for(const Function &_func)
Definition: parallel_for_each.h:44
tbb::internal::parallel_for_each_body_for::my_func
const Function & my_func
Definition: parallel_for_each.h:42
tbb::internal::parallel_for_each_body_for::operator()
void operator()(tbb::blocked_range< Iterator > range) const
Definition: parallel_for_each.h:46
tbb::internal::parallel_for_each_impl
Definition: parallel_for_each.h:57
tbb::internal::parallel_for_each_impl::doit
static void doit(Iterator first, Iterator last, const Function &f, task_group_context &context)
Definition: parallel_for_each.h:59
tbb::internal::parallel_for_each_impl::doit
static void doit(Iterator first, Iterator last, const Function &f)
Definition: parallel_for_each.h:64
tbb::internal::parallel_for_each_impl< Iterator, Function, std::random_access_iterator_tag >::doit
static void doit(Iterator first, Iterator last, const Function &f)
Definition: parallel_for_each.h:77
tbb::internal::parallel_for_each_impl< Iterator, Function, std::random_access_iterator_tag >::doit
static void doit(Iterator first, Iterator last, const Function &f, task_group_context &context)
Definition: parallel_for_each.h:72
tbb::task_group_context
Used to form groups of tasks.
Definition: task.h:358
tbb::internal::no_assign
Base class for types that should not be assigned.
Definition: tbb_stddef.h:322
parallel_for.h

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.