|
|
|
@ -14,8 +14,12 @@
|
|
|
|
|
|
|
|
|
|
#include "paddle/fluid/framework/threadpool.h"
|
|
|
|
|
|
|
|
|
|
#include "gflags/gflags.h"
|
|
|
|
|
#include "paddle/fluid/platform/enforce.h"
|
|
|
|
|
|
|
|
|
|
DEFINE_int32(io_threadpool_size, 100,
|
|
|
|
|
"number of threads used for doing IO, default 100");
|
|
|
|
|
|
|
|
|
|
namespace paddle {
|
|
|
|
|
namespace framework {
|
|
|
|
|
|
|
|
|
@ -94,15 +98,15 @@ void ThreadPool::TaskLoop() {
|
|
|
|
|
std::unique_ptr<ThreadPool> MultiStreamThreadPool::io_threadpool_(nullptr);
|
|
|
|
|
std::once_flag MultiStreamThreadPool::io_init_flag_;
|
|
|
|
|
|
|
|
|
|
MultiStreamThreadPool* MultiStreamThreadPool::GetInstanceIO() {
|
|
|
|
|
ThreadPool* MultiStreamThreadPool::GetInstanceIO() {
|
|
|
|
|
std::call_once(io_init_flag_, &MultiStreamThreadPool::InitIO);
|
|
|
|
|
return static_cast<MultiStreamThreadPool*>(io_threadpool_.get());
|
|
|
|
|
return io_threadpool_.get();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MultiStreamThreadPool::InitIO() {
|
|
|
|
|
if (io_threadpool_.get() == nullptr) {
|
|
|
|
|
// TODO(typhoonzero1986): make this configurable
|
|
|
|
|
io_threadpool_.reset(new ThreadPool(100));
|
|
|
|
|
io_threadpool_.reset(new ThreadPool(FLAGS_io_threadpool_size));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|