Classes | Macros
Shared memory parallelization module

Classes

class  blaze::ParallelSection< T >
 Section for the debugging of the shared-memory parallelization.The ParallelSection class is an auxiliary helper class for the BLAZE_PARALLEL_SECTION macro. It provides the functionality to detected whether a parallel section has been started and with that serves as a utility for debugging the shared-memory parallelization. More...
 
class  blaze::SerialSection< T >
 Section to enforce the serial execution of operations.The SerialSection class is an auxiliary helper class for the BLAZE_SERIAL_SECTION macro. It provides the functionality to detect whether a serial section is active, i.e. if the currently executed code is inside a serial section. More...
 

Macros

#define BLAZE_PARALLEL_SECTION   if( blaze::ParallelSection<int> BLAZE_JOIN( parallelSection, __LINE__ ) = true )
 Section for the debugging of the shared-memory parallelization.During the shared-memory parallel (SMP) execution of an operation nested calls to the SMP assign functions are conceptually not allowed. In other words, it is not allowed to call a SMP assign function from within a non-SMP assign function. The BLAZE_PARALLEL_SECTION macro can be used to mark the start of a parallel section and with that detect nested SMP assign function calls. In case a nested use of a parallel section is detected, a std::runtime_error exception is thrown.
Note that this macro is reserved for internal debugging purposes only and therefore must NOT be used explicitly! Using this macro might result in erroneous results, runtime or compilation errors.
 
#define BLAZE_SERIAL_SECTION   if( blaze::SerialSection<int> BLAZE_JOIN( serialSection, __LINE__ ) = true )
 Section to enforce the serial execution of operations.This macro provides the option to start a serial section to enforce the serial execution of operations. The following example demonstrates how a serial section is used: More...
 

Dense matrix SMP functions

template<typename MT1 , bool SO1, typename MT2 , bool SO2>
EnableIf_< IsDenseMatrix< MT1 > > blaze::smpAssign (Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs)
 Default implementation of the SMP assignment of a matrix to a dense matrix. More...
 
template<typename MT1 , bool SO1, typename MT2 , bool SO2>
EnableIf_< IsDenseMatrix< MT1 > > blaze::smpAddAssign (Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs)
 Default implementation of the SMP addition assignment of a matrix to a dense matrix. More...
 
template<typename MT1 , bool SO1, typename MT2 , bool SO2>
EnableIf_< IsDenseMatrix< MT1 > > blaze::smpSubAssign (Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs)
 Default implementation of the SMP subtraction assignment of a matrix to dense matrix. More...
 

Dense vector SMP functions

template<typename VT1 , bool TF1, typename VT2 , bool TF2>
EnableIf_< IsDenseVector< VT1 > > blaze::smpAssign (Vector< VT1, TF1 > &lhs, const Vector< VT2, TF2 > &rhs)
 Default implementation of the SMP assignment of a vector to a dense vector. More...
 
template<typename VT1 , bool TF1, typename VT2 , bool TF2>
EnableIf_< IsDenseVector< VT1 > > blaze::smpAddAssign (Vector< VT1, TF1 > &lhs, const Vector< VT2, TF2 > &rhs)
 Default implementation of the SMP addition assignment of a vector to a dense vector. More...
 
template<typename VT1 , bool TF1, typename VT2 , bool TF2>
EnableIf_< IsDenseVector< VT1 > > blaze::smpSubAssign (Vector< VT1, TF1 > &lhs, const Vector< VT2, TF2 > &rhs)
 Default implementation of the SMP subtraction assignment of a vector to a dense vector. More...
 
template<typename VT1 , bool TF1, typename VT2 , bool TF2>
EnableIf_< IsDenseVector< VT1 > > blaze::smpMultAssign (Vector< VT1, TF1 > &lhs, const Vector< VT2, TF2 > &rhs)
 Default implementation of the SMP multiplication assignment of a vector to a dense vector. More...
 
template<typename VT1 , bool TF1, typename VT2 , bool TF2>
EnableIf_< IsDenseVector< VT1 > > blaze::smpDivAssign (Vector< VT1, TF1 > &lhs, const Vector< VT2, TF2 > &rhs)
 Default implementation of the SMP division assignment of a vector to a dense vector. More...
 

SMP utility functions

BLAZE_ALWAYS_INLINE size_t blaze::getNumThreads ()
 Returns the number of threads used for thread parallel operations. More...
 
BLAZE_ALWAYS_INLINE void blaze::setNumThreads (size_t number)
 Sets the number of threads to be used for thread parallel operations. More...
 
BLAZE_ALWAYS_INLINE void blaze::shutDownThreads ()
 Provides a reliable shutdown of C++11 threads for Visual Studio compilers. More...
 

ParallelSection functions

bool blaze::isParallelSectionActive ()
 Returns whether a parallel section is active or not. More...
 

SerialSection functions

bool blaze::isSerialSectionActive ()
 Returns whether a serial section is active or not. More...
 

Detailed Description

Macro Definition Documentation

#define BLAZE_SERIAL_SECTION   if( blaze::SerialSection<int> BLAZE_JOIN( serialSection, __LINE__ ) = true )

Section to enforce the serial execution of operations.This macro provides the option to start a serial section to enforce the serial execution of operations. The following example demonstrates how a serial section is used:

1 using blaze::rowMajor;
2 using blaze::columnVector;
3 
4 blaze::DynamicMatrix<double,rowMajor> A;
5 blaze::DynamicVector<double,columnVector> b, c, d, x, y, z;
6 
7 // ... Resizing and initialization
8 
9 // Start of a serial section
10 // All operations executed within the serial section are guaranteed to be executed in
11 // serial (even if a parallel execution would be possible and/or beneficial).
12 BLAZE_SERIAL_SECTION {
13  x = A * b;
14  y = A * c;
15  z = A * d;
16 }

Note that it is not allowed to use nested serial sections (i.e. a serial section within another serial section). In case the nested use of a serial section is detected, a std::runtime_error exception is thrown.

Function Documentation

BLAZE_ALWAYS_INLINE size_t blaze::getNumThreads ( )

Returns the number of threads used for thread parallel operations.

Returns
The number of threads used for thread parallel operations.

Via this function the number of threads used for thread parallel operations can be queried. Note that in case no parallelization is active the function will always return 1.

bool blaze::isParallelSectionActive ( )
inline

Returns whether a parallel section is active or not.

Returns
true if a parallel section is active, false if not.
bool blaze::isSerialSectionActive ( )
inline

Returns whether a serial section is active or not.

Returns
true if a serial section is active, false if not.
BLAZE_ALWAYS_INLINE void blaze::setNumThreads ( size_t  number)

Sets the number of threads to be used for thread parallel operations.

Parameters
numberThe given number of threads $[1..\infty)$.
Returns
void
Exceptions
std::invalid_argumentInvalid number of threads.

Via this function the maximum number of threads for thread parallel operations can be specified. Note that the given number must be in the range $[1..\infty)$. In case an invalid number of threads is specified, a std::invalid_argument exception is thrown. Also note that in case no parallelization is active, the function has no effect.

BLAZE_ALWAYS_INLINE void blaze::shutDownThreads ( )

Provides a reliable shutdown of C++11 threads for Visual Studio compilers.

Returns
void

There is a known issue in Visual Studio 2012 and 2013 that may cause C++11 threads to hang if their destructor is executed after the main() function:

http://connect.microsoft.com/VisualStudio/feedback/details/747145

This function, which has only an effect for Visual Studio compilers, provides a reliable way to circumvent this problem. If called directly before the end of the main() function it blocks until all threads have been destroyed:

int main()
{
// ... Using the C++11 thread parallelization of Blaze
}
template<typename VT1 , bool TF1, typename VT2 , bool TF2>
EnableIf_< IsDenseVector< VT1 > > blaze::smpAddAssign ( Vector< VT1, TF1 > &  lhs,
const Vector< VT2, TF2 > &  rhs 
)
inline

Default implementation of the SMP addition assignment of a vector to a dense vector.

Parameters
lhsThe target left-hand side dense vector.
rhsThe right-hand side vector to be added.
Returns
void

This function implements the default SMP addition assignment of a vector to a dense vector.
This function must NOT be called explicitly! It is used internally for the performance optimized evaluation of expression templates. Calling this function explicitly might result in erroneous results and/or in compilation errors. Instead of using this function use the assignment operator.

template<typename MT1 , bool SO1, typename MT2 , bool SO2>
EnableIf_< IsDenseMatrix< MT1 > > blaze::smpAddAssign ( Matrix< MT1, SO1 > &  lhs,
const Matrix< MT2, SO2 > &  rhs 
)
inline

Default implementation of the SMP addition assignment of a matrix to a dense matrix.

Parameters
lhsThe target left-hand side dense matrix.
rhsThe right-hand side matrix to be added.
Returns
void

This function implements the default SMP addition assignment of a matrix to a dense matrix.
This function must NOT be called explicitly! It is used internally for the performance optimized evaluation of expression templates. Calling this function explicitly might result in erroneous results and/or in compilation errors. Instead of using this function use the assignment operator.

template<typename MT1 , bool SO1, typename MT2 , bool SO2>
EnableIf_< IsDenseMatrix< MT1 > > blaze::smpAssign ( Matrix< MT1, SO1 > &  lhs,
const Matrix< MT2, SO2 > &  rhs 
)
inline

Default implementation of the SMP assignment of a matrix to a dense matrix.

Parameters
lhsThe target left-hand side dense matrix.
rhsThe right-hand side matrix to be assigned.
Returns
void

This function implements the default SMP assignment of a matrix to a dense matrix.
This function must NOT be called explicitly! It is used internally for the performance optimized evaluation of expression templates. Calling this function explicitly might result in erroneous results and/or in compilation errors. Instead of using this function use the assignment operator.

template<typename VT1 , bool TF1, typename VT2 , bool TF2>
EnableIf_< IsDenseVector< VT1 > > blaze::smpAssign ( Vector< VT1, TF1 > &  lhs,
const Vector< VT2, TF2 > &  rhs 
)
inline

Default implementation of the SMP assignment of a vector to a dense vector.

Parameters
lhsThe target left-hand side dense vector.
rhsThe right-hand side vector to be assigned.
Returns
void

This function implements the default SMP assignment of a vector to a dense vector.
This function must NOT be called explicitly! It is used internally for the performance optimized evaluation of expression templates. Calling this function explicitly might result in erroneous results and/or in compilation errors. Instead of using this function use the assignment operator.

template<typename VT1 , bool TF1, typename VT2 , bool TF2>
EnableIf_< IsDenseVector< VT1 > > blaze::smpDivAssign ( Vector< VT1, TF1 > &  lhs,
const Vector< VT2, TF2 > &  rhs 
)
inline

Default implementation of the SMP division assignment of a vector to a dense vector.

Parameters
lhsThe target left-hand side dense vector.
rhsThe right-hand side vector divisor.
Returns
void

This function implements the default SMP division assignment of a vector to a dense vector.
This function must NOT be called explicitly! It is used internally for the performance optimized evaluation of expression templates. Calling this function explicitly might result in erroneous results and/or in compilation errors. Instead of using this function use the assignment operator.

template<typename VT1 , bool TF1, typename VT2 , bool TF2>
EnableIf_< IsDenseVector< VT1 > > blaze::smpMultAssign ( Vector< VT1, TF1 > &  lhs,
const Vector< VT2, TF2 > &  rhs 
)
inline

Default implementation of the SMP multiplication assignment of a vector to a dense vector.

Parameters
lhsThe target left-hand side dense vector.
rhsThe right-hand side vector to be multiplied.
Returns
void

This function implements the default SMP multiplication assignment of a vector to a dense vector.
This function must NOT be called explicitly! It is used internally for the performance optimized evaluation of expression templates. Calling this function explicitly might result in erroneous results and/or in compilation errors. Instead of using this function use the assignment operator.

template<typename VT1 , bool TF1, typename VT2 , bool TF2>
EnableIf_< IsDenseVector< VT1 > > blaze::smpSubAssign ( Vector< VT1, TF1 > &  lhs,
const Vector< VT2, TF2 > &  rhs 
)
inline

Default implementation of the SMP subtraction assignment of a vector to a dense vector.

Parameters
lhsThe target left-hand side dense vector.
rhsThe right-hand side vector to be subtracted.
Returns
void

This function implements the default SMP subtraction assignment of a vector to a dense vector.
This function must NOT be called explicitly! It is used internally for the performance optimized evaluation of expression templates. Calling this function explicitly might result in erroneous results and/or in compilation errors. Instead of using this function use the assignment operator.

template<typename MT1 , bool SO1, typename MT2 , bool SO2>
EnableIf_< IsDenseMatrix< MT1 > > blaze::smpSubAssign ( Matrix< MT1, SO1 > &  lhs,
const Matrix< MT2, SO2 > &  rhs 
)
inline

Default implementation of the SMP subtraction assignment of a matrix to dense matrix.

Parameters
lhsThe target left-hand side dense matrix.
rhsThe right-hand side matrix to be subtracted.
Returns
void

This function implements the default SMP subtraction assignment of a matrix to a dense matrix.
This function must NOT be called explicitly! It is used internally for the performance optimized evaluation of expression templates. Calling this function explicitly might result in erroneous results and/or in compilation errors. Instead of using this function use the assignment operator.