MPSolve 3.2.1
Loading...
Searching...
No Matches
threading.h File Reference

Multithreading iterations for MPSolve. More...

#include <pthread.h>
#include <semaphore.h>
#include <mps/mps.h>

Go to the source code of this file.

Classes

struct  mps_thread_job
 A new job for mps_thread_fsolve(), mps_thread_dsolve() or mps_thread_msolve(). More...
 
struct  mps_thread_job_queue
 Struct holding a job queue. More...
 
struct  mps_thread_worker_data
 Data packed to be passed to a new thread that will perform floating point, dpe or multiprecision iterations. More...
 
struct  mps_thread
 A thread that is part of a thread pool. More...
 
struct  mps_thread_pool_queue_item
 An item that can be inserted and/or extracted from a mps_thread_pool_queue. More...
 
struct  mps_thread_pool_queue
 A queue of work items that thread can consume. More...
 
struct  mps_thread_pool
 A thread pool that contains a set of mps_thread and allow to manage them as a set of worker. More...
 

Macros

#define MPS_THREAD_JOB_EXCEP   -1
 
#define MPS_MAX_CORES   8192
 
#define mps_with_lock(pmutex, code)
 
#define mps_thread_get_spar2(s, n_thread)   (s->spar2 + (s->deg + 2) * (n_thread))
 Get a pointer to an array of n+2 booleans that is local to the thread.
 
#define mps_thread_get_mfpc2(s, n_thread)   (s->mfpc2 + (s->deg + 1) * (n_thread))
 Get a pointer to an array of n+1 multiprecision that is local to the thread.
 
#define mps_thread_get_dap2(s, n_thread)   (s->dap2 + (s->deg + 2) * (n_thread))
 Get a pointer to an array of n+2 DPE that is local to the thread.
 

Typedefs

typedef void *(* mps_thread_work) (void *)
 A generic routine that can be performed by a mps_thread.
 

Functions

void * mps_thread_mainloop (void *thread_ptr)
 
void mps_thread_start_mainloop (mps_context *s, mps_thread *thread)
 Start the thread mainloop.
 
mps_threadmps_thread_new (mps_context *s, mps_thread_pool *pool)
 Allocate a new mps_thread and start its mainloop.
 
void mps_thread_free (mps_context *s, mps_thread *thread)
 Free a thread asking it to stop.
 
void mps_thread_pool_set_concurrency_limit (mps_context *s, mps_thread_pool *pool, unsigned int concurrency_limit)
 Limit the maximum number of threads that can be used in the thread pool.
 
void mps_thread_pool_assign (mps_context *s, mps_thread_pool *pool, mps_thread_work work, void *args)
 
void mps_thread_pool_insert_new_thread (mps_context *s, mps_thread_pool *pool)
 Create a new thread and add it to the specified thread pool.
 
void mps_thread_pool_wait (mps_context *s, mps_thread_pool *pool)
 Wait for a thread pool to complete its jobs.
 
mps_thread_poolmps_thread_pool_get_system_pool (mps_context *s)
 Obtain a pointer to the default shared thread pool on this system.
 
void mps_thread_pool_set_strict_async (mps_thread_pool *pool, mps_boolean strict_async)
 Set the value of the internal field strict_async of the pool. More...
 
mps_thread_poolmps_thread_pool_new (mps_context *s, int n_threads)
 Allocate a new thread pool and return a pointer to it, with a number of threads suitable for this system.
 
void mps_thread_pool_free (mps_context *s, mps_thread_pool *pool)
 Free a thread pool and all its threads, waiting for them to terminate.
 
mps_thread_job_queuemps_thread_job_queue_new (mps_context *s)
 Create a new mps_thread_job_queue that can handle at most max_iter iterations for n_roots roots.
 
void mps_thread_job_queue_free (mps_thread_job_queue *q)
 
mps_thread_job mps_thread_job_queue_next (mps_context *s, mps_thread_job_queue *q)
 Obtain iter and i for the next available job.
 
void mps_thread_fpolzer (mps_context *s, int *nit, mps_boolean *excep, int required_zeros)
 Drop-in replacement for the stock fpolzer routine. This version adds multithread support.
 
void mps_thread_mpolzer (mps_context *s, int *nit, mps_boolean *excep, int required_zeros)
 Drop-in threaded replacement for the stock mpolzer.
 
void mps_thread_dpolzer (mps_context *s, int *nit, mps_boolean *excep, int required_zeros)
 Multithread version of mps_dpolzer ().
 
int mps_thread_get_core_number (mps_context *s)
 Get number of logic cores on the local machine, or 0 if that information is not available with the method known to this implementations.
 
int mps_thread_get_id (mps_context *s, mps_thread_pool *pool)
 

Detailed Description

Multithreading iterations for MPSolve.

Macro Definition Documentation

◆ mps_with_lock

#define mps_with_lock (   pmutex,
  code 
)
Value:
{ \
pthread_mutex_lock (&pmutex); \
code \
pthread_mutex_unlock (&pmutex); \
}

Function Documentation

◆ mps_thread_pool_set_strict_async()

void mps_thread_pool_set_strict_async ( mps_thread_pool pool,
mps_boolean  strict_async 
)

Set the value of the internal field strict_async of the pool.

This is used to control the optimizations performed in the case where the number of threads is 1. In case strict_async is set to true (that is currently the default value) every call to mps_thread_pool_assign() will not return immediately but instead complete the job.