35 #ifndef _BLAZE_MATH_SMP_THREADMAPPING_H_ 36 #define _BLAZE_MATH_SMP_THREADMAPPING_H_ 62 using ThreadMapping = std::pair<size_t,size_t>;
82 ThreadMapping createThreadMapping(
size_t threads,
const Matrix<MT,SO>& A )
84 const size_t M( (~A).
rows() );
85 const size_t N( (~A).
columns() );
87 if( M > N || ( M == N && !SO ) )
89 const double ratio(
double(M)/
double(N) );
90 size_t m =
min( threads,
max( 1UL, static_cast<size_t>(
round(
sqrt( threads*ratio ) ) ) ) );
91 size_t n = threads / m;
93 while( m * n != threads ) {
98 return ThreadMapping( m, n );
102 const double ratio(
double(N)/
double(M) );
103 size_t n =
min( threads,
max( 1UL, static_cast<size_t>(
round(
sqrt( threads*ratio ) ) ) ) );
104 size_t m = threads / n;
106 while( m * n != threads ) {
111 return ThreadMapping( m, n );
Headerfile for the generic min algorithm.
Header file for basic type definitions.
const ElementType_< MT > min(const DenseMatrix< MT, SO > &dm)
Returns the smallest element of the dense matrix.
Definition: DenseMatrix.h:1762
const ElementType_< MT > max(const DenseMatrix< MT, SO > &dm)
Returns the largest element of the dense matrix.
Definition: DenseMatrix.h:1809
Header file for the sqrt shim.
Headerfile for the generic max algorithm.
Namespace of the Blaze C++ math library.
Definition: Blaze.h:57
BLAZE_ALWAYS_INLINE size_t columns(const Matrix< MT, SO > &matrix) noexcept
Returns the current number of columns of the matrix.
Definition: Matrix.h:340
decltype(auto) round(const DenseMatrix< MT, SO > &dm)
Applies the round() function to each single element of the dense matrix dm.
Definition: DMatMapExpr.h:1292
Header file for the Matrix base class.
Header file for the round shim.
BLAZE_ALWAYS_INLINE size_t rows(const Matrix< MT, SO > &matrix) noexcept
Returns the current number of rows of the matrix.
Definition: Matrix.h:324
decltype(auto) sqrt(const DenseMatrix< MT, SO > &dm)
Computes the square root of each single element of the dense matrix dm.
Definition: DMatMapExpr.h:1448