对于 C 语言代码,提供的函数包括:
-
xrtURStart()
- 此函数用于确定含指定 ID 的活动的测量范围的开始时间。函数特征符为:
void xrtURStart(unsigned int id, const char* label, const char* tooltip)
-
xrtUREnd()
- 此函数用于标记含指定 ID 的活动的测量范围的结束时间。函数特征符为:
void xrtUREnd(unsigned int id)
-
xrtUEMark()
- 此函数用于标记在单一时间点发生的事件,并在时间线轨迹上添加指定标签。函数特征符为:
void xrtUEMark(const char* label)
xrtURStart()
和 xrtUREnd()
函数可用于立即开始记录时间、指定 ID 以与开始/结束调用配对,并定义用户范围。user_range
函数的使用详情:
- 任一 ID 的开始/结束范围都可嵌套在其他 ID 的其他开始/结束范围内。
- 您自行负责确保您要剖析的开始/结束范围的各 ID 匹配。 重要: 使用同一个 ID 多次调用
xrtURStart
和xrtUREnd
可能导致出现意外行为。 - 在时间线上可以为用户范围添加一个标签,当您将光标置于此用户范围上时,可显示工具提示。
调用 xrtUEMark()
将在时间线轨迹上事件发生的时间点创建一个用户标记。
-
xrtUEMark()
允许您为该事件指定标签。此标签将随标记一起显示在时间线上。 - 您可以为此标签使用
NULL
来添加无标签的标记。
代码示例如下所示:
int main(int argc, char* argv[]) {
58
59 xrtURStart(0, "Software execution", "Whole program execution") ;
60 ...
61 //TARGET_DEVICE macro needs to be passed from gcc command line
62 if(argc != 2) {
63 std::cout << "Usage: " << argv[0] <<" <xclbin>" << std::endl;
64 return EXIT_FAILURE;
65 }
....
153 q.enqueueTask(krnl_vector_add);
154
155 // The result of the previous kernel execution will need to be retrieved in
156 // order to view the results. This call will transfer the data from FPGA to
157 // source_results vector
158 q.enqueueMigrateMemObjects({buffer_result},CL_MIGRATE_MEM_OBJECT_HOST);
159 ····
160 q.finish();
161
162 xrtUEMark("Starting verification") ;
163