the interface functions for openmp
Definition in file tpi_openmp.c.
#include "tpi/tpi.h"
#include "blockmemshell/memory.h"
#include "scip/pub_message.h"
#include "scip/pub_misc.h"
#include <omp.h>
Go to the source code of this file.
Data Structures | |
struct | SCIP_Lock |
struct | SCIP_Condition |
struct | SCIP_Job |
struct | SCIP_JobQueue |
struct | SCIP_JobQueues |
Macros | |
#define | SCIPompInitLock(lock) |
#define | SCIPompDestroyLock(lock) |
#define | SCIPompAcquireLock(lock) |
#define | SCIPompReleaseLock(lock) |
#define | SCIPompInitCondition(condition) |
#define | SCIPompDestroyCondition(condition) |
#define SCIPompInitLock | ( | lock | ) |
Definition at line 44 of file tpi_openmp.c.
Referenced by createJobQueue().
#define SCIPompDestroyLock | ( | lock | ) |
Definition at line 45 of file tpi_openmp.c.
Referenced by freeJobQueue().
#define SCIPompAcquireLock | ( | lock | ) |
Definition at line 46 of file tpi_openmp.c.
Referenced by executeJob(), jobQueueAddJob(), jobQueueProcessJob(), SCIPompWaitCondition(), SCIPtpiBroadcastCondition(), SCIPtpiCollectJobs(), SCIPtpiSignalCondition(), and SCIPtpiWaitCondition().
#define SCIPompReleaseLock | ( | lock | ) |
Definition at line 47 of file tpi_openmp.c.
Referenced by executeJob(), jobQueueAddJob(), jobQueueProcessJob(), SCIPompWaitCondition(), SCIPtpiBroadcastCondition(), SCIPtpiCollectJobs(), SCIPtpiSignalCondition(), and SCIPtpiWaitCondition().
#define SCIPompInitCondition | ( | condition | ) |
Definition at line 50 of file tpi_openmp.c.
Referenced by createJobQueue().
#define SCIPompDestroyCondition | ( | condition | ) |
Definition at line 52 of file tpi_openmp.c.
Referenced by freeJobQueue().
typedef struct SCIP_JobQueue SCIP_JOBQUEUE |
Definition at line 88 of file tpi_openmp.c.
typedef struct SCIP_JobQueues SCIP_JOBQUEUES |
Definition at line 100 of file tpi_openmp.c.
|
static |
create job queue
nthreads | the number of threads |
qsize | the queue size |
blockwhenfull | should the queue be blocked from new jobs when full |
Definition at line 107 of file tpi_openmp.c.
References assert(), BMSallocMemory, BMSallocMemoryArray, i, SCIP_JobQueues::nthreads, NULL, SCIP_ALLOC, SCIP_Bool, SCIP_CALL, SCIP_OKAY, SCIP_UNUSED, SCIPompInitCondition, and SCIPompInitLock.
Referenced by SCIPtpiInit().
|
static |
free job queue
Definition at line 144 of file tpi_openmp.c.
References assert(), BMSfreeMemory, BMSfreeMemoryArray, NULL, SCIP_OKAY, SCIPompDestroyCondition, and SCIPompDestroyLock.
Referenced by freeThreadPool(), and SCIPtpiExit().
|
static |
execute job
job | the job to be executed in parallel |
Definition at line 162 of file tpi_openmp.c.
References SCIP_Job::args, SCIP_Job::jobfunc, NULL, SCIP_Job::retcode, SCIP_CALL_ABORT, SCIPompAcquireLock, SCIPompReleaseLock, SCIPtpiBroadcastCondition(), and SCIPtpiGetThreadNum().
Referenced by jobQueueAddJob(), and jobQueueProcessJob().
SCIP_RETCODE SCIPtpiWaitCondition | ( | SCIP_CONDITION * | condition, |
SCIP_LOCK * | lock ) |
wait for a condition
condition | condition to wait for |
lock | corresponding lock |
Definition at line 200 of file tpi_openmp.c.
References SCIP_JobQueues::lock, SCIP_CALL, SCIP_OKAY, SCIPompAcquireLock, SCIPompReleaseLock, SCIPtpiAcquireLock(), and SCIPtpiReleaseLock().
|
static |
wait for a condition (direct access to lock)
condition | condition to wait for |
lock | corresponding lock |
Definition at line 239 of file tpi_openmp.c.
References SCIP_JobQueues::lock, SCIP_CALL, SCIP_OKAY, SCIPompAcquireLock, and SCIPompReleaseLock.
Referenced by jobQueueProcessJob(), and SCIPtpiCollectJobs().
|
static |
process jobs from job queue
The job will only be added when the number of active jobs is equal to the number of threads. As such, there will always be number of threads + 1 tasks available for the scheduler to run.
Definition at line 283 of file tpi_openmp.c.
References executeJob(), SCIP_Job::nextjob, NULL, SCIP_CALL_ABORT, SCIPompAcquireLock, SCIPompReleaseLock, SCIPompWaitCondition(), and SCIPtpiGetNumThreads().
Referenced by jobQueueAddJob().
|
static |
adding a job to the job queue
This gives some more flexibility in the handling of new jobs. IMPORTANT: This function MUST be called from within a mutex.
Definition at line 330 of file tpi_openmp.c.
References assert(), executeJob(), jobQueueProcessJob(), SCIP_Job::nextjob, NULL, SCIP_CALL, SCIP_OKAY, SCIPompAcquireLock, SCIPompReleaseLock, and SCIPtpiGetNumThreads().
Referenced by SCIPtpiSubmitJob().
SCIP_RETCODE SCIPtpiSignalCondition | ( | SCIP_CONDITION * | condition | ) |
signal a condition
condition | condition to signal |
Definition at line 382 of file tpi_openmp.c.
References assert(), NULL, SCIP_CALL, SCIP_OKAY, SCIPompAcquireLock, and SCIPompReleaseLock.
SCIP_RETCODE SCIPtpiBroadcastCondition | ( | SCIP_CONDITION * | condition | ) |
broadcase a condition
condition | broadcast a condition |
Definition at line 400 of file tpi_openmp.c.
References assert(), NULL, SCIP_CALL, SCIP_OKAY, SCIPompAcquireLock, and SCIPompReleaseLock.
Referenced by executeJob().
int SCIPtpiGetNumThreads | ( | void | ) |
returns the number of threads
Definition at line 416 of file tpi_openmp.c.
int SCIPtpiGetThreadNum | ( | void | ) |
SCIP_RETCODE SCIPtpiCreateJob | ( | SCIP_JOB ** | job, |
int | jobid, | ||
SCIP_RETCODE(* | jobfunc )(void *args), | ||
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 430 of file tpi_openmp.c.
References BMSallocMemory, NULL, SCIP_ALLOC, and SCIP_OKAY.
int SCIPtpiGetNewJobID | ( | void | ) |
get a new job id for the new set of submitted jobs
Definition at line 448 of file tpi_openmp.c.
SCIP_RETCODE SCIPtpiSubmitJob | ( | SCIP_JOB * | job, |
SCIP_SUBMITSTATUS * | status ) |
submit a job for parallel processing; the return value is a globally defined status
job | pointer to the job to be submitted |
status | pointer to store the submit status |
Definition at line 462 of file tpi_openmp.c.
References assert(), jobQueueAddJob(), NULL, SCIP_CALL, SCIP_OKAY, and SCIP_SUBMIT_SUCCESS.
|
static |
check whether a job is running
jobid | job id to check |
Definition at line 478 of file tpi_openmp.c.
References FALSE, i, NULL, SCIP_Bool, and TRUE.
Referenced by SCIPtpiCollectJobs().
|
static |
check whether a job is waiting
jobid | job id to check |
Definition at line 499 of file tpi_openmp.c.
References FALSE, SCIP_Job::jobid, SCIP_Job::nextjob, SCIP_Bool, and TRUE.
Referenced by SCIPtpiCollectJobs().
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
jobid | the jobid of the jobs to wait for |
Definition at line 527 of file tpi_openmp.c.
References BMSfreeMemory, isJobRunning(), isJobWaiting(), SCIP_Job::jobid, MIN, SCIP_Job::nextjob, NULL, SCIP_Job::retcode, SCIP_CALL, SCIP_CALL_ABORT, SCIP_ERROR, SCIP_OKAY, SCIPompAcquireLock, SCIPompReleaseLock, and SCIPompWaitCondition().
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 596 of file tpi_openmp.c.
References assert(), createJobQueue(), SCIP_JobQueues::nthreads, NULL, SCIP_Bool, SCIP_CALL, and SCIP_OKAY.
SCIP_RETCODE SCIPtpiExit | ( | void | ) |
deinitializes tpi
Definition at line 611 of file tpi_openmp.c.
References assert(), freeJobQueue(), NULL, SCIP_CALL, and SCIP_OKAY.
SCIP_RETCODE SCIPtpiInitLock | ( | SCIP_LOCK ** | lock | ) |
initializes the given lock
lock | the lock |
Definition at line 631 of file tpi_openmp.c.
References assert(), BMSallocMemory, SCIP_JobQueues::lock, NULL, SCIP_ALLOC, and SCIP_OKAY.
void SCIPtpiDestroyLock | ( | SCIP_LOCK ** | lock | ) |
destroys the given lock
lock | the lock |
Definition at line 643 of file tpi_openmp.c.
References assert(), BMSfreeMemory, SCIP_JobQueues::lock, and NULL.
SCIP_RETCODE SCIPtpiAcquireLock | ( | SCIP_LOCK * | lock | ) |
acquires the given lock
lock | the lock |
Definition at line 654 of file tpi_openmp.c.
References SCIP_JobQueues::lock, and SCIP_OKAY.
Referenced by SCIPtpiWaitCondition().
SCIP_RETCODE SCIPtpiReleaseLock | ( | SCIP_LOCK * | lock | ) |
releases the given lock
lock | the lock |
Definition at line 663 of file tpi_openmp.c.
References SCIP_JobQueues::lock, and SCIP_OKAY.
Referenced by SCIPtpiWaitCondition().
SCIP_RETCODE SCIPtpiInitCondition | ( | SCIP_CONDITION ** | condition | ) |
initializes the given condition variable
condition | condition to be created and initialized |
Definition at line 677 of file tpi_openmp.c.
References assert(), BMSallocMemory, NULL, SCIP_ALLOC, and SCIP_OKAY.
void SCIPtpiDestroyCondition | ( | SCIP_CONDITION ** | condition | ) |
destroys the given condition variable
condition | condition to be destroyed and freed |
Definition at line 694 of file tpi_openmp.c.
References assert(), and BMSfreeMemory.
SCIP_Bool SCIPtpiIsAvailable | ( | void | ) |
indicate whether a working TPI is available
Definition at line 708 of file tpi_openmp.c.
void SCIPtpiGetLibraryName | ( | char * | name, |
int | namesize ) |
get name of library that the TPI interfaces to
name | buffer to store name |
namesize | length of name buffer |
Definition at line 714 of file tpi_openmp.c.
References assert(), NULL, and SCIPsnprintf().
void SCIPtpiGetLibraryDesc | ( | char * | desc, |
int | descsize ) |
get description of library that the TPI interfaces to
desc | buffer to store description |
descsize | length of description |
Definition at line 725 of file tpi_openmp.c.
References assert(), NULL, and SCIPsnprintf().