48 #define get_cores() (sysconf( _SC_NPROCESSORS_ONLN )) 54 #define new_thread(entry, arg) pthread_create(&os_tid, NULL, entry, arg) 65 CPU_SET(core, &cpuset);
67 sched_setaffinity(0,
sizeof(cpuset), &cpuset);
70 #elif defined(OS_WINDOWS) 75 #define get_cores() ({\ 76 SYSTEM_INFO _sysinfo;\ 77 GetSystemInfo( &_sysinfo );\ 78 _sysinfo.dwNumberOfProcessors;\ 85 #define new_thread(entry, arg) CreateThread(NULL, 0, entry, arg, 0, &os_tid) 88 #define set_affinity(core) SetThreadAffinityMask(GetCurrentThread(), 1<<core) 91 #error Unsupported operating system 97 void *(*start_routine)(
void *);
117 #define HALF_UINT_BITS (sizeof(unsigned int) * 8 / 2) 129 #define MAX_KERNELS ((1 << HALF_UINT_BITS) - 1) 137 #define MAX_THREADS_PER_KERNEL ((1 << HALF_UINT_BITS) - 1) 152 #define to_global_tid(kid, local_tid) ( (kid << HALF_UINT_BITS) | local_tid ) 155 #define master_thread() (local_tid == 0) 167 #define thread_barrier_reset(b) do { \ 168 (atomic_set((&b->c1), (b)->num_threads)); \ 169 (atomic_set((&b->c2), (b)->num_threads)); \ 170 (atomic_set((&b->barr), -1)); \ 174 extern __thread
unsigned int tid;
atomic_t c2
Second synchronization counter.
pthread_t tid_t
How do we identify a thread?
bool thread_barrier(barrier_t *b)
void barrier_init(barrier_t *b, int t)
void * arg
Arguments to be passed to start_routine.
This structure is used to call the thread creation helper function.
void *(* start_routine)(void *)
A pointer to the entry point of the next-to-be thread.
atomic_t c1
First synchronization counter.
int num_threads
Number of threads which will synchronize on the barrier.
void create_threads(unsigned short int n, void *(*start_routine)(void *), void *arg)
__thread unsigned int tid
__thread unsigned int local_tid
static void set_affinity(int core)
Thread barrier definition.