TBCI Numerical high perf. C++ Library 2.8.0
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)
#define ERRDECL
#define _cpu_relax()
#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

◆ _cpu_relax

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

Definition at line 510 of file smp.cc.

Referenced by busy_read().

◆ _GNU_SOURCE

#define _GNU_SOURCE   1

Definition at line 52 of file smp.cc.

◆ ERRDECL

#define ERRDECL

Definition at line 125 of file smp.cc.

Referenced by _thread_start_off(), and free_threads().

◆ MAX_THREADS

#define MAX_THREADS   160

Definition at line 83 of file smp.cc.

Referenced by init_threads().

◆ NEED_SMP_DECLS

#define NEED_SMP_DECLS   1

Definition at line 54 of file smp.cc.

◆ POLL_REP

#define POLL_REP   1

Definition at line 520 of file smp.cc.

Referenced by busy_read().

◆ POLL_REP2

#define POLL_REP2   168

Definition at line 523 of file smp.cc.

Referenced by thread_wait(), and thread_wait_result().

◆ TCHK

#define TCHK ( x)
Value:
const Vector< T > const Vector< T > & x
Definition LM_fit.h:97

Definition at line 124 of file smp.cc.

Referenced by free_threads(), and init_threads().

Function Documentation

◆ _thread_start_off()

void _thread_start_off ( const int thr_no,
thr_job_t ljob,
const unsigned long off,
const unsigned long sz,
va_list vl )

◆ bind_threads()

void bind_threads ( bool bind_main,
bool enable_numa,
bool add_sibl )

◆ busy_read()

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

◆ detect_num_cpu()

int detect_num_cpu ( int rmv_ht)
static

Definition at line 267 of file smp.cc.

References CSTD__, and gettid().

Referenced by init_threads().

◆ disable_threads()

void disable_threads ( )

Definition at line 1037 of file smp.cc.

References threads_busy.

◆ empty_thread()

void * empty_thread ( void * dummy)

Definition at line 361 of file smp.cc.

References NULL.

◆ free_threads()

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, ismainthread, main_thread_pid, NULL, num_threads, poll_efail, poll_fail, poll_succ, poll_usucc, res, job_input::t_job, job_output::t_retval, TCHK, thread_cbacks, threads, threads_bound, thrno, tot_cpu_tm, and ts.

◆ gettid()

pid_t gettid ( )
inlinestatic

Definition at line 92 of file smp.cc.

Referenced by detect_num_cpu(), and lina_thread().

◆ init_threads()

int init_threads ( const int num_cpu,
const bool load_magic )

◆ lina_empty()

void lina_empty ( struct thr_ctrl * dummy)

Definition at line 356 of file smp.cc.

◆ lina_err()

void lina_err ( struct thr_ctrl * tc)

Definition at line 350 of file smp.cc.

References thr_ctrl::t_no.

Referenced by lina_thread().

◆ lina_thread()

◆ reenable_threads()

void reenable_threads ( )

Definition at line 1045 of file smp.cc.

References num_threads, and threads_busy.

◆ thread_dereg_callback()

void thread_dereg_callback ( cbackfn ctor,
cbackfn dtor,
void * parm )

Definition at line 340 of file smp.cc.

References BCHK, and thread_cbacks.

Referenced by tbci_memalloc_cache< T >::~tbci_memalloc_cache().

◆ thread_reg_callback()

void thread_reg_callback ( cbackfn ctor,
cbackfn dtor,
void * parm )

Definition at line 333 of file smp.cc.

References thread_cbacks.

Referenced by tbci_memalloc_cache< T >::tbci_memalloc_cache().

◆ thread_start()

void thread_start ( const int thr_no,
thr_job_t job,
const unsigned long sz,
... )

◆ thread_start_off()

void thread_start_off ( const int thr_no,
thr_job_t job,
const unsigned long off,
const unsigned long sz,
... )

◆ thread_wait()

◆ thread_wait_result()

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, job_output::t_res_d, threads, threads_busy, and ts.

Referenced by Vector< T >::fabssqr().

Variable Documentation

◆ bound_main

bool bound_main = false

Definition at line 109 of file smp.cc.

Referenced by bind_threads(), and free_threads().

◆ curr_n_thr

unsigned int curr_n_thr

Definition at line 1056 of file smp.cc.

◆ ismainthread

THREAD__ int ismainthread = 1

Definition at line 111 of file smp.cc.

◆ job_no

unsigned long job_no = 0
static

Definition at line 944 of file smp.cc.

Referenced by _thread_start_off().

◆ last_n_thr

unsigned int last_n_thr

Definition at line 1056 of file smp.cc.

◆ main_numa_node

int main_numa_node = 0

Definition at line 110 of file smp.cc.

Referenced by bind_threads().

◆ main_thread_pid

pid_t main_thread_pid = 0

Definition at line 107 of file smp.cc.

Referenced by bind_threads(), free_threads(), and init_threads().

◆ num_threads

NAMESPACE_TBCI int num_threads = 0

Definition at line 103 of file smp.cc.

Referenced by init_threads().

◆ numa_avail

int numa_avail = 0

Definition at line 105 of file smp.cc.

Referenced by bind_threads().

◆ poll_efail

unsigned long poll_efail = 0

Definition at line 517 of file smp.cc.

Referenced by busy_read(), and free_threads().

◆ poll_fail

unsigned long poll_fail = 0

Definition at line 516 of file smp.cc.

Referenced by busy_read(), and free_threads().

◆ poll_succ

unsigned long poll_succ = 0

Definition at line 514 of file smp.cc.

Referenced by busy_read(), and free_threads().

◆ poll_usucc

unsigned long poll_usucc = 0

Definition at line 515 of file smp.cc.

Referenced by busy_read(), and free_threads().

◆ prev_n_thr

unsigned int prev_n_thr

Definition at line 1056 of file smp.cc.

◆ this_thread

THREAD__ struct thr_struct* this_thread = 0

Definition at line 113 of file smp.cc.

Referenced by lina_thread().

◆ thread_cbacks

List<cback> thread_cbacks
static

Definition at line 329 of file smp.cc.

Referenced by free_threads(), init_threads(), thread_dereg_callback(), and thread_reg_callback().

◆ threads

◆ threads_bound

bool threads_bound = false

Definition at line 108 of file smp.cc.

Referenced by bind_threads(), and free_threads().

◆ threads_busy

int threads_busy = 0

◆ thrno

THREAD__ int thrno = 0

Definition at line 112 of file smp.cc.

◆ tot_cpu_tm

int tot_cpu_tm

Definition at line 872 of file smp.cc.

Referenced by free_threads().

◆ WEAKA

Definition at line 1133 of file smp.cc.