17 #ifndef _TBB_tbb_misc_H 18 #define _TBB_tbb_misc_H 24 #if __linux__ || __FreeBSD__ 25 #include <sys/param.h> 26 #if __FreeBSD_version >= 701000 27 #include <sys/cpuset.h> 32 #define __TBB_OS_AFFINITY_SYSCALL_PRESENT ((__linux__ && !__ANDROID__) || (__FreeBSD_version >= 701000)) 35 #define __TBB_USE_OS_AFFINITY_SYSCALL (__TBB_OS_AFFINITY_SYSCALL_PRESENT && !__bg__) 42 #if __TBB_WIN8UI_SUPPORT && (_WIN32_WINNT < 0x0A00) 49 const size_t ThreadStackSize = (
sizeof(uintptr_t) <= 4 ? 2 : 4 )*
MByte;
52 #ifndef __TBB_HardwareConcurrency 72 int NumberOfProcessorGroups();
75 int FindProcessorGroupIndex (
int processorIndex );
78 void MoveThreadIntoProcessorGroup(
void* hThread,
int groupIndex );
95 #if defined(min) || defined(max) 105 T
min (
const T& val1,
const T& val2 ) {
106 return val1 < val2 ? val1 : val2;
114 T
max (
const T& val1,
const T& val2 ) {
115 return val1 < val2 ? val2 : val1;
126 unsigned GetPrime (
unsigned seed );
132 #if __TBB_OLD_PRIMES_RNG 134 static const unsigned c = 1;
137 static const unsigned a = 0x9e3779b1;
138 #endif //__TBB_OLD_PRIMES_RNG 141 unsigned short get() {
145 unsigned short get(
unsigned& seed ) {
146 unsigned short r = (
unsigned short)(seed>>16);
152 FastRandom(
void* unique_ptr ) { init(uintptr_t(unique_ptr)); }
155 template <
typename T>
163 #if __TBB_OLD_PRIMES_RNG 168 c = (seed|1)*0xba5703f5;
180 template<
typename T1,
typename T2,
class Pred>
183 while ( compare(oldValue, newValue) ) {
184 if ( dst.compare_and_swap((T1)newValue, oldValue) == oldValue )
207 template <
typename F>
237 #if __TBB_USE_OS_AFFINITY_SYSCALL 239 typedef cpu_set_t basic_mask_t;
240 #elif __FreeBSD_version >= 701000 241 typedef cpuset_t basic_mask_t;
243 #error affinity_helper is not implemented in this OS 246 basic_mask_t* threadMask;
251 void protect_affinity_mask(
bool restore_process_mask );
bool cpu_has_speculation()
check for transaction support.
void init(uint64_t seed, int_to_type< 8 >)
void run_initializer(void(*f)(), atomic< do_once_state > &state)
A fast random number generator.
void atomic_do_once(const F &initializer, atomic< do_once_state > &state)
One-time initialization function.
int AvailableHwConcurrency()
Returns maximal parallelism level supported by the current OS configuration.
const size_t ThreadStackSize
A thread is executing associated do-once routine.
void protect_affinity_mask(bool)
T min(const T &val1, const T &val2)
Utility template function returning lesser of the two values.
void PrintVersion()
Prints TBB version information on stderr.
size_t DefaultSystemPageSize()
Returns OS regular memory page size.
Utility helper structure to ease overload resolution.
void init(uint32_t seed, int_to_type< 4 >)
do_once_state
One-time initialization states.
void PrintRMLVersionInfo(void *arg, const char *server_info)
A callback routine to print RML version information on stderr.
FastRandom(uint32_t seed)
T max(const T &val1, const T &val2)
Utility template function returning greater of the two values.
T1 atomic_update(tbb::atomic< T1 > &dst, T2 newValue, Pred compare)
Atomically replaces value of dst with newValue if they satisfy condition of compare predicate...
void PrintExtraVersionInfo(const char *category, const char *format,...)
Prints arbitrary extra TBB version information on stderr.
void spin_wait_while_eq(const volatile T &location, U value)
Spin WHILE the value of the variable is equal to a given value.
void handle_win_error(int error_code)
Throws std::runtime_error with what() returning error_code description prefixed with aux_info...
Base class for types that should not be copied or assigned.
#define __TBB_ASSERT(predicate, comment)
No-op version of __TBB_ASSERT.
Do-once routine has been executed.
unsigned GetPrime(unsigned seed)
void destroy_process_mask()
No execution attempts have been undertaken yet.
FastRandom(uint64_t seed)
void fix_broken_rethrow()
FastRandom(void *unique_ptr)
Construct a random number generator.
bool gcc_rethrow_exception_broken()
#define __TBB_HardwareConcurrency()