Using Ascend Graph APIs for Data Profiling
Ascend Graph APIs are used to collect profile data during graph construction.
The --task-trace option will be discarded in later versions. Use --task-time instead.
Applicability
Atlas 350 Accelerator Card
Enabling Modes
Method |
API |
|---|---|
Pass options through the GEInitialize API. |
You can pass ge.exec.profilingOptions through the GEInitialize API to profile iteration trace data. The passed fields include training_trace, bp_point, and fp_point. This method saves profile data to the path set in the output parameter of ge.exec.profilingOptions. |
aclgrph APIs |
This method saves profile data to the path set in the profiler_path parameter of aclgrphProfInit. |
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 data collection, parse the raw data and export the parsing results as visualized timeline and summary files. For details, see Using the msprof Command to Parse, Query, and Export the Profile Data.