diff --git a/onnxruntime/core/common/threadpool.cc b/onnxruntime/core/common/threadpool.cc index 9f08dc68bb..d4eba8a0ec 100644 --- a/onnxruntime/core/common/threadpool.cc +++ b/onnxruntime/core/common/threadpool.cc @@ -43,17 +43,16 @@ void ThreadPool::ParallelFor(int32_t total, std::function fn) { // TODO: Eigen supports a more efficient ThreadPoolDevice mechanism // We will simply rely on the work queue and stealing in the short term. - Barrier barrier(static_cast(total - 1)); + Barrier barrier(static_cast(total)); std::function handle_iteration = [&barrier, &fn](int iteration) { fn(iteration); barrier.Notify(); }; - for (int32_t id = 1; id < total; ++id) { + for (int32_t id = 0; id < total; ++id) { Schedule([=, &handle_iteration]() { handle_iteration(id); }); } - fn(0); barrier.Wait(); } diff --git a/onnxruntime/core/mlas/lib/mlasi.h b/onnxruntime/core/mlas/lib/mlasi.h index 12ed28672e..d11feb930c 100644 --- a/onnxruntime/core/mlas/lib/mlasi.h +++ b/onnxruntime/core/mlas/lib/mlasi.h @@ -669,7 +669,7 @@ MlasGetMaximumThreadCount( MLAS_UNREFERENCED_PARAMETER(ThreadPool); #else if (ThreadPool != nullptr) { - return ThreadPool->NumThreads() + 1; + return ThreadPool->NumThreads(); } #endif