MPI - Printing in an order

后端 未结 5 1273
臣服心动
臣服心动 2020-12-03 20:12

I\'m trying to write a function in C where every processor prints it\'s own data. Here is what i have:

void print_mesh(int p,int myid,int** U0,int X,int Y){
         


        
5条回答
  •  借酒劲吻你
    2020-12-03 20:54

    The MPI standard doesn't specify how stdout from different nodes should be collected and fflush doesn't help.

    If you need to print big outputs in order, probably the best solution is not to gather them all and print at once, because this will generate traffic over the network. A better solution is to create something similar to a virtual ring where each process waits a token from the previous process, prints and sends the token to the next one. Of course the first process doesn't have to wait, it prints and send to the next one.

    Anyway in case of really big output, where probably there is no sense to print outputs on video, you should use MPI-IO as suggested by Jonathan Dursi.

提交回复
热议问题