MPI C fprintf() output not showing up if the process hangs on MPI_Recv
I'm writing an MPI C program. I have troubles debugging it, because whenever I use fprintf, like this: fprintf(stdout, "worker: %d", worker); if the program hangs, because of so开发者_如何学Gome blocking MPI_Recv, I can't see any output. I'm sure the line of code is reached, because I can put a return statement after the fprintf statement, in which case the process finishes execution and the output is printed. Any ideas, on how to print (see the output) even though the process gets blocked later by Recv? I hope this makes sense.
By default, stdout
is line buffered, so you may want to end your debugging print calls with newlines:
fprintf(stdout, "workder: %d\n", worker);
If you don't want a newline, you can flush the stream yourself:
fprintf(stdout, "workder: %d", worker);
fflush(stdout);
精彩评论