Profiling of C Code - 2022.2 English

Vitis Unified Software Platform Documentation: Application Acceleration Development (UG1393)

Document ID
UG1393
Release Date
2022-12-07
Version
2022.2 English

For C code the provided functions are:

xrtURStart()
This function establishes the start time of a measured range of activity with the specified ID. The function signature is:
void xrtURStart(unsigned int id, const char* label, const char* tooltip)
xrtUREnd()
This function marks the end time of a measured range with the specified ID. The function signature is:
void xrtUREnd(unsigned int id) 
xrtUEMark()
This function marks an event occurring at single point in time, adding the specified label onto the timeline trace. The function signature is:
void xrtUEMark(const char* label) 

Use the xrtURStart() and xrtUREnd() functions to start keeping track of time immediately, and specify an ID to pair the start/end calls and define the user range. Usage details of the user_range functions:

  • Start/End ranges of one ID can be nested inside other Start/End ranges of a different ID.
  • It is your responsibility to make sure the IDs match for the Start/End range you are profiling.
    Important: Multiple calls to xrtURStart and xrtUREnd with the same ID can cause unexpected behavior.
  • The user range can have a label that is added to the timeline, and a tooltip that is displayed when you place the cursor over the user range.

A call to xrtUEMark() will create a user marker on the timeline trace at the point of the event.

  • xrtUEMark() lets you specify a label for the event. The label will appear on the timeline with the mark.
  • You can use NULL for the label to add an unlabeled mark.

The following is example code:

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