All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Functions.h
Go to the documentation of this file.
1 //=================================================================================================
33 //=================================================================================================
34 
35 #ifndef _BLAZE_MATH_SMP_OPENMP_FUNCTIONS_H_
36 #define _BLAZE_MATH_SMP_OPENMP_FUNCTIONS_H_
37 
38 
39 //*************************************************************************************************
40 // Includes
41 //*************************************************************************************************
42 
43 #include <stdexcept>
44 #include <omp.h>
45 #include <blaze/system/SMP.h>
47 
48 
49 namespace blaze {
50 
51 //=================================================================================================
52 //
53 // SMP UTILITY FUNCTIONS
54 //
55 //=================================================================================================
56 
57 //*************************************************************************************************
68 inline size_t getNumThreads()
69 {
70  return omp_get_max_threads();
71 }
73 //*************************************************************************************************
74 
75 
76 //*************************************************************************************************
89 inline size_t setNumThreads( size_t number )
90 {
91  if( number == 0UL )
92  throw std::invalid_argument( "Invalid number of threads" );
93 
94  omp_set_num_threads( number );
95 }
97 //*************************************************************************************************
98 
99 
100 //*************************************************************************************************
125 inline void shutDownThreads()
126 {}
128 //*************************************************************************************************
129 
130 
131 
132 
133 //=================================================================================================
134 //
135 // COMPILE TIME CONSTRAINTS
136 //
137 //=================================================================================================
138 
139 //*************************************************************************************************
141 namespace {
142 
144 
145 }
147 //*************************************************************************************************
148 
149 } // namespace blaze
150 
151 #endif
void setNumThreads(size_t number)
Sets the number of threads to be used for thread parallel operations.
Definition: Functions.h:95
Compile time assertion.
System settings for the shared-memory parallelization.
void shutDownThreads()
Provides a reliable shutdown of C++11 threads for Visual Studio compilers.
Definition: Functions.h:126
#define BLAZE_OPENMP_PARALLEL_MODE
Compilation switch for the OpenMP parallelization.This compilation switch enables/disables the OpenMP...
Definition: SMP.h:67
size_t getNumThreads()
Returns the number of threads used for thread parallel operations.
Definition: Functions.h:75
#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