TBCI Numerical high perf. C++ Library  2.8.0
Classes | Macros | Functions | Variables
smp.cc File Reference
#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>
Include dependency graph for smp.cc:

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_structthreads = 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_structthis_thread = 0
 
static List< cbackthread_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
 

Detailed Description

Author
Kurt Garloff
Date
1998-11-02
Version
Id:
smp.cc,v 1.26.2.102 2022/11/03 16:53:01 garloff Exp

License: GNU LGPL

Definition in file smp.cc.

Macro Definition Documentation

#define _cpu_relax ( )    do {} while(0)

Definition at line 510 of file smp.cc.

Referenced by busy_read().

#define _GNU_SOURCE   1

Definition at line 52 of file smp.cc.

#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 NEED_SMP_DECLS   1

Definition at line 54 of file smp.cc.

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

#define TCHK (   x)    x

Definition at line 124 of file smp.cc.

Referenced by free_threads(), and init_threads().

Function Documentation

void _thread_start_off ( const int  thr_no,
thr_job_t  ljob,
const unsigned long  off,
const unsigned long  sz,
va_list  vl 
)
void bind_threads ( bool  bind_main,
bool  enable_numa,
bool  add_sibl 
)
static int busy_read ( int  fd,
void *  ptr,
size_t  sz,
int  rep = 1 
)
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 int detect_num_cpu ( int  rmv_ht)
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* empty_thread ( void *  dummy)

Definition at line 361 of file smp.cc.

References NULL.

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.

static pid_t gettid ( )
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 
)
void lina_empty ( struct thr_ctrl dummy)

Definition at line 356 of file smp.cc.

void lina_err ( struct thr_ctrl tc)

Definition at line 350 of file smp.cc.

References thr_ctrl::t_no.

Referenced by lina_thread().

void* lina_thread ( void *  thr)
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,
  ... 
)
void thread_start_off ( const int  thr_no,
thr_job_t  job,
const unsigned long  off,
const unsigned long  sz,
  ... 
)
void thread_wait ( const int  thr_no,
struct job_output out 
)
double thread_wait_result ( const int  thr_no)

Variable Documentation

bool bound_main = false

Definition at line 109 of file smp.cc.

Referenced by bind_threads(), and free_threads().

unsigned int curr_n_thr

Definition at line 1056 of file smp.cc.

THREAD__ int ismainthread = 1
unsigned long job_no = 0
static

Definition at line 944 of file smp.cc.

unsigned int last_n_thr

Definition at line 1056 of file smp.cc.

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

unsigned int prev_n_thr

Definition at line 1056 of file smp.cc.

THREAD__ struct thr_struct* this_thread = 0

Definition at line 113 of file smp.cc.

List<cback> thread_cbacks
static

Definition at line 329 of file smp.cc.

struct thr_struct* threads = 0

Definition at line 106 of file smp.cc.

Referenced by dot(), and Vector< T >::operator*().

bool threads_bound = false

Definition at line 108 of file smp.cc.

Referenced by bind_threads(), and free_threads().

int threads_busy = 0
THREAD__ int thrno = 0
int tot_cpu_tm

Definition at line 872 of file smp.cc.

Definition at line 1133 of file smp.cc.