| 133 | }; |
| 134 | |
| 135 | void NormalStrategy::run() { |
| 136 | auto v0 = mgb::get_version(); |
| 137 | auto v1 = megdnn::get_version(); |
| 138 | mgb_log("megbrain/lite/load_and_run:\nusing MegBrain " |
| 139 | "%d.%d.%d(%d) and MegDNN %d.%d.%d\n", |
| 140 | v0.major, v0.minor, v0.patch, v0.is_dev, v1.major, v1.minor, v1.patch); |
| 141 | |
| 142 | size_t thread_num = m_runtime_param.threads; |
| 143 | auto run_sub = [&]() { run_subline(); }; |
| 144 | if (thread_num == 1) { |
| 145 | run_sub(); |
| 146 | } else if (thread_num > 1) { |
| 147 | #if MGB_HAVE_THREAD |
| 148 | std::vector<std::thread> threads; |
| 149 | |
| 150 | for (size_t i = 0; i < thread_num; ++i) { |
| 151 | threads.emplace_back(run_sub); |
| 152 | } |
| 153 | for (auto&& i : threads) { |
| 154 | i.join(); |
| 155 | } |
| 156 | #else |
| 157 | mgb_log_error( |
| 158 | "%d threads requested, but load_and_run was compiled " |
| 159 | "without <thread> support.", |
| 160 | thread_num); |
| 161 | #endif |
| 162 | } else { |
| 163 | mgb_assert(false, "--thread must input a positive number!!"); |
| 164 | } |
| 165 | //! execute before run |
| 166 | } |