2 #include <tbb/blocked_range.h>
3 #include <tbb/parallel_for.h>
4 #include <tbb/parallel_reduce.h>
5 #include <tbb/task_arena.h>
6 #include <tbb/task_group.h>
9 namespace threading_tbb {
11 using tbb::blocked_range;
12 using tbb::task_arena;
13 using tbb::task_group;
14 namespace this_task_arena {
15 using namespace tbb::this_task_arena;
19 template <
typename...
X>
26 template <
typename...
X>
29 return this_task_arena::isolate(
45 std::unique_ptr<tbb_packaged_task<T>>
task_;
60 std::unique_ptr<tbb_packaged_task<void>>
task_;
67 void get() { wait(); }
70 template <
typename Fn,
72 typename Result = std::result_of_t<Fn && (Args && ...)>>
74 auto f = std::bind(std::forward<Fn>(fn), std::forward<Args>(
args)...);
75 auto ptask = std::make_unique<tbb_packaged_task<Result>>();
76 #if TBB_INTERFACE_VERSION >= 12040
future(std::unique_ptr< tbb_packaged_task< void >> &&p)
future(std::unique_ptr< tbb_packaged_task< T >> &&p)
tbb::task_arena g_tbb_arena
auto parallel_reduce(X &&...x) -> decltype(tbb::parallel_reduce(std::forward< X >(x)...))
Value parallel_reduce(const blocked_range< Int > &range, const Value &identity, const RealBody &real_body, const Reduction &reduction, const Partitioner &p=Partitioner())
Parallel iteration with reduction.
torch::Tensor f(torch::Tensor x, torch::Tensor W_target, torch::Tensor b_target)
void parallel_for(const blocked_range< Int > &range, const Body &body, const Partitioner &p=Partitioner())
std::unique_ptr< tbb_packaged_task< T > > task_
std::unique_ptr< tbb_packaged_task< void > > task_
future< Result > async(Fn &&fn, Args &&...args)
void parallel_for(X &&...x)