Profiling AscendCL API for Extension(Profiling AscendCL API扩展接口)
为了获取用户和上层框架程序的性能数据,Profiling开启msproftx功能之前,需要在程序内调用msproftx相关接口(Profiling AscendCL API扩展接口)对用户程序进行打点以输出对应的性能数据。调用接口如Profiling AscendCL API扩展接口所示,调用示例如Profiling AscendCL API扩展接口调用示例所示。
Profiling AscendCL API扩展接口
接口 |
说明 |
---|---|
aclprofCreateStamp |
创建msproftx事件标记,用于描述瞬时事件。 |
aclprofDestroyStamp |
释放msproftx事件标记。 |
aclprofSetStampTraceMessage |
为msproftx事件标记携带描述信息,在Profiling解析结果中msprof_tx summary数据展示。 |
aclprofMark |
msproftx标记瞬时事件。 |
aclprofPush |
msproftx用于记录事件发生的时间跨度的开始时间。与aclprofPop成对使用,仅能在单线程内使用。 |
aclprofPop |
msproftx用于记录事件发生的时间跨度的结束时间。与aclprofPush成对使用,仅能在单线程内使用。 |
aclprofRangeStart |
msproftx用于记录事件发生的时间跨度的开始时间。与aclprofRangeStop成对使用,可跨线程使用。 |
aclprofRangeStop |
msproftx用于记录事件发生的时间跨度的结束时间。与aclprofRangeStop成对使用,可跨线程使用。 |

- Profiling AscendCL API扩展接口在main函数内调用,具体应用进程编程框架示例请参见《应用软件开发指南 (C&C++)》手册下的“Profiling性能数据采集>Profiling AscendCL API for Extension示例代码”。
- Profiling AscendCL API扩展接口详细介绍请参见《应用软件开发指南 (C&C++)》“AscendCL API参考”章节下“Profiling数据采集>Profiling AscendCL API for Extension(Profiling AscendCL API扩展接口)”。
- 当只开启msproftx功能时,aclCreateProfConfig接口的deviceIdList参数值需设为空,deviceNums参数值设为0。
Profiling AscendCL API扩展接口调用示例
Profiling msproftx接口,示例如下加粗部分代码:
for (int i = 0; i < 200000; ++i) { g_stamp = aclprofCreateStamp(); if (g_stamp == nullptr) { printf("[ERROR] Stamp is nullptr"); return FAILED; } std::string mesg = "test msprof tx"; aclprofSetStampTraceMessage(g_stamp, mesg.c_str(), mesg.size()); aclprofMark(g_stamp); aclprofDestroyStamp(g_stamp); }
或
for (int i = 0; i < 200000; ++i) { g_stamp = aclprofCreateStamp(); if (g_stamp == nullptr) { printf("[ERROR] Stamp is nullptr"); return FAILED; } std::string mesg = "test msprof tx"; aclprofSetStampTraceMessage(g_stamp, mesg.c_str(), mesg.size()); // aclprofPush和aclprofPop接口配对使用,完成单进程采集 aclprofPush(g_stamp); aclprofPop(); aclprofDestroyStamp(g_stamp); }
或
for (int i = 0; i < 200000; ++i) { g_stamp = aclprofCreateStamp(); if (g_stamp == nullptr) { printf("[ERROR] Stamp is nullptr"); return FAILED; } std::string mesg = "test msprof tx"; aclprofSetStampTraceMessage(g_stamp, mesg.c_str(), mesg.size()); // aclprofRangeStart和aclprofRangeStop接口配对使用,可以完成多进程采集 uint32_t rangeId = 0; aclprofRangeStart(stamp, &rangeId); aclprofRangeStop(rangeId); aclprofDestroyStamp(g_stamp); }