文档
注册

Profiling AscendCL API(通过Profiling AscendCL API采集并落盘性能数据)

通过调用AscendCL API方式使能Profiling功能,从而自动采集性能原始数据。采集性能原始数据成功后,可将采集的原始数据拷贝到装有Ascend-cann-toolkit开发套件包的开发环境上进行性能原始数据解析,可视化展示性能原始数据解析结果。

调用接口如Profiling AscendCL API所示,调用示例如Profiling AscendCL API调用示例所示。

Profiling AscendCL API

表1 Profiling AscendCL API

接口

说明

aclprofCreateConfig

创建Profiling配置。与aclprofDestroyConfig成对使用。

aclprofInit

初始化Profiling,目前用于设置保存性能数据的文件的路径。与aclprofFinalize成对使用。

aclprofSetConfig

aclprofCreateConfig的扩展接口,用于设置采集配置参数。

aclprofStart

下发Profiling请求,使能对应数据的采集。与aclprofStop成对使用。

aclprofStop

停止Profiling数据采集。与aclprofStart成对使用。

aclprofFinalize

结束Profiling。与aclprofInit成对使用。

aclprofDestroyConfig

销毁通过aclprofCreateConfig接口创建的aclprofConfig类型的数据。与aclprofCreateConfig成对使用。

aclprofInit接口传入的Profiling性能采集数据的落盘路径,需要确保用户进程具有读写权限。

Profiling AscendCL API详细介绍请参见Profiling AscendCL API(通过Profiling AscendCL API采集并落盘性能数据)

Profiling AscendCL API调用示例

Profiling AscendCL API,示例如下:

 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
40
//1.AscendCL初始化

//2.申请运行管理资源,包括设置用于计算的Device、创建Context、创建Stream
ret = aclrtCreateStream(&stream_);

//3.Profiling初始化
//设置数据落盘路径
const char *aclProfPath = "...";
aclprofInit(aclProfPath, strlen(aclProfPath));

//4.进行Profiling配置
uint32_t deviceIdList[1] = {0};
//创建配置结构体
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.模型加载,加载成功后,返回标识模型的modelId

//6.创建aclmdlDataset类型的数据,用于描述模型的输入数据input、输出数据output
 
//7.执行模型
ret = aclmdlExecute(modelId, input, output);

//8.处理模型推理结果

//9.释放描述模型输入/输出信息、内存等资源,卸载模型


//10.关闭Profiling配置, 释放配置资源, 释放Profiling组件资源
aclprofStop(config);
aclprofDestroyConfig(config);
aclprofFinalize();

//11.释放运行管理资源

//12. AscendCL去初始化
//......
上述Profiling AscendCL API调用示例中接口的配置参数取值参考以下,请根据实际情况选择需要的采集参数。
  • aclprofCreateConfig接口:
    1
    ACL_PROF_ACL_API | ACL_PROF_TASK_TIME | ACL_PROF_AICORE_METRICS | ACL_PROF_AICPU | ACL_PROF_L2CACHE | ACL_PROF_HCCL_TRACE | ACL_PROF_MSPROFTX | ACL_PROF_RUNTIME_API
    

    参数详细介绍请参见aclprofCreateConfig章节的dataTypeConfig参数说明。

  • aclprofSetConfig接口:
    1
    ACL_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
    

    参数详细介绍请参见aclprofSetConfig章节的configType参数说明。

搜索结果
找到“0”个结果

当前产品无相关内容

未找到相关内容,请尝试其他搜索词