Profile Data Collection with Ascend Graph APIs
Ascend Graph APIs are used to collect profile data during graph construction.
Availability
Enabling Modes
Raw Performance Data Profiling (Passing Options Through the GEInitialize API)
The following is an example of using GEInitialize to pass required option arguments:
// 0. System init
std::map<AscendString, AscendString> config = {{"ge.exec.deviceId", "0"},
{"ge.graphRunMode", "1"},
{"ge.exec.precision_mode", "allow_fp32_to_fp16"},
{"ge.exec.profilingMode", "1"},
{"ge.exec.profilingOptions", R"({"output":"/tmp/profiling","training_trace":"on","fp_point":"","bp_point":""})"}};
Status ret = ge::GEInitialize(config);
if (ret != SUCCESS) {
return FAILED;
}
Raw Performance Data Profiling (aclgrph APIs)
This following is an example of calling APIs to collect profile data:
// Construct a graph. The details are omitted here.
// ......
// init ge
std::map<std::string, std::string> ge_options = {{"ge.socVersion", "Ascendxxx"}, {"ge.graphRunMode", "1"}};
ge::GEInitialize(ge_options);
std::string profilerResultPath = "/home/test/prof"; // Create the path in advance.
uint32_t length = strlen("/home/test/prof");
ret = ge::aclgrphProfInit(profilerResultPath.c_str(), length);
std::map<string, string> options = {{"a", "b"}, {"c", "d"}};
uint32_t graphId = 0;
ge::Session *session = new Session(options);
ret = session->AddGraph(graphId, graph);
uint32_t deviceid_list[1] = {0};
uint32_t device_nums = 1;
uint64_t data_type_config = ProfDataTypeConfig::kProfTaskTime | ProfDataTypeConfig::kProfAiCoreMetrics | ProfDataTypeConfig::kProfAicpu | ProfDataTypeConfig::kProfTrainingTrace;
ProfAicoreEvents *aicore_events = NULL;
ProfilingAicoreMetrics aicore_metrics = ProfilingAicoreMetrics::kAicoreArithmeticUtilization;
ge::aclgrphProfConfig *pro_config = ge::aclgrphProfCreateConfig(deviceid_list, device_nums, aicore_metrics, aicore_events, data_type_config);
ge::aclgrphProfStart(pro_config);
session->RunGraph(graphId, inputs_r, outputs_r);
ge::aclgrphProfStop(pro_config);
ge::aclgrphProfDestroyConfig(pro_config);
ge::aclgrphProfFinalize();
delete session;
ge::GEFinalize();
Data Collection Description
After the Ascend Graph API method is configured for data collection, parse the raw data and export the parsing results as visualized timeline and summary files. For details, see Profile Data Parsing and Export (msprof Command). The following table shows the generated profile data.
Argument |
Profile Data File |
|---|---|
Automatically generated by default |
Ascend Hardware level in msprof_*.json |
task_time, task_trace |
The CANN level in msprof_*.json and the api_statistic_*.csv file The CANN level in msprof_*.json and the api_statistic_*.csv file |
runtime_api |
The CANN_Runtime level in msprof_*.json and the api_statistic_*.csv file |
hccl |
The HCCL level in msprof_*.json and the hccl_statistic_*.csv file |
aicpu |
|
host_sys_usage |
CPU usage of processes on the host |
Argument |
Profile Data File |
|---|---|
kProfTaskTime |
The CANN level in msprof_*.json and the api_statistic_*.csv file The Ascend Hardware level in msprof_*.json and the task_time_*.csv file The HCCL level in msprof_*.json and the hccl_statistic_*.csv file |
kProfHccl |
The HCCL level in msprof_*.json and the hccl_statistic_*.csv file |
kProfAicpu |
|
kProfL2cache |
|
Automatically generated by default |
CPU usage of processes on the host |