【问题标题】:Is it possible to send nested structure using MPI_Datatype in MPI using C是否可以使用 C 在 MPI 中使用 MPI_Datatype 发送嵌套结构
【发布时间】:2011-08-23 16:50:37
【问题描述】:

我有一个结构:

    struct vertex
    {
     double a; double b;
    }

    struct polygon
    {
     int numofVertex;
     vertex v[10];
    }

如何使用 MPI_Send 在 MPI 中发送这个嵌套结构?

【问题讨论】:

    标签: c algorithm mpi distributed-computing


    【解决方案1】:

    由于您的结构不包含任何指针,因此很容易实现。

    MPI_Send(ptr_to_your_struct, sizeof(struct polygon), MPI_BYTES, ...);
    

    【讨论】:

    • 感谢您的解决方案,我认为发送的结构可以通过 MPI_Recv(ptr_to_struct, sizeof(struct polygon), MPI_BYTES, ...); 轻松访问
    • 当结构包含指针字段时,您能否提供一些见解。此外,我已将这个问题作为一个新问题提出。 stackoverflow.com/questions/5972018/…
    猜你喜欢
    • 2011-08-23
    • 1970-01-01
    • 2014-12-20
    • 2011-08-23
    • 1970-01-01
    • 2021-05-30
    • 1970-01-01
    • 2019-12-20
    • 2015-12-11
    相关资源
    最近更新 更多