Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

WKFThreads.C File Reference

Cross-platform APIs for multithreading and atomic ops. More...

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "WKFThreads.h"

Go to the source code of this file.

Defines

#define WKF_USEINTCPUID   1

Typedefs

typedef void *(* WKFTHREAD_START_ROUTINE )(void *)

Functions

int wkf_thread_numphysprocessors (void)
int wkf_thread_numprocessors (void)
int wkf_cpu_capability_flags (wkf_cpu_caps_t *cpucaps)
int wkf_cpu_smt_depth (void)
int * wkf_cpu_affinitylist (int *cpuaffinitycount)
int wkf_thread_set_self_cpuaffinity (int cpu)
int wkf_thread_setconcurrency (int nthr)
int wkf_thread_create (wkf_thread_t *thr, void *fctn(void *), void *arg)
int wkf_thread_join (wkf_thread_t thr, void **stat)
int wkf_mutex_init (wkf_mutex_t *mp)
int wkf_mutex_lock (wkf_mutex_t *mp)
int wkf_mutex_trylock (wkf_mutex_t *mp)
int wkf_mutex_spin_lock (wkf_mutex_t *mp)
int wkf_mutex_unlock (wkf_mutex_t *mp)
int wkf_mutex_destroy (wkf_mutex_t *mp)
int wkf_cond_init (wkf_cond_t *cvp)
int wkf_cond_destroy (wkf_cond_t *cvp)
int wkf_cond_wait (wkf_cond_t *cvp, wkf_mutex_t *mp)
int wkf_cond_signal (wkf_cond_t *cvp)
int wkf_cond_broadcast (wkf_cond_t *cvp)
int wkf_atomic_int_init (wkf_atomic_int_t *atomp, int val)
int wkf_atomic_int_destroy (wkf_atomic_int_t *atomp)
int wkf_atomic_int_set (wkf_atomic_int_t *atomp, int val)
int wkf_atomic_int_get (wkf_atomic_int_t *atomp)
int wkf_atomic_int_fetch_and_add (wkf_atomic_int_t *atomp, int inc)
int wkf_atomic_int_add_and_fetch (wkf_atomic_int_t *atomp, int inc)
int wkf_rwlock_init (wkf_rwlock_t *rwp)
int wkf_rwlock_readlock (wkf_rwlock_t *rwp)
int wkf_rwlock_writelock (wkf_rwlock_t *rwp)
int wkf_rwlock_unlock (wkf_rwlock_t *rwp)
wkf_barrier_twkf_thread_barrier_init (int n_clients)
int wkf_thread_barrier_init_proc_shared (wkf_barrier_t *barrier, int n_clients)
void wkf_thread_barrier_destroy (wkf_barrier_t *barrier)
int wkf_thread_barrier (wkf_barrier_t *barrier, int increment)
int wkf_thread_run_barrier_init (wkf_run_barrier_t *barrier, int n_clients)
void wkf_thread_run_barrier_destroy (wkf_run_barrier_t *barrier)
void *(*)(void *) wkf_thread_run_barrier (wkf_run_barrier_t *barrier, void *fctn(void *), void *parms, void **rsltparms)
int wkf_thread_run_barrier_poll (wkf_run_barrier_t *barrier)
int wkf_tilestack_init (wkf_tilestack_t *s, int size)
void wkf_tilestack_destroy (wkf_tilestack_t *s)
int wkf_tilestack_compact (wkf_tilestack_t *s)
int wkf_tilestack_push (wkf_tilestack_t *s, const wkf_tasktile_t *t)
int wkf_tilestack_pop (wkf_tilestack_t *s, wkf_tasktile_t *t)
int wkf_tilestack_popall (wkf_tilestack_t *s)
int wkf_tilestack_empty (wkf_tilestack_t *s)
int wkf_shared_iterator_init (wkf_shared_iterator_t *it)
int wkf_shared_iterator_destroy (wkf_shared_iterator_t *it)
int wkf_shared_iterator_set (wkf_shared_iterator_t *it, wkf_tasktile_t *tile)
int wkf_shared_iterator_next_tile (wkf_shared_iterator_t *it, int reqsize, wkf_tasktile_t *tile)
int wkf_shared_iterator_setfatalerror (wkf_shared_iterator_t *it)
int wkf_shared_iterator_getfatalerror (wkf_shared_iterator_t *it)
wkf_threadpool_twkf_threadpool_create (int workercount, int *devlist)
int wkf_threadpool_launch (wkf_threadpool_t *thrpool, void *fctn(void *), void *parms, int blocking)
int wkf_threadpool_wait (wkf_threadpool_t *thrpool)
int wkf_threadpool_poll (wkf_threadpool_t *thrpool)
int wkf_threadpool_destroy (wkf_threadpool_t *thrpool)
int wkf_threadpool_get_workercount (wkf_threadpool_t *thrpool)
int wkf_threadpool_worker_getid (void *voiddata, int *threadid, int *threadcount)
int wkf_threadpool_worker_getdevid (void *voiddata, int *devid)
int wkf_threadpool_worker_setdevspeed (void *voiddata, float speed)
int wkf_threadpool_worker_getdevspeed (void *voiddata, float *speed)
int wkf_threadpool_worker_devscaletile (void *voiddata, int *tilesize)
int wkf_threadpool_worker_getdata (void *voiddata, void **clientdata)
int wkf_threadpool_sched_dynamic (wkf_threadpool_t *thrpool, wkf_tasktile_t *tile)
int wkf_threadpool_next_tile (void *voidparms, int reqsize, wkf_tasktile_t *tile)
int wkf_threadpool_tile_failed (void *voidparms, wkf_tasktile_t *tile)
int wkf_threadpool_setfatalerror (void *voidparms)
int wkf_threadpool_getfatalerror (void *voidparms)
int wkf_threadlaunch (int numprocs, void *clientdata, void *fctn(void *), wkf_tasktile_t *tile)
int wkf_threadlaunch_getid (void *voidparms, int *threadid, int *threadcount)
int wkf_threadlaunch_getdata (void *voidparms, void **clientdata)
int wkf_threadlaunch_next_tile (void *voidparms, int reqsize, wkf_tasktile_t *tile)
int wkf_threadlaunch_setfatalerror (void *voidparms)


Detailed Description

Cross-platform APIs for multithreading and atomic ops.

Code for spawning threads on various platforms. Code donated by John Stone, john.stone@gmail.com This code was originally written for the Tachyon Parallel/Multiprocessor Ray Tracer. Improvements have been donated by Mr. Stone on an ongoing basis. This code is provided under the three clause BSD Open Source License.

NOTE: The latest version of this source file can be re-generated by running the sequence of 'sed' commands shown at the top of the "threads.c" file within the Tachyon source distribution.

Revision:
1.36
Date:
2022/04/08 08:06:44

Author:
John E. Stone - john.stone@gmail.com \copyright This trivial code is made available under the "new" 3-clause BSD license, and/or any of the GPL licenses you prefer. Feel free to use the code and modify as you see fit.

Definition in file WKFThreads.C.


Define Documentation

#define WKF_USEINTCPUID   1
 

Definition at line 244 of file WKFThreads.C.


Typedef Documentation

typedef void*(* WKFTHREAD_START_ROUTINE)(void *)
 

Typedef to eliminate compiler warning caused by C/C++ linkage conflict.

Definition at line 653 of file WKFThreads.C.

Referenced by wkf_thread_create.


Function Documentation

int wkf_atomic_int_add_and_fetch wkf_atomic_int_t   atomp,
int    inc
 

fetch an atomic int and add inc to it, returning new value

Definition at line 1190 of file WKFThreads.C.

References atomic_int_struct::lock, atomic_int_struct::val, wkf_mutex_lock, and wkf_mutex_unlock.

int wkf_atomic_int_destroy wkf_atomic_int_t   atomp
 

destroy an atomic int variable

Definition at line 1076 of file WKFThreads.C.

References atomic_int_struct::lock, and wkf_mutex_destroy.

int wkf_atomic_int_fetch_and_add wkf_atomic_int_t   atomp,
int    inc
 

fetch an atomic int and add inc to it, returning original value

Definition at line 1162 of file WKFThreads.C.

References atomic_int_struct::lock, atomic_int_struct::val, wkf_mutex_lock, and wkf_mutex_unlock.

int wkf_atomic_int_get wkf_atomic_int_t   atomp
 

get an atomic int variable

Definition at line 1133 of file WKFThreads.C.

References atomic_int_struct::lock, atomic_int_struct::val, wkf_mutex_lock, and wkf_mutex_unlock.

int wkf_atomic_int_init wkf_atomic_int_t   atomp,
int    val
 

initialize an atomic int variable

Definition at line 1053 of file WKFThreads.C.

References atomic_int_struct::lock, atomic_int_struct::val, and wkf_mutex_init.

int wkf_atomic_int_set wkf_atomic_int_t   atomp,
int    val
 

set an atomic int variable

Definition at line 1097 of file WKFThreads.C.

References atomic_int_struct::lock, atomic_int_struct::val, wkf_mutex_lock, and wkf_mutex_unlock.

int wkf_cond_broadcast wkf_cond_t  
 

signal a condition variable, waking all threads

Definition at line 1013 of file WKFThreads.C.

References wkf_cond_t.

int wkf_cond_destroy wkf_cond_t  
 

destroy a condition variable

Definition at line 898 of file WKFThreads.C.

References wkf_cond_t.

int wkf_cond_init wkf_cond_t  
 

initialize a condition variable

Definition at line 862 of file WKFThreads.C.

References NULL, and wkf_cond_t.

int wkf_cond_signal wkf_cond_t  
 

signal a condition variable, waking at least one thread

Definition at line 981 of file WKFThreads.C.

References wkf_cond_t.

int wkf_cond_wait wkf_cond_t  ,
wkf_mutex_t  
 

wait on a condition variable

Definition at line 922 of file WKFThreads.C.

References result, wkf_cond_t, and wkf_mutex_t.

int* wkf_cpu_affinitylist int *    cpuaffinitycount
 

query CPU affinity of the calling process (if allowed by host system)

Definition at line 493 of file WKFThreads.C.

References NULL.

int wkf_cpu_capability_flags wkf_cpu_caps_t   cpucaps
 

CPU optional instruction set capability flags

Definition at line 292 of file WKFThreads.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, wkf_cpu_caps_struct::flags, and wkf_cpu_caps_struct::smtdepth.

int wkf_cpu_smt_depth void   
 

Definition at line 476 of file WKFThreads.C.

References CPU_SMTDEPTH_UNKNOWN, wkf_cpu_caps_struct::smtdepth, and wkf_cpu_capability_flags.

int wkf_mutex_destroy wkf_mutex_t  
 

destroy a mutex

Definition at line 838 of file WKFThreads.C.

References wkf_mutex_t.

int wkf_mutex_init wkf_mutex_t  
 

initialize a mutex

Definition at line 731 of file WKFThreads.C.

References NULL, and wkf_mutex_t.

int wkf_mutex_lock wkf_mutex_t  
 

lock a mutex

Definition at line 752 of file WKFThreads.C.

References wkf_mutex_t.

int wkf_mutex_spin_lock wkf_mutex_t  
 

lock a mutex by spinning only

Definition at line 794 of file WKFThreads.C.

References wkf_mutex_t.

int wkf_mutex_trylock wkf_mutex_t  
 

try to lock a mutex

Definition at line 773 of file WKFThreads.C.

References wkf_mutex_t.

int wkf_mutex_unlock wkf_mutex_t  
 

unlock a mutex

Definition at line 817 of file WKFThreads.C.

References wkf_mutex_t.

int wkf_rwlock_init wkf_rwlock_t  
 

initialize a reader/writer lock

Definition at line 1222 of file WKFThreads.C.

References NULL, wkf_cond_init, wkf_mutex_init, and wkf_rwlock_t.

int wkf_rwlock_readlock wkf_rwlock_t  
 

set reader lock

Definition at line 1251 of file WKFThreads.C.

References wkf_cond_wait, wkf_mutex_lock, wkf_mutex_unlock, and wkf_rwlock_t.

int wkf_rwlock_unlock wkf_rwlock_t  
 

unlock reader/writer lock

Definition at line 1315 of file WKFThreads.C.

References wkf_cond_signal, wkf_mutex_lock, wkf_mutex_unlock, and wkf_rwlock_t.

int wkf_rwlock_writelock wkf_rwlock_t  
 

set writer lock

Definition at line 1280 of file WKFThreads.C.

References wkf_cond_wait, wkf_mutex_lock, wkf_mutex_unlock, and wkf_rwlock_t.

int wkf_shared_iterator_destroy wkf_shared_iterator_t   it
 

destroy a shared iterator

Definition at line 1720 of file WKFThreads.C.

References it, wkf_shared_iterator_struct::mtx, and wkf_mutex_destroy.

int wkf_shared_iterator_getfatalerror wkf_shared_iterator_t   it
 

master thread calls this to query for fatal errors

Definition at line 1795 of file WKFThreads.C.

References wkf_shared_iterator_struct::fatalerror, it, wkf_shared_iterator_struct::mtx, wkf_mutex_lock, and wkf_mutex_unlock.

int wkf_shared_iterator_init wkf_shared_iterator_t   it
 

initialize a shared iterator

Definition at line 1710 of file WKFThreads.C.

References it, wkf_shared_iterator_struct::mtx, and wkf_mutex_init.

int wkf_shared_iterator_next_tile wkf_shared_iterator_t   it,
int    reqsize,
wkf_tasktile_t   tile
 

iterate the shared iterator, over a requested half-open interval

Definition at line 1746 of file WKFThreads.C.

References wkf_shared_iterator_struct::current, wkf_shared_iterator_struct::end, wkf_tasktile_struct::end, wkf_shared_iterator_struct::fatalerror, it, wkf_shared_iterator_struct::mtx, wkf_tasktile_struct::start, wkf_mutex_spin_lock, wkf_mutex_unlock, WKF_SCHED_CONTINUE, and WKF_SCHED_DONE.

int wkf_shared_iterator_set wkf_shared_iterator_t   it,
wkf_tasktile_t   tile
 

set shared iterator parameters

Definition at line 1729 of file WKFThreads.C.

References wkf_shared_iterator_struct::current, wkf_tasktile_struct::end, wkf_shared_iterator_struct::end, wkf_shared_iterator_struct::fatalerror, it, wkf_shared_iterator_struct::mtx, wkf_tasktile_struct::start, wkf_shared_iterator_struct::start, wkf_mutex_lock, and wkf_mutex_unlock.

int wkf_shared_iterator_setfatalerror wkf_shared_iterator_t   it
 

worker thread calls this to indicate a fatal error

Definition at line 1782 of file WKFThreads.C.

References wkf_shared_iterator_struct::fatalerror, it, wkf_shared_iterator_struct::mtx, wkf_mutex_spin_lock, and wkf_mutex_unlock.

int wkf_thread_barrier wkf_barrier_t   barrier,
int    increment
 

synchronize on counting barrier primitive

Definition at line 1435 of file WKFThreads.C.

References barrier_struct::lock, barrier_struct::n_clients, barrier_struct::n_waiting, barrier_struct::phase, barrier_struct::result, barrier_struct::sum, barrier_struct::wait_cv, wkf_cond_broadcast, wkf_cond_wait, wkf_mutex_lock, and wkf_mutex_unlock.

void wkf_thread_barrier_destroy wkf_barrier_t   barrier
 

destroy counting barrier primitive

Definition at line 1426 of file WKFThreads.C.

References barrier_struct::lock, barrier_struct::wait_cv, wkf_cond_destroy, and wkf_mutex_destroy.

wkf_barrier_t* wkf_thread_barrier_init int    n_clients
 

initialize counting barrier primitive

Definition at line 1365 of file WKFThreads.C.

References barrier_struct::lock, barrier_struct::n_clients, barrier_struct::n_waiting, NULL, barrier_struct::phase, barrier_struct::sum, barrier_struct::wait_cv, wkf_cond_init, and wkf_mutex_init.

int wkf_thread_barrier_init_proc_shared wkf_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 1389 of file WKFThreads.C.

References barrier_struct::lock, barrier_struct::n_clients, barrier_struct::n_waiting, NULL, barrier_struct::phase, barrier_struct::sum, and barrier_struct::wait_cv.

int wkf_thread_create wkf_thread_t  ,
void *fctn(void *)   ,
void *   
 

create a new child thread

Definition at line 655 of file WKFThreads.C.

References NULL, wkf_thread_t, and WKFTHREAD_START_ROUTINE.

int wkf_thread_join wkf_thread_t   ,
void **   
 

join (wait for completion of, and merge with) a thread

Definition at line 698 of file WKFThreads.C.

References NULL, and wkf_thread_t.

int wkf_thread_numphysprocessors void   
 

If compiling on Linux, enable the GNU CPU affinity functions in both libc and the libpthreads

Definition at line 120 of file WKFThreads.C.

References NULL.

Referenced by affinitize_threads, vmd_cuda_affinitize_threads, and wkf_thread_numprocessors.

int wkf_thread_numprocessors void   
 

number of processors available, subject to user override

Definition at line 208 of file WKFThreads.C.

References NULL, and wkf_thread_numphysprocessors.

Referenced by Orbital::calculate_mo, cc_threaded, find_next_cluster, find_within, measure_gofr, measure_rmsdmat_qcp, measure_rmsdmat_qcp_ooc, measure_sasalist, vmd_bondsearch_thr, vmd_cuda_vol_cpotential, vmd_gaussdensity_threaded, vmdinfo_tcl, VMDApp::VMDinit, vol_cpotential_cpu, volin_threaded, and volin_threaded_prob.

void*(*)(void *) wkf_thread_run_barrier  
 

Wait until all threads reach barrier, and return the function pointer passed in by the master thread.

Definition at line 1500 of file WKFThreads.C.

References wkf_run_barrier_struct::fctn, wkf_run_barrier_struct::lock, wkf_run_barrier_struct::n_clients, wkf_run_barrier_struct::n_waiting, NULL, wkf_run_barrier_struct::parms, wkf_run_barrier_struct::phase, wkf_run_barrier_struct::rslt, wkf_run_barrier_struct::rsltparms, wkf_run_barrier_struct::wait_cv, wkf_cond_broadcast, wkf_cond_wait, wkf_mutex_lock, and wkf_mutex_unlock.

Referenced by wkf_threadpool_destroy, wkf_threadpool_launch, and wkf_threadpool_wait.

void wkf_thread_run_barrier_destroy wkf_run_barrier_t   barrier
 

destroy thread pool barrier

Definition at line 1488 of file WKFThreads.C.

References wkf_run_barrier_struct::lock, wkf_run_barrier_struct::wait_cv, wkf_cond_destroy, and wkf_mutex_destroy.

int wkf_thread_run_barrier_init wkf_run_barrier_t   barrier,
int    n_clients
 

initialize thread pool barrier

Definition at line 1472 of file WKFThreads.C.

References wkf_run_barrier_struct::fctn, wkf_run_barrier_struct::lock, wkf_run_barrier_struct::n_clients, wkf_run_barrier_struct::n_waiting, NULL, wkf_run_barrier_struct::phase, wkf_run_barrier_struct::wait_cv, wkf_cond_init, and wkf_mutex_init.

int wkf_thread_run_barrier_poll wkf_run_barrier_t   barrier
 

non-blocking poll to see if peers are already at the barrier

Definition at line 1546 of file WKFThreads.C.

References wkf_run_barrier_struct::lock, wkf_run_barrier_struct::n_clients, wkf_run_barrier_struct::n_waiting, wkf_mutex_lock, and wkf_mutex_unlock.

int wkf_thread_set_self_cpuaffinity int    cpu
 

set the CPU affinity of the current thread (if allowed by host system)

Definition at line 582 of file WKFThreads.C.

int wkf_thread_setconcurrency int   
 

set the concurrency level and scheduling scope for threads

Definition at line 628 of file WKFThreads.C.

int wkf_threadlaunch int    numprocs,
void *    clientdata,
void *fctn(void *)   ,
wkf_tasktile_t   tile
 

launch up to numprocs threads using shared iterator as a load balancer

Definition at line 2095 of file WKFThreads.C.

References wkf_threadlaunch_struct::clientdata, wkf_threadlaunch_struct::iter, NULL, wkf_threadlaunch_struct::threadcount, wkf_threadlaunch_struct::threadid, wkf_shared_iterator_destroy, wkf_shared_iterator_getfatalerror, wkf_shared_iterator_init, wkf_shared_iterator_set, wkf_thread_create, wkf_thread_join, and wkf_thread_t.

int wkf_threadlaunch_getdata void *    voidparms,
void **    clientdata
 

worker thread can call this to get its client data pointer

Definition at line 2185 of file WKFThreads.C.

References wkf_threadlaunch_struct::clientdata, and NULL.

int wkf_threadlaunch_getid void *    voidparms,
int *    threadid,
int *    threadcount
 

worker thread can call this to get its ID and number of peers

Definition at line 2172 of file WKFThreads.C.

References NULL, wkf_threadlaunch_struct::threadcount, and wkf_threadlaunch_struct::threadid.

int wkf_threadlaunch_next_tile void *    voidparms,
int    reqsize,
wkf_tasktile_t   tile
 

iterate the shared iterator over the requested half-open interval

Definition at line 2195 of file WKFThreads.C.

References wkf_threadlaunch_struct::iter, and wkf_shared_iterator_next_tile.

int wkf_threadlaunch_setfatalerror void *    voidparms
 

worker thread calls this to indicate that an unrecoverable error occured

Definition at line 2203 of file WKFThreads.C.

References wkf_threadlaunch_struct::iter, and wkf_shared_iterator_setfatalerror.

wkf_threadpool_t* wkf_threadpool_create int    workercount,
int *    devlist
 

create a thread pool with a specified number of worker threads

Definition at line 1832 of file WKFThreads.C.

References wkf_threadpool_workerdata_struct::devid, wkf_threadpool_struct::devlist, wkf_threadpool_workerdata_struct::devspeed, wkf_threadpool_workerdata_struct::errorstack, wkf_threadpool_struct::errorstack, wkf_threadpool_workerdata_struct::iter, wkf_threadpool_struct::iter, NULL, wkf_threadpool_struct::runbar, wkf_threadpool_workerdata_struct::threadcount, wkf_threadpool_workerdata_struct::threadid, wkf_threadpool_struct::threads, wkf_threadpool_workerdata_struct::thrpool, wkf_shared_iterator_init, wkf_thread_create, wkf_thread_run_barrier_init, wkf_thread_t, wkf_tilestack_init, wkf_threadpool_struct::workercount, and wkf_threadpool_struct::workerdata.

int wkf_threadpool_destroy wkf_threadpool_t   thrpool
 

join all worker threads and free resources

Definition at line 1927 of file WKFThreads.C.

References wkf_threadpool_struct::devlist, wkf_threadpool_struct::errorstack, wkf_threadpool_struct::iter, NULL, wkf_threadpool_struct::runbar, wkf_threadpool_struct::threads, wkf_shared_iterator_destroy, wkf_thread_join, wkf_thread_run_barrier, wkf_thread_run_barrier_destroy, wkf_tilestack_destroy, wkf_threadpool_struct::workercount, and wkf_threadpool_struct::workerdata.

int wkf_threadpool_get_workercount wkf_threadpool_t   thrpool
 

return the number of worker threads currently in the pool

Definition at line 1961 of file WKFThreads.C.

References wkf_threadpool_struct::workercount.

int wkf_threadpool_getfatalerror void *    thrparms
 

master thread calls this to query for fatal errors

Definition at line 2087 of file WKFThreads.C.

References wkf_threadpool_workerdata_struct::iter, and wkf_shared_iterator_getfatalerror.

int wkf_threadpool_launch wkf_threadpool_t   thrpool,
void *fctn(void *)   ,
void *    parms,
int    blocking
 

launch threads onto a new function, with associated parms

Definition at line 1892 of file WKFThreads.C.

References NULL, wkf_threadpool_workerdata_struct::parms, wkf_threadpool_struct::runbar, wkf_thread_run_barrier, and wkf_threadpool_struct::workerdata.

int wkf_threadpool_next_tile void *    voidparms,
int    reqsize,
wkf_tasktile_t   tile
 

iterate the shared iterator over the requested half-open interval

Definition at line 2052 of file WKFThreads.C.

References wkf_threadpool_workerdata_struct::errorstack, wkf_threadpool_workerdata_struct::iter, WKF_SCHED_CONTINUE, WKF_SCHED_DONE, wkf_shared_iterator_next_tile, WKF_TILESTACK_EMPTY, and wkf_tilestack_pop.

int wkf_threadpool_poll wkf_threadpool_t   thrpool
 

Definition at line 1918 of file WKFThreads.C.

References wkf_threadpool_struct::runbar, and wkf_thread_run_barrier_poll.

int wkf_threadpool_sched_dynamic wkf_threadpool_t   thrpool,
wkf_tasktile_t   tile
 

Set shared iterator state to half-open interval defined by tile

Definition at line 2044 of file WKFThreads.C.

References wkf_threadpool_struct::iter, NULL, and wkf_shared_iterator_set.

int wkf_threadpool_setfatalerror void *    thrparms
 

worker thread calls this to indicate that an unrecoverable error occured

Definition at line 2079 of file WKFThreads.C.

References wkf_threadpool_workerdata_struct::iter, and wkf_shared_iterator_setfatalerror.

int wkf_threadpool_tile_failed void *    voidparms,
wkf_tasktile_t   tile
 

worker thread calls this when a failure occurs on a tile it has already taken from the scheduler

Definition at line 2072 of file WKFThreads.C.

References wkf_threadpool_workerdata_struct::errorstack, and wkf_tilestack_push.

int wkf_threadpool_wait wkf_threadpool_t   thrpool
 

wait for all worker threads to complete their work

Definition at line 1910 of file WKFThreads.C.

References NULL, wkf_threadpool_struct::runbar, and wkf_thread_run_barrier.

int wkf_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 2018 of file WKFThreads.C.

References wkf_threadpool_workerdata_struct::devspeed, and NULL.

int wkf_threadpool_worker_getdata void *    voiddata,
void **    clientdata
 

worker thread can call this to get its client data pointer

Definition at line 2034 of file WKFThreads.C.

References NULL, and wkf_threadpool_workerdata_struct::parms.

int wkf_threadpool_worker_getdevid void *    voiddata,
int *    devid
 

worker thread can call this to get its CPU/GPU device ID

Definition at line 1980 of file WKFThreads.C.

References wkf_threadpool_workerdata_struct::devid, and NULL.

int wkf_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

Definition at line 2006 of file WKFThreads.C.

References wkf_threadpool_workerdata_struct::devspeed, and NULL.

int wkf_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 1967 of file WKFThreads.C.

References NULL, wkf_threadpool_workerdata_struct::threadcount, and wkf_threadpool_workerdata_struct::threadid.

int wkf_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

Definition at line 1995 of file WKFThreads.C.

References wkf_threadpool_workerdata_struct::devspeed.

int wkf_tilestack_compact wkf_tilestack_t  
 

shrink memory buffers associated with task tile stack if possible

Definition at line 1594 of file WKFThreads.C.

References wkf_tilestack_t::mtx, NULL, wkf_tilestack_t::s, wkf_tilestack_t::size, wkf_tilestack_t::top, wkf_mutex_lock, and wkf_mutex_unlock.

void wkf_tilestack_destroy wkf_tilestack_t  
 

destroy task tile stack

Definition at line 1585 of file WKFThreads.C.

References wkf_tilestack_t::mtx, NULL, wkf_tilestack_t::s, and wkf_mutex_destroy.

int wkf_tilestack_empty wkf_tilestack_t  
 

query if the task tile stack is empty or not

Definition at line 1685 of file WKFThreads.C.

References wkf_tilestack_t::mtx, wkf_tilestack_t::top, wkf_mutex_lock, and wkf_mutex_unlock.

int wkf_tilestack_init wkf_tilestack_t   s,
int    size
 

initialize task tile stack (to empty)

Definition at line 1562 of file WKFThreads.C.

References wkf_tilestack_t::growthrate, wkf_tilestack_t::mtx, NULL, wkf_tilestack_t::s, wkf_tilestack_t::size, size, wkf_tilestack_t::top, and wkf_mutex_init.

int wkf_tilestack_pop wkf_tilestack_t  ,
wkf_tasktile_t  
 

pop a task tile off of the stack

Definition at line 1647 of file WKFThreads.C.

References wkf_tilestack_t::mtx, wkf_tilestack_t::s, wkf_tilestack_t::top, wkf_mutex_lock, wkf_mutex_unlock, and WKF_TILESTACK_EMPTY.

int wkf_tilestack_popall wkf_tilestack_t  
 

pop all of the task tiles off of the stack

Definition at line 1670 of file WKFThreads.C.

References wkf_tilestack_t::mtx, wkf_tilestack_t::top, wkf_mutex_lock, and wkf_mutex_unlock.

int wkf_tilestack_push wkf_tilestack_t  ,
const wkf_tasktile_t  
 

push a task tile onto the stack

Definition at line 1618 of file WKFThreads.C.

References wkf_tilestack_t::growthrate, wkf_tilestack_t::mtx, NULL, wkf_tilestack_t::s, wkf_tilestack_t::size, wkf_tilestack_t::top, wkf_mutex_lock, and wkf_mutex_unlock.


Generated on Mon May 13 04:29:35 2024 for VMD (current) by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002