未验证 提交 f335d9e1 编写于 作者: L liutiexing 提交者: GitHub

Trace level env (#39926)

* add align for WorkQueue

* add spinlock

* merge develop

* merge

* Add EventsWaiter

* Revert "Add EventsWaiter"

This reverts commit e206173aa9be7401b83a53581627bfaf557c8fb2.

* Add host_trace_level env variable

* Revert "Optimize perf of softmax_with_cross_entropy (#39553)"

This reverts commit bbe5228c.
Co-authored-by: Nliutiexing <liutiexing@google.com>
Co-authored-by: NZzSean <18818272991@163.com>
上级 7ecefec3
...@@ -389,7 +389,7 @@ void InterpreterCore::RunInstruction(const Instruction& instr_node) { ...@@ -389,7 +389,7 @@ void InterpreterCore::RunInstruction(const Instruction& instr_node) {
auto op_with_kernel = dynamic_cast<const framework::OperatorWithKernel*>(op); auto op_with_kernel = dynamic_cast<const framework::OperatorWithKernel*>(op);
{ {
platform::RecordEvent infershape_event( platform::RecordEvent infershape_event(
"InferShape", platform::TracerEventType::OperatorInner, 1, "infer_shape", platform::TracerEventType::OperatorInner, 1,
platform::EventRole::kInnerOp); platform::EventRole::kInnerOp);
// If it is OperatorBase, InferShape do nothing. // If it is OperatorBase, InferShape do nothing.
if (op_with_kernel != nullptr) if (op_with_kernel != nullptr)
...@@ -411,7 +411,7 @@ void InterpreterCore::RunInstruction(const Instruction& instr_node) { ...@@ -411,7 +411,7 @@ void InterpreterCore::RunInstruction(const Instruction& instr_node) {
} }
{ {
platform::RecordEvent compute_event( platform::RecordEvent compute_event(
"Compute", platform::TracerEventType::OperatorInner, 1, "compute", platform::TracerEventType::OperatorInner, 1,
platform::EventRole::kInnerOp); platform::EventRole::kInnerOp);
if (op_with_kernel == nullptr) { if (op_with_kernel == nullptr) {
instr_node.OpBase()->Run(*local_scope, place_); instr_node.OpBase()->Run(*local_scope, place_);
...@@ -561,7 +561,8 @@ void InterpreterCore::RunInstructionAsync(size_t instr_id) { ...@@ -561,7 +561,8 @@ void InterpreterCore::RunInstructionAsync(size_t instr_id) {
<< " runs on " << platform::GetCurrentThreadName(); << " runs on " << platform::GetCurrentThreadName();
auto* op = instr_node.OpBase(); auto* op = instr_node.OpBase();
platform::RecordEvent instruction_event(op->Type().c_str()); platform::RecordEvent instruction_event(
op->Type(), platform::TracerEventType::Operator, 1);
interpreter::WaitEvent(instr_node, place_); interpreter::WaitEvent(instr_node, place_);
try { try {
......
...@@ -175,7 +175,7 @@ void Tracer::TraceOp(const std::string& type, const NameVarMap<VarType>& ins, ...@@ -175,7 +175,7 @@ void Tracer::TraceOp(const std::string& type, const NameVarMap<VarType>& ins,
paddle::framework::AttributeMap* passed_default_attrs_, paddle::framework::AttributeMap* passed_default_attrs_,
bool use_default_attr_map) { bool use_default_attr_map) {
platform::RecordEvent op_type_record_event( platform::RecordEvent op_type_record_event(
type, platform::TracerEventType::Operator, 2); type, platform::TracerEventType::Operator, 1);
platform::ScopedFlushDenormal flush; platform::ScopedFlushDenormal flush;
VLOG(1) << "Trace Op: " << type; VLOG(1) << "Trace Op: " << type;
if (FLAGS_use_mkldnn) { if (FLAGS_use_mkldnn) {
......
...@@ -14,9 +14,16 @@ ...@@ -14,9 +14,16 @@
#include "paddle/fluid/platform/profiler/host_tracer.h" #include "paddle/fluid/platform/profiler/host_tracer.h"
#include "glog/logging.h" #include "glog/logging.h"
#include "paddle/fluid/platform/flags.h"
#include "paddle/fluid/platform/profiler/common_event.h" #include "paddle/fluid/platform/profiler/common_event.h"
#include "paddle/fluid/platform/profiler/host_event_recorder.h" #include "paddle/fluid/platform/profiler/host_event_recorder.h"
// Used to filter events, works like glog VLOG(level).
// RecordEvent will works if host_trace_level >= level.
PADDLE_DEFINE_EXPORTED_int64(host_trace_level, 2,
"RecordEvent will works "
"if host_trace_level >= level.");
namespace paddle { namespace paddle {
namespace platform { namespace platform {
......
...@@ -23,11 +23,13 @@ ...@@ -23,11 +23,13 @@
#include "paddle/fluid/platform/profiler/event_node.h" #include "paddle/fluid/platform/profiler/event_node.h"
#include "paddle/fluid/platform/profiler/tracer_base.h" #include "paddle/fluid/platform/profiler/tracer_base.h"
DECLARE_int64(host_trace_level);
namespace paddle { namespace paddle {
namespace platform { namespace platform {
struct ProfilerOptions { struct ProfilerOptions {
uint32_t trace_level = 0; uint32_t trace_level = FLAGS_host_trace_level;
}; };
class Profiler { class Profiler {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册