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 the following technique.
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 to observe printf() outputs. The x86 simulator enables printf calls by default—no additional options are
required. This default behavior is one of the benefits of the x86 simulator.
Important:
AMD 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.