Hi :)
Can I use ‘printf’ or something in OpenACC kernel region?
I faced some trouble with my OpenACC code.
It is making wrong result, but I don’t know how to debug OpenACC kernel region.
I have to debug the code, so I want to show variable values when the kernel is running on GPU.
I tried cuda-gdb, Nsight(from CUDA toolkit), but failed to show values.
How can I show and debug OpenACC code?
Can I use ‘printf’ or something in OpenACC kernel region?
Yes, but… printing is un-formatted and buffered so if often difficult to use.
The commercial debuggers TotalView and Allinea DDT support OpenACC debugging. Cuda-gdb has limited support but should be considered more experimental and does not always correlate the original source code to the generated device code (especially with Fortran).
Also, debugging OpenACC device code can be difficult given the extent the code has been transformed. It’s akin to debugging highly optimized assembly code on the CPU.
If you are just checking intermediary values, the best method that I’ve found is to create a temporary array, one element per thread, store the values to this array, then print the array from the host.
Hope this helps,
Mat