SDSoC Event Tracing from Console

Although Xilinx has not documented it, it is possible to collect event traces from the console. The generated traces can then be imported and viewed in SDSoC. This can come in handy when you have automated the build process, and you would like to find out how much time is spend in the accelerator(s) and how much in communication overhead. Following is an explanation of how I collected traces for a Linux application running on a ZCU102 board with SDSoC 2019.1.

We start with adding support for tracing to the hardware. To insert tracing hardware, we add the -trace option to the sdscc or sds++ command. Typically, these commands are invoked from a makefile, such as the one generated by SDSoC GUI in the Debug or Release subdirectory of the project.

Next, we build and run the application as usual. During this run, the application will collect a trace. To collect the trace, we invoke the xsct interpreter, which should be part of the SDSoC installation. Enter the following TCL command to connect to the hardware server daemon:

set conn [connect -new -host 127.0.0.1]

Here, I assume that it is running at the local host. If this doesn’t work, you probably haven’t installed the drivers. Next, we load the trace scripts:

source <Directory>/_sds/trace/sdsoc_trace.tcl

For a project generated by the SDSoC GUI, <Directory> is the Debug or Release subdirectory of the project. Now, we have to select the target from which the trace will be collected:

targets -set -filter {name =~"*Debug Module at*"} -index 0

If you have more boards connected to your host, you will probably have to use a more elaborate filter. Now, it is time to retrieve the traces:

exportTraces <Directory>

Here, <Directory> is where we want to store the traces. Finally, we close the connection to the daemon:

disconnect $conn

At this point, an archive with a name of the form archive_<Date>.zip should be stored in the directory that was provided to exportTraces earlier. You may get warnings that your trace buffer overflowed, such as this:

ERROR! Trace error from target!
         Buffer overflow, end of application unknown!

Note that this error may be anywhere in the output. You can increase your trace buffer with the -trace-buffer option to sdscc or sds++. Unfortunately, that requires rebuilding the hardware. Moreover, a larger buffer leaves less room for other hardware.

Start the SDSoC GUI and create a new workspace. Select File -> Import… from the menu. Choose Trace Package Import, which should be in the Tracing category. Click on Browse…, and locate the created archive. Press OK and Finish to open it. The archive should now be part of the project. Locate it in the Project Explorer under Traces in the current project, and double-click to open it. The trace should now be visible in the AXI State View, which is typically in the bottom right of the window.

I prefer to clean the trace buffer before starting the application. This can be done with the following TCL code:

set addr [expr 0x$mdmAddr + 8]
set cnt [getCount $mdmAddr]
while {$cnt > 0} {
  mrd $addr $cnt
  set cnt [getCount $mdmAddr]
}