Skip to content

Commit

Permalink
switch to SCIPtpiIsAvailable() in SCIPsolveConcurrent()
Browse files Browse the repository at this point in the history
- and fix lint warnings that became visible now
  • Loading branch information
svigerske committed Jul 19, 2024
1 parent 3bfbe9e commit 7ad21be
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions src/scip/scip_solve.c
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@
#include "scip/tree.h"
#include "scip/var.h"
#include "scip/visual.h"
#include "tpi/tpi.h"

/** calculates number of nonzeros in problem */
static
Expand Down Expand Up @@ -2861,10 +2862,6 @@ SCIP_RETCODE SCIPsolveConcurrent(
SCIP* scip /**< SCIP data structure */
)
{
#ifdef TPI_NONE
SCIPerrorMessage("SCIP was compiled without task processing interface. Concurrent solve not possible\n");
return SCIP_PLUGINNOTFOUND;
#else
SCIP_RETCODE retcode;
int i;
SCIP_RANDNUMGEN* rndgen;
Expand All @@ -2873,7 +2870,13 @@ SCIP_RETCODE SCIPsolveConcurrent(

SCIP_CALL( SCIPcheckStage(scip, "SCIPsolveConcurrent", FALSE, TRUE, FALSE, TRUE, FALSE, TRUE, FALSE, TRUE, FALSE, TRUE, TRUE, FALSE, FALSE, FALSE) );

SCIP_CALL( SCIPsetIntParam(scip, "timing/clocktype", SCIP_CLOCKTYPE_WALL) );
if( !SCIPtpiIsAvailable() )
{
SCIPerrorMessage("SCIP was compiled without task processing interface. Concurrent solve not possible\n");
return SCIP_PLUGINNOTFOUND;
}

SCIP_CALL( SCIPsetIntParam(scip, "timing/clocktype", (int)SCIP_CLOCKTYPE_WALL) );

minnthreads = scip->set->parallel_minnthreads;
maxnthreads = scip->set->parallel_maxnthreads;
Expand All @@ -2887,7 +2890,7 @@ SCIP_RETCODE SCIPsolveConcurrent(
{
int nconcsolvertypes;
SCIP_CONCSOLVERTYPE** concsolvertypes;
SCIP_Longint nthreads;
int nthreads;
SCIP_Real memorylimit;
int* solvertypes;
SCIP_Longint* weights;
Expand Down Expand Up @@ -2933,8 +2936,8 @@ SCIP_RETCODE SCIPsolveConcurrent(
/* estimate maximum number of copies that be created based on memory limit */
if( !scip->set->misc_avoidmemout )
{
nthreads = MAX(1, memorylimit / (4.0*SCIPgetMemExternEstim(scip)/1048576.0));
SCIPverbMessage(scip, SCIP_VERBLEVEL_FULL, NULL, "estimated a maximum of %lli threads based on memory limit\n", nthreads);
nthreads = MAX(1, memorylimit / (4.0*SCIPgetMemExternEstim(scip)/1048576.0)); /*lint !e666 !e524*/
SCIPverbMessage(scip, SCIP_VERBLEVEL_FULL, NULL, "estimated a maximum of %d threads based on memory limit\n", nthreads);
}
else
{
Expand Down Expand Up @@ -2962,14 +2965,15 @@ SCIP_RETCODE SCIPsolveConcurrent(
return SCIPsolve(scip);
}
nthreads = MIN(nthreads, maxnthreads);
SCIPverbMessage(scip, SCIP_VERBLEVEL_FULL, NULL, "using %lli threads for concurrent solve\n", nthreads);
SCIPverbMessage(scip, SCIP_VERBLEVEL_FULL, NULL, "using %d threads for concurrent solve\n", nthreads);

/* now set up nthreads many concurrent solvers that will be used for the concurrent solve
* using the preferred priorities of each concurrent solver
*/
prefpriosum = 0.0;
for( i = 0; i < nconcsolvertypes; ++i )
prefpriosum += SCIPconcsolverTypeGetPrefPrio(concsolvertypes[i]);
assert(prefpriosum != 0.0);

ncandsolvertypes = 0;
SCIP_CALL( SCIPallocBufferArray(scip, &solvertypes, nthreads + nconcsolvertypes) );
Expand Down Expand Up @@ -3005,7 +3009,7 @@ SCIP_RETCODE SCIPsolveConcurrent(

SCIP_CALL( SCIPconcsolverCreateInstance(scip->set, concsolvertypes[solvertypes[i]], &concsolver) );
if( scip->set->concurrent_changeseeds && SCIPgetNConcurrentSolvers(scip) > 1 )
SCIP_CALL( SCIPconcsolverInitSeeds(concsolver, SCIPrandomGetInt(rndgen, 0, INT_MAX)) );
SCIP_CALL( SCIPconcsolverInitSeeds(concsolver, (unsigned int)SCIPrandomGetInt(rndgen, 0, INT_MAX)) );
}
SCIPfreeRandom(scip, &rndgen);
SCIPfreeBufferArray(scip, &prios);
Expand All @@ -3029,7 +3033,6 @@ SCIP_RETCODE SCIPsolveConcurrent(
SCIP_CALL( displayRelevantStats(scip) );

return retcode;
#endif
}

/** include specific heuristics and branching rules for reoptimization
Expand Down

0 comments on commit 7ad21be

Please sign in to comment.