mirror of
https://github.com/zebrajr/pytorch.git
synced 2025-12-06 00:20:18 +01:00
Allow forcing single-threaded execution at runtime.
Summary: Might be useful for the EXC_RESOURCE / CPU issues. Reviewed By: salexspb Differential Revision: D4565494 fbshipit-source-id: 74ac9edeba6334a46ee6799a93ca96eb68216439
This commit is contained in:
parent
40534de705
commit
7d9a0a41fd
|
|
@ -1,6 +1,9 @@
|
|||
#include "caffe2/utils/threadpool/ThreadPool.h"
|
||||
#include "caffe2/core/logging.h"
|
||||
|
||||
CAFFE2_DEFINE_bool(caffe2_threadpool_force_inline, false,
|
||||
"Force to always run jobs on the calling thread");
|
||||
|
||||
#if CAFFE2_THREADPOOL_MOBILE
|
||||
|
||||
namespace caffe2 {
|
||||
|
|
@ -122,7 +125,8 @@ ThreadPool::run(const std::function<void(int, size_t)>& fn, size_t range) {
|
|||
|
||||
// If there are no worker threads, or if the range is too small (too
|
||||
// little work), just run locally
|
||||
bool runLocally = (threads_.empty() || range < minWorkSize_);
|
||||
bool runLocally = threads_.empty() || range < minWorkSize_ ||
|
||||
FLAGS_caffe2_threadpool_force_inline;
|
||||
|
||||
auto numThreads = threadInfo_.size();
|
||||
size_t workUnitsPerThread = 0;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user