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-2020 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 scipopt.org. */
13 /* */
14 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
15 
16 /**@file tpi.h
17  * @ingroup TASKINTERFACE
18  * @brief the type definitions for the SCIP parallel interface
19  * @author Leona 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 */
36  SCIP_LOCK* lock /**< the lock */
37  );
38 
39 /** destroys the given lock */
42  SCIP_LOCK* lock /**< the lock */
43  );
44 
45 /** acquires the given lock */
48  SCIP_LOCK* lock /**< the lock */
49  );
50 
51 /** releases the given lock */
54  SCIP_LOCK* lock /**< the lock */
55  );
56 
57 /** initializes the given condition variable */
60  SCIP_LOCK* lock /**< the lock */
61  );
62 
63 /** destroys the given condition variable */
66  SCIP_LOCK* lock /**< the lock */
67  );
68 
69 /** signals one waiting thread */
72  SCIP_CONDITION* condition /**< the condition variable to signal */
73  );
74 
75 /** signals all waiting threads */
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  */
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 */
93  void
94  );
95 
96 /** returns the thread number */
99  void
100  );
101 
102 /** creates a job for parallel processing */
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 */
114  void
115  );
116 
117 /** submit a job for parallel processing the return is a globally defined status */
120  SCIP_JOB* job, /**< pointer to the job to be submitted */
121  SCIP_SUBMITSTATUS* status /**< pointer to store the job's submit status */
122  );
123 
124 /** blocks until all jobs of the given jobid have finished
125  * and then returns the smallest SCIP_RETCODE of all the jobs
126  */
129  int jobid /**< the jobid of the jobs to wait for */
130  );
131 
132 /** initializes tpi */
135  int nthreads, /**< the number of threads to be used */
136  int queuesize, /**< the size of the queue */
137  /*TODO: specify and implement behaviour of blockwhenfull flag*/
138  SCIP_Bool blockwhenfull /**< should the queue block when full */
139  );
140 
141 /** deinitializes the tpi */
144  void
145  );
146 
147 #endif
148 
149 #include "tpi/tpi_openmp.h"
150 #include "tpi/tpi_tnycthrd.h"
151 #include "tpi/tpi_none.h"
SCIP_EXPORT int SCIPtpiGetNumThreads(void)
Definition: tpi_openmp.c:325
SCIP_EXPORT SCIP_RETCODE SCIPtpiSignalCondition(SCIP_CONDITION *condition)
Definition: tpi_openmp.c:261
the type definitions for the task processing interface
enum SCIP_Submitstatus SCIP_SUBMITSTATUS
Definition: type_tpi.h:45
wrappers for OpenMP defines
#define SCIP_EXPORT
Definition: def.h:100
enum SCIP_Retcode SCIP_RETCODE
Definition: type_retcode.h:54
SCIP_EXPORT SCIP_RETCODE SCIPtpiWaitCondition(SCIP_CONDITION *condition, SCIP_LOCK *lock)
Definition: tpi_openmp.c:287
the dummy implementation defines all functions as macros
SCIP_EXPORT SCIP_RETCODE SCIPtpiInitCondition(SCIP_LOCK *lock)
the tinycthreads implementation defines the lock and condition functionality as macros ...
SCIP_EXPORT void SCIPtpiDestroyCondition(SCIP_LOCK *lock)
SCIP_EXPORT SCIP_RETCODE SCIPtpiCollectJobs(int jobid)
Definition: tpi_none.c:57
the tpi_openmp redefines the lock functionality and some condition functionality as macros ...
SCIP_EXPORT SCIP_RETCODE SCIPtpiInitLock(SCIP_LOCK *lock)
#define SCIP_Bool
Definition: def.h:70
SCIP_EXPORT SCIP_RETCODE SCIPtpiExit(void)
Definition: tpi_none.c:81
SCIP_EXPORT SCIP_RETCODE SCIPtpiBroadcastCondition(SCIP_CONDITION *condition)
Definition: tpi_openmp.c:275
SCIP_EXPORT void SCIPtpiDestroyLock(SCIP_LOCK *lock)
SCIP_EXPORT SCIP_RETCODE SCIPtpiCreateJob(SCIP_JOB **job, int jobid, SCIP_RETCODE(*jobfunc)(void *args), void *jobarg)
Definition: tpi_none.c:28
SCIP_EXPORT int SCIPtpiGetThreadNum(void)
Definition: tpi_openmp.c:332
public methods for message output
SCIP_EXPORT SCIP_RETCODE SCIPtpiAcquireLock(SCIP_LOCK *lock)
SCIP_EXPORT int SCIPtpiGetNewJobID(void)
Definition: tpi_openmp.c:357
SCIP_EXPORT SCIP_RETCODE SCIPtpiInit(int nthreads, int queuesize, SCIP_Bool blockwhenfull)
Definition: tpi_none.c:67
common defines and data types used in all packages of SCIP
SCIP_EXPORT SCIP_RETCODE SCIPtpiSumbitJob(SCIP_JOB *job, SCIP_SUBMITSTATUS *status)
Definition: tpi_none.c:44
SCIP_EXPORT SCIP_RETCODE SCIPtpiReleaseLock(SCIP_LOCK *lock)