Collecting and Flushing Profile Data
You can call APIs to enable automatic collection of raw profile data. After the raw profile data is successfully collected, you can copy it to a development environment where the CANN Toolkit package and ops operator package are installed to parse the data, and view the visualized parsing results.
API Overview
|
API |
Description |
|---|---|
|
aclprofCreateConfig |
Creates a profiling configuration. This API is used together with aclprofDestroyConfig. |
|
aclprofInit |
Initializes profiling and sets the path for saving profile data files. This API is used together with aclprofFinalize. |
|
aclprofSetConfig |
Functions as an extended API of aclprofCreateConfig and is used to configure collection parameters. |
|
aclprofStart |
Starts profiling. This API is used together with aclprofStop. |
|
aclprofStop |
Stops profiling. This API is used together with aclprofStart. |
|
aclprofFinalize |
Finalizes profiling. This API is used together with aclprofInit. |
|
aclprofDestroyConfig |
Destroys data of the aclprofConfig type created by the aclprofCreateConfig API call. This API is used together with aclprofCreateConfig. |
API Call Examples
The following are examples of API calls:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
// 1. Call aclInit to initialize. // 2. Allocate runtime resources, including setting the compute device and creating a context and a stream. // 3. Initialize profiling. // Set the data flush path. const char *aclProfPath = "./output"; aclprofInit(aclProfPath, strlen(aclProfPath)); // 4. Configure profiling. uint32_t deviceIdList[1] = {0}; // Set this parameter based on the device ID in the actual environment. // Create a configuration struct. aclprofConfig *config = aclprofCreateConfig(deviceIdList, 1, ACL_AICORE_ARITHMETIC_UTILIZATION, nullptr,ACL_PROF_ACL_API | ACL_PROF_TASK_TIME); const char *memFreq = "15"; ret = aclprofSetConfig(ACL_PROF_SYS_HARDWARE_MEM_FREQ, memFreq, strlen(memFreq)); aclprofStart(config); // 5. Load your model. After the model is successfully loaded, modelId that identifies the model is returned. // 6. Create data of type aclmdlDataset to describe the inputs and outputs of your model. // 7. Execute your model. ret = aclmdlExecute(modelId, input, output); // 8. Process the model inference result. // 9. Destroy the model input and output descriptions, free memory, and unload the model. // 10. Stop profiling and destroy the configuration and related resources. aclprofStop(config); aclprofDestroyConfig(config); aclprofFinalize(); // 11. Destroy runtime allocations. // 12. Call aclFinalize to deinitialize. //...... |
- aclprofCreateConfig:
1ACL_PROF_ACL_API | ACL_PROF_TASK_TIME | ACL_PROF_OP_ATTR | ACL_PROF_AICORE_METRICS | ACL_PROF_AICPU | ACL_PROF_L2CACHE | ACL_PROF_HCCL_TRACE | ACL_PROF_MSPROFTX | ACL_PROF_RUNTIME_API | ACL_PROF_TASK_MEMORY | ACL_PROF_TRAINING_TRACE
For details about the parameters, see the dataTypeConfig description of the aclprofCreateConfig API.
- aclprofSetConfig:
1ACL_PROF_STORAGE_LIMIT | ACL_PROF_SYS_HARDWARE_MEM_FREQ | ACL_PROF_LLC_MODE | ACL_PROF_SYS_IO_FREQ | ACL_PROF_SYS_INTERCONNECTION_FREQ | ACL_PROF_DVPP_FREQ | ACL_PROF_HOST_SYS | ACL_PROF_HOST_SYS_USAGE | ACL_PROF_HOST_SYS_USAGE_FREQ
For details about the parameters, see the configType description of the "aclprofSetConfig" API.