【发布时间】:2020-03-23 10:39:03
【问题描述】:
这是我程序的最基本功能,因此不一定可重现。但是,我想知道是否有办法使用 MPI 发送数组数组?或者这是不可能的事情,我应该展平我的阵列?任何帮助都将不胜感激,因为我一直在努力解决这个问题。
int *individual_topIds;
int **cell_topIds;
cell_topIds = (int**) malloc(sizeof(int*)*25*boxes);
if(rank == 0) {
for (int i = 0; i < boxes; i++) {
individual_topIds = (int*) malloc(sizeof(int)*25);
for(int j = 0; j < cellMatrix[i].numTop; j++){
individual_topIds[j] = cellMatrix[i].aTopIds[j];
}
cell_topIds[i] = individual_topIds;
}
MPI_Send(cell_topIds, boxes*25, MPI_INT, 1, 10, MPI_COMM_WORLD);
}
然后在我的排名 == 1 部分。我试过只用盒子发送和接收,而不是盒子*25。
for 1 -> boxes
MPI_Recv(cell_topIds, boxes*25, MPI_INT, 0, 10, MPI_COMM_WORLD, &status);
int *ptop;
ptop = (int*) malloc(sizeof(int)*25);
ptop = cell_topIds[i];
printf("1\n");
for(int j = 0; j < sizeof(&ptop)/sizeof(int); j++){
printf("%d, ", ptop[j]);
}
printf("2\n");
end for i -> boxes
free(ptop);
编辑:忘了提到打印的输出是段错误 捕获的错误:分段错误(信号 11)
【问题讨论】:
标签: c parallel-processing mpi