From ce238f107b758b08f79cba68c27b3dca9e4dab75 Mon Sep 17 00:00:00 2001 From: chengmo Date: Fri, 18 Sep 2020 17:36:55 +0800 Subject: [PATCH] fix --- .../operators/distributed/parameter_prefetch.cc | 6 ++++-- paddle/fluid/operators/distributed/parameter_recv.cc | 8 ++++---- paddle/fluid/operators/distributed/parameter_send.cc | 10 ++++------ paddle/fluid/platform/device_tracer.cc | 12 ++++++++++-- 4 files changed, 22 insertions(+), 14 deletions(-) diff --git a/paddle/fluid/operators/distributed/parameter_prefetch.cc b/paddle/fluid/operators/distributed/parameter_prefetch.cc index 84828c7cd0c..88e87fc6385 100644 --- a/paddle/fluid/operators/distributed/parameter_prefetch.cc +++ b/paddle/fluid/operators/distributed/parameter_prefetch.cc @@ -195,8 +195,8 @@ void prefetchs(const std::vector &id_var_names, const std::vector &endpoints, const framework::ExecutionContext &context, const framework::Scope &scope) { - platform::RecordEvent record_event("Distributed_lookup_table::prefetchs", - platform::EventRole::kInnerOp); + platform::PushEvent("Distributed_lookup_table::prefetchs", + platform::EventRole::kInnerOp); auto vec_dim_1 = 0; auto vec_dim_0 = 0; framework::Variable *var = scope.FindVar(persistable_var_name); @@ -304,6 +304,8 @@ void prefetchs(const std::vector &id_var_names, #endif } } + platform::PopEvent("Distributed_lookup_table::prefetchs", + platform::EventRole::kInnerOp); } }; // namespace distributed diff --git a/paddle/fluid/operators/distributed/parameter_recv.cc b/paddle/fluid/operators/distributed/parameter_recv.cc index ce256cb8b23..65c4b26b0d8 100644 --- a/paddle/fluid/operators/distributed/parameter_recv.cc +++ b/paddle/fluid/operators/distributed/parameter_recv.cc @@ -43,8 +43,8 @@ using DDim = framework::DDim; template void RecvSelectedRows(const CommContext &rpc_ctx, const framework::Scope &scope) { - platform::RecordEvent record_event("ParameterRecv::RecvSelectedRows", - platform::EventRole::kInnerOp); + platform::RecordEvent record_event_grpc("ParameterRecv::RecvSelectedRows", + platform::EventRole::kInnerOp); platform::DeviceContextPool &pool = platform::DeviceContextPool::Instance(); auto cpu_place = platform::CPUPlace(); auto &cpu_ctx = *pool.Get(cpu_place); @@ -114,8 +114,8 @@ void RecvSelectedRows(const CommContext &rpc_ctx, template void RecvLodTensor(const CommContext &rpc_ctx, const framework::Scope &scope) { - platform::RecordEvent record_event("ParameterRecv::RecvLodTensor", - platform::EventRole::kInnerOp); + platform::RecordEvent record_event_grpc("ParameterRecv::RecvLodTensor", + platform::EventRole::kInnerOp); platform::DeviceContextPool &pool = platform::DeviceContextPool::Instance(); auto cpu_place = platform::CPUPlace(); auto &cpu_ctx = *pool.Get(cpu_place); diff --git a/paddle/fluid/operators/distributed/parameter_send.cc b/paddle/fluid/operators/distributed/parameter_send.cc index e95420d4279..de6ca7d2e35 100644 --- a/paddle/fluid/operators/distributed/parameter_send.cc +++ b/paddle/fluid/operators/distributed/parameter_send.cc @@ -98,8 +98,6 @@ template void ParameterSend::operator()(const CommContext &rpc_ctx, const framework::Scope &scope, bool sync, int multi_parts) { - platform::RecordEvent record_event("ParameterSend::operator", - platform::EventRole::kInnerOp); if (rpc_ctx.var_name == STEP_COUNTER) { SendByNotifyRPC(rpc_ctx, scope); return; @@ -117,8 +115,8 @@ void ParameterSend::operator()(const CommContext &rpc_ctx, auto *send_var = scope.FindVar(rpc_ctx.var_name); if (send_var->IsType()) { - platform::RecordEvent record_event("ParameterSend::LoDTensor", - platform::EventRole::kInnerOp); + platform::RecordEvent record_event_grpc("ParameterSend::LoDTensor", + platform::EventRole::kInnerOp); size_t out_num = rpc_ctx.splited_varnames.size(); if (out_num > 1) { auto &send_tensor = send_var->Get(); @@ -167,8 +165,8 @@ void ParameterSend::operator()(const CommContext &rpc_ctx, } } } else if (send_var->IsType()) { - platform::RecordEvent record_event("ParameterSend::SelectedRows", - platform::EventRole::kInnerOp); + platform::RecordEvent record_event_grpc("ParameterSend::SelectedRows", + platform::EventRole::kInnerOp); auto &send_slr = send_var->Get(); auto &send_rows = send_slr.rows(); diff --git a/paddle/fluid/platform/device_tracer.cc b/paddle/fluid/platform/device_tracer.cc index ec934c3b980..7cbd05189a1 100644 --- a/paddle/fluid/platform/device_tracer.cc +++ b/paddle/fluid/platform/device_tracer.cc @@ -694,8 +694,16 @@ Event *CurAnnotation() { return annotation_stack.back(); } std::string CurAnnotationName() { - if (annotation_stack.empty()) return "Unknown"; - return annotation_stack.back()->name(); + std::string curr_annotation_name = "Unknown"; + try { + if (annotation_stack.empty()) { + return curr_annotation_name; + } + return annotation_stack.back()->name(); + } catch (...) { + VLOG(1) << "CurAnnotationName Failed"; + } + return curr_annotation_name; } void SetCurBlock(int block_id) { block_id_stack.push_back(block_id); } -- GitLab