mirror of
https://github.com/saymrwulf/onnxruntime.git
synced 2026-05-26 22:35:43 +00:00
This reverts commit 166b1f86db.
This commit is contained in:
parent
686bd36210
commit
aa92daecc5
2 changed files with 3 additions and 17 deletions
|
|
@ -39,23 +39,9 @@ void ThreadPool::ParallelFor(int32_t total, std::function<void(int32_t)> fn) {
|
|||
fn(0);
|
||||
return;
|
||||
}
|
||||
|
||||
// TODO: Eigen supports a more efficient ThreadPoolDevice mechanism
|
||||
// We will simply rely on the work queue and stealing in the short term.
|
||||
if (total > NumThreads()) {
|
||||
//The dispatcher thread will be idle at here
|
||||
Barrier barrier(static_cast<unsigned int>(total));
|
||||
std::function<void(int32_t)> handle_iteration = [&barrier, &fn](int iteration) {
|
||||
fn(iteration);
|
||||
barrier.Notify();
|
||||
};
|
||||
|
||||
for (int32_t id = 0; id < total; ++id) {
|
||||
Schedule([=, &handle_iteration]() { handle_iteration(id); });
|
||||
}
|
||||
|
||||
barrier.Wait();
|
||||
return;
|
||||
}
|
||||
Barrier barrier(static_cast<unsigned int>(total - 1));
|
||||
std::function<void(int32_t)> handle_iteration = [&barrier, &fn](int iteration) {
|
||||
fn(iteration);
|
||||
|
|
@ -65,7 +51,7 @@ void ThreadPool::ParallelFor(int32_t total, std::function<void(int32_t)> fn) {
|
|||
for (int32_t id = 1; id < total; ++id) {
|
||||
Schedule([=, &handle_iteration]() { handle_iteration(id); });
|
||||
}
|
||||
//reuse the current thread for one task
|
||||
|
||||
fn(0);
|
||||
barrier.Wait();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -545,7 +545,7 @@ MlasGetMaximumThreadCount(
|
|||
MLAS_UNREFERENCED_PARAMETER(ThreadPool);
|
||||
#else
|
||||
if (ThreadPool != nullptr) {
|
||||
return ThreadPool->NumThreads();
|
||||
return ThreadPool->NumThreads() + 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue