diff --git a/paddle/fluid/framework/fleet/fleet_wrapper.cc b/paddle/fluid/framework/fleet/fleet_wrapper.cc index 7f4fa69e17f328f25379a5758a2c5bb423dc28f0..59532562434fb56bd370f4c91189a1f97abb8309 100644 --- a/paddle/fluid/framework/fleet/fleet_wrapper.cc +++ b/paddle/fluid/framework/fleet/fleet_wrapper.cc @@ -235,8 +235,8 @@ void FleetWrapper::PushDenseParamSync( } } int cnt = 1; - for (auto& i: dim) { - cnt *= i; + for (auto& i : dim) { + cnt *= i; } DDim d(std::vector{cnt}.data(), 1); float* g = tensor->mutable_data(d, place); @@ -254,8 +254,7 @@ void FleetWrapper::PushDenseParamSync( regions.data(), regions.size(), table_id); push_status.wait(); auto status = push_status.get(); - CHECK(status == 0) << "push dense param failed, status[" - << status << "]"; + CHECK(status == 0) << "push dense param failed, status[" << status << "]"; } #endif } @@ -346,13 +345,14 @@ void FleetWrapper::PushSparseVarsWithLabelAsync( #endif } -int FleetWrapper::RegisterClientToClientMsgHandler( - int msg_type, MsgHandlerFunc handler) { +int FleetWrapper::RegisterClientToClientMsgHandler(int msg_type, + MsgHandlerFunc handler) { #ifdef PADDLE_WITH_PSLIB VLOG(3) << "calling FleetWrapper::RegisterClientToClientMsgHandler"; VLOG(3) << "pslib_ptr_=" << pslib_ptr_; VLOG(3) << "_worker_ptr=" << pslib_ptr_->_worker_ptr; - return pslib_ptr_->_worker_ptr->registe_client2client_msg_handler(msg_type, handler); + return pslib_ptr_->_worker_ptr->registe_client2client_msg_handler(msg_type, + handler); #else VLOG(0) << "FleetWrapper::RegisterClientToClientMsgHandler" << " does nothing when no pslib"; @@ -363,7 +363,8 @@ int FleetWrapper::RegisterClientToClientMsgHandler( std::future FleetWrapper::SendClientToClientMsg( int msg_type, int to_client_id, const std::string& msg) { #ifdef PADDLE_WITH_PSLIB - return pslib_ptr_->_worker_ptr->send_client2client_msg(msg_type, to_client_id, msg); + return pslib_ptr_->_worker_ptr->send_client2client_msg(msg_type, to_client_id, + msg); #else VLOG(0) << "FleetWrapper::SendClientToClientMsg" << " does nothing when no pslib"; diff --git a/paddle/fluid/framework/io/shell.cc b/paddle/fluid/framework/io/shell.cc index 286f48f6f177787c1a0e543e1a0c17a9680d88a8..47de5c650a44e41bef12cc0f68f4c6f34e051e7a 100644 --- a/paddle/fluid/framework/io/shell.cc +++ b/paddle/fluid/framework/io/shell.cc @@ -19,6 +19,7 @@ namespace framework { std::shared_ptr shell_fopen(const std::string& path, const std::string& mode) { +#ifndef _WIN32 if (shell_verbose()) { LOG(INFO) << "Opening file[" << path << "] with mode[" << mode << "]"; } @@ -34,12 +35,16 @@ std::shared_ptr shell_fopen(const std::string& path, LOG(FATAL) << "fclose fail, path[" << path << "]"; } }}; +#else + return nullptr; +#endif } // Close all open file descriptors // The implementation is async signal safe // Mostly copy from CPython code static int close_open_fds_internal() { +#ifndef _WIN32 struct linux_dirent { long d_ino = 0; // NOLINT off_t d_off; @@ -86,11 +91,13 @@ static int close_open_fds_internal() { } close(dir_fd); +#endif return 0; } static int shell_popen_fork_internal(const char* real_cmd, bool do_read, int parent_end, int child_end) { +#ifndef _WIN32 int child_pid = -1; // Too frequent calls to fork() makes openmpi very slow. Use vfork() instead. // But vfork() is very dangerous. Be careful. @@ -119,10 +126,13 @@ static int shell_popen_fork_internal(const char* real_cmd, bool do_read, return -1; } exit(127); +#endif + return 0; } std::shared_ptr shell_popen(const std::string& cmd, const std::string& mode, int* err_no) { +#ifndef _WIN32 bool do_read = mode == "r"; bool do_write = mode == "w"; if (!(do_read || do_write)) { @@ -170,12 +180,9 @@ std::shared_ptr shell_popen(const std::string& cmd, *err_no = -1; } int wstatus = -1; - // int ret = waitpid(child_pid, &wstatus, 0); waitpid(child_pid, &wstatus, 0); if (wstatus == 0 || wstatus == (128 + SIGPIPE) * 256 || (wstatus == -1 && errno == ECHILD)) { - // LOG(INFO) << "status[" << wstatus << "], cmd[" << cmd << "]" << - // ", err_no[" << *err_no << "]"; } else { *err_no = -1; LOG(WARNING) << "status[" << wstatus << "], cmd[" << cmd << "]" @@ -185,10 +192,12 @@ std::shared_ptr shell_popen(const std::string& cmd, LOG(WARNING) << "errno is ECHILD"; } }}; +#endif } static int shell_p2open_fork_internal(const char* real_cmd, int pipein_fds[2], int pipeout_fds[2]) { +#ifndef int child_pid = -1; if ((child_pid = fork()) < 0) { return -1; @@ -220,10 +229,13 @@ static int shell_p2open_fork_internal(const char* real_cmd, int pipein_fds[2], return -1; } exit(127); +#endif + return 0; } std::pair, std::shared_ptr> shell_p2open( const std::string& cmd) { +#ifndef _WIN32 if (shell_verbose()) { LOG(INFO) << "Opening bidirectional pipe[" << cmd << "]"; } @@ -275,9 +287,13 @@ std::pair, std::shared_ptr> shell_p2open( PCHECK((out_fp = fdopen(pipeout_fds[1], "w")) != NULL); return {{in_fp, [child_life](FILE* fp) { PCHECK(fclose(fp) == 0); }}, {out_fp, [child_life](FILE* fp) { PCHECK(fclose(fp) == 0); }}}; +#else + return nullptr; +#endif } std::string shell_get_command_output(const std::string& cmd) { +#ifndef _WIN32 int err_no = 0; do { err_no = 0; @@ -291,7 +307,7 @@ std::string shell_get_command_output(const std::string& cmd) { } } } while (err_no == -1); - +#endif return ""; } } // end namespace framework diff --git a/paddle/fluid/platform/lodtensor_printer_test.cc b/paddle/fluid/platform/lodtensor_printer_test.cc index 248237b0c9694e33f24db87bb92ad3c52fb3b546..f0618c9216fb9646dd3a960a0088347855d4f7a9 100644 --- a/paddle/fluid/platform/lodtensor_printer_test.cc +++ b/paddle/fluid/platform/lodtensor_printer_test.cc @@ -17,30 +17,8 @@ #include "paddle/fluid/framework/variable.h" TEST(LodTensorPrinter, PrintVar) { - Scope scope; - PrintVar(&scope, "NotAVar"); - Variable* v = scope.Var("NotAVar"); - PrintVar(&scope, "NotAVar"); -} - -TEST(Timer, Start) { - paddle::platform::Timer timeline; - timeline.Start(); - sleep(3); - timeline.Pause(); -} - -TEST(Timer, Pause) { - paddle::platform::Timer timeline; - timeline.Start(); - sleep(3); - timeline.Pause(); -} - -TEST(Timer, Resume) { - paddle::platform::Timer timeline; - timeline.Start(); - sleep(3); - timeline.Pause(); - timeline.Resume(); + paddle::framework::Scope scope; + PrintVar(&scope, "NotAVar", "We don't have var"); + paddle::framework::Variable* v = scope.Var("NotAVar"); + PrintVar(&scope, "NotAVar", "Now we have a var"); } diff --git a/paddle/fluid/string/string_helper.h b/paddle/fluid/string/string_helper.h index 48af332bb816b4fe51b86cc8c21ef62db2292f1e..0cdbf7d0e409237c61292e3f0740676329103106 100644 --- a/paddle/fluid/string/string_helper.h +++ b/paddle/fluid/string/string_helper.h @@ -211,7 +211,7 @@ class LineFileReader { ~LineFileReader() { ::free(_buffer); } char* getline(FILE* f) { return this->getdelim(f, '\n'); } char* getdelim(FILE* f, char delim) { - ssize_t ret = ::getdelim(&_buffer, &_buf_size, delim, f); + int32_t ret = ::getdelim(&_buffer, &_buf_size, delim, f); if (ret >= 0) { if (ret >= 1 && _buffer[ret - 1] == delim) {