cancel
Showing results for 
Search instead for 
Did you mean: 

Archives Discussions

divot_powell
Journeyman III

Incorrect StdOut/printf behaviour when using opencl and command line pipes

I have noticed some odd behaviour when using openCL. After using any openCL function, say clGetPlatformIDs, StdOut no longer automatically flushes itself when the program exits. This is most apparent when piping stdout between programs in linux (fedora, ubuntu and suse tested) as any data written to stdout does not make it to the other file or program.

Has anyone else noticed this? Is there a solution?

Note: This is using printf inside normal cpu code, not inside an opencl kernel.

0 Likes
4 Replies
corry
Adept III

Just in case this isn't obvious, and I don't mean to insult your intelligence, or anyone elses, as a workaround, you could just fflush(stdout); right before exiting.  stdout is defined as a FILE*, so fflush will work just fine with it...

As for the problem itself....got me 😕

0 Likes

Thanks. Using fflush was how I actually pinned down what was going on. It's a workaround definitely, but not ideal.

0 Likes
arsenm
Adept III

Strange things do seem to happen to stdout, but fflush mostly solves them for me.

0 Likes

divot_powell/arsenm,
We ran into this problem recently and are working on a solution.
0 Likes