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> 92 static inline size_t size ();
93 static inline void resize(
size_t n,
bool block=
false );
94 static inline void wait ();
101 template<
typename Target,
typename Source,
typename OP >
102 static inline void schedule( Target& target,
const Source& source, OP op );
110 template<
typename Target
122 explicit inline Assigner( Target& target,
const Source& source, OP op )
134 inline void operator()() {
135 op_( target_, source_ );
141 const Source source_;
155 static inline size_t initPool();
162 static ThreadPool<TT,MT,LT,CT> threadpool_;
185 template<
typename TT,
typename MT,
typename LT,
typename CT >
186 ThreadPool<TT,MT,LT,CT> ThreadBackend<TT,MT,LT,CT>::threadpool_( initPool() );
205 template<
typename TT
211 return threadpool_.size();
233 template<
typename TT
239 return threadpool_.resize( n, block );
253 template<
typename TT
257 inline void ThreadBackend<TT,MT,LT,CT>::wait()
284 template<
typename TT
288 template<
typename Target
291 inline void ThreadBackend<TT,MT,LT,CT>::schedule( Target& target,
const Source& source, OP op )
294 threadpool_.schedule( Assigner<Target,Source,OP>( target, source, op ) );
318 #if (defined _MSC_VER) 319 # pragma warning(push) 320 # pragma warning(disable:4996) 322 template<
typename TT
326 inline size_t ThreadBackend<TT,MT,LT,CT>::initPool()
328 const char* env = std::getenv(
"BLAZE_NUM_THREADS" );
332 else return max( 1, atoi( env ) );
334 #if (defined _MSC_VER) 335 # pragma warning(pop) 358 #if BLAZE_CPP_THREADS_PARALLEL_MODE 359 using TheThreadBackend = ThreadBackend< std::thread
361 , std::unique_lock< std::mutex >
362 , std::condition_variable
364 #elif BLAZE_BOOST_THREADS_PARALLEL_MODE 365 using TheThreadBackend = ThreadBackend< boost::thread
367 , boost::unique_lock< boost::mutex >
368 , 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:79
Header file of the ThreadPool class.
Header file for basic type definitions.
#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:61
BLAZE_ALWAYS_INLINE size_t size(const Vector< VT, TF > &vector) noexcept
Returns the current size/dimension of the vector.
Definition: Vector.h:265
#define BLAZE_BOOST_THREADS_PARALLEL_MODE
Compilation switch for the Boost parallelization.This compilation switch enables/disables the paralle...
Definition: SMP.h:122
Constraint on the data type.
const ElementType_< MT > max(const DenseMatrix< MT, SO > &dm)
Returns the largest element of the dense matrix.
Definition: DenseMatrix.h:1950
Headerfile for the generic max algorithm.
Namespace of the Blaze C++ math library.
Definition: Blaze.h:58
System settings for the shared-memory parallelization.
#define BLAZE_CPP_THREADS_PARALLEL_MODE
Compilation switch for the C++11 parallelization.This compilation switch enables/disables the paralle...
Definition: SMP.h:95
BLAZE_ALWAYS_INLINE void resize(Matrix< MT, SO > &matrix, size_t rows, size_t columns, bool preserve=true)
Changing the size of the matrix.
Definition: Matrix.h:714
Constraint on the data type.
#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:112