llvm icon indicating copy to clipboard operation
llvm copied to clipboard

SYCL stream print nothing when kernel is in endless loop

Open CaoZhongZ opened this issue 1 year ago • 1 comments

How to flush the content in realtime?

CaoZhongZ avatar Feb 16 '24 03:02 CaoZhongZ

@CaoZhongZ hi, could you please provide a bit more context, like code snippet, command to compile, may be some environment info and so on.

KornevNikita avatar Feb 16 '24 12:02 KornevNikita

How to flush the content in realtime?

@CaoZhongZ, I'm afraid that we currently don't have such functionality.

sycl::stream is designed by the spec to be backend-independent, i.e. it is merely a char buffer for which you automatically have an accessor and fill it through operator<<. The actual printing happens on the host, once kernel is complete and the data is available there.

We have a non-standard undocumented extension of exposing OpenCL C printf function in our implementation, which can be used in kernels: https://github.com/intel/llvm/blob/5a92a19f0e4e4535560a2f6190d774d1b8e19fc5/sycl/include/sycl/ext/oneapi/experimental/builtins.hpp#L38

Please note that this is not a C99 printf and it has its quirks around format string. I can't guarantee that it will work in an endless loop kernel, but there is at least a chance for that, depending on the backend implementation, whilst there are no chances for that with sycl::stream.

AlexeySachkov avatar Feb 23 '24 09:02 AlexeySachkov

Thanks! I'll try backend specific implementation.

CaoZhongZ avatar Feb 24 '24 10:02 CaoZhongZ