Tachyon (current)
Current Main Branch
|
Tachyon cross-platform thread creation and management, atomic operations, and CPU feature query APIs. More...
Go to the source code of this file.
Macros | |
#define | RT_USEINTCPUID 1 |
Typedefs | |
typedef void *(* | RTTHREAD_START_ROUTINE) (void *) |
Typedef to eliminate compiler warning caused by C/C++ linkage conflict. More... | |
Functions | |
int | rt_thread_numphysprocessors (void) |
If compiling on Linux, enable the GNU CPU affinity functions in both libc and the libpthreads. More... | |
int | rt_thread_numprocessors (void) |
number of processors available, subject to user override More... | |
int | rt_cpu_capability_flags (rt_cpu_caps_t *cpucaps) |
CPU optional instruction set capability flags. More... | |
int | rt_cpu_smt_depth (void) |
CPU logical processors (SMT depth / aka hyperthreading) More... | |
int * | rt_cpu_affinitylist (int *cpuaffinitycount) |
query CPU affinity of the calling process (if allowed by host system) More... | |
int | rt_thread_set_self_cpuaffinity (int cpu) |
set the CPU affinity of the current thread (if allowed by host system) More... | |
int | rt_thread_setconcurrency (int nthr) |
set the concurrency level and scheduling scope for threads More... | |
int | rt_thread_create (rt_thread_t *thr, void *fctn(void *), void *arg) |
create a new child thread More... | |
int | rt_thread_join (rt_thread_t thr, void **stat) |
join (wait for completion of, and merge with) a thread More... | |
int | rt_mutex_init (rt_mutex_t *mp) |
initialize a mutex More... | |
int | rt_mutex_lock (rt_mutex_t *mp) |
lock a mutex More... | |
int | rt_mutex_trylock (rt_mutex_t *mp) |
try to lock a mutex More... | |
int | rt_mutex_spin_lock (rt_mutex_t *mp) |
lock a mutex by spinning only More... | |
int | rt_mutex_unlock (rt_mutex_t *mp) |
unlock a mutex More... | |
int | rt_mutex_destroy (rt_mutex_t *mp) |
destroy a mutex More... | |
int | rt_cond_init (rt_cond_t *cvp) |
initialize a condition variable More... | |
int | rt_cond_destroy (rt_cond_t *cvp) |
destroy a condition variable More... | |
int | rt_cond_wait (rt_cond_t *cvp, rt_mutex_t *mp) |
wait on a condition variable More... | |
int | rt_cond_signal (rt_cond_t *cvp) |
signal a condition variable, waking at least one thread More... | |
int | rt_cond_broadcast (rt_cond_t *cvp) |
signal a condition variable, waking all threads More... | |
int | rt_atomic_int_init (rt_atomic_int_t *atomp, int val) |
initialize an atomic int variable More... | |
int | rt_atomic_int_destroy (rt_atomic_int_t *atomp) |
destroy an atomic int variable More... | |
int | rt_atomic_int_set (rt_atomic_int_t *atomp, int val) |
set an atomic int variable More... | |
int | rt_atomic_int_get (rt_atomic_int_t *atomp) |
get an atomic int variable More... | |
int | rt_atomic_int_fetch_and_add (rt_atomic_int_t *atomp, int inc) |
fetch an atomic int and add inc to it, returning original value More... | |
int | rt_atomic_int_add_and_fetch (rt_atomic_int_t *atomp, int inc) |
fetch an atomic int and add inc to it, returning new value More... | |
int | rt_rwlock_init (rt_rwlock_t *rwp) |
initialize a reader/writer lock More... | |
int | rt_rwlock_readlock (rt_rwlock_t *rwp) |
set reader lock More... | |
int | rt_rwlock_writelock (rt_rwlock_t *rwp) |
set writer lock More... | |
int | rt_rwlock_unlock (rt_rwlock_t *rwp) |
unlock reader/writer lock More... | |
rt_barrier_t * | rt_thread_barrier_init (int n_clients) |
initialize counting barrier primitive More... | |
int | rt_thread_barrier_init_proc_shared (rt_barrier_t *barrier, int n_clients) |
When rendering in the CAVE we use a special synchronization mode so that shared memory mutexes and condition variables will work correctly when accessed from multiple processes. More... | |
void | rt_thread_barrier_destroy (rt_barrier_t *barrier) |
destroy counting barrier primitive More... | |
int | rt_thread_barrier (rt_barrier_t *barrier, int increment) |
synchronize on counting barrier primitive More... | |
int | rt_thread_run_barrier_init (rt_run_barrier_t *barrier, int n_clients) |
initialize thread pool barrier More... | |
void | rt_thread_run_barrier_destroy (rt_run_barrier_t *barrier) |
destroy thread pool barrier More... | |
int | rt_thread_run_barrier_poll (rt_run_barrier_t *barrier) |
non-blocking poll to see if peers are already at the barrier More... | |
int | rt_tilestack_init (rt_tilestack_t *s, int size) |
initialize task tile stack (to empty) More... | |
void | rt_tilestack_destroy (rt_tilestack_t *s) |
destroy task tile stack More... | |
int | rt_tilestack_compact (rt_tilestack_t *s) |
shrink memory buffers associated with task tile stack if possible More... | |
int | rt_tilestack_push (rt_tilestack_t *s, const rt_tasktile_t *t) |
push a task tile onto the stack More... | |
int | rt_tilestack_pop (rt_tilestack_t *s, rt_tasktile_t *t) |
pop a task tile off of the stack More... | |
int | rt_tilestack_popall (rt_tilestack_t *s) |
pop all of the task tiles off of the stack More... | |
int | rt_tilestack_empty (rt_tilestack_t *s) |
query if the task tile stack is empty or not More... | |
int | rt_shared_iterator_init (rt_shared_iterator_t *it) |
initialize a shared iterator More... | |
int | rt_shared_iterator_destroy (rt_shared_iterator_t *it) |
destroy a shared iterator More... | |
int | rt_shared_iterator_set (rt_shared_iterator_t *it, rt_tasktile_t *tile) |
set shared iterator parameters More... | |
int | rt_shared_iterator_next_tile (rt_shared_iterator_t *it, int reqsize, rt_tasktile_t *tile) |
iterate the shared iterator, over a requested half-open interval More... | |
int | rt_shared_iterator_setfatalerror (rt_shared_iterator_t *it) |
worker thread calls this to indicate a fatal error More... | |
int | rt_shared_iterator_getfatalerror (rt_shared_iterator_t *it) |
master thread calls this to query for fatal errors More... | |
rt_threadpool_t * | rt_threadpool_create (int workercount, int *devlist) |
create a thread pool with a specified number of worker threads More... | |
int | rt_threadpool_launch (rt_threadpool_t *thrpool, void *fctn(void *), void *parms, int blocking) |
launch threads onto a new function, with associated parms More... | |
int | rt_threadpool_wait (rt_threadpool_t *thrpool) |
wait for all worker threads to complete their work More... | |
int | rt_threadpool_poll (rt_threadpool_t *thrpool) |
int | rt_threadpool_destroy (rt_threadpool_t *thrpool) |
join all worker threads and free resources More... | |
int | rt_threadpool_get_workercount (rt_threadpool_t *thrpool) |
return the number of worker threads currently in the pool More... | |
int | rt_threadpool_worker_getid (void *voiddata, int *threadid, int *threadcount) |
worker thread can call this to get its ID and number of peers More... | |
int | rt_threadpool_worker_getdevid (void *voiddata, int *devid) |
worker thread can call this to get its CPU/GPU device ID More... | |
int | rt_threadpool_worker_setdevspeed (void *voiddata, float speed) |
worker thread calls this to set relative speed of this device as determined by the SM/core count and clock rate Note: this should only be called once, during the worker's device initialization process More... | |
int | rt_threadpool_worker_getdevspeed (void *voiddata, float *speed) |
worker thread calls this to get relative speed of this device as determined by the SM/core count and clock rate More... | |
int | rt_threadpool_worker_devscaletile (void *voiddata, int *tilesize) |
worker thread calls this to scale max tile size by worker speed as determined by the SM/core count and clock rate More... | |
int | rt_threadpool_worker_getdata (void *voiddata, void **clientdata) |
worker thread can call this to get its client data pointer More... | |
int | rt_threadpool_sched_dynamic (rt_threadpool_t *thrpool, rt_tasktile_t *tile) |
Set shared iterator state to half-open interval defined by tile. More... | |
int | rt_threadpool_next_tile (void *voidparms, int reqsize, rt_tasktile_t *tile) |
iterate the shared iterator over the requested half-open interval More... | |
int | rt_threadpool_tile_failed (void *voidparms, rt_tasktile_t *tile) |
worker thread calls this when a failure occurs on a tile it has already taken from the scheduler More... | |
int | rt_threadpool_setfatalerror (void *voidparms) |
worker thread calls this to indicate that an unrecoverable error occured More... | |
int | rt_threadpool_getfatalerror (void *voidparms) |
master thread calls this to query for fatal errors More... | |
int | rt_threadlaunch (int numprocs, void *clientdata, void *fctn(void *), rt_tasktile_t *tile) |
launch up to numprocs threads using shared iterator as a load balancer More... | |
int | rt_threadlaunch_getid (void *voidparms, int *threadid, int *threadcount) |
worker thread can call this to get its ID and number of peers More... | |
int | rt_threadlaunch_getdata (void *voidparms, void **clientdata) |
worker thread can call this to get its client data pointer More... | |
int | rt_threadlaunch_next_tile (void *voidparms, int reqsize, rt_tasktile_t *tile) |
iterate the shared iterator over the requested half-open interval More... | |
int | rt_threadlaunch_setfatalerror (void *voidparms) |
worker thread calls this to indicate that an unrecoverable error occured More... | |
Variables | |
void *(*)(void *) | rt_thread_run_barrier (rt_run_barrier_t *barrier, void *fctn(void *), void *parms, void **rsltparms) |
Wait until all threads reach barrier, and return the function pointer passed in by the master thread. More... | |
Tachyon cross-platform thread creation and management, atomic operations, and CPU feature query APIs.
Definition in file threads.c.
typedef void*(* RTTHREAD_START_ROUTINE) (void *) |
int rt_atomic_int_add_and_fetch | ( | rt_atomic_int_t * | atomp, |
int | inc | ||
) |
fetch an atomic int and add inc to it, returning new value
Definition at line 1180 of file threads.c.
References atomic_int_struct::lock, rt_mutex_lock(), rt_mutex_unlock(), and atomic_int_struct::val.
int rt_atomic_int_destroy | ( | rt_atomic_int_t * | atomp | ) |
destroy an atomic int variable
Definition at line 1066 of file threads.c.
References atomic_int_struct::lock, and rt_mutex_destroy().
Referenced by destroy_render_threads().
int rt_atomic_int_fetch_and_add | ( | rt_atomic_int_t * | atomp, |
int | inc | ||
) |
fetch an atomic int and add inc to it, returning original value
Definition at line 1152 of file threads.c.
References atomic_int_struct::lock, rt_mutex_lock(), rt_mutex_unlock(), and atomic_int_struct::val.
Referenced by thread_trace().
int rt_atomic_int_get | ( | rt_atomic_int_t * | atomp | ) |
get an atomic int variable
Definition at line 1123 of file threads.c.
References atomic_int_struct::lock, rt_mutex_lock(), rt_mutex_unlock(), and atomic_int_struct::val.
int rt_atomic_int_init | ( | rt_atomic_int_t * | atomp, |
int | val | ||
) |
initialize an atomic int variable
Definition at line 1043 of file threads.c.
References atomic_int_struct::lock, rt_mutex_init(), and atomic_int_struct::val.
Referenced by create_render_threads().
int rt_atomic_int_set | ( | rt_atomic_int_t * | atomp, |
int | val | ||
) |
set an atomic int variable
Definition at line 1087 of file threads.c.
References atomic_int_struct::lock, rt_mutex_lock(), rt_mutex_unlock(), and atomic_int_struct::val.
Referenced by renderscene().
int rt_cond_broadcast | ( | rt_cond_t * | cvp | ) |
signal a condition variable, waking all threads
Definition at line 1003 of file threads.c.
Referenced by rt_thread_barrier().
int rt_cond_destroy | ( | rt_cond_t * | cvp | ) |
destroy a condition variable
Definition at line 888 of file threads.c.
Referenced by rt_thread_barrier_destroy(), and rt_thread_run_barrier_destroy().
int rt_cond_init | ( | rt_cond_t * | cvp | ) |
initialize a condition variable
Definition at line 852 of file threads.c.
Referenced by rt_rwlock_init(), rt_thread_barrier_init(), and rt_thread_run_barrier_init().
int rt_cond_signal | ( | rt_cond_t * | cvp | ) |
signal a condition variable, waking at least one thread
Definition at line 971 of file threads.c.
Referenced by rt_rwlock_unlock().
int rt_cond_wait | ( | rt_cond_t * | cvp, |
rt_mutex_t * | mp | ||
) |
wait on a condition variable
Definition at line 912 of file threads.c.
Referenced by rt_rwlock_readlock(), rt_rwlock_writelock(), and rt_thread_barrier().
int* rt_cpu_affinitylist | ( | int * | cpuaffinitycount | ) |
int rt_cpu_capability_flags | ( | rt_cpu_caps_t * | cpucaps | ) |
CPU optional instruction set capability flags.
Definition at line 281 of file threads.c.
References CPU_ARM64_AES, CPU_ARM64_ASIMD, CPU_ARM64_ASIMDDP, CPU_ARM64_ASIMDFHM, CPU_ARM64_ASIMDHP, CPU_ARM64_ASIMDRDM, CPU_ARM64_CRC32, CPU_ARM64_FP, CPU_ARM64_SHA1, CPU_ARM64_SHA2, CPU_ARM64_SHA3, CPU_ARM64_SHA512, CPU_ARM64_SVE, CPU_AVX, CPU_AVX2, CPU_AVX512CD, CPU_AVX512ER, CPU_AVX512F, CPU_AVX512PF, CPU_F16C, CPU_FMA, CPU_HT, CPU_HYPERVISOR, CPU_SMTDEPTH_UNKNOWN, CPU_SSE2, CPU_SSE4_1, CPU_UNKNOWN, rt_cpu_caps_struct::flags, and rt_cpu_caps_struct::smtdepth.
Referenced by rt_cpu_smt_depth(), and rt_par_getcpuinfo().
int rt_cpu_smt_depth | ( | void | ) |
CPU logical processors (SMT depth / aka hyperthreading)
Definition at line 466 of file threads.c.
References CPU_SMTDEPTH_UNKNOWN, rt_cpu_capability_flags(), and rt_cpu_caps_struct::smtdepth.
int rt_mutex_destroy | ( | rt_mutex_t * | mp | ) |
destroy a mutex
Definition at line 828 of file threads.c.
Referenced by rt_atomic_int_destroy(), rt_shared_iterator_destroy(), rt_thread_barrier_destroy(), rt_thread_run_barrier_destroy(), and rt_tilestack_destroy().
int rt_mutex_init | ( | rt_mutex_t * | mp | ) |
initialize a mutex
Definition at line 721 of file threads.c.
Referenced by rt_atomic_int_init(), rt_rwlock_init(), rt_shared_iterator_init(), rt_thread_barrier_init(), rt_thread_run_barrier_init(), and rt_tilestack_init().
int rt_mutex_lock | ( | rt_mutex_t * | mp | ) |
lock a mutex
Definition at line 742 of file threads.c.
Referenced by rt_atomic_int_add_and_fetch(), rt_atomic_int_fetch_and_add(), rt_atomic_int_get(), rt_atomic_int_set(), rt_rwlock_readlock(), rt_rwlock_unlock(), rt_rwlock_writelock(), rt_shared_iterator_getfatalerror(), rt_shared_iterator_set(), rt_thread_barrier(), rt_thread_run_barrier_poll(), rt_tilestack_compact(), rt_tilestack_empty(), rt_tilestack_pop(), rt_tilestack_popall(), and rt_tilestack_push().
int rt_mutex_spin_lock | ( | rt_mutex_t * | mp | ) |
lock a mutex by spinning only
Definition at line 784 of file threads.c.
Referenced by rt_shared_iterator_next_tile(), and rt_shared_iterator_setfatalerror().
int rt_mutex_trylock | ( | rt_mutex_t * | mp | ) |
int rt_mutex_unlock | ( | rt_mutex_t * | mp | ) |
unlock a mutex
Definition at line 807 of file threads.c.
Referenced by rt_atomic_int_add_and_fetch(), rt_atomic_int_fetch_and_add(), rt_atomic_int_get(), rt_atomic_int_set(), rt_rwlock_readlock(), rt_rwlock_unlock(), rt_rwlock_writelock(), rt_shared_iterator_getfatalerror(), rt_shared_iterator_next_tile(), rt_shared_iterator_set(), rt_shared_iterator_setfatalerror(), rt_thread_barrier(), rt_thread_run_barrier_poll(), rt_tilestack_compact(), rt_tilestack_empty(), rt_tilestack_pop(), rt_tilestack_popall(), and rt_tilestack_push().
int rt_rwlock_init | ( | rt_rwlock_t * | rwp | ) |
initialize a reader/writer lock
Definition at line 1212 of file threads.c.
References rt_cond_init(), and rt_mutex_init().
int rt_rwlock_readlock | ( | rt_rwlock_t * | rwp | ) |
set reader lock
Definition at line 1241 of file threads.c.
References rt_cond_wait(), rt_mutex_lock(), and rt_mutex_unlock().
int rt_rwlock_unlock | ( | rt_rwlock_t * | rwp | ) |
unlock reader/writer lock
Definition at line 1305 of file threads.c.
References rt_cond_signal(), rt_mutex_lock(), and rt_mutex_unlock().
int rt_rwlock_writelock | ( | rt_rwlock_t * | rwp | ) |
set writer lock
Definition at line 1270 of file threads.c.
References rt_cond_wait(), rt_mutex_lock(), and rt_mutex_unlock().
int rt_shared_iterator_destroy | ( | rt_shared_iterator_t * | it | ) |
destroy a shared iterator
Definition at line 1710 of file threads.c.
References rt_shared_iterator_struct::mtx, and rt_mutex_destroy().
Referenced by rt_threadlaunch(), and rt_threadpool_destroy().
int rt_shared_iterator_getfatalerror | ( | rt_shared_iterator_t * | it | ) |
master thread calls this to query for fatal errors
Definition at line 1785 of file threads.c.
References rt_shared_iterator_struct::fatalerror, rt_shared_iterator_struct::mtx, rt_mutex_lock(), and rt_mutex_unlock().
Referenced by rt_threadlaunch(), and rt_threadpool_getfatalerror().
int rt_shared_iterator_init | ( | rt_shared_iterator_t * | it | ) |
initialize a shared iterator
Definition at line 1700 of file threads.c.
References rt_shared_iterator_struct::mtx, and rt_mutex_init().
Referenced by rt_threadlaunch(), and rt_threadpool_create().
int rt_shared_iterator_next_tile | ( | rt_shared_iterator_t * | it, |
int | reqsize, | ||
rt_tasktile_t * | tile | ||
) |
iterate the shared iterator, over a requested half-open interval
iterate the shared iterator with a requested tile size, returns the tile received, and a return code of -1 if no iterations left or a fatal error has occured during processing, canceling all worker threads.
Definition at line 1736 of file threads.c.
References rt_shared_iterator_struct::current, rt_tasktile_struct::end, rt_shared_iterator_struct::end, rt_shared_iterator_struct::fatalerror, rt_shared_iterator_struct::mtx, rt_mutex_spin_lock(), rt_mutex_unlock(), RT_SCHED_CONTINUE, RT_SCHED_DONE, and rt_tasktile_struct::start.
Referenced by rt_threadlaunch_next_tile(), and rt_threadpool_next_tile().
int rt_shared_iterator_set | ( | rt_shared_iterator_t * | it, |
rt_tasktile_t * | tile | ||
) |
set shared iterator parameters
Set shared iterator state to half-open interval defined by tile.
Definition at line 1719 of file threads.c.
References rt_shared_iterator_struct::current, rt_tasktile_struct::end, rt_shared_iterator_struct::end, rt_shared_iterator_struct::fatalerror, rt_shared_iterator_struct::mtx, rt_mutex_lock(), rt_mutex_unlock(), rt_tasktile_struct::start, and rt_shared_iterator_struct::start.
Referenced by rt_threadlaunch(), and rt_threadpool_sched_dynamic().
int rt_shared_iterator_setfatalerror | ( | rt_shared_iterator_t * | it | ) |
worker thread calls this to indicate a fatal error
Definition at line 1772 of file threads.c.
References rt_shared_iterator_struct::fatalerror, rt_shared_iterator_struct::mtx, rt_mutex_spin_lock(), and rt_mutex_unlock().
Referenced by rt_threadlaunch_setfatalerror(), and rt_threadpool_setfatalerror().
int rt_thread_barrier | ( | rt_barrier_t * | barrier, |
int | increment | ||
) |
synchronize on counting barrier primitive
Definition at line 1425 of file threads.c.
References barrier_struct::lock, barrier_struct::n_clients, barrier_struct::n_waiting, barrier_struct::phase, barrier_struct::result, rt_cond_broadcast(), rt_cond_wait(), rt_mutex_lock(), rt_mutex_unlock(), barrier_struct::sum, and barrier_struct::wait_cv.
Referenced by destroy_render_threads(), renderscene(), thread_trace(), and thread_worker().
void rt_thread_barrier_destroy | ( | rt_barrier_t * | barrier | ) |
destroy counting barrier primitive
Definition at line 1416 of file threads.c.
References barrier_struct::lock, rt_cond_destroy(), rt_mutex_destroy(), and barrier_struct::wait_cv.
Referenced by destroy_render_threads().
rt_barrier_t* rt_thread_barrier_init | ( | int | n_clients | ) |
initialize counting barrier primitive
Definition at line 1355 of file threads.c.
References barrier_struct::lock, barrier_struct::n_clients, barrier_struct::n_waiting, barrier_struct::phase, rt_cond_init(), rt_mutex_init(), barrier_struct::sum, and barrier_struct::wait_cv.
Referenced by create_render_threads().
int rt_thread_barrier_init_proc_shared | ( | rt_barrier_t * | , |
int | n_clients | ||
) |
When rendering in the CAVE we use a special synchronization mode so that shared memory mutexes and condition variables will work correctly when accessed from multiple processes.
Inter-process synchronization involves the kernel to a greater degree, so these barriers are substantially more costly to use than the ones designed for use within a single-process.
Definition at line 1379 of file threads.c.
References barrier_struct::lock, barrier_struct::n_clients, barrier_struct::n_waiting, barrier_struct::phase, barrier_struct::sum, and barrier_struct::wait_cv.
int rt_thread_create | ( | rt_thread_t * | thr, |
void * | fctnvoid *, | ||
void * | arg | ||
) |
create a new child thread
Definition at line 645 of file threads.c.
Referenced by create_render_threads(), rt_threadlaunch(), and rt_threadpool_create().
int rt_thread_join | ( | rt_thread_t | thr, |
void ** | stat | ||
) |
join (wait for completion of, and merge with) a thread
Definition at line 688 of file threads.c.
Referenced by destroy_render_threads(), rt_threadlaunch(), and rt_threadpool_destroy().
int rt_thread_numphysprocessors | ( | void | ) |
If compiling on Linux, enable the GNU CPU affinity functions in both libc and the libpthreads.
number of physical processors available
Definition at line 114 of file threads.c.
Referenced by rt_thread_numprocessors().
int rt_thread_numprocessors | ( | void | ) |
number of processors available, subject to user override
Definition at line 202 of file threads.c.
References rt_thread_numphysprocessors().
Referenced by rt_par_getcpuinfo(), and rt_set_numthreads().
void rt_thread_run_barrier_destroy | ( | rt_run_barrier_t * | barrier | ) |
destroy thread pool barrier
Definition at line 1478 of file threads.c.
References rt_run_barrier_struct::lock, rt_cond_destroy(), rt_mutex_destroy(), and rt_run_barrier_struct::wait_cv.
Referenced by rt_threadpool_destroy().
int rt_thread_run_barrier_init | ( | rt_run_barrier_t * | barrier, |
int | n_clients | ||
) |
initialize thread pool barrier
Definition at line 1462 of file threads.c.
References rt_run_barrier_struct::fctn, rt_run_barrier_struct::lock, rt_run_barrier_struct::n_clients, rt_run_barrier_struct::n_waiting, rt_run_barrier_struct::phase, rt_cond_init(), rt_mutex_init(), and rt_run_barrier_struct::wait_cv.
Referenced by rt_threadpool_create().
int rt_thread_run_barrier_poll | ( | rt_run_barrier_t * | barrier | ) |
non-blocking poll to see if peers are already at the barrier
Definition at line 1536 of file threads.c.
References rt_run_barrier_struct::lock, rt_run_barrier_struct::n_clients, rt_run_barrier_struct::n_waiting, rt_mutex_lock(), and rt_mutex_unlock().
Referenced by rt_threadpool_poll().
int rt_thread_set_self_cpuaffinity | ( | int | cpu | ) |
set the CPU affinity of the current thread (if allowed by host system)
Definition at line 572 of file threads.c.
Referenced by thread_worker().
int rt_thread_setconcurrency | ( | int | nthr | ) |
set the concurrency level and scheduling scope for threads
Definition at line 618 of file threads.c.
Referenced by rt_set_numthreads().
int rt_threadlaunch | ( | int | numprocs, |
void * | clientdata, | ||
void * | fctnvoid *, | ||
rt_tasktile_t * | tile | ||
) |
launch up to numprocs threads using shared iterator as a load balancer
Definition at line 2085 of file threads.c.
References rt_threadlaunch_struct::clientdata, rt_threadlaunch_struct::iter, rt_shared_iterator_destroy(), rt_shared_iterator_getfatalerror(), rt_shared_iterator_init(), rt_shared_iterator_set(), rt_thread_create(), rt_thread_join(), rt_threadlaunch_struct::threadcount, and rt_threadlaunch_struct::threadid.
int rt_threadlaunch_getdata | ( | void * | voidparms, |
void ** | clientdata | ||
) |
worker thread can call this to get its client data pointer
Definition at line 2175 of file threads.c.
References rt_threadlaunch_struct::clientdata.
int rt_threadlaunch_getid | ( | void * | voidparms, |
int * | threadid, | ||
int * | threadcount | ||
) |
worker thread can call this to get its ID and number of peers
Definition at line 2162 of file threads.c.
References rt_threadlaunch_struct::threadcount, and rt_threadlaunch_struct::threadid.
int rt_threadlaunch_next_tile | ( | void * | voidparms, |
int | reqsize, | ||
rt_tasktile_t * | tile | ||
) |
iterate the shared iterator over the requested half-open interval
worker thread calls this to get its next work unit iterate the shared iterator, returns -1 if no iterations left
Definition at line 2185 of file threads.c.
References rt_threadlaunch_struct::iter, and rt_shared_iterator_next_tile().
int rt_threadlaunch_setfatalerror | ( | void * | voidparms | ) |
worker thread calls this to indicate that an unrecoverable error occured
Definition at line 2193 of file threads.c.
References rt_threadlaunch_struct::iter, and rt_shared_iterator_setfatalerror().
rt_threadpool_t* rt_threadpool_create | ( | int | workercount, |
int * | devlist | ||
) |
create a thread pool with a specified number of worker threads
Definition at line 1822 of file threads.c.
References rt_threadpool_workerdata_struct::devid, rt_threadpool_struct::devlist, rt_threadpool_workerdata_struct::devspeed, rt_threadpool_workerdata_struct::errorstack, rt_threadpool_struct::errorstack, rt_threadpool_workerdata_struct::iter, rt_threadpool_struct::iter, rt_shared_iterator_init(), rt_thread_create(), rt_thread_run_barrier_init(), rt_tilestack_init(), rt_threadpool_struct::runbar, rt_threadpool_workerdata_struct::threadcount, rt_threadpool_workerdata_struct::threadid, rt_threadpool_struct::threads, rt_threadpool_workerdata_struct::thrpool, rt_threadpool_struct::workercount, and rt_threadpool_struct::workerdata.
int rt_threadpool_destroy | ( | rt_threadpool_t * | thrpool | ) |
join all worker threads and free resources
Definition at line 1917 of file threads.c.
References rt_threadpool_struct::devlist, rt_threadpool_struct::errorstack, rt_threadpool_struct::iter, rt_shared_iterator_destroy(), rt_thread_join(), rt_thread_run_barrier, rt_thread_run_barrier_destroy(), rt_tilestack_destroy(), rt_threadpool_struct::runbar, rt_threadpool_struct::threads, rt_threadpool_struct::workercount, and rt_threadpool_struct::workerdata.
int rt_threadpool_get_workercount | ( | rt_threadpool_t * | thrpool | ) |
return the number of worker threads currently in the pool
query number of worker threads in the pool
Definition at line 1951 of file threads.c.
References rt_threadpool_struct::workercount.
int rt_threadpool_getfatalerror | ( | void * | voidparms | ) |
master thread calls this to query for fatal errors
Definition at line 2077 of file threads.c.
References rt_threadpool_workerdata_struct::iter, and rt_shared_iterator_getfatalerror().
int rt_threadpool_launch | ( | rt_threadpool_t * | thrpool, |
void * | fctnvoid *, | ||
void * | parms, | ||
int | blocking | ||
) |
launch threads onto a new function, with associated parms
Definition at line 1882 of file threads.c.
References rt_threadpool_workerdata_struct::parms, rt_thread_run_barrier, rt_threadpool_struct::runbar, and rt_threadpool_struct::workerdata.
int rt_threadpool_next_tile | ( | void * | voidparms, |
int | reqsize, | ||
rt_tasktile_t * | tile | ||
) |
iterate the shared iterator over the requested half-open interval
worker thread calls this to get its next work unit iterate the shared iterator, returns -1 if no iterations left
Definition at line 2042 of file threads.c.
References rt_threadpool_workerdata_struct::errorstack, rt_threadpool_workerdata_struct::iter, RT_SCHED_CONTINUE, RT_SCHED_DONE, rt_shared_iterator_next_tile(), RT_TILESTACK_EMPTY, and rt_tilestack_pop().
int rt_threadpool_poll | ( | rt_threadpool_t * | thrpool | ) |
Definition at line 1908 of file threads.c.
References rt_thread_run_barrier_poll(), and rt_threadpool_struct::runbar.
int rt_threadpool_sched_dynamic | ( | rt_threadpool_t * | thrpool, |
rt_tasktile_t * | tile | ||
) |
Set shared iterator state to half-open interval defined by tile.
Set dynamic scheduler state to half-open interval defined by tile.
Definition at line 2034 of file threads.c.
References rt_threadpool_struct::iter, and rt_shared_iterator_set().
int rt_threadpool_setfatalerror | ( | void * | voidparms | ) |
worker thread calls this to indicate that an unrecoverable error occured
Definition at line 2069 of file threads.c.
References rt_threadpool_workerdata_struct::iter, and rt_shared_iterator_setfatalerror().
int rt_threadpool_tile_failed | ( | void * | voidparms, |
rt_tasktile_t * | tile | ||
) |
worker thread calls this when a failure occurs on a tile it has already taken from the scheduler
worker thread calls this when it fails computing a tile after it has already taken it from the scheduler
Definition at line 2062 of file threads.c.
References rt_threadpool_workerdata_struct::errorstack, and rt_tilestack_push().
int rt_threadpool_wait | ( | rt_threadpool_t * | thrpool | ) |
wait for all worker threads to complete their work
Definition at line 1900 of file threads.c.
References rt_thread_run_barrier, and rt_threadpool_struct::runbar.
int rt_threadpool_worker_devscaletile | ( | void * | voiddata, |
int * | tilesize | ||
) |
worker thread calls this to scale max tile size by worker speed as determined by the SM/core count and clock rate
Definition at line 2008 of file threads.c.
References rt_threadpool_workerdata_struct::devspeed.
int rt_threadpool_worker_getdata | ( | void * | voiddata, |
void ** | clientdata | ||
) |
worker thread can call this to get its client data pointer
Definition at line 2024 of file threads.c.
References rt_threadpool_workerdata_struct::parms.
int rt_threadpool_worker_getdevid | ( | void * | voiddata, |
int * | devid | ||
) |
worker thread can call this to get its CPU/GPU device ID
Definition at line 1970 of file threads.c.
References rt_threadpool_workerdata_struct::devid.
int rt_threadpool_worker_getdevspeed | ( | void * | voiddata, |
float * | speed | ||
) |
worker thread calls this to get relative speed of this device as determined by the SM/core count and clock rate
Worker thread calls this to get relative speed of this device as determined by the SM/core count and clock rate.
Definition at line 1996 of file threads.c.
References rt_threadpool_workerdata_struct::devspeed.
int rt_threadpool_worker_getid | ( | void * | voiddata, |
int * | threadid, | ||
int * | threadcount | ||
) |
worker thread can call this to get its ID and number of peers
Definition at line 1957 of file threads.c.
References rt_threadpool_workerdata_struct::threadcount, and rt_threadpool_workerdata_struct::threadid.
int rt_threadpool_worker_setdevspeed | ( | void * | voiddata, |
float | speed | ||
) |
worker thread calls this to set relative speed of this device as determined by the SM/core count and clock rate Note: this should only be called once, during the worker's device initialization process
Worker thread calls this to set relative speed of this device as determined by the SM/core count and clock rate Note: this should only be called once, during the worker's device initialization process.
Definition at line 1985 of file threads.c.
References rt_threadpool_workerdata_struct::devspeed.
int rt_tilestack_compact | ( | rt_tilestack_t * | s | ) |
shrink memory buffers associated with task tile stack if possible
Definition at line 1584 of file threads.c.
References rt_tilestack_t::mtx, rt_mutex_lock(), rt_mutex_unlock(), rt_tilestack_t::s, rt_tilestack_t::size, and rt_tilestack_t::top.
void rt_tilestack_destroy | ( | rt_tilestack_t * | s | ) |
destroy task tile stack
Definition at line 1575 of file threads.c.
References rt_tilestack_t::mtx, rt_mutex_destroy(), and rt_tilestack_t::s.
Referenced by rt_threadpool_destroy().
int rt_tilestack_empty | ( | rt_tilestack_t * | s | ) |
query if the task tile stack is empty or not
Definition at line 1675 of file threads.c.
References rt_tilestack_t::mtx, rt_mutex_lock(), rt_mutex_unlock(), and rt_tilestack_t::top.
int rt_tilestack_init | ( | rt_tilestack_t * | s, |
int | size | ||
) |
initialize task tile stack (to empty)
Definition at line 1552 of file threads.c.
References rt_tilestack_t::growthrate, rt_tilestack_t::mtx, rt_mutex_init(), rt_tilestack_t::s, rt_tilestack_t::size, and rt_tilestack_t::top.
Referenced by rt_threadpool_create().
int rt_tilestack_pop | ( | rt_tilestack_t * | s, |
rt_tasktile_t * | t | ||
) |
pop a task tile off of the stack
Definition at line 1637 of file threads.c.
References rt_tilestack_t::mtx, rt_mutex_lock(), rt_mutex_unlock(), RT_TILESTACK_EMPTY, rt_tilestack_t::s, and rt_tilestack_t::top.
Referenced by rt_threadpool_next_tile().
int rt_tilestack_popall | ( | rt_tilestack_t * | s | ) |
pop all of the task tiles off of the stack
Definition at line 1660 of file threads.c.
References rt_tilestack_t::mtx, rt_mutex_lock(), rt_mutex_unlock(), and rt_tilestack_t::top.
int rt_tilestack_push | ( | rt_tilestack_t * | s, |
const rt_tasktile_t * | t | ||
) |
push a task tile onto the stack
Definition at line 1608 of file threads.c.
References rt_tilestack_t::growthrate, rt_tilestack_t::mtx, rt_mutex_lock(), rt_mutex_unlock(), rt_tilestack_t::s, rt_tilestack_t::size, and rt_tilestack_t::top.
Referenced by rt_threadpool_tile_failed().
void*(*)(void *) rt_thread_run_barrier(rt_run_barrier_t *barrier, void *fctn(void *), void *parms, void **rsltparms) |
Wait until all threads reach barrier, and return the function pointer passed in by the master thread.
Definition at line 1490 of file threads.c.
Referenced by rt_threadpool_destroy(), rt_threadpool_launch(), and rt_threadpool_wait().