Skip to content

Commit 3bfbe9e

Browse files
committed
add SCIPtpiIsAvailable(), SCIPtpiGetLibraryName(), SCIPtpiGetLibraryDesc()
- and use to setup info on external libraries in doScipCreate() (instead of SCIPincludeDefaultPlugins(), which is wrong)
1 parent 13df56a commit 3bfbe9e

File tree

7 files changed

+120
-4
lines changed

7 files changed

+120
-4
lines changed

CHANGELOG

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ Interface changes
1919
-----------------
2020
### New callbacks
2121
### New API functions
22+
23+
- added SCIPtpiIsAvailable() to check whether a working task processing interface is available (TPI != none)
24+
- added SCIPtpiGetLibraryName() and SCIPtpiGetLibraryDesc()
25+
2226
### Command line interface
2327
### Interfaces to external software
2428
### New parameters

src/scip/scip_general.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@
7373
#include "scip/struct_stat.h"
7474
#include "scip/syncstore.h"
7575
#include "scip/lapack_calls.h"
76+
#include "tpi/tpi.h"
7677

7778
#include <string.h>
7879
#if defined(_WIN32) || defined(_WIN64)
@@ -288,6 +289,15 @@ SCIP_RETCODE doScipCreate(
288289
}
289290
#endif
290291

292+
if( SCIPtpiIsAvailable() )
293+
{
294+
char name[20];
295+
char desc[80];
296+
SCIPtpiGetLibraryName(name, (int)sizeof(name));
297+
SCIPtpiGetLibraryDesc(desc, (int)sizeof(desc));
298+
SCIP_CALL( SCIPsetIncludeExternalCode((*scip)->set, name, desc) );
299+
}
300+
291301
return SCIP_OKAY;
292302
}
293303

src/scip/scipdefplugins.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -272,10 +272,6 @@ SCIP_RETCODE SCIPincludeDefaultPlugins(
272272
SCIP_CALL( SCIPincludeNlpSolverWorhp(scip, FALSE) );
273273
SCIP_CALL( SCIPincludeNlpSolverAll(scip) );
274274

275-
#ifdef TPI_TNY
276-
SCIP_CALL( SCIPincludeExternalCodeInformation(scip, "TinyCThread", "Small, portable implementation of the C11 threads API (tinycthread.github.io)") );
277-
#endif
278-
279275
SCIP_CALL( SCIPdebugIncludeProp(scip) ); /*lint !e506 !e774*/
280276

281277
return SCIP_OKAY;

src/tpi/tpi.h

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,4 +153,22 @@ SCIP_RETCODE SCIPtpiExit(
153153
void
154154
);
155155

156+
/** indicate whether a working TPI is available */
157+
SCIP_EXPORT
158+
SCIP_Bool SCIPtpiIsAvailable(void);
159+
160+
/** get name of library that the TPI interfaces to */
161+
SCIP_EXPORT
162+
void SCIPtpiGetLibraryName(
163+
char* name, /**< buffer to store name */
164+
int namesize /**< length of name buffer */
165+
);
166+
167+
/** get description of library that the TPI interfaces to */
168+
SCIP_EXPORT
169+
void SCIPtpiGetLibraryDesc(
170+
char* desc, /**< buffer to store description */
171+
int descsize /**< length of description */
172+
);
173+
156174
#endif

src/tpi/tpi_none.c

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
3434

3535
#include "tpi/tpi.h"
36+
#include "scip/pub_misc.h"
3637

3738
/* do not define struct SCIP_Lock and struct SCIP_Condition, since they are not used */
3839

@@ -219,3 +220,32 @@ SCIP_RETCODE SCIPtpiExit(
219220
{
220221
return SCIP_ERROR;
221222
}
223+
224+
/** indicate whether a working TPI is available */
225+
SCIP_Bool SCIPtpiIsAvailable(void)
226+
{
227+
return FALSE;
228+
}
229+
230+
/** get name of library that the TPI interfaces to */
231+
void SCIPtpiGetLibraryName(
232+
char* name, /**< buffer to store name */
233+
int namesize /**< length of name buffer */
234+
)
235+
{
236+
assert(name != NULL);
237+
238+
(void) SCIPsnprintf(name, namesize, "none");
239+
}
240+
241+
/** get description of library that the TPI interfaces to */
242+
void SCIPtpiGetLibraryDesc(
243+
char* desc, /**< buffer to store description */
244+
int descsize /**< length of description */
245+
)
246+
{
247+
assert(desc != NULL);
248+
assert(descsize >= 1);
249+
250+
*desc = '\0';
251+
}

src/tpi/tpi_openmp.c

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
#include "tpi/tpi.h"
3636
#include "blockmemshell/memory.h"
3737
#include "scip/pub_message.h"
38+
#include "scip/pub_misc.h"
3839
#include <omp.h>
3940

4041
/* macros for direct access */
@@ -702,3 +703,31 @@ void SCIPtpiDestroyCondition(
702703

703704
BMSfreeMemory(condition);
704705
}
706+
707+
/** indicate whether a working TPI is available */
708+
SCIP_Bool SCIPtpiIsAvailable(void)
709+
{
710+
return TRUE;
711+
}
712+
713+
/** get name of library that the TPI interfaces to */
714+
void SCIPtpiGetLibraryName(
715+
char* name, /**< buffer to store name */
716+
int namesize /**< length of name buffer */
717+
)
718+
{
719+
assert(name != NULL);
720+
721+
(void) SCIPsnprintf(name, namesize, "OpenMP %d", _OPENMP); /*lint !e40*/
722+
}
723+
724+
/** get description of library that the TPI interfaces to */
725+
void SCIPtpiGetLibraryDesc(
726+
char* desc, /**< buffer to store description */
727+
int descsize /**< length of description */
728+
)
729+
{
730+
assert(desc != NULL);
731+
732+
(void) SCIPsnprintf(desc, descsize, "shared-memory multiprocessing library (openmp.org)");
733+
}

src/tpi/tpi_tnycthrd.c

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
#include "blockmemshell/memory.h"
3737
#include "tinycthread/tinycthread.h"
3838
#include "scip/pub_message.h"
39+
#include "scip/pub_misc.h"
3940

4041
/* macros for direct access */
4142

@@ -840,3 +841,31 @@ int SCIPtpiGetThreadNum(
840841
{
841842
return _threadnumber;
842843
}
844+
845+
/** indicate whether a working TPI is available */
846+
SCIP_Bool SCIPtpiIsAvailable(void)
847+
{
848+
return TRUE;
849+
}
850+
851+
/** get name of library that the TPI interfaces to */
852+
void SCIPtpiGetLibraryName(
853+
char* name, /**< buffer to store name */
854+
int namesize /**< length of name buffer */
855+
)
856+
{
857+
assert(name != NULL);
858+
859+
(void) SCIPsnprintf(name, namesize, "TinyCThread %d.%d", TINYCTHREAD_VERSION_MAJOR, TINYCTHREAD_VERSION_MINOR);
860+
}
861+
862+
/** get description of library that the TPI interfaces to */
863+
void SCIPtpiGetLibraryDesc(
864+
char* desc, /**< buffer to store description */
865+
int descsize /**< length of description */
866+
)
867+
{
868+
assert(desc != NULL);
869+
870+
(void) SCIPsnprintf(desc, descsize, "small portable implementation of the C11 threads API (tinycthread.github.io)");
871+
}

0 commit comments

Comments
 (0)