Using Ascend Graph APIs for Data Profiling
Ascend Graph APIs are used to collect profile data during graph construction.
Availability
Atlas Inference Series Product
Atlas Training Series Product
Atlas A2 Training Series Product/Atlas 800I A2 Inference Product
Atlas A3 Training Series Product
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();
Profiling Description
After the Ascend Graph API method is configured for profiling, parse the raw data and export the parsing results as visualized timeline and summary files. For details, see Offline Parsing. The following table shows the generated profile data.
|
Argument |
Profile Data File |
|---|---|
|
Automatically generated by default |
The Ascend Hardware layer in msprof_*.json |
|
task_time, task_trace |
The CANN layer in msprof_*.json and the api_statistic_*.csv file The Communication layer in msprof_*.json and the communication_statistic_*.csv file |
|
runtime_api |
The CANN_Runtime layer in msprof_*.json and the api_statistic_*.csv file |
|
hccl |
The Communication layer in msprof_*.json and the communication_statistic_*.csv file |
|
aicpu |
|
|
host_sys_usage |
CPU usage of processes on the host |
|
Argument |
Profile Data File |
|---|---|
|
kProfTaskTime |
The CANN layer in msprof_*.json and the api_statistic_*.csv file The Ascend Hardware layer in msprof_*.json and the task_time_*.csv file The Communication layer in msprof_*.json and the communication_statistic_*.csv file |
|
kProfHccl |
The Communication layer in msprof_*.json and the communication_statistic_*.csv file |
|
kProfAicpu |
|
|
kProfL2cache |
|
|
Automatically generated by default |
CPU usage of processes on the host |