MAOS
Multithreaded Adaptive Optics Simulator
thread.h File Reference

Data Structures

struct  thread_t
 

Macros

#define DO_PRAGMA(A...)   _Pragma(#A)
 
#define PRINT_MACRO(x)   DO_PRAGMA(message #x " is " STR(x))
 
#define STR(x)   #x
 
#define LOCK(A)   pthread_mutex_lock(&A)
 
#define TRYLOCK(A)   pthread_mutex_trylock(&A)
 
#define UNLOCK(A)   pthread_mutex_unlock(&A)
 
#define PINIT(A)   pthread_mutex_init(&A,NULL)
 
#define PDEINIT(A)   pthread_mutex_destroy(&A)
 
#define PNEW(A)   static pthread_mutex_t A=PTHREAD_MUTEX_INITIALIZER
 
#define PNEW2(A)   pthread_mutex_t A=PTHREAD_MUTEX_INITIALIZER
 
#define LOCK_FFT   LOCK(mutex_fftw)
 
#define UNLOCK_FFT   UNLOCK(mutex_fftw)
 
#define MEM_ORDER   __ATOMIC_RELAXED
 
#define atomic_compare_exchange_n(ptr, pexpected, desired)   __atomic_compare_exchange_n(ptr, pexpected, desired, 0, MEM_ORDER, MEM_ORDER)
 
#define atomic_compare_exchange(ptr, pexpected, pdesired)   __atomic_compare_exchange(ptr, pexpected, pdesired, 0, MEM_ORDER, MEM_ORDER)
 
#define atomic_load(ptr)   __atomic_load_n(ptr, MEM_ORDER)
 
#define atomic_store(ptr, val)   __atomic_store_n(ptr, val, MEM_ORDER)
 
#define OMPTASK_SINGLE
 
#define OMP_IN_PARALLEL   0
 
#define OMP_FOR(n)
 
#define OMP_FOR_COLLAPSE(n)
 
#define OMP_TASK_FOR(ntask)
 
#define OMP_TASK_FOR_COLLAPSE(n, ntask)
 
#define THREAD_POOL_INIT(A)   ({thread_pool_init(A);info("Using thread pool with %d threads\n", A);})
 
#define QUEUE(counter, fun, arg, njob, urgent)   thread_pool_queue(counter, (thread_wrapfun)fun, arg, njob, urgent)
 Queue jobs to counter. Do not wait.
 
#define QUEUE_THREAD(counter, A, urgent)   thread_pool_queue(counter, NULL, A, A[0].nthread, urgent)
 
#define WAIT(counter, urgent)   thread_pool_wait(counter, urgent)
 
#define CALL(fun, arg, nthread, urgent)
 Queue jobs to a temp counter, Then wait for it to complete.
 
#define CALL_THREAD(A, urgent)
 

Typedefs

typedef void *(* thread_fun) (void *)
 
typedef void *(* thread_wrapfun) (thread_t *)
 

Functions

long thread_id (void)
 
thread_tthread_prep (long start, long end, long nthread, thread_wrapfun fun, void *data)
 prepare thread information More...
 
int thread_new (thread_fun fun, void *arg)
 Create a thread and take it away. More...
 
void thread_block_signal ()
 

Detailed Description

Functions regarding to threading.

Openmp version: 3.0 (200805): Introduced task 4.0 (201307): Introduced taskgroup. 4.5 (201511): Introduced taskloop and priority. Taskloop has implicit taskgroup.


Data Structure Documentation

◆ thread_t

struct thread_t

Information about job to launch for each thread. start and end are the two indices.

+ Collaboration diagram for thread_t:
Data Fields
long start
long end
long ithread
long nthread
thread_wrapfun fun
void * data
void * thread_data

Function Documentation

◆ thread_prep()

thread_t* thread_prep ( long  start,
long  end,
long  nthread,
thread_wrapfun  fun,
void *  data 
)

prepare thread information

Break out the job to be executed by multiple threads.

◆ thread_new()

int thread_new ( thread_fun  fun,
void *  arg 
)

Create a thread and take it away.

Create a new thread and forget.

◆ thread_block_signal()

void thread_block_signal ( )

After calling this routine, this thread will nolonger receive signals