17 #ifndef _TBB_tbb_misc_H 18 #define _TBB_tbb_misc_H 24 #if __TBB_NUMA_SUPPORT 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__) 43 #if __TBB_NUMA_SUPPORT 44 namespace interface7 {
class task_arena; }
45 namespace interface6 {
class task_scheduler_observer; }
52 #if __TBB_WIN8UI_SUPPORT && (_WIN32_WINNT < 0x0A00) 59 const size_t ThreadStackSize = (
sizeof(uintptr_t) <= 4 ? 2 : 4 )*
MByte;
62 #ifndef __TBB_HardwareConcurrency 82 int NumberOfProcessorGroups();
85 int FindProcessorGroupIndex (
int processorIndex );
88 void MoveThreadIntoProcessorGroup(
void* hThread,
int groupIndex );
105 #if defined(min) || defined(max) 115 T
min (
const T& val1,
const T& val2 ) {
116 return val1 < val2 ? val1 : val2;
124 T
max (
const T& val1,
const T& val2 ) {
125 return val1 < val2 ? val2 : val1;
136 unsigned GetPrime (
unsigned seed );
142 #if __TBB_OLD_PRIMES_RNG 144 static const unsigned c = 1;
147 static const unsigned a = 0x9e3779b1;
148 #endif //__TBB_OLD_PRIMES_RNG 151 unsigned short get() {
155 unsigned short get(
unsigned& seed ) {
156 unsigned short r = (
unsigned short)(seed>>16);
162 FastRandom(
void* unique_ptr ) { init(uintptr_t(unique_ptr)); }
165 template <
typename T>
173 #if __TBB_OLD_PRIMES_RNG 178 c = (seed|1)*0xba5703f5;
190 template<
typename T1,
typename T2,
class Pred>
193 while ( compare(oldValue, newValue) ) {
194 if ( dst.compare_and_swap((T1)newValue, oldValue) == oldValue )
217 template <
typename F>
247 #if __TBB_USE_OS_AFFINITY_SYSCALL 249 typedef cpu_set_t basic_mask_t;
250 #elif __FreeBSD_version >= 701000 251 typedef cpuset_t basic_mask_t;
253 #error affinity_helper is not implemented in this OS 256 basic_mask_t* threadMask;
261 void protect_affinity_mask(
bool restore_process_mask );
278 #if __TBB_NUMA_SUPPORT 290 namespace numa_topology {
291 bool is_initialized();
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 init(uint32_t seed, int_to_type< 4 >)
void protect_affinity_mask(bool)
unsigned GetPrime(unsigned seed)
const size_t ThreadStackSize
Base class for types that should not be copied or assigned.
void run_initializer(bool(*f)(), atomic< do_once_state > &state)
size_t DefaultSystemPageSize()
Returns OS regular memory page size.
#define __TBB_HardwareConcurrency()
void spin_wait_while_eq(const volatile T &location, U value)
Spin WHILE the value of the variable is equal to a given value.
No execution attempts have been undertaken yet.
bool gcc_rethrow_exception_broken()
A thread is executing associated do-once routine.
do_once_state
One-time initialization states.
T min(const T &val1, const T &val2)
Utility template function returning lesser of the two values.
FastRandom(uint32_t seed)
void PrintExtraVersionInfo(const char *category, const char *format,...)
Prints arbitrary extra TBB version information on stderr.
void handle_win_error(int error_code)
Throws std::runtime_error with what() returning error_code description prefixed with aux_info...
void init(uint64_t seed, int_to_type< 8 >)
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.
A fast random number generator.
#define __TBB_ASSERT(predicate, comment)
No-op version of __TBB_ASSERT.
Do-once routine has been executed.
void atomic_do_once(const F &initializer, atomic< do_once_state > &state)
One-time initialization function.
FastRandom(uint64_t seed)
void PrintVersion()
Prints TBB version information on stderr.
void fix_broken_rethrow()
Utility helper structure to ease overload resolution.
FastRandom(void *unique_ptr)
Construct a random number generator.
void destroy_process_mask()
int AvailableHwConcurrency()
Returns maximal parallelism level supported by the current OS configuration.
bool cpu_has_speculation()
check for transaction support.