| 5109 | } |
| 5110 | |
| 5111 | HighsStatus 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 | |
| 5137 | void Highs::resetGlobalScheduler(bool blocking) { |
| 5138 | HighsTaskExecutor::shutdown(blocking); |
no test coverage detected