Scippy

SCIP

Solving Constraint Integer Programs

tpi.h
Go to the documentation of this file.
1 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2 /* */
3 /* This file is part of the program and library */
4 /* SCIP --- Solving Constraint Integer Programs */
5 /* */
6 /* Copyright (C) 2002-2017 Konrad-Zuse-Zentrum */
7 /* fuer Informationstechnik Berlin */
8 /* */
9 /* SCIP is distributed under the terms of the ZIB Academic License. */
10 /* */
11 /* You should have received a copy of the ZIB Academic License */
12 /* along with SCIP; see the file COPYING. If not email to scip@zib.de. */
13 /* */
14 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
15 
16 /**@file tpi.h
17  * @ingroup TASKINTERFACE
18  * @brief the type definitions for the SCIP parallel interface
19  * @author Robert Lion Gottwald
20  * @author Stephen J. Maher
21  */
22 
23 /*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
24 
25 #ifndef __TPI_H__
26 #define __TPI_H__
27 
28 #include "scip/def.h"
29 #include "tpi/def_openmp.h"
30 #include "tpi/type_tpi.h"
31 
32 /** initializes the given lock */
33 extern
35  SCIP_LOCK* lock /**< the lock */
36  );
37 
38 /** destroys the given lock */
39 extern
41  SCIP_LOCK* lock /**< the lock */
42  );
43 
44 /** acquires the given lock */
45 extern
47  SCIP_LOCK* lock /**< the lock */
48  );
49 
50 /** releases the given lock */
51 extern
53  SCIP_LOCK* lock /**< the lock */
54  );
55 
56 /** initializes the given condition variable */
57 extern
59  SCIP_LOCK* lock /**< the lock */
60  );
61 
62 /** destroys the given condition variable */
63 extern
65  SCIP_LOCK* lock /**< the lock */
66  );
67 
68 /** signals one waiting thread */
69 extern
71  SCIP_CONDITION* condition /**< the condition variable to signal */
72  );
73 
74 /** signals all waiting threads */
75 extern
77  SCIP_CONDITION* condition /**< the condition variable to broadcast */
78  );
79 
80 /** waits on a condition variable. The given lock must be held by the caller and will
81  * be held when this function returns.
82  */
83 extern
85  SCIP_CONDITION* condition, /**< the condition variable to wait on */
86  SCIP_LOCK* lock /**< the lock that is held by the caller */
87  );
88 
89 /** returns the number of threads */
90 extern
92  void
93  );
94 
95 /** returns the thread number */
96 extern
98  void
99  );
100 
101 /** creates a job for parallel processing */
102 extern
104  SCIP_JOB** job, /**< pointer to the job that will be created */
105  int jobid, /**< the id for the current job */
106  SCIP_RETCODE (*jobfunc)(void* args),/**< pointer to the job function */
107  void* jobarg /**< the job's argument */
108  );
109 
110 /** get a new job id for a new set of jobs */
111 extern
113  void
114  );
115 
116 /** submit a job for parallel processing
117  * the return is a globally defined status
118  */
119 extern
121  SCIP_JOB* job, /**< pointer to the job to be submitted */
122  SCIP_SUBMITSTATUS* status /**< pointer to store the job's submit status */
123  );
124 
125 /** blocks until all jobs of the given jobid have finished
126  * and then returns the smallest SCIP_RETCODE of all the jobs
127  */
128 extern
130  int jobid /**< the jobid of the jobs to wait for */
131  );
132 
133 /** initializes tpi */
134 extern
136  int nthreads, /**< the number of threads to be used */
137  int queuesize, /**< the size of the queue */
138  /*TODO: specify and implement behaviour of blockwhenfull flag*/
139  SCIP_Bool blockwhenfull /**< should the queue block when full */
140  );
141 
142 /** deinitializes the tpi */
143 extern
145  void
146  );
147 
148 #endif
149 
150 #include "tpi/tpi_openmp.h"
151 #include "tpi/tpi_tnycthrd.h"
152 #include "tpi/tpi_none.h"
SCIP_RETCODE SCIPtpiWaitCondition(SCIP_CONDITION *condition, SCIP_LOCK *lock)
Definition: tpi_openmp.c:286
the type definitions for the task processing interface
enum SCIP_Submitstatus SCIP_SUBMITSTATUS
Definition: type_tpi.h:45
wrappers for OpenMP defines
enum SCIP_Retcode SCIP_RETCODE
Definition: type_retcode.h:53
SCIP_RETCODE SCIPtpiBroadcastCondition(SCIP_CONDITION *condition)
Definition: tpi_openmp.c:274
SCIP_RETCODE SCIPtpiAcquireLock(SCIP_LOCK *lock)
SCIP_RETCODE SCIPtpiInitCondition(SCIP_LOCK *lock)
the dummy implementation defines all functions as macros
SCIP_RETCODE SCIPtpiReleaseLock(SCIP_LOCK *lock)
the tinycthreads implementation defines the lock and condition functionality as macros ...
int SCIPtpiGetNewJobID(void)
Definition: tpi_openmp.c:356
the tpi_openmp redefines the lock functionality and some condition functionality as macros ...
SCIP_RETCODE SCIPtpiCollectJobs(int jobid)
Definition: tpi_none.c:58
SCIP_RETCODE SCIPtpiCreateJob(SCIP_JOB **job, int jobid, SCIP_RETCODE(*jobfunc)(void *args), void *jobarg)
Definition: tpi_none.c:28
SCIP_RETCODE SCIPtpiExit(void)
Definition: tpi_none.c:82
#define SCIP_Bool
Definition: def.h:61
SCIP_RETCODE SCIPtpiInitLock(SCIP_LOCK *lock)
void SCIPtpiDestroyLock(SCIP_LOCK *lock)
void SCIPtpiDestroyCondition(SCIP_LOCK *lock)
SCIP_RETCODE SCIPtpiSumbitJob(SCIP_JOB *job, SCIP_SUBMITSTATUS *status)
Definition: tpi_none.c:45
SCIP_RETCODE SCIPtpiSignalCondition(SCIP_CONDITION *condition)
Definition: tpi_openmp.c:260
int SCIPtpiGetThreadNum(void)
Definition: tpi_openmp.c:331
common defines and data types used in all packages of SCIP
SCIP_RETCODE SCIPtpiInit(int nthreads, int queuesize, SCIP_Bool blockwhenfull)
Definition: tpi_none.c:68
int SCIPtpiGetNumThreads(void)
Definition: tpi_openmp.c:324