MCPcopy Create free account
hub / github.com/ERGO-Code/HiGHS / initializeMultiThreading

Method initializeMultiThreading

highs/lp_data/Highs.cpp:5111–5135  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5109}
5110
5111HighsStatus Highs::initializeMultiThreading() {
5112 highs::parallel::initialize_scheduler(this->options_.threads);
5113 this->max_threads_ = highs::parallel::num_threads();
5114 HighsLogOptions& log_options = this->options_.log_options;
5115 if (this->options_.threads != 0 &&
5116 this->max_threads_ != this->options_.threads) {
5117 highsLogUser(
5118 log_options, HighsLogType::kError,
5119 "Option 'threads' is set to %d but global scheduler has already been "
5120 "initialized to use %d threads. The previous scheduler instance can "
5121 "be destroyed by calling Highs::resetGlobalScheduler().\n",
5122 int(options_.threads), int(this->max_threads_));
5123 return HighsStatus::kError;
5124 }
5125 if (this->max_threads_ <= 0) {
5126 highsLogDev(log_options, HighsLogType::kError, "max_threads() returns %d\n",
5127 int(this->max_threads_));
5128 assert(this->max_threads_ > 0);
5129 return HighsStatus::kError;
5130 }
5131 highsLogDev(log_options, HighsLogType::kDetailed,
5132 "Running with %d thread(s)\n", int(max_threads_));
5133
5134 return HighsStatus::kOk;
5135}
5136
5137void Highs::resetGlobalScheduler(bool blocking) {
5138 HighsTaskExecutor::shutdown(blocking);

Callers 2

presolveMethod · 0.95
optimizeModelMethod · 0.95

Calls 4

initialize_schedulerFunction · 0.85
num_threadsFunction · 0.85
highsLogUserFunction · 0.85
highsLogDevFunction · 0.85

Tested by

no test coverage detected