21 #ifndef mia_core_parallel_hh 22 #define mia_core_parallel_hh 25 #include <miaconfig.h> 31 #include <tbb/task_scheduler_init.h> 32 #include <tbb/recursive_mutex.h> 33 #include <tbb/mutex.h> 34 #include <tbb/parallel_for.h> 35 #include <tbb/parallel_reduce.h> 36 #include <tbb/blocked_range.h> 37 #include <tbb/recursive_mutex.h> 38 #include <tbb/spin_mutex.h> 49 #define ATOMIC tbb::atomic 51 template <
typename Range,
typename Func>
52 void pfor(
const Range& range, Func body) {
53 tbb::parallel_for(range, body);
56 template<
typename Range,
typename Value,
57 typename Func,
typename Reduction>
58 Value
preduce(
const Range& range,
const Value& identity,
59 const Func& func,
const Reduction& reduction) {
60 return tbb::parallel_reduce(range, identity, func, reduction);
65 #else // no TBB: use C++ 11 thread void pfor(Range range, const Func &f)
TScopedLock< CRecursiveMutex > CRecursiveScopedLock
#define NS_MIA_BEGIN
conveniance define to start the mia namespace
std::recursive_mutex CRecursiveMutex
Value preduce(Range range, Value identity, const Func &f, Reduce r)
TScopedLock< CMutex > CScopedLock
#define NS_MIA_END
conveniance define to end the mia namespace