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__) 47 #if __TBB_WIN8UI_SUPPORT && (_WIN32_WINNT < 0x0A00) 54 const size_t ThreadStackSize = (
sizeof(uintptr_t) <= 4 ? 2 : 4 )*
MByte;
57 #ifndef __TBB_HardwareConcurrency 77 int NumberOfProcessorGroups();
80 int FindProcessorGroupIndex (
int processorIndex );
83 void MoveThreadIntoProcessorGroup(
void* hThread,
int groupIndex );
100 #if defined(min) || defined(max) 110 T
min (
const T& val1,
const T& val2 ) {
111 return val1 < val2 ? val1 : val2;
119 T
max (
const T& val1,
const T& val2 ) {
120 return val1 < val2 ? val2 : val1;
131 unsigned GetPrime (
unsigned seed );
137 #if __TBB_OLD_PRIMES_RNG 139 static const unsigned c = 1;
142 static const unsigned a = 0x9e3779b1;
143 #endif //__TBB_OLD_PRIMES_RNG 146 unsigned short get() {
150 unsigned short get(
unsigned& seed ) {
151 unsigned short r = (
unsigned short)(seed>>16);
157 FastRandom(
void* unique_ptr ) { init(uintptr_t(unique_ptr)); }
160 template <
typename T>
168 #if __TBB_OLD_PRIMES_RNG 173 c = (seed|1)*0xba5703f5;
185 template<
typename T1,
typename T2,
class Pred>
188 while ( compare(oldValue, newValue) ) {
189 if ( dst.compare_and_swap((T1)newValue, oldValue) == oldValue )
212 template <
typename F>
242 #if __TBB_USE_OS_AFFINITY_SYSCALL 244 typedef cpu_set_t basic_mask_t;
245 #elif __FreeBSD_version >= 701000 246 typedef cpuset_t basic_mask_t;
248 #error affinity_helper is not implemented in this OS 251 basic_mask_t* threadMask;
256 void protect_affinity_mask(
bool restore_process_mask );
273 #if __TBB_NUMA_SUPPORT 278 void bind_thread_to_node(
binding_handler* handler_ptr,
int slot_num ,
int numa_id);
279 void restore_affinity_mask(
binding_handler* handler_ptr,
int slot_num);
281 namespace numa_topology {
282 bool is_initialized();
Base class for types that should not be copied or assigned.
void protect_affinity_mask(bool)
void fix_broken_rethrow()
do_once_state
One-time initialization states.
FastRandom(uint32_t seed)
void destroy_process_mask()
size_t DefaultSystemPageSize()
Returns OS regular memory page size.
bool cpu_has_speculation()
check for transaction support.
No execution attempts have been undertaken yet.
T max(const T &val1, const T &val2)
Utility template function returning greater of the two values.
A thread is executing associated do-once routine.
unsigned GetPrime(unsigned seed)
A fast random number generator.
void spin_wait_while_eq(const volatile T &location, U value)
Spin WHILE the value of the variable is equal to a given value.
Utility helper structure to ease overload resolution.
void atomic_do_once(const F &initializer, atomic< do_once_state > &state)
One-time initialization function.
FastRandom(uint64_t seed)
int AvailableHwConcurrency()
Returns maximal parallelism level supported by the current OS configuration.
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.
void init(uint32_t seed, int_to_type< 4 >)
void run_initializer(void(*f)(), atomic< do_once_state > &state)
void PrintVersion()
Prints TBB version information on stderr.
bool gcc_rethrow_exception_broken()
const size_t ThreadStackSize
FastRandom(void *unique_ptr)
Construct a random number generator.
#define __TBB_ASSERT(predicate, comment)
No-op version of __TBB_ASSERT.
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 handle_win_error(int error_code)
Throws std::runtime_error with what() returning error_code description prefixed with aux_info...
T min(const T &val1, const T &val2)
Utility template function returning lesser of the two values.
#define __TBB_HardwareConcurrency()
Do-once routine has been executed.
void init(uint64_t seed, int_to_type< 8 >)