未验证 提交 c984cd85 编写于 作者: C chenjian 提交者: GitHub

Update record interface using part2 (#39694)

* fix RecordEvent interface

* modify default level to 4

* update interface use

* add const default trace level

* update record event interface using

* update record event interface using

* update operator.cc

* update part2

* update part1

* fix include profiler.h header in ps server

* fix include profiler.h header in ps server

* fix profiler.h header
上级 83dd7e47
......@@ -13,7 +13,7 @@
// limitations under the License.
#include "paddle/fluid/framework/details/scope_buffered_monitor.h"
#include "paddle/fluid/platform/profiler.h"
#include "paddle/fluid/platform/profiler/event_tracing.h"
namespace paddle {
namespace framework {
......@@ -91,7 +91,8 @@ void ScopeBufferedMonitor::Apply(const std::function<void()> &callback,
bool has_fetch) {
std::unique_ptr<platform::RecordEvent> pre_local_exec_scopes_event(
new platform::RecordEvent(
"ScopeBufferedMonitor::pre_local_exec_scopes_process"));
"ScopeBufferedMonitor::pre_local_exec_scopes_process",
platform::TracerEventType::UserDefined, 2));
for (size_t scope_id = 0; scope_id < local_exec_scopes_.size(); ++scope_id) {
pre_local_exec_scopes_.at(scope_id).clear();
auto scopes = local_exec_scopes_.at(scope_id)->kids();
......@@ -105,7 +106,8 @@ void ScopeBufferedMonitor::Apply(const std::function<void()> &callback,
std::unique_ptr<platform::RecordEvent> post_local_exec_scopes_event(
new platform::RecordEvent(
"ScopeBufferedMonitor::post_local_exec_scopes_process"));
"ScopeBufferedMonitor::post_local_exec_scopes_process",
platform::TracerEventType::UserDefined, 2));
for (size_t scope_id = 0; scope_id < local_exec_scopes_.size(); ++scope_id) {
post_local_exec_scopes_.at(scope_id).clear();
auto scopes = local_exec_scopes_.at(scope_id)->kids();
......
......@@ -23,7 +23,7 @@
#include "paddle/fluid/framework/op_registry.h"
#include "paddle/fluid/framework/variable_helper.h"
#include "paddle/fluid/platform/cuda_graph_with_memory_pool.h"
#include "paddle/fluid/platform/profiler.h"
#include "paddle/fluid/platform/profiler/event_tracing.h"
namespace paddle {
namespace framework {
......@@ -75,7 +75,8 @@ FetchResultType ScopeBufferedSSAGraphExecutor::Run(
#endif
if (drop_scope_counter_ == 0) {
platform::RecordEvent e("InitLocalVars");
platform::RecordEvent e("InitLocalVars",
platform::TracerEventType::UserDefined, 2);
InitVariables();
}
......@@ -164,7 +165,8 @@ void ScopeBufferedSSAGraphExecutor::InitVariables() {
}
void ScopeBufferedSSAGraphExecutor::DropLocalExeScopes(bool need_wait) {
platform::RecordEvent drop_scope_event("DropLocalExeScopes");
platform::RecordEvent drop_scope_event(
"DropLocalExeScopes", platform::TracerEventType::UserDefined, 2);
drop_scope_counter_ = 0;
if (need_wait) {
for (auto &p : places_) {
......
......@@ -25,7 +25,7 @@
#include "paddle/fluid/memory/malloc.h"
#include "paddle/fluid/platform/cuda_device_guard.h"
#include "paddle/fluid/platform/device/gpu/gpu_info.h"
#include "paddle/fluid/platform/profiler.h"
#include "paddle/fluid/platform/profiler/event_tracing.h"
DECLARE_bool(sync_nccl_allreduce);
......@@ -66,7 +66,8 @@ SparseAllReduceOpHandle::SparseAllReduceOpHandle(
}
void SparseAllReduceOpHandle::RunImplEncoded() {
platform::RecordEvent record_event(Name());
platform::RecordEvent record_event(Name(),
platform::TracerEventType::UserDefined, 2);
auto in_var_handles = DynamicCast<VarHandle>(this->Inputs());
auto out_var_handles = DynamicCast<VarHandle>(this->Outputs());
......@@ -279,6 +280,8 @@ bool SparseAllReduceOpHandle::IsEncoded() {
}
void SparseAllReduceOpHandle::RunImpl() {
platform::RecordEvent record_event(
Name(), platform::TracerEventType::Communication, 1);
if (!IsEncoded()) {
AllReduceOpHandle::RunImpl();
return;
......
......@@ -15,7 +15,7 @@
#include "paddle/fluid/framework/details/threaded_ssa_graph_executor.h"
#include "paddle/fluid/framework/ir/graph_helper.h"
#include "paddle/fluid/platform/profiler.h"
#include "paddle/fluid/platform/profiler/event_tracing.h"
#if defined PADDLE_WITH_PSCORE
#include "paddle/fluid/distributed/ps/service/communicator/communicator.h"
......@@ -56,7 +56,8 @@ ThreadedSSAGraphExecutor::ThreadedSSAGraphExecutor(
inline FetchResultType ThreadedSSAGraphExecutor::RunImpl(
const std::vector<std::string> &fetch_tensors, bool return_merged) {
std::unique_ptr<platform::RecordEvent> event(
new platform::RecordEvent("ThreadedSSAGraphExecutorPrepare"));
new platform::RecordEvent("ThreadedSSAGraphExecutorPrepare",
platform::TracerEventType::UserDefined, 2));
std::unique_ptr<OpDependentData> op_deps = op_deps_futures_.get();
CopyOpDeps();
......
......@@ -22,6 +22,7 @@ limitations under the License. */
#include "paddle/fluid/operators/controlflow/while_op_helper.h"
#include "paddle/fluid/platform/place.h"
#include "paddle/fluid/platform/profiler.h"
#include "paddle/fluid/platform/profiler/event_tracing.h"
#ifdef PADDLE_WITH_MKLDNN
#include "paddle/fluid/platform/mkldnn_helper.h"
#endif
......
......@@ -26,6 +26,7 @@
#include "paddle/fluid/framework/ir/node.h"
#include "paddle/fluid/framework/program_desc.h"
#include "paddle/fluid/platform/profiler.h"
#include "paddle/fluid/platform/profiler/event_tracing.h"
#include "paddle/fluid/platform/variant.h"
namespace paddle {
......
......@@ -388,7 +388,9 @@ void InterpreterCore::RunInstruction(const Instruction& instr_node) {
: global_scope_->GetMutableScope();
auto op_with_kernel = dynamic_cast<const framework::OperatorWithKernel*>(op);
{
platform::RecordEvent infershape_event("InferShape");
platform::RecordEvent infershape_event(
"InferShape", platform::TracerEventType::OperatorInner, 1,
platform::EventRole::kInnerOp);
// If it is OperatorBase, InferShape do nothing.
if (op_with_kernel != nullptr)
op_with_kernel->Info().infer_shape_(
......@@ -408,7 +410,9 @@ void InterpreterCore::RunInstruction(const Instruction& instr_node) {
}
}
{
platform::RecordEvent compute_event("Compute");
platform::RecordEvent compute_event(
"Compute", platform::TracerEventType::OperatorInner, 1,
platform::EventRole::kInnerOp);
if (op_with_kernel == nullptr) {
instr_node.OpBase()->Run(*local_scope, place_);
} else {
......
......@@ -408,7 +408,8 @@ class ThreadPoolTempl {
ec_.Notify(true);
return false;
}
platform::RecordEvent("SleepWaitForWork");
platform::RecordEvent("SleepWaitForWork",
platform::TracerEventType::UserDefined, 2);
ec_.CommitWait(waiter);
blocked_--;
return true;
......
......@@ -39,6 +39,7 @@ limitations under the License. */
#include "paddle/fluid/platform/cuda_graph_with_memory_pool.h"
#include "paddle/fluid/platform/event.h"
#include "paddle/fluid/platform/profiler.h"
#include "paddle/fluid/platform/profiler/event_tracing.h"
#if defined(PADDLE_WITH_CUDA) || defined(PADDLE_WITH_HIP)
#include "paddle/fluid/platform/cuda_device_guard.h"
......
......@@ -23,7 +23,7 @@ limitations under the License. */
#include "paddle/fluid/framework/data_type.h"
#include "paddle/fluid/framework/tensor_util.h"
#include "paddle/fluid/platform/complex.h"
#include "paddle/fluid/platform/profiler.h"
#include "paddle/fluid/platform/profiler/event_tracing.h"
#include "paddle/phi/core/dense_tensor.h"
......
......@@ -410,7 +410,8 @@ void BasicEngine::Execute() {
auto& inplace_grad_name_map = shared_cur_node->InplaceGradNameMap();
for (auto& cur_op : *shared_cur_node) {
platform::RecordEvent op_type_record_event(cur_op.Type());
platform::RecordEvent op_type_record_event(
cur_op.Type(), platform::TracerEventType::Operator, 1);
++op_num;
......
......@@ -233,7 +233,8 @@ void VarBase::ClearGradient(bool set_to_zero) {
grad_t->mutable_value()->clear();
}
} else {
platform::RecordEvent record_event("ClearGradient");
platform::RecordEvent record_event(
"ClearGradient", platform::TracerEventType::UserDefined, 2);
auto* grad_t =
grad_var_->MutableVar()->GetMutable<framework::LoDTensor>();
if (grad_t->IsInitialized()) {
......
......@@ -30,7 +30,7 @@
#include "paddle/fluid/imperative/op_base.h"
#include "paddle/fluid/imperative/tracer.h"
#include "paddle/fluid/platform/device_context.h"
#include "paddle/fluid/platform/profiler.h"
#include "paddle/fluid/platform/profiler/event_tracing.h"
#include "paddle/fluid/string/string_helper.h"
#include "paddle/phi/kernels/funcs/math_function.h"
......
......@@ -22,6 +22,7 @@
#include "paddle/fluid/platform/denormal.h"
#include "paddle/fluid/platform/device/device_wrapper.h"
#include "paddle/fluid/platform/profiler.h"
#include "paddle/fluid/platform/profiler/event_tracing.h"
#include "paddle/fluid/string/string_helper.h"
DECLARE_bool(use_mkldnn);
......@@ -171,7 +172,8 @@ void Tracer::TraceOp(const std::string& type, const NameVarMap<VarType>& ins,
const std::map<std::string, std::string>& inplace_map,
paddle::framework::AttributeMap* passed_default_attrs_,
bool use_default_attr_map) {
platform::RecordEvent op_type_record_event(type);
platform::RecordEvent op_type_record_event(
type, platform::TracerEventType::Operator, 2);
platform::ScopedFlushDenormal flush;
VLOG(1) << "Trace Op: " << type;
if (FLAGS_use_mkldnn) {
......
......@@ -24,7 +24,7 @@
#include "paddle/fluid/inference/tensorrt/helper.h"
#include "paddle/fluid/inference/tensorrt/plugin/trt_plugin_utils.h"
#include "paddle/fluid/platform/enforce.h"
#include "paddle/fluid/platform/profiler.h"
#include "paddle/fluid/platform/profiler/event_tracing.h"
namespace nvinfer1 {
class ITensor;
......
......@@ -38,7 +38,7 @@
#include "paddle/fluid/inference/tests/api/config_printer.h"
#include "paddle/fluid/inference/tests/test_helper.h"
#include "paddle/fluid/inference/utils/benchmark.h"
#include "paddle/fluid/platform/profiler.h"
#include "paddle/fluid/platform/profiler/event_tracing.h"
DEFINE_string(model_name, "", "model name");
DEFINE_string(infer_model, "", "model path");
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册