35 #ifndef _BLAZE_MATH_SMP_THREADS_THREADBACKEND_H_
36 #define _BLAZE_MATH_SMP_THREADS_THREADBACKEND_H_
43 #if BLAZE_CPP_THREADS_PARALLEL_MODE
44 # include <condition_variable>
47 #elif BLAZE_BOOST_THREADS_PARALLEL_MODE
48 # include <boost/thread/condition.hpp>
49 # include <boost/thread/mutex.hpp>
50 # include <boost/thread/thread.hpp>
90 static inline size_t size ();
91 static inline void resize(
size_t n,
bool block=
false );
92 static inline void wait ();
99 template<
typename Target,
typename Source >
100 static inline void scheduleAssign( Target& target,
const Source& source );
102 template<
typename Target,
typename Source >
103 static inline void scheduleAddAssign( Target& target,
const Source& source );
105 template<
typename Target,
typename Source >
106 static inline void scheduleSubAssign( Target& target,
const Source& source );
108 template<
typename Target,
typename Source >
109 static inline void scheduleMultAssign( Target& target,
const Source& source );
117 template<
typename Target
127 explicit inline Assigner( Target& target,
const Source& source )
138 inline void operator()() {
139 assign( target_, source_ );
145 const Source source_;
158 template<
typename Target
168 explicit inline AddAssigner( Target& target,
const Source& source )
179 inline void operator()() {
186 const Source source_;
199 template<
typename Target
209 explicit inline SubAssigner( Target& target,
const Source& source )
220 inline void operator()() {
227 const Source source_;
240 template<
typename Target
250 explicit inline MultAssigner( Target& target,
const Source& source )
261 inline void operator()() {
268 const Source source_;
281 static inline size_t initPool();
288 static ThreadPool<TT,MT,LT,CT> threadpool_;
311 template<
typename TT,
typename MT,
typename LT,
typename CT >
312 ThreadPool<TT,MT,LT,CT> ThreadBackend<TT,MT,LT,CT>::threadpool_( initPool() );
331 template<
typename TT
335 inline size_t ThreadBackend<TT,MT,LT,CT>::size()
337 return threadpool_.size();
359 template<
typename TT
363 inline void ThreadBackend<TT,MT,LT,CT>::resize(
size_t n,
bool block )
365 return threadpool_.resize( n, block );
379 template<
typename TT
383 inline void ThreadBackend<TT,MT,LT,CT>::wait()
409 template<
typename TT
413 template<
typename Target
415 inline void ThreadBackend<TT,MT,LT,CT>::scheduleAssign( Target& target,
const Source& source )
418 threadpool_.schedule( Assigner<Target,Source>( target, source ) );
434 template<
typename TT
438 template<
typename Target
440 inline void ThreadBackend<TT,MT,LT,CT>::scheduleAddAssign( Target& target,
const Source& source )
443 threadpool_.schedule( AddAssigner<Target,Source>( target, source ) );
459 template<
typename TT
463 template<
typename Target
465 inline void ThreadBackend<TT,MT,LT,CT>::scheduleSubAssign( Target& target,
const Source& source )
468 threadpool_.schedule( SubAssigner<Target,Source>( target, source ) );
484 template<
typename TT
488 template<
typename Target
490 inline void ThreadBackend<TT,MT,LT,CT>::scheduleMultAssign( Target& target,
const Source& source )
493 threadpool_.schedule( MultAssigner<Target,Source>( target, source ) );
517 #if (defined _MSC_VER)
518 # pragma warning(push)
519 # pragma warning(disable:4996)
521 template<
typename TT
525 inline size_t ThreadBackend<TT,MT,LT,CT>::initPool()
527 const char* env = std::getenv(
"BLAZE_NUM_THREADS" );
531 else return max( 1, atoi( env ) );
533 #if (defined _MSC_VER)
534 # pragma warning(pop)
557 #if BLAZE_CPP_THREADS_PARALLEL_MODE
558 typedef ThreadBackend< std::thread
560 , std::unique_lock< std::mutex >
561 , std::condition_variable
563 #elif BLAZE_BOOST_THREADS_PARALLEL_MODE
564 typedef ThreadBackend< boost::thread
566 , boost::unique_lock< boost::mutex >
567 , boost::condition_variable
#define BLAZE_CONSTRAINT_MUST_NOT_BE_CONST(T)
Constraint on the data type.In case the given data type is a const-qualified type, a compilation error is created.
Definition: Const.h:116
Header file for mathematical functions.
Header file of the ThreadPool class.
#define BLAZE_CONSTRAINT_MUST_BE_EXPRESSION_TYPE(T)
Constraint on the data type.In case the given data type T is not an expression (i.e. a type derived from the Expression base class), a compilation error is created.
Definition: Expression.h:79
#define BLAZE_BOOST_THREADS_PARALLEL_MODE
Compilation switch for the Boost parallelization.This compilation switch enables/disables the paralle...
Definition: SMP.h:122
const blaze::Null NULL
Global NULL pointer.This instance of the Null class replaces the NULL macro to ensure a type-safe NUL...
Definition: Null.h:300
Constraint on the data type.
System settings for the shared-memory parallelization.
void assign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs)
Default implementation of the assignment of a matrix to a matrix.
Definition: Matrix.h:271
#define BLAZE_CPP_THREADS_PARALLEL_MODE
Compilation switch for the C++11 parallelization.This compilation switch enables/disables the paralle...
Definition: SMP.h:95
void multAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs)
Default implementation of the multiplication assignment of a matrix to a matrix.
Definition: Matrix.h:361
void addAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs)
Default implementation of the addition assignment of a matrix to a matrix.
Definition: Matrix.h:301
void subAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs)
Default implementation of the subtraction assignment of a matrix to matrix.
Definition: Matrix.h:331
#define BLAZE_STATIC_ASSERT(expr)
Compile time assertion macro.In case of an invalid compile time expression, a compilation error is cr...
Definition: StaticAssert.h:143