Collecting and Flushing Profile Data
You can call APIs to enable automatic collection of raw profile data. After the raw profile data is collected, copy the collected data to the development environment with the tool installed for data parsing, and visualize the parsing results of raw profile data.
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 profile data collection. 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 API call example is as follows:
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 39 | // 1. Call aclInit for initialization. // 2. Allocate runtime resources, including setting the compute device and creating a context and a stream. // 3. Initialize profiling. // Set the data flush path. If aclprofInit is not called to set the flush path, call aclprofSetConfig instead. 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 structure. 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)); // ret = aclprofSetConfig(ACL_PROF_PATH, aclProfPath, strlen(aclProfPath)); aclprofStart(config); // 5. Load the 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 the model. // 7. Execute the model. ret = aclmdlExecute(modelId, input, output); // 8. Process the model inference result. // 9. Destroy allocations such as the model inputs and outputs, 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 for deinitialization. //...... |
