Template Function sequant::for_each¶
Defined in File runtime.hpp
Function Documentation¶
-
template<typename SizedRange, typename UnaryOp>
void sequant::for_each(SizedRange &rng, const UnaryOp &op)¶ Parallel version of std::for_each , using either parallel C++ algorithms or manual threaded implementation with at most
nthreadsinstances executing concurrently, wherenthreadsis the value returned by get_num_threads() .See also
get_num_threads()
Note
The load is balanced dynamically.
Note
each invocation of
opsees the scoped contexts of the calling thread- Template Parameters:
SizedRange – a sied range
UnaryOp – a function type for which
Lambda(int)is valid
- Parameters:
rng – the
SizedRangeobjectop – the function object to execute, each will be invoked as
op(std::advance(begin(rng) + task_id)) wheretask_idis an integer in[0,size(rng)) .op(t1)will be commenced not afterop(t2)ift1<t2.
- Throws:
the – exception thrown by an invocation of
op, once all have finished; ParallelExceptions if several throw