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 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_;
185template<
typename TT,
typename MT,
typename LT,
typename CT >
186ThreadPool<TT,MT,LT,CT> ThreadBackend<TT,MT,LT,CT>::threadpool_( initPool() );
211 return threadpool_.size();
239 return threadpool_.resize( n, block );
257inline void ThreadBackend<TT,MT,LT,CT>::wait()
288template<
typename Target
291inline 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)
326inline 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)
358#if BLAZE_CPP_THREADS_PARALLEL_MODE
359using TheThreadBackend = ThreadBackend< std::thread
361 , std::unique_lock< std::mutex >
362 , std::condition_variable
364#elif BLAZE_BOOST_THREADS_PARALLEL_MODE
365using TheThreadBackend = ThreadBackend< boost::thread
367 , boost::unique_lock< boost::mutex >
368 , boost::condition_variable
Constraint on the data type.
Header file of the ThreadPool class.
Constraint on the data type.
#define BLAZE_CONSTRAINT_MUST_NOT_BE_CONST(T)
Constraint on the data type.
Definition: Const.h:79
decltype(auto) max(const DenseMatrix< MT1, SO1 > &lhs, const DenseMatrix< MT2, SO2 > &rhs)
Computes the componentwise maximum of the dense matrices lhs and rhs.
Definition: DMatDMatMapExpr.h:1375
#define BLAZE_CONSTRAINT_MUST_BE_EXPRESSION_TYPE(T)
Constraint on the data type.
Definition: Expression.h:61
void resize(Matrix< MT, SO > &matrix, size_t rows, size_t columns, bool preserve=true)
Changing the size of the matrix.
Definition: Matrix.h:1108
constexpr size_t size(const Matrix< MT, SO > &matrix) noexcept
Returns the total number of elements of the matrix.
Definition: Matrix.h:676
#define BLAZE_STATIC_ASSERT(expr)
Compile time assertion macro.
Definition: StaticAssert.h:112
#define BLAZE_CPP_THREADS_PARALLEL_MODE
Compilation switch for the C++11 parallelization.
Definition: SMP.h:124
#define BLAZE_BOOST_THREADS_PARALLEL_MODE
Compilation switch for the Boost parallelization.
Definition: SMP.h:152
System settings for the shared-memory parallelization.
Header file for basic type definitions.
Header file for the generic max algorithm.