【问题标题】:How to send a struct inside another struct over mpi send如何通过 mpi send 在另一个结构内发送一个结构
【发布时间】:2021-11-19 15:56:02
【问题描述】:

如果我有 2 个结构,

struct {
   int a;
   int b;
} st_a;

struct {
  double c;
  st_a d;
} st_b;

有没有办法使用 mpi_Send 发送 st_b?

【问题讨论】:

  • MPI 类型构造是递归的。所以你可以为st_a创建一个结构或连续类型,然后为st_b创建一个结构类型。

标签: c struct mpi


【解决方案1】:

你以同样的方式发送结构。结构只是连续的字节,嵌套结构也不例外。根据文档https://www.mpich.org/static/docs/v3.3/www3/MPI_Send.html,您只需要注意大小,但这应该不是问题,因为您有多种方法可以在 C 中获得所需的 sizeof

你也可能想看看这篇文章:
How to send nested structure using MPI_Datatype in MPI using C

【讨论】:

    猜你喜欢
    • 2013-06-23
    • 1970-01-01
    • 1970-01-01
    • 2018-11-09
    • 2021-03-24
    • 1970-01-01
    • 2021-11-07
    • 2013-08-29
    • 1970-01-01
    相关资源
    最近更新 更多