a TPI implementation using tinycthreads
Definition in file tpi_tnycthrd.c.
Go to the source code of this file.
Typedefs | |
| typedef struct SCIP_ThreadPool | SCIP_THREADPOOL |
| typedef struct SCIP_JobQueue | SCIP_JOBQUEUE |
| typedef struct SCIP_ThreadPool SCIP_THREADPOOL |
Definition at line 28 of file tpi_tnycthrd.c.
| typedef struct SCIP_JobQueue SCIP_JOBQUEUE |
Definition at line 49 of file tpi_tnycthrd.c.
|
static |
this function controls the execution of each of the threads
| threadnum | thread number is passed in as argument stored inside a void pointer |
Definition at line 82 of file tpi_tnycthrd.c.
Referenced by threadPoolThread().
|
static |
this function controls the execution of each of the threads
| threadnum | thread number is passed in as argument stored inside a void pointer |
Definition at line 209 of file tpi_tnycthrd.c.
References threadPoolThreadRetcode().
Referenced by createThreadPool().
|
static |
creates a threadpool
| thrdpool | pointer to store threadpool |
| nthreads | number of threads in the threadpool |
| qsize | maximum size of the jobqueue |
| blockwhenfull | should the jobqueue block if it is full |
Definition at line 218 of file tpi_tnycthrd.c.
References BMSallocMemory, BMSallocMemoryArray, FALSE, SCIP_ALLOC, SCIP_CALL, SCIP_ERROR, SCIPtpiInitCondition(), SCIPtpiInitLock(), threadPoolThread(), and TRUE.
|
static |
adding a job to the job queue. This gives some more flexibility in the handling of new jobs. This function needs to be called from within a mutex.
Definition at line 292 of file tpi_tnycthrd.c.
References SCIP_JobQueue::firstjob, SCIP_ThreadPool::jobqueue, SCIP_JobQueue::lastjob, SCIP_Job::nextjob, SCIP_JobQueue::njobs, SCIP_ThreadPool::queuenotempty, SCIP_ThreadPool::queuesize, SCIP_CALL_ABORT, and SCIPtpiSignalCondition().
|
static |
adds a job to the threadpool
| newjob | job to add to threadpool |
| status | pointer to store the job's submit status |
Definition at line 324 of file tpi_tnycthrd.c.
|
static |
frees the jobqueue of the threadpool
Definition at line 381 of file tpi_tnycthrd.c.
References BMSfreeMemory, SCIP_JobQueue::firstjob, SCIP_ThreadPool::jobqueue, SCIP_JobQueue::lastjob, SCIP_Job::nextjob, SCIP_ThreadPool::queueopen, and SCIP_ThreadPool::shutdown.
Referenced by freeThreadPool().
|
static |
Definition at line 408 of file tpi_tnycthrd.c.
References BMSfreeMemory, BMSfreeMemoryArray, FALSE, freeJobQueue(), SCIP_Job::retcode, SCIP_CALL, SCIP_ERROR, SCIP_OKAY, SCIP_UNUSED, SCIPtpiAcquireLock(), SCIPtpiBroadcastCondition(), SCIPtpiDestroyCondition(), SCIPtpiDestroyLock(), SCIPtpiReleaseLock(), SCIPtpiWaitCondition(), and TRUE.
|
static |
Definition at line 494 of file tpi_tnycthrd.c.
References SCIP_JobQueue::firstjob, SCIP_Job::jobid, SCIP_JobQueue::lastjob, SCIP_Job::nextjob, SCIP_JOB_DOESNOTEXIST, and SCIP_JOB_INQUEUE.
Referenced by isJobRunning().
|
static |
Definition at line 523 of file tpi_tnycthrd.c.
References checkJobQueue(), FALSE, SCIP_JOB_INQUEUE, and TRUE.
| int SCIPtpiGetNumThreads | ( | void | ) |
returns the number of threads
Definition at line 535 of file tpi_tnycthrd.c.
| SCIP_RETCODE SCIPtpiInit | ( | int | nthreads, |
| int | queuesize, | ||
| SCIP_Bool | blockwhenfull | ||
| ) |
initializes tpi
| nthreads | the number of threads to be used |
| queuesize | the size of the queue |
| blockwhenfull | should the queue block when full |
Definition at line 543 of file tpi_tnycthrd.c.
Referenced by SCIPsyncstoreInit().
| SCIP_RETCODE SCIPtpiExit | ( | void | ) |
| SCIP_RETCODE SCIPtpiCreateJob | ( | SCIP_JOB ** | job, |
| int | jobid, | ||
| SCIP_RETCODE(*)(void *args) | jobfunc, | ||
| void * | jobarg | ||
| ) |
creates a job for parallel processing
| job | pointer to the job that will be created |
| jobid | the id for the current job |
| jobfunc | pointer to the job function |
| jobarg | the job's argument |
Definition at line 568 of file tpi_tnycthrd.c.
References BMSallocMemory, SCIP_Job::jobfunc, SCIP_Job::jobid, SCIP_ALLOC, and SCIP_OKAY.
Referenced by SCIPconcurrentSolve().
| int SCIPtpiGetNewJobID | ( | void | ) |
get a new job id for the new set of submitted jobs
Definition at line 586 of file tpi_tnycthrd.c.
Referenced by SCIPconcurrentSolve().
| SCIP_RETCODE SCIPtpiSumbitJob | ( | SCIP_JOB * | job, |
| SCIP_SUBMITSTATUS * | status | ||
| ) |
submit a job for parallel processing the return is a globally defined status
| job | pointer to the job to be submitted |
| status | pointer to store the job's submit status |
Definition at line 602 of file tpi_tnycthrd.c.
References SCIP_Job::jobid.
Referenced by SCIPconcurrentSolve().
| SCIP_RETCODE SCIPtpiCollectJobs | ( | int | jobid | ) |
blocks until all jobs of the given jobid have finished and then returns the smallest SCIP_RETCODE of all the jobs
if the job has the right jobid collect its retcode, remove it from the finished job list, and free it
| jobid | the jobid of the jobs to wait for |
Definition at line 621 of file tpi_tnycthrd.c.
References SCIP_Job::retcode, SCIP_CALL, and SCIPtpiAcquireLock().
Referenced by SCIPconcurrentSolve().