diff --git a/paddle/fluid/platform/profiler/cupti_data_process.cc b/paddle/fluid/platform/profiler/cupti_data_process.cc index 4d3b807aba82ea91770dddfcf655ec2431cdb197..da12dccb74924fd27dee3047d29636341f7c47a2 100644 --- a/paddle/fluid/platform/profiler/cupti_data_process.cc +++ b/paddle/fluid/platform/profiler/cupti_data_process.cc @@ -14,6 +14,7 @@ #include "paddle/fluid/platform/profiler/cupti_data_process.h" #include +#include "paddle/fluid/platform/enforce.h" #include "paddle/fluid/platform/os_info.h" namespace paddle { @@ -26,7 +27,7 @@ void AddKernelRecord(const CUpti_ActivityKernel4* kernel, uint64_t start_ns, return; } DeviceTraceEvent event; - event.name = kernel->name; + event.name = demangle(kernel->name); event.type = TracerEventType::Kernel; event.start_ns = kernel->start; event.end_ns = kernel->end; diff --git a/paddle/fluid/platform/profiler/event_python.h b/paddle/fluid/platform/profiler/event_python.h old mode 100755 new mode 100644 diff --git a/paddle/fluid/platform/profiler/event_tracing.h b/paddle/fluid/platform/profiler/event_tracing.h index 54c5b219310a9c64214e721f2f6b310e20c5d733..fcaba9a43ca9385ab38e440f7b8659298a02ef05 100644 --- a/paddle/fluid/platform/profiler/event_tracing.h +++ b/paddle/fluid/platform/profiler/event_tracing.h @@ -21,26 +21,55 @@ limitations under the License. */ namespace paddle { namespace platform { +// Default tracing level. +// It is Recommended to set the level explicitly. static constexpr uint32_t kDefaultTraceLevel = 4; -// CPU event tracing. A trace marks something that happens but has no duration + +// Host event tracing. A trace marks something that happens but has no duration // associated with it. For example, thread starts working. // Chrome Trace Viewer Format: Instant Event struct RecordInstantEvent { + /** + * @param name: It is the caller's reponsibility to manage the underlying + * storage. RecordInstantEvent stores the pointer. + * @param type: Classification which is used to instruct the profiling + * data statistics. + * @param level: Used to filter events, works like glog VLOG(level). + * RecordEvent will works if HostTraceLevel >= level. + */ explicit RecordInstantEvent(const char* name, TracerEventType type, uint32_t level = kDefaultTraceLevel); }; -// CPU event tracing. A trace starts when an object of this clas is created and +// Host event tracing. A trace starts when an object of this clas is created and // stops when the object is destroyed. // Chrome Trace Viewer Format: Duration Event/Complte Event class RecordEvent { public: + /** + * @param name: If your string argument has a longer lifetime (e.g.: string + * literal, static variables, etc) than the event, use 'const char* name'. + * Do your best to avoid using 'std::string' as the argument type. It will + * cause deep-copy to harm performance. + * @param type: Classification which is used to instruct the profiling + * data statistics. + * @param level: Used to filter events, works like glog VLOG(level). + * RecordEvent will works if HostTraceLevel >= level. + */ explicit RecordEvent( const std::string& name, const TracerEventType type = TracerEventType::UserDefined, uint32_t level = kDefaultTraceLevel, const EventRole role = EventRole::kOrdinary); + /** + * @param name: It is the caller's reponsibility to manage the underlying + * storage. RecordEvent stores the pointer. + * @param type: Classification which is used to instruct the profiling + * data statistics. + * @param level: Used to filter events, works like glog VLOG(level). + * RecordEvent will works if HostTraceLevel >= level. + */ explicit RecordEvent(const char* name, const TracerEventType type = TracerEventType::UserDefined, uint32_t level = kDefaultTraceLevel, diff --git a/paddle/fluid/platform/profiler/host_event_recorder.h b/paddle/fluid/platform/profiler/host_event_recorder.h index 3bcd68c55963082bfc0ce12bbcdc0b07a05bbe97..49f9362527591744dd0685375e0244673a7b3081 100644 --- a/paddle/fluid/platform/profiler/host_event_recorder.h +++ b/paddle/fluid/platform/profiler/host_event_recorder.h @@ -202,7 +202,7 @@ class ThreadEventRecorder { ThreadEventSection GatherEvents() { ThreadEventSection thr_sec; - thr_sec.thread_name = thread_name_; + thr_sec.thread_name = GetCurrentThreadName(); thr_sec.thread_id = thread_id_; thr_sec.events = std::move(base_evt_cntr_.Reduce()); return thr_sec; @@ -210,7 +210,6 @@ class ThreadEventRecorder { private: uint64_t thread_id_; - std::string thread_name_; EventContainer base_evt_cntr_; }; diff --git a/paddle/fluid/platform/profiler/output_logger.h b/paddle/fluid/platform/profiler/output_logger.h old mode 100755 new mode 100644