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-2018 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 visit 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 "scip/pub_message.h"
30 #include "tpi/def_openmp.h"
31 #include "tpi/type_tpi.h"
32 
33 /** initializes the given lock */
34 extern
36  SCIP_LOCK* lock /**< the lock */
37  );
38 
39 /** destroys the given lock */
40 extern
42  SCIP_LOCK* lock /**< the lock */
43  );
44 
45 /** acquires the given lock */
46 extern
48  SCIP_LOCK* lock /**< the lock */
49  );
50 
51 /** releases the given lock */
52 extern
54  SCIP_LOCK* lock /**< the lock */
55  );
56 
57 /** initializes the given condition variable */
58 extern
60  SCIP_LOCK* lock /**< the lock */
61  );
62 
63 /** destroys the given condition variable */
64 extern
66  SCIP_LOCK* lock /**< the lock */
67  );
68 
69 /** signals one waiting thread */
70 extern
72  SCIP_CONDITION* condition /**< the condition variable to signal */
73  );
74 
75 /** signals all waiting threads */
76 extern
78  SCIP_CONDITION* condition /**< the condition variable to broadcast */
79  );
80 
81 /** waits on a condition variable. The given lock must be held by the caller and will
82  * be held when this function returns.
83  */
84 extern
86  SCIP_CONDITION* condition, /**< the condition variable to wait on */
87  SCIP_LOCK* lock /**< the lock that is held by the caller */
88  );
89 
90 /** returns the number of threads */
91 extern
93  void
94  );
95 
96 /** returns the thread number */
97 extern
99  void
100  );
101 
102 /** creates a job for parallel processing */
103 extern
105  SCIP_JOB** job, /**< pointer to the job that will be created */
106  int jobid, /**< the id for the current job */
107  SCIP_RETCODE (*jobfunc)(void* args),/**< pointer to the job function */
108  void* jobarg /**< the job's argument */
109  );
110 
111 /** get a new job id for a new set of jobs */
112 extern
114  void
115  );
116 
117 /** submit a job for parallel processing
118  * the return is a globally defined status
119  */
120 extern
122  SCIP_JOB* job, /**< pointer to the job to be submitted */
123  SCIP_SUBMITSTATUS* status /**< pointer to store the job's submit status */
124  );
125 
126 /** blocks until all jobs of the given jobid have finished
127  * and then returns the smallest SCIP_RETCODE of all the jobs
128  */
129 extern
131  int jobid /**< the jobid of the jobs to wait for */
132  );
133 
134 /** initializes tpi */
135 extern
137  int nthreads, /**< the number of threads to be used */
138  int queuesize, /**< the size of the queue */
139  /*TODO: specify and implement behaviour of blockwhenfull flag*/
140  SCIP_Bool blockwhenfull /**< should the queue block when full */
141  );
142 
143 /** deinitializes the tpi */
144 extern
146  void
147  );
148 
149 #endif
150 
151 #include "tpi/tpi_openmp.h"
152 #include "tpi/tpi_tnycthrd.h"
153 #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:62
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
public methods for message output
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