Using printf() in Kernels - 2022.1 English

Versal ACAP AI Engine Programming Environment User Guide (UG1076)

Document ID
UG1076
Release Date
2022-05-25
Version
2022.1 English

Vector data types are the most commonly used types in AI Engine kernel code. To debug vector operations within a kernel it is helpful to use printf.

Using printf() with Vector Data Types

To printf() the native vector types you can use a technique as follows.

v4cint16 input_vector;
...
int16_t* print_ptr =(int16_t*)&input_vector;
    for (int qq=0; qq<4;qq++) //4 here so we print two int16s, real + imag per loop.
    printf("vector re: %d, im: %d\r\n",print_ptr[2*qq],print_ptr[2*qq+1]);
}

With the AI Engine simulator the --profile option is required in order to observe printf() outputs. With the x86 simulator no additional options are needed to enable printf calls. This is one of the benefits of the x86 simulator.

Important: Xilinx recommends avoiding std::cout in kernel and host code. If std::cout is used its outputs can appear interleaved, given the multi-threaded nature of the x86 simulator. Using printf() is recommended instead.