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.
Data Structures | |
struct | rt_cpu_caps_struct |
struct | atomic_int_struct |
atomic int structure with padding to prevent false sharing More... | |
struct | barrier_struct |
barrier sync object with padding to prevent false sharing More... | |
struct | rt_run_barrier_struct |
run-barrier sync object with padding to prevent false sharing More... | |
struct | rt_tasktile_struct |
Task tile struct for stack, iterator, and scheduler routines; 'start' is inclusive, 'end' is exclusive. More... | |
struct | rt_tilestack_t |
stack of work tiles, for error handling More... | |
struct | rt_shared_iterator_struct |
iterator used for dynamic load balancing More... | |
struct | rt_threadpool_workerdata_struct |
thread-specific handle data for workers More... | |
struct | rt_threadpool_struct |
persistent thread pool More... | |
struct | rt_threadlaunch_struct |
Routines to generate a pool of threads which then grind through a dynamically load balanced work queue implemented as a shared iterator. More... | |
Macros | |
#define | CPU_SMTDEPTH_UNKNOWN 0 |
Unknown SMT depth. More... | |
#define | CPU_UNKNOWN 0x00000001 |
Unknown CPU type. More... | |
#define | CPU_HT 0x00000010 |
x86 Hyperthreading detected More... | |
#define | CPU_HYPERVISOR 0x00000020 |
VM/Hypervisor environment. More... | |
#define | CPU_SSE2 0x00000100 |
SSE2 SIMD avail. More... | |
#define | CPU_SSE4_1 0x00000200 |
SSE4.1 SIMD avail. More... | |
#define | CPU_F16C 0x00000400 |
F16C insns avail. More... | |
#define | CPU_FMA 0x00000800 |
FMA insns avail. More... | |
#define | CPU_AVX 0x00001000 |
AVX SIMD avail. More... | |
#define | CPU_AVX2 0x00002000 |
AVX2 SIMD avail. More... | |
#define | CPU_AVX512F 0x00010000 |
AVX-512F SIMD avail. More... | |
#define | CPU_AVX512CD 0x00020000 |
AVX-512CD SIMD avail. More... | |
#define | CPU_AVX512ER 0x00040000 |
AVX-512ER SIMD avail. More... | |
#define | CPU_AVX512PF 0x00080000 |
AVX-512PF SIMD avail. More... | |
#define | CPU_KNL |
Intel KNL. More... | |
#define | CPU_ARM64_CPUID 0x00000010 |
ARM64 CPUID. More... | |
#define | CPU_ARM64_CRC32 0x00000020 |
CRC32 insns avail. More... | |
#define | CPU_ARM64_FP 0x00000080 |
FP insns avail. More... | |
#define | CPU_ARM64_HPFP 0x00000080 |
High-prec FP insns avail. More... | |
#define | CPU_ARM64_AES 0x00000100 |
AES insns avail. More... | |
#define | CPU_ARM64_ATOMICS 0x00000200 |
Atomic insns avail. More... | |
#define | CPU_ARM64_ASIMD 0x00000400 |
Advanced SIMD avail. More... | |
#define | CPU_ARM64_ASIMDDP 0x00000800 |
Advanced SIMD DP avail. More... | |
#define | CPU_ARM64_ASIMDHP 0x00001000 |
Advanced SIMD HP avail. More... | |
#define | CPU_ARM64_ASIMDRDM 0x00002000 |
Advanced SIMD RDM avail. More... | |
#define | CPU_ARM64_ASIMDFHM 0x00004000 |
Advanced SIMD FHM avail. More... | |
#define | CPU_ARM64_SVE 0x00008000 |
Scalable Vector Extns avail. More... | |
#define | CPU_ARM64_SHA512 0x00010000 |
SHA-512 insns avail. More... | |
#define | CPU_ARM64_SHA1 0x00020000 |
SHA-1 insns avail. More... | |
#define | CPU_ARM64_SHA2 0x00040000 |
SHA-2 insns avail. More... | |
#define | CPU_ARM64_SHA3 0x00080000 |
SHA-3 insns avail. More... | |
#define | RT_TILESTACK_EMPTY -1 |
#define | RT_SCHED_DONE -1 |
Shared iterators intended for trivial CPU/GPU load balancing with no exception handling capability (all work units must complete with no errors, or else the whole thing is canceled). More... | |
#define | RT_SCHED_CONTINUE 0 |
some work remains in the queue More... | |
#define | RT_THREADPOOL_DEVLIST_CPUSONLY NULL |
shortcut macro to tell the create routine we only want CPU cores More... | |
#define | RT_THREADPOOL_DEVID_CPU -1 |
symbolic constant macro to test if we have a GPU or not More... | |
Typedefs | |
typedef struct rt_cpu_caps_struct | rt_cpu_caps_t |
typedef int | rt_thread_t |
typedef int | rt_mutex_t |
typedef int | rt_cond_t |
typedef int | rt_rwlock_t |
typedef struct atomic_int_struct | rt_atomic_int_t |
atomic int structure with padding to prevent false sharing More... | |
typedef struct barrier_struct | rt_barrier_t |
barrier sync object with padding to prevent false sharing More... | |
typedef struct rt_run_barrier_struct | rt_run_barrier_t |
run-barrier sync object with padding to prevent false sharing More... | |
typedef struct rt_tasktile_struct | rt_tasktile_t |
Task tile struct for stack, iterator, and scheduler routines; 'start' is inclusive, 'end' is exclusive. More... | |
typedef struct rt_shared_iterator_struct | rt_shared_iterator_t |
iterator used for dynamic load balancing More... | |
typedef struct rt_threadpool_workerdata_struct | rt_threadpool_workerdata_t |
thread-specific handle data for workers More... | |
typedef struct rt_threadpool_struct | rt_threadpool_t |
persistent thread pool More... | |
typedef struct rt_threadlaunch_struct | rt_threadlaunch_t |
Routines to generate a pool of threads which then grind through a dynamically load balanced work queue implemented as a shared iterator. More... | |
Functions | |
int | rt_thread_numphysprocessors (void) |
number of physical processors available 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) |
set the concurrency level and scheduling scope for threads More... | |
int | rt_thread_create (rt_thread_t *, void *fctn(void *), void *) |
create a new child thread More... | |
int | rt_thread_join (rt_thread_t, void **) |
join (wait for completion of, and merge with) a thread More... | |
int | rt_mutex_init (rt_mutex_t *) |
initialize a mutex More... | |
int | rt_mutex_lock (rt_mutex_t *) |
lock a mutex More... | |
int | rt_mutex_trylock (rt_mutex_t *) |
try to lock a mutex More... | |
int | rt_mutex_spin_lock (rt_mutex_t *) |
lock a mutex by spinning only More... | |
int | rt_mutex_unlock (rt_mutex_t *) |
unlock a mutex More... | |
int | rt_mutex_destroy (rt_mutex_t *) |
destroy a mutex More... | |
int | rt_cond_init (rt_cond_t *) |
initialize a condition variable More... | |
int | rt_cond_destroy (rt_cond_t *) |
destroy a condition variable More... | |
int | rt_cond_wait (rt_cond_t *, rt_mutex_t *) |
wait on a condition variable More... | |
int | rt_cond_signal (rt_cond_t *) |
signal a condition variable, waking at least one thread More... | |
int | rt_cond_broadcast (rt_cond_t *) |
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 *) |
initialize a reader/writer lock More... | |
int | rt_rwlock_readlock (rt_rwlock_t *) |
set reader lock More... | |
int | rt_rwlock_writelock (rt_rwlock_t *) |
set writer lock More... | |
int | rt_rwlock_unlock (rt_rwlock_t *) |
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 *, 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 *) |
destroy task tile stack More... | |
int | rt_tilestack_compact (rt_tilestack_t *) |
shrink memory buffers associated with task tile stack if possible More... | |
int | rt_tilestack_push (rt_tilestack_t *, const rt_tasktile_t *) |
push a task tile onto the stack More... | |
int | rt_tilestack_pop (rt_tilestack_t *, rt_tasktile_t *) |
pop a task tile off of the stack More... | |
int | rt_tilestack_popall (rt_tilestack_t *) |
pop all of the task tiles off of the stack More... | |
int | rt_tilestack_empty (rt_tilestack_t *) |
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 state to half-open interval defined by tile. More... | |
int | rt_shared_iterator_next_tile (rt_shared_iterator_t *it, int reqsize, rt_tasktile_t *tile) |
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. 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_destroy (rt_threadpool_t *thrpool) |
join all worker threads and free resources More... | |
int | rt_threadpool_get_workercount (rt_threadpool_t *thrpool) |
query number of worker threads 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 dynamic scheduler state to half-open interval defined by tile. More... | |
int | rt_threadpool_next_tile (void *thrpool, int reqsize, rt_tasktile_t *tile) |
worker thread calls this to get its next work unit iterate the shared iterator, returns -1 if no iterations left More... | |
int | rt_threadpool_tile_failed (void *thrpool, rt_tasktile_t *tile) |
worker thread calls this when it fails computing a tile after it has already taken it from the scheduler More... | |
int | rt_threadpool_setfatalerror (void *thrparms) |
worker thread calls this to indicate that an unrecoverable error occured More... | |
int | rt_threadpool_getfatalerror (void *thrparms) |
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 *thrparms, int *threadid, int *threadcount) |
worker thread can call this to get its ID and number of peers More... | |
int | rt_threadlaunch_getdata (void *thrparms, 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) |
worker thread calls this to get its next work unit iterate the shared iterator, returns -1 if no iterations left More... | |
int | rt_threadlaunch_setfatalerror (void *thrparms) |
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) |
sleeping barrier synchronization for thread pool More... | |
Tachyon cross-platform thread creation and management, atomic operations, and CPU feature query APIs.
Definition in file threads.h.
#define CPU_ARM64_AES 0x00000100 |
AES insns avail.
Definition at line 75 of file threads.h.
Referenced by rendercheck(), and rt_cpu_capability_flags().
#define CPU_ARM64_ASIMD 0x00000400 |
Advanced SIMD avail.
Definition at line 77 of file threads.h.
Referenced by rendercheck(), and rt_cpu_capability_flags().
#define CPU_ARM64_ASIMDDP 0x00000800 |
Advanced SIMD DP avail.
Definition at line 78 of file threads.h.
Referenced by rendercheck(), and rt_cpu_capability_flags().
#define CPU_ARM64_ASIMDFHM 0x00004000 |
Advanced SIMD FHM avail.
Definition at line 81 of file threads.h.
Referenced by rendercheck(), and rt_cpu_capability_flags().
#define CPU_ARM64_ASIMDHP 0x00001000 |
Advanced SIMD HP avail.
Definition at line 79 of file threads.h.
Referenced by rendercheck(), and rt_cpu_capability_flags().
#define CPU_ARM64_ASIMDRDM 0x00002000 |
Advanced SIMD RDM avail.
Definition at line 80 of file threads.h.
Referenced by rendercheck(), and rt_cpu_capability_flags().
#define CPU_ARM64_CRC32 0x00000020 |
CRC32 insns avail.
Definition at line 72 of file threads.h.
Referenced by rendercheck(), and rt_cpu_capability_flags().
#define CPU_ARM64_FP 0x00000080 |
FP insns avail.
Definition at line 73 of file threads.h.
Referenced by rendercheck(), and rt_cpu_capability_flags().
#define CPU_ARM64_HPFP 0x00000080 |
#define CPU_ARM64_SHA1 0x00020000 |
SHA-1 insns avail.
Definition at line 84 of file threads.h.
Referenced by rendercheck(), and rt_cpu_capability_flags().
#define CPU_ARM64_SHA2 0x00040000 |
SHA-2 insns avail.
Definition at line 85 of file threads.h.
Referenced by rendercheck(), and rt_cpu_capability_flags().
#define CPU_ARM64_SHA3 0x00080000 |
SHA-3 insns avail.
Definition at line 86 of file threads.h.
Referenced by rendercheck(), and rt_cpu_capability_flags().
#define CPU_ARM64_SHA512 0x00010000 |
SHA-512 insns avail.
Definition at line 83 of file threads.h.
Referenced by rendercheck(), and rt_cpu_capability_flags().
#define CPU_ARM64_SVE 0x00008000 |
Scalable Vector Extns avail.
Definition at line 82 of file threads.h.
Referenced by rendercheck(), and rt_cpu_capability_flags().
#define CPU_AVX 0x00001000 |
AVX SIMD avail.
Definition at line 61 of file threads.h.
Referenced by rendercheck(), and rt_cpu_capability_flags().
#define CPU_AVX2 0x00002000 |
AVX2 SIMD avail.
Definition at line 62 of file threads.h.
Referenced by rendercheck(), and rt_cpu_capability_flags().
#define CPU_AVX512CD 0x00020000 |
AVX-512CD SIMD avail.
Definition at line 64 of file threads.h.
Referenced by rendercheck(), and rt_cpu_capability_flags().
#define CPU_AVX512ER 0x00040000 |
AVX-512ER SIMD avail.
Definition at line 65 of file threads.h.
Referenced by rendercheck(), and rt_cpu_capability_flags().
#define CPU_AVX512F 0x00010000 |
AVX-512F SIMD avail.
Definition at line 63 of file threads.h.
Referenced by rendercheck(), and rt_cpu_capability_flags().
#define CPU_AVX512PF 0x00080000 |
AVX-512PF SIMD avail.
Definition at line 66 of file threads.h.
Referenced by rendercheck(), and rt_cpu_capability_flags().
#define CPU_F16C 0x00000400 |
F16C insns avail.
Definition at line 59 of file threads.h.
Referenced by rendercheck(), and rt_cpu_capability_flags().
#define CPU_FMA 0x00000800 |
FMA insns avail.
Definition at line 60 of file threads.h.
Referenced by rendercheck(), and rt_cpu_capability_flags().
#define CPU_HT 0x00000010 |
x86 Hyperthreading detected
Definition at line 55 of file threads.h.
Referenced by rendercheck(), and rt_cpu_capability_flags().
#define CPU_HYPERVISOR 0x00000020 |
VM/Hypervisor environment.
Definition at line 56 of file threads.h.
Referenced by rendercheck(), and rt_cpu_capability_flags().
#define CPU_KNL |
Intel KNL.
Definition at line 67 of file threads.h.
Referenced by rendercheck().
#define CPU_SMTDEPTH_UNKNOWN 0 |
Unknown SMT depth.
Definition at line 51 of file threads.h.
Referenced by rt_cpu_capability_flags(), and rt_cpu_smt_depth().
#define CPU_SSE2 0x00000100 |
SSE2 SIMD avail.
Definition at line 57 of file threads.h.
Referenced by rendercheck(), and rt_cpu_capability_flags().
#define CPU_SSE4_1 0x00000200 |
SSE4.1 SIMD avail.
Definition at line 58 of file threads.h.
Referenced by rendercheck(), and rt_cpu_capability_flags().
#define CPU_UNKNOWN 0x00000001 |
#define RT_SCHED_CONTINUE 0 |
some work remains in the queue
Definition at line 437 of file threads.h.
Referenced by rt_shared_iterator_next_tile(), and rt_threadpool_next_tile().
#define RT_SCHED_DONE -1 |
Shared iterators intended for trivial CPU/GPU load balancing with no exception handling capability (all work units must complete with no errors, or else the whole thing is canceled).
no work left to process
Definition at line 436 of file threads.h.
Referenced by rt_shared_iterator_next_tile(), and rt_threadpool_next_tile().
#define RT_THREADPOOL_DEVID_CPU -1 |
#define RT_THREADPOOL_DEVLIST_CPUSONLY NULL |
#define RT_TILESTACK_EMPTY -1 |
Definition at line 396 of file threads.h.
Referenced by rt_threadpool_next_tile(), and rt_tilestack_pop().
typedef struct atomic_int_struct rt_atomic_int_t |
atomic int structure with padding to prevent false sharing
typedef struct barrier_struct rt_barrier_t |
barrier sync object with padding to prevent false sharing
typedef struct rt_cpu_caps_struct rt_cpu_caps_t |
typedef int rt_mutex_t |
typedef struct rt_run_barrier_struct rt_run_barrier_t |
run-barrier sync object with padding to prevent false sharing
typedef int rt_rwlock_t |
typedef struct rt_shared_iterator_struct rt_shared_iterator_t |
iterator used for dynamic load balancing
typedef struct rt_tasktile_struct rt_tasktile_t |
Task tile struct for stack, iterator, and scheduler routines; 'start' is inclusive, 'end' is exclusive.
This yields a half-open interval that corresponds to a typical 'for' loop.
typedef int rt_thread_t |
typedef struct rt_threadlaunch_struct rt_threadlaunch_t |
Routines to generate a pool of threads which then grind through a dynamically load balanced work queue implemented as a shared iterator.
No exception handling is possible, just a simple all-or-nothing attept. Useful for simple calculations that take very little time. An array of threads is generated, launched, and joined all with one call.
typedef struct rt_threadpool_struct rt_threadpool_t |
persistent thread pool
typedef struct rt_threadpool_workerdata_struct rt_threadpool_workerdata_t |
thread-specific handle data for workers
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 * | ) |
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 * | ) |
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 * | ) |
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 * | ) |
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 * | , |
rt_mutex_t * | |||
) |
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 * | ) |
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 * | ) |
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 * | ) |
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 * | ) |
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 * | ) |
int rt_mutex_unlock | ( | rt_mutex_t * | ) |
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 * | ) |
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 * | ) |
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 * | ) |
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 * | ) |
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 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.
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 state to half-open interval defined by tile.
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 * | , |
void * | fctnvoid *, | ||
void * | |||
) |
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 | , |
void ** | |||
) |
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 | ) |
number of physical processors available
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 | ) |
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 * | thrparms, |
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 * | thrparms, |
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 | ||
) |
worker thread calls this to get its next work unit iterate the shared iterator, returns -1 if no iterations left
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 * | thrparms | ) |
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 | ) |
query number of worker threads 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 * | thrparms | ) |
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 | ||
) |
worker thread calls this to get its next work unit iterate the shared iterator, returns -1 if no iterations left
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_sched_dynamic | ( | rt_threadpool_t * | thrpool, |
rt_tasktile_t * | tile | ||
) |
Set dynamic scheduler 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 * | thrparms | ) |
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 it fails computing a tile after it has already taken it 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 * | ) |
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 * | ) |
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 * | ) |
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 * | , |
rt_tasktile_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 * | ) |
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 * | , |
const rt_tasktile_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) |