Cuda 8.0 - Simple question regarding the use of printf from kernel.

Hello,

I’m relatively new to CUDA having written a few kernels over the past 6-8 weeks. I am running ubuntu 16.04 with CUDA 8.0 and drivers 375.39.

Up until today I could use printf to debug / report values as calculated by a kernel and displayed through a terminal window. The results would print as the kernel code executed; perfect for debugging.

Today (April 2 2017) I have discovered that printf is only printing dynamically when a cudaDeviceSynchronize(); method is called after the relevant kernel. When not called printf displays no results.

Is this normal or has something changed? I couldn’t find this in a release note.

It’s normal, if there is no host synchronizing activity in your application before app termination.

Kernel calls are asynchronous, which means control is returned to the calling (CPU) thread before the kernel completes. If the application terminates shortly thereafter, then the kernel will have no opportunity to print.

Thank you!