From d839bd0dd4ffecaa061aed32684a1a0b09f28d30 Mon Sep 17 00:00:00 2001 From: dongdaxiang Date: Thu, 13 Dec 2018 19:14:35 +0800 Subject: [PATCH] simple commit --- paddle/fluid/framework/async_executor.h | 52 +++++++++++-------------- 1 file changed, 23 insertions(+), 29 deletions(-) diff --git a/paddle/fluid/framework/async_executor.h b/paddle/fluid/framework/async_executor.h index 126421264..a82e94155 100644 --- a/paddle/fluid/framework/async_executor.h +++ b/paddle/fluid/framework/async_executor.h @@ -17,13 +17,13 @@ limitations under the License. */ #include #include #include -#include // NOLINT +#include // NOLINT +#include // local_random_engine #include #include #include // NOLINT #include #include -#include // local_random_engine #include "paddle/fluid/framework/data_feed.pb.h" #include "paddle/fluid/framework/executor.h" #include "paddle/fluid/framework/executor_thread_worker.h" @@ -34,24 +34,23 @@ namespace paddle { namespace framework { inline double current_realtime() { - struct timespec tp; - clock_gettime(CLOCK_REALTIME, &tp); - return tp.tv_sec + tp.tv_nsec * 1e-9; + struct timespec tp; + clock_gettime(CLOCK_REALTIME, &tp); + return tp.tv_sec + tp.tv_nsec * 1e-9; } inline std::default_random_engine& local_random_engine() { - struct engine_wrapper_t { - std::default_random_engine engine; - engine_wrapper_t() { - static std::atomic x(0); - std::seed_seq sseq = {x++, x++, x++, - static_cast( - current_realtime() * 1000)}; - engine.seed(sseq); - } - }; - thread_local engine_wrapper_t r; - return r.engine; + struct engine_wrapper_t { + std::default_random_engine engine; + engine_wrapper_t() { + static std::atomic x(0); + std::seed_seq sseq = {x++, x++, x++, + static_cast(current_realtime() * 1000)}; + engine.seed(sseq); + } + }; + thread_local engine_wrapper_t r; + return r.engine; } class AsyncExecutor { @@ -63,14 +62,12 @@ class AsyncExecutor { const std::vector& filelist, const int thread_num, const std::vector& fetch_names, - const std::string& mode, - const bool debug = false); + const std::string& mode, const bool debug = false); #ifdef PADDLE_WITH_PSLIB void InitServer(const std::string& dist_desc, int index); - void InitWorker( - const std::string& dist_desc, - const std::vector& host_sign_list, - int node_num, int index); + void InitWorker(const std::string& dist_desc, + const std::vector& host_sign_list, int node_num, + int index); uint64_t StartServer(); void StopServer(); void GatherServers(const std::vector& host_sign_list, int node_num); @@ -92,19 +89,16 @@ class AsyncExecutor { public: #ifdef PADDLE_WITH_PSLIB - std::shared_ptr _pslib_ptr; - std::shared_ptr _pull_dense_thread; + std::shared_ptr _pslib_ptr; + std::shared_ptr _pull_dense_thread; AsyncWorkerParamConfig _param_config; #endif Scope* root_scope_; platform::Place place_; - + private: int actual_thread_num; - }; - - } // namespace framework } // namespace paddle -- GitLab