The simplest form of tracing is to use a formatted
printf() statement in the code for printing debug messages. Visual inspection of intermediate values and addresses can help you understand the progress of program execution. No additional include files are necessary for using
printf() other than standard C/C++ includes (
stdio.h). You can add
printf() statements to your code to be processed during the aiesimulation or hardware emulation, and remove them or comment them out for hardware builds.
Open the source file,
src/kernels/upscale.cc. Add the following lines after
in_t = *IniIter++;:
float * print_ptr = (float*)&in_t; for(int pp=0;pp<16;pp++) printf("Iteration-%d -> Vector-%d -> value = %f\n",i,pp,print_ptr[pp]);
printf()statements to your AI Engine kernel code will increase the compiled size of the AI Engine program. Be careful that the compiled size of your kernel code does not exceed the per-AI Engine processor memory limit of 16 KB.
Rebuild the AI Engine component.
To enable the
printf()function, it is required to enable profile option in launch configuration settings. To do this, hover your mouse over the Run option in the Flow navigator and click on the settings button. Now, in the launch configuration window, tick the Enable Profile option under Profile Options as shown below.
Observe the following
Configuring PL-Interface for graph mygraph... Set iterations for the core(s) of graph mygraph Enabling core(s) of graph mygraph Waiting for core(s) of graph mygraph to finish execution ... Iteration-0 -> Vector-0 -> value = 0.000000 Iteration-0 -> Vector-1 -> value = 0.000000 ... ... Iteration-0 -> Vector-13 -> value = 0.000000 Iteration-0 -> Vector-14 -> value = 0.000000 Iteration-0 -> Vector-15 -> value = 0.000000 Iteration-1 -> Vector-0 -> value = 0.000000 Iteration-1 -> Vector-1 -> value = 3.141500 Iteration-1 -> Vector-2 -> value = 6.283000
Revert the changes in the source file to exercise other debug features.