|
TBCI Numerical high perf. C++ Library
2.8.0
|
#include "tbci/basics.h"#include "tbci/smp.h"#include <stdio.h>#include <time.h>#include <errno.h>#include <fcntl.h>#include <stdlib.h>#include "tbci/list.h"#include <sys/syscall.h>#include <unistd.h>
Go to the source code of this file.
Classes | |
| class | cback |
Macros | |
| #define | _GNU_SOURCE 1 |
| #define | NEED_SMP_DECLS 1 |
| #define | MAX_THREADS 160 |
| #define | TCHK(x) x |
| #define | ERRDECL |
| #define | _cpu_relax() do {} while(0) |
| #define | POLL_REP 1 |
| #define | POLL_REP2 168 |
Functions | |
| static pid_t | gettid () |
| static int | detect_num_cpu (int rmv_ht) |
| void | thread_reg_callback (cbackfn ctor, cbackfn dtor, void *parm) |
| void | thread_dereg_callback (cbackfn ctor, cbackfn dtor, void *parm) |
| void | lina_err (struct thr_ctrl *tc) |
| void | lina_empty (struct thr_ctrl *dummy) |
| void * | empty_thread (void *dummy) |
| static int | busy_read (int fd, void *ptr, size_t sz, int rep=1) |
| void * | lina_thread (void *thr) |
| int | init_threads (const int num_cpu, const bool load_magic) |
| void | bind_threads (bool bind_main, bool enable_numa, bool add_sibl) |
| void | free_threads () |
| void | _thread_start_off (const int thr_no, thr_job_t ljob, const unsigned long off, const unsigned long sz, va_list vl) |
| void | thread_start_off (const int thr_no, thr_job_t job, const unsigned long off, const unsigned long sz,...) |
| void | thread_start (const int thr_no, thr_job_t job, const unsigned long sz,...) |
| void | thread_wait (const int thr_no, struct job_output *out) |
| double | thread_wait_result (const int thr_no) |
| void | disable_threads () |
| void | reenable_threads () |
Variables | |
| NAMESPACE_TBCI int | num_threads = 0 |
| int | threads_busy = 0 |
| int | numa_avail = 0 |
| struct thr_struct * | threads = 0 |
| pid_t | main_thread_pid = 0 |
| bool | threads_bound = false |
| bool | bound_main = false |
| int | main_numa_node = 0 |
| THREAD__ int | ismainthread = 1 |
| THREAD__ int | thrno = 0 |
| THREAD__ struct thr_struct * | this_thread = 0 |
| static List< cback > | thread_cbacks |
| unsigned long | poll_succ = 0 |
| unsigned long | poll_usucc = 0 |
| unsigned long | poll_fail = 0 |
| unsigned long | poll_efail = 0 |
| int | tot_cpu_tm |
| static unsigned long | job_no = 0 |
| unsigned int | curr_n_thr |
| unsigned int | last_n_thr |
| unsigned int | prev_n_thr |
| NAMESPACE_END NAMESPACE_TBCI unsigned int tbci_control | WEAKA = _TBCI_CWD_DEFAULT |
License: GNU LGPL
Definition in file smp.cc.
| #define _cpu_relax | ( | ) | do {} while(0) |
Definition at line 510 of file smp.cc.
Referenced by busy_read().
| #define ERRDECL |
Definition at line 125 of file smp.cc.
Referenced by _thread_start_off(), and free_threads().
| #define MAX_THREADS 160 |
Definition at line 83 of file smp.cc.
Referenced by init_threads().
| #define POLL_REP 1 |
Definition at line 520 of file smp.cc.
Referenced by busy_read().
| #define POLL_REP2 168 |
Definition at line 523 of file smp.cc.
Referenced by thread_wait(), and thread_wait_result().
Definition at line 124 of file smp.cc.
Referenced by free_threads(), and init_threads().
| void _thread_start_off | ( | const int | thr_no, |
| thr_job_t | ljob, | ||
| const unsigned long | off, | ||
| const unsigned long | sz, | ||
| va_list | vl | ||
| ) |
Definition at line 946 of file smp.cc.
References BCHKNR, ERRDECL, num_threads, job_input::t_job, job_input::t_job_no, thr_struct::t_no, job_input::t_off, job_input::t_par, thr_struct::t_pipe_to_thread, job_input::t_size, THREAD_MAX_ARGS, thread_start(), and threads_busy.
Referenced by thread_start(), and thread_start_off().
Definition at line 727 of file smp.cc.
References bound_main, i, main_numa_node, main_thread_pid, num_threads, numa_avail, thr_struct::numa_node, thr_struct::t_id, thr_struct::t_no, thr_struct::t_pid, thread_start(), thread_wait(), and threads_bound.
|
static |
Definition at line 525 of file smp.cc.
References _cpu_relax, poll_efail, poll_fail, POLL_REP, poll_succ, poll_usucc, and PREFETCH_R.
Referenced by lina_thread(), thread_wait(), and thread_wait_result().
|
static |
Definition at line 267 of file smp.cc.
References CSTD__, and gettid().
Referenced by init_threads().
| void disable_threads | ( | ) |
Definition at line 1037 of file smp.cc.
References threads_busy.
| void free_threads | ( | ) |
Since Linux 2.6.16, we get the same time for all threads We need clock_gettime(CLOCK_THREAD_CPUTIME_ID) to get per thread times now (in librt).
Definition at line 873 of file smp.cc.
References bound_main, c, CSTD__, err, ERRDECL, List< T >::getfirst(), List< T >::getnext(), ismainthread, main_thread_pid, NULL, num_threads, res, thr_struct::t_id, job_input::t_job, thr_struct::t_no, thr_struct::t_pipe_from_thread, thr_struct::t_pipe_to_thread, job_output::t_retval, TCHK, threads_bound, and thrno.
|
inlinestatic |
Definition at line 92 of file smp.cc.
Referenced by detect_num_cpu(), and lina_thread().
| int init_threads | ( | const int | num_cpu, |
| const bool | load_magic | ||
| ) |
Definition at line 629 of file smp.cc.
References c, CSTD__, detect_num_cpu(), err, List< T >::getfirst(), List< T >::getnext(), ismainthread, lina_thread(), main_thread_pid, MAX, MAX_THREADS, NULL, num_threads, thr_struct::t_id, thr_struct::t_no, thr_struct::t_pipe_from_thread, thr_struct::t_pipe_to_thread, TCHK, and thrno.
| void lina_err | ( | struct thr_ctrl * | tc | ) |
| void* lina_thread | ( | void * | thr | ) |
Definition at line 551 of file smp.cc.
References busy_read(), err, gettid(), ismainthread, lina_err(), NULL, thr_struct::t_done_var, thr_struct::t_id, thr_ctrl::t_job, thr_ctrl::t_job_no, job_output::t_job_output_no, thr_struct::t_no, thr_ctrl::t_no, thr_struct::t_pid, thr_struct::t_pipe_from_thread, thr_struct::t_pipe_to_thread, job_output::t_res_dummy, thr_ctrl::t_res_dummy, job_output::t_retval, thrno, ts, and UNLIKELY.
Referenced by init_threads().
| void reenable_threads | ( | ) |
Definition at line 1045 of file smp.cc.
References num_threads, and threads_busy.
| void thread_dereg_callback | ( | cbackfn | ctor, |
| cbackfn | dtor, | ||
| void * | parm | ||
| ) |
Definition at line 340 of file smp.cc.
References BCHK, List< T >::delcurr(), and List< T >::setcurr().
Referenced by tbci_memalloc_cache< T >::~tbci_memalloc_cache().
| void thread_reg_callback | ( | cbackfn | ctor, |
| cbackfn | dtor, | ||
| void * | parm | ||
| ) |
Definition at line 333 of file smp.cc.
References List< T >::append().
| void thread_start | ( | const int | thr_no, |
| thr_job_t | job, | ||
| const unsigned long | sz, | ||
| ... | |||
| ) |
Definition at line 988 of file smp.cc.
References _thread_start_off().
Referenced by _thread_start_off(), bind_threads(), dot(), Vector< T >::fabssqr(), HOTDECL(), Vector< T >::operator*(), and Vector< T >::sum().
| void thread_start_off | ( | const int | thr_no, |
| thr_job_t | job, | ||
| const unsigned long | off, | ||
| const unsigned long | sz, | ||
| ... | |||
| ) |
Definition at line 979 of file smp.cc.
References _thread_start_off().
Referenced by BdMatrix< T >::operator*(), Matrix< T >::operator*(), par_fill(), BdMatrix< T >::transMult(), and Matrix< T >::transMult().
| void thread_wait | ( | const int | thr_no, |
| struct job_output * | out | ||
| ) |
Definition at line 997 of file smp.cc.
References BCHKNR, busy_read(), num_threads, POLL_REP2, thr_struct::t_no, thr_struct::t_pipe_from_thread, and threads_busy.
Referenced by bind_threads(), dot(), HOTDECL(), BdMatrix< T >::operator*(), Vector< T >::operator*(), Matrix< T >::operator*(), par_fill(), Vector< T >::sum(), BdMatrix< T >::transMult(), and Matrix< T >::transMult().
| double thread_wait_result | ( | const int | thr_no | ) |
Definition at line 1017 of file smp.cc.
References BCHKNR, busy_read(), err, num_threads, POLL_REP2, thr_struct::t_no, thr_struct::t_pipe_from_thread, job_output::t_res_d, and threads_busy.
Referenced by Vector< T >::fabssqr().
Definition at line 109 of file smp.cc.
Referenced by bind_threads(), and free_threads().
| THREAD__ int ismainthread = 1 |
Definition at line 111 of file smp.cc.
Referenced by tbci_memalloc_cache< T >::alloc(), tbci_memalloc_cache< T >::dealloc(), free_threads(), init_threads(), and lina_thread().
| int main_numa_node = 0 |
Definition at line 110 of file smp.cc.
Referenced by bind_threads().
| pid_t main_thread_pid = 0 |
Definition at line 107 of file smp.cc.
Referenced by bind_threads(), free_threads(), and init_threads().
| NAMESPACE_TBCI int num_threads = 0 |
Definition at line 103 of file smp.cc.
Referenced by _thread_start_off(), bind_threads(), free_threads(), init_threads(), reenable_threads(), thread_wait(), and thread_wait_result().
| int numa_avail = 0 |
Definition at line 105 of file smp.cc.
Referenced by bind_threads().
| unsigned long poll_efail = 0 |
Definition at line 517 of file smp.cc.
Referenced by busy_read().
| unsigned long poll_fail = 0 |
Definition at line 516 of file smp.cc.
Referenced by busy_read().
| unsigned long poll_succ = 0 |
Definition at line 514 of file smp.cc.
Referenced by busy_read().
| unsigned long poll_usucc = 0 |
Definition at line 515 of file smp.cc.
Referenced by busy_read().
| THREAD__ struct thr_struct* this_thread = 0 |
| struct thr_struct* threads = 0 |
Definition at line 106 of file smp.cc.
Referenced by dot(), and Vector< T >::operator*().
Definition at line 108 of file smp.cc.
Referenced by bind_threads(), and free_threads().
| int threads_busy = 0 |
Definition at line 104 of file smp.cc.
Referenced by _thread_start_off(), disable_threads(), reenable_threads(), thread_wait(), and thread_wait_result().
| THREAD__ int thrno = 0 |
Definition at line 112 of file smp.cc.
Referenced by tbci_memalloc_cache< T >::alloc(), tbci_memalloc_cache< T >::enter(), tbci_memalloc_cache< T >::find_and_rmv(), tbci_memalloc_cache< T >::find_by_sz(), tbci_memalloc_cache< T >::free_and_enter(), free_threads(), init_threads(), lina_thread(), tbci_memalloc_cache< T >::rmv(), and tbci_memalloc_cache< T >::smp_deinit().
| NAMESPACE_END NAMESPACE_TBCI unsigned int tbci_control WEAKA = _TBCI_CWD_DEFAULT |
1.8.5