21 #ifndef _TBB_tbb_misc_H 22 #define _TBB_tbb_misc_H 28 #if __linux__ || __FreeBSD__ 29 #include <sys/param.h> 30 #if __FreeBSD_version >= 701000 31 #include <sys/cpuset.h> 36 #define __TBB_OS_AFFINITY_SYSCALL_PRESENT ((__linux__ && !__ANDROID__) || (__FreeBSD_version >= 701000)) 39 #define __TBB_USE_OS_AFFINITY_SYSCALL (__TBB_OS_AFFINITY_SYSCALL_PRESENT && !__bg__) 46 #if __TBB_WIN8UI_SUPPORT 55 #ifndef __TBB_HardwareConcurrency 73 int NumberOfProcessorGroups();
76 int FindProcessorGroupIndex (
int processorIndex );
79 void MoveThreadIntoProcessorGroup(
void* hThread,
int groupIndex );
99 #if defined(min) || defined(max) 109 T
min (
const T& val1,
const T& val2 ) {
110 return val1 < val2 ? val1 : val2;
118 T
max (
const T& val1,
const T& val2 ) {
119 return val1 < val2 ? val2 : val1;
130 unsigned GetPrime (
unsigned seed );
136 #if __TBB_OLD_PRIMES_RNG 138 static const unsigned c = 1;
141 static const unsigned a = 0x9e3779b1;
142 #endif //__TBB_OLD_PRIMES_RNG 149 unsigned short get(
unsigned& seed ) {
150 unsigned short r = (
unsigned short)(seed>>16);
159 template <
typename T>
167 #if __TBB_OLD_PRIMES_RNG 172 c = (seed|1)*0xba5703f5;
184 template<
typename T1,
typename T2,
class Pred>
187 while ( compare(oldValue, newValue) ) {
211 template <
typename F>
241 #if __TBB_USE_OS_AFFINITY_SYSCALL 243 typedef cpu_set_t basic_mask_t;
244 #elif __FreeBSD_version >= 701000 245 typedef cpuset_t basic_mask_t;
247 #error affinity_helper is not implemented in this OS 250 basic_mask_t* threadMask;
void destroy_process_mask()
int AvailableHwConcurrency()
Returns maximal parallelism level supported by the current OS configuration.
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 atomic_do_once(const F &initializer, atomic< do_once_state > &state)
One-time initialization function.
A fast random number generator.
unsigned GetPrime(unsigned seed)
Base class for types that should not be copied or assigned.
const size_t ThreadStackSize
FastRandom(uint64_t seed)
void init(uint32_t seed, int_to_type< 4 >)
void run_initializer(void(*f)(), atomic< do_once_state > &state)
#define __TBB_ASSERT(predicate, comment)
No-op version of __TBB_ASSERT.
No execution attempts have been undertaken yet.
do_once_state
One-time initialization states.
A thread is executing associated do-once routine.
Utility helper structure to ease overload resolution.
#define __TBB_HardwareConcurrency()
bool gcc_rethrow_exception_broken()
void PrintExtraVersionInfo(const char *category, const char *format,...)
Prints arbitrary extra TBB version information on stderr.
void PrintRMLVersionInfo(void *arg, const char *server_info)
A callback routine to print RML version information on stderr.
T max(const T &val1, const T &val2)
Utility template function returning greater of the two values.
value_type compare_and_swap(value_type value, value_type comparand)
FastRandom(void *unique_ptr)
Construct a random number generator.
bool GetBoolEnvironmentVariable(const char *name)
True if environment variable with given name is set and not 0; otherwise false.
void protect_affinity_mask(bool)
bool cpu_has_speculation()
check for transaction support.
unsigned short get()
Get a random number.
void spin_wait_while_eq(const volatile T &location, U value)
Spin WHILE the value of the variable is equal to a given value.
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.
void init(uint64_t seed, int_to_type< 8 >)
void handle_win_error(int error_code)
Throws std::runtime_error with what() returning error_code description prefixed with aux_info.
FastRandom(uint32_t seed)
Primary template for atomic.
unsigned short get(unsigned &seed)
Get a random number for the given seed; update the seed for next use.
void const char const char int ITT_FORMAT __itt_group_sync x void const char * name
Do-once routine has been executed.
void fix_broken_rethrow()