MPI GRAPH:向邻居发送消息,除了它来自

时间:2015-10-09 23:09:40

标签: c++ parallel-processing mpi distributed openmpi

我在这里有一个有趣的情况。我试图让图中的节点向其所有邻居发送消息,除了它的父节点(刚刚发送消息的节点)。我的代码似乎表明这个特定节点(n)确实接收来自其所有邻居的消息(正确)。问题是发送,只有收到的第一条消息被发送。所有其他人都被忽略了 NB:这是一个星型拓扑,所有其他节点都发送到中心节点0 以下是示例输出: -

  0    received  1 from 1
  0    received  2 from 2
  0    received  3 from 3
  0    received  4 from 4
  0    received  5 from 5
  0    received  6 from 6


  Having correctly  received these values, node zero(0 ) is expected to send each message to all others in the following pattern  i.e. :-

      0 sent   1 to 2
      0 sent   1 to 3
      0 sent   1 to 4
      0 sent   1 to 5
      0 sent   1 to 6

   , 
      0 sent   2 to 1
      0 sent   2 to 3
      0 sent   2 to 4
      0 sent   2 to 5
      0 sent   2 to 6
    ,
      0 sent   3 to 2
      0 sent   3 to 1
      0 sent   3 to 4
      0 sent   3 to 5
      0 sent   3 to 6

, etc .

我很遗憾,否则,只有第一条消息被发送到其他节点,其余节点被忽略。如果1首先收到0,我只得到以下输出: -

  0 sent   1 to 2
  0 sent   1 to 3
  0 sent   1 to 4
  0 sent   1 to 5
  0 sent   1 to 6

不发送所有其他消息。

以下是星图拓扑的中心节点中的代码如何: -

     MPI_Recv(&message , 1 , MPI_INT ,  MPI_ANY_SOURCE , echo_tag, COMM, &status ); 

//Sending just received message to neighbors, except to parent :-

    parent = status.MPI_SOURCE;

    for ( int l = 0 ; l< neighbourcount ; l++ ){
         int current_neighbour =  neighbours[l];
          if (  current_neighbour != parent ){
                    MPI_Send(&message , 1 , MPI_INT , current_neighbour , tag, COMM );
          }
    }

1 个答案:

答案 0 :(得分:0)

你需要一个双倍的工作,如下:

   <li ng-repeat="orga in organization.minutesToNext"> 
         next {{orga.ID}} in {{orga.time}} sec
             </li>