From 42111a8033fd4cafd24c8a0fffb8c8996d87e42a Mon Sep 17 00:00:00 2001 From: askmiao Date: Tue, 25 Aug 2020 09:02:57 +0800 Subject: [PATCH] fix multiple epoch data issue --- .../ccsrc/profiler/device/gpu/gpu_profiling.cc | 15 +++++++++++++-- .../ccsrc/profiler/device/gpu/gpu_profiling.h | 4 ++-- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/mindspore/ccsrc/profiler/device/gpu/gpu_profiling.cc b/mindspore/ccsrc/profiler/device/gpu/gpu_profiling.cc index 0c0a7b54e71..1e92a2eb7b1 100644 --- a/mindspore/ccsrc/profiler/device/gpu/gpu_profiling.cc +++ b/mindspore/ccsrc/profiler/device/gpu/gpu_profiling.cc @@ -60,8 +60,8 @@ namespace gpu { std::shared_ptr GPUProfiler::profiler_inst_ = nullptr; int32_t GetThreadID() { - int32_t thread_id = 0; - thread_id = static_cast(pthread_self()); + uint32_t thread_id = 0; + thread_id = static_cast(pthread_self()); return thread_id; } @@ -475,6 +475,7 @@ void GPUProfiler::Stop() { StopCUPTI(); OpsParser(); SaveProfileData(); + ClearInst(); } void GPUProfiler::SaveProfileData() { @@ -486,9 +487,19 @@ void GPUProfiler::SaveProfileData() { dataSaver.ParseEvent(events_); dataSaver.WriteFile(profile_data_path_); } +} + +void GPUProfiler::ClearInst() { op_info_map_.clear(); op_name_map_.clear(); events_.clear(); + activities_enable_.clear(); + enable_flag_ = false; + sync_enable_flag_ = true; + cupti_callback_events_count_ = 0l; + cupti_callback_events_drop_count_ = 0l; + cupti_activity_events_count_ = 0l; + cupti_activity_events_drop_count_ = 0l; } void CUPTIAPI ActivityAllocBuffer(uint8_t **buffer, size_t *size, size_t *maxNumRecords) { diff --git a/mindspore/ccsrc/profiler/device/gpu/gpu_profiling.h b/mindspore/ccsrc/profiler/device/gpu/gpu_profiling.h index ad21774d825..f99364d8539 100644 --- a/mindspore/ccsrc/profiler/device/gpu/gpu_profiling.h +++ b/mindspore/ccsrc/profiler/device/gpu/gpu_profiling.h @@ -75,7 +75,7 @@ struct Event { uint32_t device_id; uint32_t correlation_id; uint32_t thread_id; - int64_t context_id; + uint32_t context_id; uint32_t stream_id; CUpti_CallbackId cb_id; union { @@ -131,7 +131,7 @@ class GPUProfiler { GPUProfiler() = default; void OpsParser(); void EventLog(const Event &event); - + void ClearInst(); void HandleActivityRecord(CUpti_Activity *record); void AddEvent(Event &&event); void SetRunTimeData(const std::string &op_name, void *stream);