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

WKFThreads.h File Reference

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

Go to the source code of this file.

Compounds

struct  atomic_int_struct
struct  barrier_struct
struct  wkf_cpu_caps_struct
struct  wkf_run_barrier_struct
struct  wkf_shared_iterator_struct
struct  wkf_tasktile_struct
struct  wkf_threadlaunch_struct
struct  wkf_threadpool_struct
struct  wkf_threadpool_workerdata_struct
struct  wkf_tilestack_t

Defines

#define WKF_THREADS_INC   1
#define CPU_SMTDEPTH_UNKNOWN   0
#define CPU_UNKNOWN   0x00000001
#define CPU_HT   0x00000010
#define CPU_HYPERVISOR   0x00000020
#define CPU_SSE2   0x00000100
#define CPU_SSE4_1   0x00000200
#define CPU_F16C   0x00000400
#define CPU_FMA   0x00000800
#define CPU_AVX   0x00001000
#define CPU_AVX2   0x00002000
#define CPU_AVX512F   0x00010000
#define CPU_AVX512CD   0x00020000
#define CPU_AVX512ER   0x00040000
#define CPU_AVX512PF   0x00080000
#define CPU_KNL
#define CPU_ARM64_CPUID   0x00000010
#define CPU_ARM64_CRC32   0x00000020
#define CPU_ARM64_FP   0x00000080
#define CPU_ARM64_HPFP   0x00000080
#define CPU_ARM64_AES   0x00000100
#define CPU_ARM64_ATOMICS   0x00000200
#define CPU_ARM64_ASIMD   0x00000400
#define CPU_ARM64_ASIMDDP   0x00000800
#define CPU_ARM64_ASIMDHP   0x00001000
#define CPU_ARM64_ASIMDRDM   0x00002000
#define CPU_ARM64_ASIMDFHM   0x00004000
#define CPU_ARM64_SVE   0x00008000
#define CPU_ARM64_SHA512   0x00010000
#define CPU_ARM64_SHA1   0x00020000
#define CPU_ARM64_SHA2   0x00040000
#define CPU_ARM64_SHA3   0x00080000
#define WKF_TILESTACK_EMPTY   -1
#define WKF_SCHED_DONE   -1 /**< no work left to process */
#define WKF_SCHED_CONTINUE   0 /**< some work remains in the queue */
#define WKF_THREADPOOL_DEVLIST_CPUSONLY   NULL
#define WKF_THREADPOOL_DEVID_CPU   -1

Typedefs

typedef wkf_cpu_caps_struct wkf_cpu_caps_t
typedef int wkf_thread_t
typedef int wkf_mutex_t
typedef int wkf_cond_t
typedef int wkf_rwlock_t
typedef atomic_int_struct wkf_atomic_int_t
typedef barrier_struct wkf_barrier_t
typedef wkf_run_barrier_struct wkf_run_barrier_t
typedef wkf_tasktile_struct wkf_tasktile_t
typedef wkf_shared_iterator_struct wkf_shared_iterator_t
typedef wkf_threadpool_workerdata_struct wkf_threadpool_workerdata_t
typedef wkf_threadpool_struct wkf_threadpool_t
typedef wkf_threadlaunch_struct wkf_threadlaunch_t

Functions

int wkf_thread_numphysprocessors (void)
int wkf_thread_numprocessors (void)
int wkf_cpu_capability_flags (wkf_cpu_caps_t *cpucaps)
int * wkf_cpu_affinitylist (int *cpuaffinitycount)
int wkf_thread_set_self_cpuaffinity (int cpu)
int wkf_thread_setconcurrency (int)
int wkf_thread_create (wkf_thread_t *, void *fctn(void *), void *)
int wkf_thread_join (wkf_thread_t, void **)
int wkf_mutex_init (wkf_mutex_t *)
int wkf_mutex_lock (wkf_mutex_t *)
int wkf_mutex_trylock (wkf_mutex_t *)
int wkf_mutex_spin_lock (wkf_mutex_t *)
int wkf_mutex_unlock (wkf_mutex_t *)
int wkf_mutex_destroy (wkf_mutex_t *)
int wkf_cond_init (wkf_cond_t *)
int wkf_cond_destroy (wkf_cond_t *)
int wkf_cond_wait (wkf_cond_t *, wkf_mutex_t *)
int wkf_cond_signal (wkf_cond_t *)
int wkf_cond_broadcast (wkf_cond_t *)
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 *)
int wkf_rwlock_readlock (wkf_rwlock_t *)
int wkf_rwlock_writelock (wkf_rwlock_t *)
int wkf_rwlock_unlock (wkf_rwlock_t *)
wkf_barrier_twkf_thread_barrier_init (int n_clients)
int wkf_thread_barrier_init_proc_shared (wkf_barrier_t *, 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)
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 *)
int wkf_tilestack_compact (wkf_tilestack_t *)
int wkf_tilestack_push (wkf_tilestack_t *, const wkf_tasktile_t *)
int wkf_tilestack_pop (wkf_tilestack_t *, wkf_tasktile_t *)
int wkf_tilestack_popall (wkf_tilestack_t *)
int wkf_tilestack_empty (wkf_tilestack_t *)
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_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 *thrpool, int reqsize, wkf_tasktile_t *tile)
int wkf_threadpool_tile_failed (void *thrpool, wkf_tasktile_t *tile)
int wkf_threadpool_setfatalerror (void *thrparms)
int wkf_threadpool_getfatalerror (void *thrparms)
int wkf_threadlaunch (int numprocs, void *clientdata, void *fctn(void *), wkf_tasktile_t *tile)
int wkf_threadlaunch_getid (void *thrparms, int *threadid, int *threadcount)
int wkf_threadlaunch_getdata (void *thrparms, void **clientdata)
int wkf_threadlaunch_next_tile (void *voidparms, int reqsize, wkf_tasktile_t *tile)
int wkf_threadlaunch_setfatalerror (void *thrparms)

Variables

void *(*)(void *) wkf_thread_run_barrier (wkf_run_barrier_t *barrier, void *fctn(void *), void *parms, void **rsltparms)


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.19
Date:
2020/10/27 15:30:49

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.h.


Define Documentation

#define CPU_ARM64_AES   0x00000100
 

Definition at line 117 of file WKFThreads.h.

Referenced by VMDApp::VMDinit, and wkf_cpu_capability_flags.

#define CPU_ARM64_ASIMD   0x00000400
 

Definition at line 119 of file WKFThreads.h.

Referenced by orbitalthread, VMDApp::VMDinit, and wkf_cpu_capability_flags.

#define CPU_ARM64_ASIMDDP   0x00000800
 

Definition at line 120 of file WKFThreads.h.

Referenced by VMDApp::VMDinit, and wkf_cpu_capability_flags.

#define CPU_ARM64_ASIMDFHM   0x00004000
 

Definition at line 123 of file WKFThreads.h.

Referenced by VMDApp::VMDinit, and wkf_cpu_capability_flags.

#define CPU_ARM64_ASIMDHP   0x00001000
 

Definition at line 121 of file WKFThreads.h.

Referenced by VMDApp::VMDinit, and wkf_cpu_capability_flags.

#define CPU_ARM64_ASIMDRDM   0x00002000
 

Definition at line 122 of file WKFThreads.h.

Referenced by VMDApp::VMDinit, and wkf_cpu_capability_flags.

#define CPU_ARM64_ATOMICS   0x00000200
 

Definition at line 118 of file WKFThreads.h.

#define CPU_ARM64_CPUID   0x00000010
 

Definition at line 113 of file WKFThreads.h.

#define CPU_ARM64_CRC32   0x00000020
 

Definition at line 114 of file WKFThreads.h.

Referenced by VMDApp::VMDinit, and wkf_cpu_capability_flags.

#define CPU_ARM64_FP   0x00000080
 

Definition at line 115 of file WKFThreads.h.

Referenced by VMDApp::VMDinit, and wkf_cpu_capability_flags.

#define CPU_ARM64_HPFP   0x00000080
 

Definition at line 116 of file WKFThreads.h.

#define CPU_ARM64_SHA1   0x00020000
 

Definition at line 126 of file WKFThreads.h.

Referenced by VMDApp::VMDinit, and wkf_cpu_capability_flags.

#define CPU_ARM64_SHA2   0x00040000
 

Definition at line 127 of file WKFThreads.h.

Referenced by VMDApp::VMDinit, and wkf_cpu_capability_flags.

#define CPU_ARM64_SHA3   0x00080000
 

Definition at line 128 of file WKFThreads.h.

Referenced by VMDApp::VMDinit, and wkf_cpu_capability_flags.

#define CPU_ARM64_SHA512   0x00010000
 

Definition at line 125 of file WKFThreads.h.

Referenced by VMDApp::VMDinit, and wkf_cpu_capability_flags.

#define CPU_ARM64_SVE   0x00008000
 

Definition at line 124 of file WKFThreads.h.

Referenced by orbitalthread, VMDApp::VMDinit, and wkf_cpu_capability_flags.

#define CPU_AVX   0x00001000
 

Definition at line 103 of file WKFThreads.h.

Referenced by analyze_selection_aligned_dispatch, VMDApp::VMDinit, and wkf_cpu_capability_flags.

#define CPU_AVX2   0x00002000
 

Definition at line 104 of file WKFThreads.h.

Referenced by analyze_selection_aligned_dispatch, Orbital::calculate_mo, orbitalthread, vmd_gaussdensity_opt, VMDApp::VMDinit, and wkf_cpu_capability_flags.

#define CPU_AVX512CD   0x00020000
 

Definition at line 106 of file WKFThreads.h.

Referenced by VMDApp::VMDinit, and wkf_cpu_capability_flags.

#define CPU_AVX512ER   0x00040000
 

Definition at line 107 of file WKFThreads.h.

Referenced by Orbital::calculate_mo, orbitalthread, VMDApp::VMDinit, and wkf_cpu_capability_flags.

#define CPU_AVX512F   0x00010000
 

Definition at line 105 of file WKFThreads.h.

Referenced by Orbital::calculate_mo, orbitalthread, VMDApp::VMDinit, and wkf_cpu_capability_flags.

#define CPU_AVX512PF   0x00080000
 

Definition at line 108 of file WKFThreads.h.

Referenced by VMDApp::VMDinit, and wkf_cpu_capability_flags.

#define CPU_F16C   0x00000400
 

Definition at line 101 of file WKFThreads.h.

Referenced by VMDApp::VMDinit, and wkf_cpu_capability_flags.

#define CPU_FMA   0x00000800
 

Definition at line 102 of file WKFThreads.h.

Referenced by vmd_gaussdensity_opt, VMDApp::VMDinit, and wkf_cpu_capability_flags.

#define CPU_HT   0x00000010
 

Definition at line 97 of file WKFThreads.h.

Referenced by VMDApp::VMDinit, and wkf_cpu_capability_flags.

#define CPU_HYPERVISOR   0x00000020
 

Definition at line 98 of file WKFThreads.h.

Referenced by VMDApp::VMDinit, and wkf_cpu_capability_flags.

#define CPU_KNL
 

Value:

Definition at line 109 of file WKFThreads.h.

Referenced by VMDApp::VMDinit.

#define CPU_SMTDEPTH_UNKNOWN   0
 

Definition at line 93 of file WKFThreads.h.

Referenced by wkf_cpu_capability_flags, and wkf_cpu_smt_depth.

#define CPU_SSE2   0x00000100
 

Definition at line 99 of file WKFThreads.h.

Referenced by VMDApp::VMDinit, and wkf_cpu_capability_flags.

#define CPU_SSE4_1   0x00000200
 

Definition at line 100 of file WKFThreads.h.

Referenced by FileRenderList::FileRenderList, VMDApp::VMDinit, and wkf_cpu_capability_flags.

#define CPU_UNKNOWN   0x00000001
 

Definition at line 94 of file WKFThreads.h.

Referenced by wkf_cpu_capability_flags.

#define WKF_SCHED_CONTINUE   0 /**< some work remains in the queue */
 

Definition at line 470 of file WKFThreads.h.

Referenced by wkf_shared_iterator_next_tile, and wkf_threadpool_next_tile.

#define WKF_SCHED_DONE   -1 /**< no work left to process */
 

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).

Definition at line 469 of file WKFThreads.h.

Referenced by correlationthread, cudaenergythread, cudaorbitalthread, densitythread, energythread, measure_rmsdmat_qcp_thread, measure_sasa_thread, openclenergythread, openclorbitalthread, orbitalthread, rdf_thread, reductionthread, text_cmd_parallel, vmddevpoolcudatilelatencythread, vmddevpooltilelatencythread, volinthread, volinthread_prob, wkf_shared_iterator_next_tile, and wkf_threadpool_next_tile.

#define WKF_THREADPOOL_DEVID_CPU   -1
 

symbolic constant macro to test if we have a GPU or not

Definition at line 513 of file WKFThreads.h.

#define WKF_THREADPOOL_DEVLIST_CPUSONLY   NULL
 

shortcut macro to tell the create routine we only want CPU cores

Definition at line 510 of file WKFThreads.h.

Referenced by VMDApp::VMDinit.

#define WKF_THREADS_INC   1
 

Definition at line 64 of file WKFThreads.h.

#define WKF_TILESTACK_EMPTY   -1
 

Definition at line 429 of file WKFThreads.h.

Referenced by wkf_threadpool_next_tile, and wkf_tilestack_pop.


Typedef Documentation

typedef struct atomic_int_struct wkf_atomic_int_t
 

typedef struct barrier_struct wkf_barrier_t
 

typedef int wkf_cond_t
 

Definition at line 208 of file WKFThreads.h.

Referenced by wkf_cond_broadcast, wkf_cond_destroy, wkf_cond_init, wkf_cond_signal, wkf_cond_wait, wkf_cpu_capability_flags, and wkf_thread_numprocessors.

typedef struct wkf_cpu_caps_struct wkf_cpu_caps_t
 

typedef int wkf_mutex_t
 

Definition at line 207 of file WKFThreads.h.

Referenced by AtomSelThr::AtomSelThr, bondsearchthread, find_next_cluster, vmd_bondsearch_thr, wkf_cond_wait, wkf_cpu_capability_flags, wkf_mutex_destroy, wkf_mutex_init, wkf_mutex_lock, wkf_mutex_spin_lock, wkf_mutex_trylock, and wkf_mutex_unlock.

typedef struct wkf_run_barrier_struct wkf_run_barrier_t
 

typedef int wkf_rwlock_t
 

Definition at line 209 of file WKFThreads.h.

Referenced by wkf_cpu_capability_flags, wkf_rwlock_init, wkf_rwlock_readlock, wkf_rwlock_unlock, and wkf_rwlock_writelock.

typedef struct wkf_shared_iterator_struct wkf_shared_iterator_t
 

iterator used for dynamic load balancing

typedef struct wkf_tasktile_struct wkf_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 wkf_thread_t
 

Definition at line 206 of file WKFThreads.h.

Referenced by find_next_cluster, find_within, measure_gofr, VMDCollab::startserver, text_cmd_parallel, vmd_bondsearch_thr, vmd_cuda_bus_bw, vmd_cuda_globmem_bw, vmd_cuda_madd_gflops, wkf_thread_create, wkf_thread_join, wkf_threadlaunch, and wkf_threadpool_create.

typedef struct wkf_threadlaunch_struct wkf_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 wkf_threadpool_struct wkf_threadpool_t
 

typedef struct wkf_threadpool_workerdata_struct wkf_threadpool_workerdata_t
 

thread-specific handle data for workers


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.

int wkf_atomic_int_destroy wkf_atomic_int_t   atomp
 

destroy an atomic int variable

Definition at line 1076 of file WKFThreads.C.

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.

int wkf_atomic_int_get wkf_atomic_int_t   atomp
 

get an atomic int variable

Definition at line 1133 of file WKFThreads.C.

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.

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.

int wkf_cond_broadcast wkf_cond_t  
 

signal a condition variable, waking all threads

Definition at line 1013 of file WKFThreads.C.

Referenced by wkf_thread_barrier, and wkf_thread_run_barrier.

int wkf_cond_destroy wkf_cond_t  
 

destroy a condition variable

Definition at line 898 of file WKFThreads.C.

Referenced by wkf_thread_barrier_destroy, and wkf_thread_run_barrier_destroy.

int wkf_cond_init wkf_cond_t  
 

initialize a condition variable

Definition at line 862 of file WKFThreads.C.

Referenced by wkf_rwlock_init, wkf_thread_barrier_init, and wkf_thread_run_barrier_init.

int wkf_cond_signal wkf_cond_t  
 

signal a condition variable, waking at least one thread

Definition at line 981 of file WKFThreads.C.

Referenced by wkf_rwlock_unlock.

int wkf_cond_wait wkf_cond_t  ,
wkf_mutex_t  
 

wait on a condition variable

Definition at line 922 of file WKFThreads.C.

Referenced by wkf_rwlock_readlock, wkf_rwlock_writelock, wkf_thread_barrier, and wkf_thread_run_barrier.

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.

Referenced by affinitize_threads, and vmdinfo_tcl.

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 wkf_cond_t, wkf_mutex_t, and wkf_rwlock_t.

Referenced by FileRenderList::FileRenderList, VMDApp::VMDinit, and wkf_cpu_smt_depth.

int wkf_mutex_destroy wkf_mutex_t  
 

destroy a mutex

Definition at line 838 of file WKFThreads.C.

Referenced by cc_threaded, find_next_cluster, vmd_bondsearch_thr, volin_threaded, volin_threaded_prob, wkf_atomic_int_destroy, wkf_shared_iterator_destroy, wkf_thread_barrier_destroy, wkf_thread_run_barrier_destroy, and wkf_tilestack_destroy.

int wkf_mutex_init wkf_mutex_t  
 

initialize a mutex

Definition at line 731 of file WKFThreads.C.

Referenced by cc_threaded, find_next_cluster, IMDSimThread::IMDSimThread, vmd_bondsearch_thr, volin_threaded, volin_threaded_prob, wkf_atomic_int_init, wkf_rwlock_init, wkf_shared_iterator_init, wkf_thread_barrier_init, wkf_thread_run_barrier_init, and wkf_tilestack_init.

int wkf_mutex_lock wkf_mutex_t  
 

lock a mutex

Definition at line 752 of file WKFThreads.C.

Referenced by bondsearchthread, correlationthread, IMDSimThread::detach, IMDSimThread::get_next_ts, IMDSimThread::kill, IMDSimThread::pause, IMDSimThread::reader, IMDSimThread::send_forces, IMDSimThread::set_transrate, IMDSimThread::unpause, AtomSelThr::update, volinthread, volinthread_prob, wkf_atomic_int_add_and_fetch, wkf_atomic_int_fetch_and_add, wkf_atomic_int_get, wkf_atomic_int_set, wkf_rwlock_readlock, wkf_rwlock_unlock, wkf_rwlock_writelock, wkf_shared_iterator_getfatalerror, wkf_shared_iterator_set, wkf_thread_barrier, wkf_thread_run_barrier, wkf_thread_run_barrier_poll, wkf_tilestack_compact, wkf_tilestack_empty, wkf_tilestack_pop, wkf_tilestack_popall, and wkf_tilestack_push.

int wkf_mutex_spin_lock wkf_mutex_t  
 

lock a mutex by spinning only

Definition at line 794 of file WKFThreads.C.

Referenced by wkf_shared_iterator_next_tile, and wkf_shared_iterator_setfatalerror.

int wkf_mutex_trylock wkf_mutex_t  
 

try to lock a mutex

Definition at line 773 of file WKFThreads.C.

int wkf_mutex_unlock wkf_mutex_t  
 

unlock a mutex

Definition at line 817 of file WKFThreads.C.

Referenced by bondsearchthread, correlationthread, IMDSimThread::detach, IMDSimThread::get_next_ts, IMDSimThread::kill, IMDSimThread::pause, IMDSimThread::reader, IMDSimThread::send_forces, IMDSimThread::set_transrate, IMDSimThread::unpause, AtomSelThr::update, volinthread, volinthread_prob, wkf_atomic_int_add_and_fetch, wkf_atomic_int_fetch_and_add, wkf_atomic_int_get, wkf_atomic_int_set, wkf_rwlock_readlock, wkf_rwlock_unlock, wkf_rwlock_writelock, wkf_shared_iterator_getfatalerror, wkf_shared_iterator_next_tile, wkf_shared_iterator_set, wkf_shared_iterator_setfatalerror, wkf_thread_barrier, wkf_thread_run_barrier, wkf_thread_run_barrier_poll, wkf_tilestack_compact, wkf_tilestack_empty, wkf_tilestack_pop, wkf_tilestack_popall, and wkf_tilestack_push.

int wkf_rwlock_init wkf_rwlock_t  
 

initialize a reader/writer lock

Definition at line 1222 of file WKFThreads.C.

int wkf_rwlock_readlock wkf_rwlock_t  
 

set reader lock

Definition at line 1251 of file WKFThreads.C.

int wkf_rwlock_unlock wkf_rwlock_t  
 

unlock reader/writer lock

Definition at line 1315 of file WKFThreads.C.

int wkf_rwlock_writelock wkf_rwlock_t  
 

set writer lock

Definition at line 1280 of file WKFThreads.C.

int wkf_shared_iterator_destroy wkf_shared_iterator_t   it
 

destroy a shared iterator

Definition at line 1720 of file WKFThreads.C.

Referenced by text_cmd_parallel, wkf_threadlaunch, and wkf_threadpool_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.

Referenced by wkf_threadlaunch, and wkf_threadpool_getfatalerror.

int wkf_shared_iterator_init wkf_shared_iterator_t   it
 

initialize a shared iterator

Definition at line 1710 of file WKFThreads.C.

Referenced by text_cmd_parallel, wkf_threadlaunch, and wkf_threadpool_create.

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.

Referenced by text_cmd_parallel, wkf_threadlaunch_next_tile, and wkf_threadpool_next_tile.

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.

Referenced by text_cmd_parallel, wkf_threadlaunch, and wkf_threadpool_sched_dynamic.

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.

Referenced by wkf_threadlaunch_setfatalerror, and wkf_threadpool_setfatalerror.

int wkf_thread_barrier wkf_barrier_t   barrier,
int    increment
 

synchronize on counting barrier primitive

Definition at line 1435 of file WKFThreads.C.

Referenced by FreeVRScene::draw, and CaveScene::draw.

void wkf_thread_barrier_destroy wkf_barrier_t   barrier
 

destroy counting barrier primitive

Definition at line 1426 of file WKFThreads.C.

wkf_barrier_t* wkf_thread_barrier_init int    n_clients
 

initialize counting barrier primitive

Definition at line 1365 of file WKFThreads.C.

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.

Referenced by CaveScene::CaveScene, and FreeVRScene::FreeVRScene.

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

create a new child thread

Definition at line 655 of file WKFThreads.C.

Referenced by find_next_cluster, find_within, IMDSimThread::IMDSimThread, measure_gofr, VMDCollab::startserver, text_cmd_parallel, vmd_bondsearch_thr, vmd_cuda_bus_bw, vmd_cuda_globmem_bw, vmd_cuda_madd_gflops, wkf_threadlaunch, and wkf_threadpool_create.

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.

Referenced by find_next_cluster, find_within, measure_gofr, text_cmd_parallel, vmd_bondsearch_thr, vmd_cuda_bus_bw, vmd_cuda_globmem_bw, vmd_cuda_madd_gflops, wkf_threadlaunch, wkf_threadpool_destroy, and IMDSimThread::~IMDSimThread.

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.

int wkf_thread_numprocessors void   
 

number of processors available, subject to user override

Definition at line 208 of file WKFThreads.C.

References wkf_cond_t.

void wkf_thread_run_barrier_destroy wkf_run_barrier_t   barrier
 

destroy thread pool barrier

Definition at line 1488 of file WKFThreads.C.

Referenced by wkf_threadpool_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.

Referenced by wkf_threadpool_create.

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.

Referenced by wkf_threadpool_poll.

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.

Referenced by affinitize_threads, and vmd_cuda_affinitize_threads.

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.

Referenced by cc_threaded, evaluate_grid_fast, measure_rmsdmat_qcp, measure_rmsdmat_qcp_ooc, measure_sasalist, vmd_cuda_vol_cpotential, vmd_gaussdensity_threaded, vmd_opencl_evaluate_orbital_grid, vmd_opencl_vol_cpotential, vol_cpotential_cpu, volin_threaded, and volin_threaded_prob.

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.

Referenced by correlationthread, cudaenergythread, densitythread, energythread, measure_rmsdmat_qcp_thread, measure_sasa_thread, openclenergythread, openclorbitalthread, orbitalthread, reductionthread, volinthread, and volinthread_prob.

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.

Referenced by cudaenergythread, densitythread, energythread, measure_rmsdmat_qcp_thread, measure_sasa_thread, openclenergythread, openclorbitalthread, and reductionthread.

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.

Referenced by correlationthread, cudaenergythread, densitythread, energythread, measure_rmsdmat_qcp_thread, measure_sasa_thread, openclenergythread, openclorbitalthread, orbitalthread, reductionthread, volinthread, and volinthread_prob.

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.

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.

Referenced by gpu_ooc_bench, qcp_soa_gpu_ooc, and VMDApp::VMDinit.

int wkf_threadpool_destroy wkf_threadpool_t   thrpool
 

join all worker threads and free resources

Definition at line 1927 of file WKFThreads.C.

Referenced by gpu_ooc_bench, qcp_soa_gpu_ooc, and VMDApp::~VMDApp.

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.

Referenced by rdf_gpu, and vmd_cuda_measure_latencies.

int wkf_threadpool_getfatalerror void *    thrparms
 

master thread calls this to query for fatal errors

Definition at line 2087 of file WKFThreads.C.

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.

Referenced by CUDAAccel::devpool_launch, evaluate_grid_fast, gpu_ooc_bench, measure_rmsdmat_qcp, measure_rmsdmat_qcp_ooc, qcp_soa_gpu, qcp_soa_gpu_ooc, rdf_gpu, vmd_cuda_devpool_latency, vmd_cuda_evaluate_orbital_grid, vmd_cuda_measure_latencies, vmd_opencl_evaluate_orbital_grid, and VMDApp::VMDinit.

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.

Referenced by cudaorbitalthread, measure_rmsdmat_qcp_thread, openclorbitalthread, orbitalthread, rdf_thread, vmddevpoolcudatilelatencythread, and vmddevpooltilelatencythread.

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.

Referenced by evaluate_grid_fast, gpu_ooc_bench, measure_rmsdmat_qcp, measure_rmsdmat_qcp_ooc, qcp_soa_gpu, qcp_soa_gpu_ooc, rdf_gpu, vmd_cuda_devpool_latency, vmd_cuda_evaluate_orbital_grid, and vmd_opencl_evaluate_orbital_grid.

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.

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.

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.

Referenced by CUDAAccel::devpool_wait, and vmd_cuda_devpool_latency.

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.

Referenced by cudaorbitalthread, openclorbitalthread, and vmddevpoolcudatilelatencythread.

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.

Referenced by cudaorbitalthread, measure_rmsdmat_qcp_thread, openclorbitalthread, orbitalthread, rdf_thread, vmd_cuda_devpool_setdevice, vmd_cuda_devpool_setdeviceonly, vmddevpoolcudalatencythread, vmddevpoolcudatilelatencythread, and vmddevpooltilelatencythread.

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.

Referenced by vmd_cuda_affinitize_threads, vmd_cuda_devpool_clear_device_mem, vmd_cuda_devpool_enable_P2P, vmd_cuda_devpool_setdevice, and vmd_cuda_devpool_setdeviceonly.

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.

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.

Referenced by affinitize_threads, cudaorbitalthread, measure_rmsdmat_qcp_thread, openclorbitalthread, rdf_thread, vmd_cuda_affinitize_threads, vmd_cuda_devpool_clear_device_mem, vmd_cuda_devpool_enable_P2P, vmd_cuda_devpool_setdevice, vmd_cuda_devpool_setdeviceonly, vmddevpoolcudalatencythread, vmddevpoolcudatilelatencythread, and vmddevpooltilelatencythread.

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.

Referenced by vmd_cuda_devpool_setdevice.

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.

void wkf_tilestack_destroy wkf_tilestack_t  
 

destroy task tile stack

Definition at line 1585 of file WKFThreads.C.

Referenced by wkf_threadpool_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.

int wkf_tilestack_init wkf_tilestack_t   s,
int    size
 

initialize task tile stack (to empty)

Definition at line 1562 of file WKFThreads.C.

Referenced by wkf_threadpool_create.

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.

Referenced by wkf_threadpool_next_tile.

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.

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.

Referenced by wkf_threadpool_tile_failed.


Variable Documentation

void*(*)(void *) wkf_thread_run_barrier(wkf_run_barrier_t *barrier, void * fctn(void*), void * parms, void **rsltparms)
 

sleeping barrier synchronization for thread pool

Definition at line 406 of file WKFThreads.h.


Generated on Fri Oct 4 02:45:44 2024 for VMD (current) by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002