简体   繁体   中英

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 some 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);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM