Overview

This section provides the following methods to implement profile data collection by using AscendCL API calls in offline inference scenarios:

Table 1 AscendCL API collection

Collection Mode

Description

Call

Profiling AscendCL APIs (collecting and flushing profile data)

Write the collected profile data to a file, parse the file by using the msprof tool, and display the profile data analysis result.

Call aclprofInit, aclprofFinalize, aclprofSetConfig, aclprofStart, aclprofStop, aclprofCreateConfig, and aclprofDestroyConfig in conjunction to collect profile data. You can obtain the AscendCL API profile data, time taken to execute AI Core operators, as well as AI Core metrics.

Profiling AscendCL APIs for Extension (extension APIs)

To locate the performance bottleneck of your application or the upper-layer framework program, call the Profiling pyACL APIs for Extension during the profiling process (between the acl.prof.start and acl.prof.stop calls). The extension APIs together achieve the function of msproftx APIs, which record the time span of specific events during application running and write data to a profile data file. You can use the msprof tool to parse the file and export and display the result.

Call the aclprofCreateStamp, aclprofSetStampTraceMessage, aclprofMark, aclprofPush, aclprofPop, aclprofRangeStart, aclprofRangeStop, and aclprofDestroyStamp APIs between aclprofStart and aclprofStop to obtain the events that occur at specific time during application execution and record the time span of the events.

Profiling AscendCL APIs for Subscription (subscription to operator information)

Parse the collected profile data and write it to a pipeline. Then, users read the data to the memory and call AscendCL APIs to obtain it.

This method is implemented by calls to the following APIs: aclprofModelSubscribe, aclprofGet*, and aclprofModelUnSubscribe. The profile data of each operator in the model can be obtained, including the operator name, operator type name, and operator execution time.

Profiling AscendCL APIs (setting iteration time)

Set the start and end timestamps of an iteration, to display the profile data parsing result by iteration.

Call aclprofGetStepTimestamp, aclprofCreateStepInfo, and aclprofDestroyStepInfo in conjunction to collect profile data.

Note:

For details about the APIs, see Profiling Data Collection.

  • Before using the Profiling AscendCL APIs to collect profile data, you need to develop, build, and run an application project. For details, see the CANN AscendCL Application Software Development Guide (C&C++).
  • The Profiling AscendCL APIs and Profiling AscendCL APIs for Extension cannot be called together with the Profiling AscendCL APIs for Subscription.