diff --git a/mindspore/ccsrc/profiler/device/gpu/gpu_profiling.cc b/mindspore/ccsrc/profiler/device/gpu/gpu_profiling.cc index 0c0a7b54e713493858be24ba7c23634d90e0dd3d..1e92a2eb7b1c6b7215b144f6dbf8ca59fa89d500 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 ad21774d8254a472ab7134ee64df4d381941d7a3..f99364d8539b6758799f360a092b9051c075cfba 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);