Browse Source

!1176 Fix CPU utilization bugs

From: @zyhstack
Reviewed-by: @ouwenchang,@yelihua
Signed-off-by: @yelihua
tags/v1.2.0-rc1
mindspore-ci-bot Gitee 4 years ago
parent
commit
3cb608e6e0
2 changed files with 13 additions and 7 deletions
  1. +6
    -7
      mindinsight/profiler/analyser/minddata_cpu_utilization_analyser.py
  2. +7
    -0
      mindinsight/profiler/proposer/allproposers/minddata_proposer.py

+ 6
- 7
mindinsight/profiler/analyser/minddata_cpu_utilization_analyser.py View File

@@ -57,14 +57,14 @@ class MinddataCpuUtilizationAnalyser(BaseAnalyser):
result["device_info"] = dict() result["device_info"] = dict()
for key in self._data.get("device_info").keys(): for key in self._data.get("device_info").keys():
arr = self._data.get("device_info")[key] arr = self._data.get("device_info")[key]
avg_value = round(sum(arr) / len(arr))
avg_value = round(sum(arr) / len(arr)) if arr else 0
result["device_info"][key] = {"metrics": arr, "avg_value": avg_value} result["device_info"][key] = {"metrics": arr, "avg_value": avg_value}


# process average CPU utilization # process average CPU utilization
result["process_info"] = dict() result["process_info"] = dict()
for key in self._data.get("process_info").keys(): for key in self._data.get("process_info").keys():
arr = self._data.get("process_info")[key] arr = self._data.get("process_info")[key]
avg_value = round(sum(arr) / len(arr))
avg_value = round(sum(arr) / len(arr)) if arr else 0
result["process_info"][key] = {"metrics": arr, "avg_value": avg_value} result["process_info"][key] = {"metrics": arr, "avg_value": avg_value}


# op average CPU utilization # op average CPU utilization
@@ -83,7 +83,7 @@ class MinddataCpuUtilizationAnalyser(BaseAnalyser):
op_info_dict["metrics"] = dict() op_info_dict["metrics"] = dict()
for key in item.get("metrics").keys(): for key in item.get("metrics").keys():
arr = item.get("metrics")[key] arr = item.get("metrics")[key]
avg_value = round(sum(arr) / len(arr))
avg_value = round(sum(arr) / len(arr)) if arr else 0
op_info_dict["metrics"][key] = {"metrics": arr, "avg_value": avg_value} op_info_dict["metrics"][key] = {"metrics": arr, "avg_value": avg_value}
result["op_info"]["total_op_avg_value"][key] += avg_value result["op_info"]["total_op_avg_value"][key] += avg_value
op_info_dict["op_id"] = item.get("op_id") op_info_dict["op_id"] = item.get("op_id")
@@ -161,11 +161,10 @@ class MinddataCpuUtilizationAnalyser(BaseAnalyser):
# queue_step_time_info[][0]:step_num # queue_step_time_info[][0]:step_num
# queue_step_time_info[][1]:sample time # queue_step_time_info[][1]:sample time
if float(item) <= float(queue_step_time_info[right_index][1]): if float(item) <= float(queue_step_time_info[right_index][1]):
if float(item) < (float(queue_step_time_info[left_index][1])) \
+ float(queue_step_time_info[right_index][1]) / 2:
steps_info.append(queue_step_time_info[right_index][0])
else:
if float(item) < float(queue_step_time_info[right_index][1]):
steps_info.append(queue_step_time_info[left_index][0]) steps_info.append(queue_step_time_info[left_index][0])
else:
steps_info.append(queue_step_time_info[right_index][0])
break break
left_index = right_index left_index = right_index
right_index += 1 right_index += 1


+ 7
- 0
mindinsight/profiler/proposer/allproposers/minddata_proposer.py View File

@@ -13,6 +13,8 @@
# limitations under the License. # limitations under the License.
# ============================================================================ # ============================================================================
"""The minddata proposer.""" """The minddata proposer."""
import os
from collections import OrderedDict from collections import OrderedDict
from mindinsight.profiler.analyser.analyser_factory import AnalyserFactory from mindinsight.profiler.analyser.analyser_factory import AnalyserFactory
@@ -86,6 +88,11 @@ class MinddataProposer(Proposer):
def minddata_cpu_utilization_proposal(self): def minddata_cpu_utilization_proposal(self):
"""Get the proposals of minddata cpu utilization""" """Get the proposals of minddata cpu utilization"""
filename = "minddata_cpu_utilization_{}.json".format(self.device_id)
file_path = os.path.join(self.profiling_path, filename)
# Forward compatibility, it is reasonable that the file does not exist.
if not os.path.exists(file_path):
return
minddata_cpu_utilization = OrderedDict() minddata_cpu_utilization = OrderedDict()
minddata_cpu_utilization_analyser = AnalyserFactory.instance().get_analyser( minddata_cpu_utilization_analyser = AnalyserFactory.instance().get_analyser(
'minddata_cpu_utilization', self.profiling_path, self.device_id) 'minddata_cpu_utilization', self.profiling_path, self.device_id)


Loading…
Cancel
Save