提升mpi相当于status.MPI_SOURCE

时间:2012-12-15 19:53:27

标签: mpi boost-mpi

是否有boost::MPI等效的以下C MPI代码?我正在尝试移植以下标准MPI代码,这是找到here的基本主从模板。从boost mpi文档开始,只有3个参数,用于mpi_send或mpi_recv排名,标记和缓冲区。

while (work != NULL) {

    /* Receive results from a slave */

    MPI_Recv(&result,           /* message buffer */
             1,                 /* one data item */
             MPI_INT,        /* of type double real */
             MPI_ANY_SOURCE,    /* receive from any sender */
             MPI_ANY_TAG,       /* any type of message */
             MPI_COMM_WORLD,    /* default communicator */
             &status);          /* info about the received message */

    /* Send the slave a new work unit */

    MPI_Send(&work,             /* message buffer */
             1,                 /* one data item */
             MPI_INT,           /* data item is an integer */
             status.MPI_SOURCE, /* to who we just received from */
             WORKTAG,           /* user chosen message tag */
             MPI_COMM_WORLD);   /* default communicator */

    /* Get the next unit of work to be done */

    work = get_next_work_item();
  }

1 个答案:

答案 0 :(得分:2)

来自boost.MPI documentation

  • MPI_ANY_SOURCE变为any_source
  • MPI_ANY_TAG变为any_tag

communicator::recv()方法返回status类的实例,该实例提供您需要的所有信息:

    {li> status.MPI_SOURCEstatus::source() 返回 {li> status.MPI_TAGstatus::tag() 返回

它还提供了两个强制转换操作符,将其内容转换为MPI_Status结构。