Scippy

SCIP

Solving Constraint Integer Programs

tpi_openmp.c File Reference

Detailed Description

the interface functions for openmp

Author
Stephen J. Maher
Leona Gottwald

Definition in file tpi_openmp.c.

#include "tpi/tpi.h"
#include "blockmemshell/memory.h"

Go to the source code of this file.

Data Structures

struct  SCIP_Job
 
struct  SCIP_JobQueue
 
struct  SCIP_JobQueues
 

Typedefs

typedef struct SCIP_JobQueue SCIP_JOBQUEUE
 
typedef struct SCIP_JobQueues SCIP_JOBQUEUES
 

Functions

static SCIP_RETCODE createJobQueue (int nthreads, int qsize, SCIP_Bool blockwhenfull)
 
static SCIP_RETCODE freeJobQueue (void)
 
static void executeJob (SCIP_JOB *job)
 
static void jobQueueProcessJob (void)
 
static SCIP_RETCODE jobQueueAddJob (SCIP_JOB *newjob)
 
SCIP_RETCODE SCIPtpiSignalCondition (SCIP_CONDITION *condition)
 
SCIP_RETCODE SCIPtpiBroadcastCondition (SCIP_CONDITION *condition)
 
SCIP_RETCODE SCIPtpiWaitCondition (SCIP_CONDITION *condition, SCIP_LOCK *lock)
 
int SCIPtpiGetNumThreads ()
 
int SCIPtpiGetThreadNum ()
 
SCIP_RETCODE SCIPtpiCreateJob (SCIP_JOB **job, int jobid, SCIP_RETCODE(*jobfunc)(void *args), void *jobarg)
 
int SCIPtpiGetNewJobID (void)
 
SCIP_RETCODE SCIPtpiSumbitJob (SCIP_JOB *job, SCIP_SUBMITSTATUS *status)
 
static SCIP_Bool isJobRunning (int jobid)
 
static SCIP_Bool isJobWaiting (int jobid)
 
SCIP_RETCODE SCIPtpiCollectJobs (int jobid)
 
SCIP_RETCODE SCIPtpiInit (int nthreads, int queuesize, SCIP_Bool blockwhenfull)
 
SCIP_RETCODE SCIPtpiExit (void)
 

Typedef Documentation

◆ SCIP_JOBQUEUE

typedef struct SCIP_JobQueue SCIP_JOBQUEUE

Definition at line 45 of file tpi_openmp.c.

◆ SCIP_JOBQUEUES

Definition at line 57 of file tpi_openmp.c.

Function Documentation

◆ createJobQueue()

static SCIP_RETCODE createJobQueue ( int  nthreads,
int  qsize,
SCIP_Bool  blockwhenfull 
)
static

create job queue

Parameters
nthreadsthe number of threads
qsizethe queue size
blockwhenfullshould the queue be blocked from new jobs when full

Definition at line 64 of file tpi_openmp.c.

References BMSallocMemory, SCIP_ALLOC, and SCIP_UNUSED.

◆ freeJobQueue()

static SCIP_RETCODE freeJobQueue ( void  )
static

free job queue

Definition at line 101 of file tpi_openmp.c.

◆ executeJob()

static void executeJob ( SCIP_JOB job)
static

execute job

Parameters
jobthe job to be executed in parallel

Definition at line 119 of file tpi_openmp.c.

References SCIP_CALL_ABORT, SCIPtpiAcquireLock(), and SCIPtpiGetThreadNum().

◆ jobQueueProcessJob()

static void jobQueueProcessJob ( void  )
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 163 of file tpi_openmp.c.

References SCIP_CALL_ABORT, and SCIPtpiAcquireLock().

◆ jobQueueAddJob()

static SCIP_RETCODE jobQueueAddJob ( SCIP_JOB newjob)
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 210 of file tpi_openmp.c.

References SCIP_Job::nextjob, NULL, SCIP_CALL, and SCIPtpiAcquireLock().

◆ SCIPtpiSignalCondition()

SCIP_RETCODE SCIPtpiSignalCondition ( SCIP_CONDITION *  condition)

signal a condition

Parameters
conditioncondition to signal

Definition at line 262 of file tpi_openmp.c.

References NULL, SCIP_CALL, SCIP_OKAY, SCIPtpiAcquireLock(), and SCIPtpiReleaseLock().

Referenced by jobQueueAddJob().

◆ SCIPtpiBroadcastCondition()

SCIP_RETCODE SCIPtpiBroadcastCondition ( SCIP_CONDITION *  condition)

broadcase a condition

Parameters
conditionbroadcast a condition

Definition at line 280 of file tpi_openmp.c.

References NULL, SCIP_CALL, SCIP_OKAY, SCIPtpiAcquireLock(), and SCIPtpiReleaseLock().

Referenced by freeThreadPool(), and SCIPsyncstoreFinishSync().

◆ SCIPtpiWaitCondition()

SCIP_RETCODE SCIPtpiWaitCondition ( SCIP_CONDITION *  condition,
SCIP_LOCK *  lock 
)

wait for a condition

Parameters
conditioncondition to wait for
lockcorresponding lock

Definition at line 295 of file tpi_openmp.c.

References SCIP_CALL, SCIP_OKAY, SCIPtpiAcquireLock(), and SCIPtpiReleaseLock().

Referenced by freeThreadPool(), and SCIPsyncstoreEnsureAllSynced().

◆ SCIPtpiGetNumThreads()

int SCIPtpiGetNumThreads ( void  )

returns the number of threads

Definition at line 333 of file tpi_openmp.c.

◆ SCIPtpiGetThreadNum()

int SCIPtpiGetThreadNum ( void  )

returns the thread number

Definition at line 340 of file tpi_openmp.c.

Referenced by applyBoundChanges(), execConcsolver(), and executeJob().

◆ SCIPtpiCreateJob()

SCIP_RETCODE SCIPtpiCreateJob ( SCIP_JOB **  job,
int  jobid,
SCIP_RETCODE(*)(void *args)  jobfunc,
void *  jobarg 
)

creates a job for parallel processing

Parameters
jobpointer to the job that will be created
jobidthe id for the current job
jobfuncpointer to the job function
jobargthe job's argument

Definition at line 347 of file tpi_openmp.c.

References BMSallocMemory, SCIP_Job::jobfunc, SCIP_Job::jobid, NULL, SCIP_ALLOC, and SCIP_OKAY.

◆ SCIPtpiGetNewJobID()

int SCIPtpiGetNewJobID ( void  )

get a new job id for the new set of submitted jobs

Definition at line 365 of file tpi_openmp.c.

References SCIP_Job::jobid.

◆ SCIPtpiSumbitJob()

SCIP_RETCODE SCIPtpiSumbitJob ( SCIP_JOB job,
SCIP_SUBMITSTATUS status 
)

submit a job for parallel processing; the return value is a globally defined status

Parameters
jobpointer to the job to be submitted
statuspointer to store the submit status

Definition at line 379 of file tpi_openmp.c.

◆ isJobRunning()

static SCIP_Bool isJobRunning ( int  jobid)
static

check whether a job is running

Parameters
jobidjob id to check

Definition at line 395 of file tpi_openmp.c.

◆ isJobWaiting()

static SCIP_Bool isJobWaiting ( int  jobid)
static

check whether a job is waiting

Parameters
jobidjob id to check

Definition at line 416 of file tpi_openmp.c.

◆ 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

Parameters
jobidthe jobid of the jobs to wait for

Definition at line 444 of file tpi_openmp.c.

References SCIP_Job::retcode, SCIP_CALL, SCIP_OKAY, and SCIPtpiAcquireLock().

◆ SCIPtpiInit()

SCIP_RETCODE SCIPtpiInit ( int  nthreads,
int  queuesize,
SCIP_Bool  blockwhenfull 
)

initializes tpi

Parameters
nthreadsthe number of threads to be used
queuesizethe size of the queue
blockwhenfullshould the queue block when full

Definition at line 513 of file tpi_openmp.c.

◆ SCIPtpiExit()

SCIP_RETCODE SCIPtpiExit ( void  )

deinitializes tpi

Definition at line 528 of file tpi_openmp.c.