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_THREADS_FUNCTIONS_H_
36 #define _BLAZE_MATH_SMP_THREADS_FUNCTIONS_H_
37 
38 
39 //*************************************************************************************************
40 // Includes
41 //*************************************************************************************************
42 
43 #include <stdexcept>
45 #include <blaze/system/SMP.h>
47 
48 
49 namespace blaze {
50 
51 //=================================================================================================
52 //
53 // SMP UTILITY FUNCTIONS
54 //
55 //=================================================================================================
56 
57 //*************************************************************************************************
66 inline size_t getNumThreads()
67 {
68  return TheThreadBackend::size();
69 }
71 //*************************************************************************************************
72 
73 
74 //*************************************************************************************************
87 inline size_t setNumThreads( size_t number )
88 {
89  if( number == 0UL )
90  throw std::invalid_argument( "Invalid number of threads" );
91 
92  TheThreadBackend::resize( number );
93 }
95 //*************************************************************************************************
96 
97 
98 //*************************************************************************************************
123 inline void shutDownThreads()
124 {
125 #if (defined _MSC_VER)
126  TheThreadBackend::resize( 0UL, true );
127 #endif
128 }
130 //*************************************************************************************************
131 
132 
133 
134 
135 //=================================================================================================
136 //
137 // COMPILE TIME CONSTRAINTS
138 //
139 //=================================================================================================
140 
141 //*************************************************************************************************
143 namespace {
144 
146 
147 }
149 //*************************************************************************************************
150 
151 } // namespace blaze
152 
153 #endif
#define BLAZE_BOOST_THREADS_PARALLEL_MODE
Compilation switch for the Boost parallelization.This compilation switch enables/disables the paralle...
Definition: SMP.h:122
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.
#define BLAZE_CPP_THREADS_PARALLEL_MODE
Compilation switch for the C++11 parallelization.This compilation switch enables/disables the paralle...
Definition: SMP.h:95
void shutDownThreads()
Provides a reliable shutdown of C++11 threads for Visual Studio compilers.
Definition: Functions.h:126
size_t getNumThreads()
Returns the number of threads used for thread parallel operations.
Definition: Functions.h:75
Header file for the C++11 and Boost thread backend.
#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