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

Maintain old profiler (#41132)

* no

* maintain old profiler

* exclude new python record events for old profiler

* maintain old profiler

* maintain

* maintain old profiler

* maintain

* fix cmakes
上级 7ef69202
...@@ -59,6 +59,7 @@ DECLARE_bool(benchmark); ...@@ -59,6 +59,7 @@ DECLARE_bool(benchmark);
DECLARE_bool(check_nan_inf); DECLARE_bool(check_nan_inf);
DECLARE_bool(enable_unused_var_check); DECLARE_bool(enable_unused_var_check);
DECLARE_bool(run_kp_kernel); DECLARE_bool(run_kp_kernel);
DECLARE_bool(enable_host_event_recorder_hook);
namespace paddle { namespace paddle {
namespace framework { namespace framework {
...@@ -264,7 +265,8 @@ void OperatorBase::Run(const Scope& scope, const platform::Place& place) { ...@@ -264,7 +265,8 @@ void OperatorBase::Run(const Scope& scope, const platform::Place& place) {
Type(), platform::TracerEventType::Operator, 1); Type(), platform::TracerEventType::Operator, 1);
auto op_name = platform::OpName(outputs_, Type()); auto op_name = platform::OpName(outputs_, Type());
platform::RecordEvent op_name_record_event( platform::RecordEvent op_name_record_event(
op_name, platform::TracerEventType::Operator, 10, op_name, platform::TracerEventType::Operator,
FLAGS_enable_host_event_recorder_hook ? 20 : 1,
platform::EventRole::kUniqueOp); platform::EventRole::kUniqueOp);
RunImpl(scope, place); RunImpl(scope, place);
} }
......
...@@ -192,13 +192,13 @@ add_subdirectory(profiler) ...@@ -192,13 +192,13 @@ add_subdirectory(profiler)
cc_library(device_tracer SRCS device_tracer.cc DEPS boost profiler_proto framework_proto ${GPU_CTX_DEPS}) cc_library(device_tracer SRCS device_tracer.cc DEPS boost profiler_proto framework_proto ${GPU_CTX_DEPS})
if(WITH_GPU) if(WITH_GPU)
nv_library(profiler SRCS profiler.cc profiler.cu DEPS os_info device_tracer gpu_info enforce dynload_cuda) nv_library(profiler SRCS profiler.cc profiler.cu DEPS os_info device_tracer gpu_info enforce dynload_cuda new_profiler)
nv_library(device_memory_aligment SRCS device_memory_aligment.cc DEPS cpu_info gpu_info place) nv_library(device_memory_aligment SRCS device_memory_aligment.cc DEPS cpu_info gpu_info place)
elseif(WITH_ROCM) elseif(WITH_ROCM)
hip_library(profiler SRCS profiler.cc profiler.cu DEPS os_info device_tracer gpu_info enforce) hip_library(profiler SRCS profiler.cc profiler.cu DEPS os_info device_tracer gpu_info enforce new_profiler)
hip_library(device_memory_aligment SRCS device_memory_aligment.cc DEPS cpu_info gpu_info place) hip_library(device_memory_aligment SRCS device_memory_aligment.cc DEPS cpu_info gpu_info place)
else() else()
cc_library(profiler SRCS profiler.cc DEPS os_info device_tracer enforce) cc_library(profiler SRCS profiler.cc DEPS os_info device_tracer enforce new_profiler)
cc_library(device_memory_aligment SRCS device_memory_aligment.cc DEPS cpu_info place) cc_library(device_memory_aligment SRCS device_memory_aligment.cc DEPS cpu_info place)
endif() endif()
......
...@@ -24,6 +24,7 @@ limitations under the License. */ ...@@ -24,6 +24,7 @@ limitations under the License. */
#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"
#include "paddle/fluid/platform/profiler/host_tracer.h" #include "paddle/fluid/platform/profiler/host_tracer.h"
#include "paddle/fluid/platform/profiler/profiler.h"
#include "paddle/fluid/platform/profiler_helper.h" #include "paddle/fluid/platform/profiler_helper.h"
#ifdef PADDLE_WITH_CUDA #ifdef PADDLE_WITH_CUDA
#include "paddle/fluid/platform/dynload/nvtx.h" #include "paddle/fluid/platform/dynload/nvtx.h"
...@@ -76,15 +77,21 @@ RecordEvent::RecordEvent(const char *name, const TracerEventType type, ...@@ -76,15 +77,21 @@ RecordEvent::RecordEvent(const char *name, const TracerEventType type,
} }
#endif #endif
#endif #endif
if (UNLIKELY(HostTraceLevel::GetInstance().NeedTrace(level) == false)) {
return;
}
if (FLAGS_enable_host_event_recorder_hook == false) { if (FLAGS_enable_host_event_recorder_hook == false) {
if (g_state != ProfilerState::kDisabled) { // avoid temp string if (g_state != ProfilerState::kDisabled) { // avoid temp string
OriginalConstruct(name, role, "none"); if (type == TracerEventType::Operator ||
type == TracerEventType::OperatorInner ||
type == TracerEventType::UserDefined) {
OriginalConstruct(name, role, "none");
}
} }
return; return;
} }
if (UNLIKELY(HostTraceLevel::GetInstance().NeedTrace(level) == false)) {
return;
}
is_enabled_ = true; is_enabled_ = true;
shallow_copy_name_ = name; shallow_copy_name_ = name;
role_ = role; role_ = role;
...@@ -102,13 +109,19 @@ RecordEvent::RecordEvent(const std::string &name, const TracerEventType type, ...@@ -102,13 +109,19 @@ RecordEvent::RecordEvent(const std::string &name, const TracerEventType type,
} }
#endif #endif
#endif #endif
if (FLAGS_enable_host_event_recorder_hook == false) { if (UNLIKELY(HostTraceLevel::GetInstance().NeedTrace(level) == false)) {
OriginalConstruct(name, role, "none");
return; return;
} }
if (UNLIKELY(HostTraceLevel::GetInstance().NeedTrace(level) == false)) {
if (FLAGS_enable_host_event_recorder_hook == false) {
if (type == TracerEventType::Operator ||
type == TracerEventType::OperatorInner ||
type == TracerEventType::UserDefined) {
OriginalConstruct(name, role, "none");
}
return; return;
} }
is_enabled_ = true; is_enabled_ = true;
name_ = new std::string(name); name_ = new std::string(name);
role_ = role; role_ = role;
...@@ -127,13 +140,20 @@ RecordEvent::RecordEvent(const std::string &name, const std::string &attr, ...@@ -127,13 +140,20 @@ RecordEvent::RecordEvent(const std::string &name, const std::string &attr,
} }
#endif #endif
#endif #endif
if (FLAGS_enable_host_event_recorder_hook == false) {
OriginalConstruct(name, role, attr); if (UNLIKELY(HostTraceLevel::GetInstance().NeedTrace(level) == false)) {
return; return;
} }
if (UNLIKELY(HostTraceLevel::GetInstance().NeedTrace(level) == false)) {
if (FLAGS_enable_host_event_recorder_hook == false) {
if (type == TracerEventType::Operator ||
type == TracerEventType::OperatorInner ||
type == TracerEventType::UserDefined) {
OriginalConstruct(name, role, attr);
}
return; return;
} }
is_enabled_ = true; is_enabled_ = true;
type_ = type; type_ = type;
name_ = new std::string(name); name_ = new std::string(name);
...@@ -333,6 +353,8 @@ void EnableProfiler(ProfilerState state) { ...@@ -333,6 +353,8 @@ void EnableProfiler(ProfilerState state) {
return; return;
} }
g_state = state; g_state = state;
ProfilerOptions option;
HostTraceLevel::GetInstance().SetLevel(option.trace_level);
should_send_profile_state = true; should_send_profile_state = true;
GetDeviceTracer()->Enable(); GetDeviceTracer()->Enable();
#if defined(PADDLE_WITH_CUDA) || defined(PADDLE_WITH_HIP) #if defined(PADDLE_WITH_CUDA) || defined(PADDLE_WITH_HIP)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册