【问题标题】:MPI struct errorMPI 结构错误
【发布时间】:2014-11-16 17:23:59
【问题描述】:

我正在尝试使用 MPI_Bcast 函数发送结构,但出现错误。
结构定义 ::

typedef struct _data{
      char table[5][20];
}data;

数据类型创建 ::

data t[100];
const int nitems=1;
int blocklengths[1] = {200};
MPI_Datatype types[1] = {MPI_CHAR};
MPI_Datatype mpi_d_type;
MPI_Aint     offsets[1];
offsets[0] = offsetof(data, table);
MPI_Type_create_struct(nitems, blocklengths, offsets, types, &mpi_d_type);
MPI_Type_commit(&mpi_d_type);
if (myid == ROOT) {
//reading values from stdin and storing into 't'
}
MPI_Bcast( t, 100, mpi_d_type, ROOT, MPI_COMM_WORLD);

以下是我得到的错误..

[surya:00652] [ 0] 0   libsystem_c.dylib                   0x00007fff8c65892a _sigtramp + 26
[surya:00652] [ 1] 0   ???                                 0x0000000000000000 0x0 + 0
[surya:00652] [ 2] 0   libsystem_c.dylib                   0x00007fff8c6b304c getenv + 29
[surya:00652] [ 3] 0   libsystem_c.dylib                   0x00007fff8c674b35 _simple_asl_init + 25
[surya:00652] [ 4] 0   libsystem_c.dylib                   0x00007fff8c66bfd0 pthread_once + 87
[surya:00652] [ 5] 0   libsystem_c.dylib                   0x00007fff8c6748f8 _simple_asl_log_prog +    48
[surya:00652] [ 6] 0   libsystem_c.dylib                   0x00007fff8c6b0d37 __stack_chk_fail + 183
[surya:00652] [ 7] 0   a.out                               0x0000000109a14e3a main + 810
[surya:00652] [ 8] 0   libdyld.dylib                       0x00007fff86b0c7e1 start + 0
[surya:00652] *** End of error message ***
--------------------------------------------------------------------------
mpirun noticed that process rank 1 with PID 652 on node surya exited on signal 11 (Segmentation      fault: 11).

【问题讨论】:

    标签: c struct char mpi


    【解决方案1】:

    您的blocklengths 的值是结构声明中字符数的两倍。 5*20 的数组只有 100 个 char 元素,但你告诉 MPI 每个有 200 个。

    【讨论】:

      猜你喜欢
      • 2014-11-24
      • 2011-02-14
      • 2021-10-07
      • 2019-10-23
      • 2013-11-18
      • 2017-06-25
      • 2019-09-04
      • 2014-05-07
      • 2014-05-07
      相关资源
      最近更新 更多