【发布时间】:2012-11-20 00:48:39
【问题描述】:
我收到 MPI_Bcast 错误(我认为这是一个旧错误)我不确定为什么会发生这种情况。错误如下:
An error occurred in MPI_Bcast
on communicator MPI_COMM_WORLD
MPI_ERR_TRUNCATE: message truncated
MPI_ERRORS_ARE_FATAL: your MPI job will now abort
发生的代码是:
for (int i = 0; i < nbProcs; i++){
for (int j = firstLocalGrainRegion; j < lastLocalGrainRegion; j++){
GrainRegion * grainRegion = microstructure->getGrainRegionAt(j);
int grainSize = grainRegion->getBoxSize(nb);
double * newValues;
if (myId == i)
newValues = grainRegion->getNewValues();
else
newValues = new double[grainSize];
MPI_Bcast(newValues, grainSize, MPI_DOUBLE, i, MPI_COMM_WORLD);
MPI_Barrier(MPI_COMM_WORLD);
if (myId != i)
grainRegion->setNewValues(newValues);
}
}
【问题讨论】:
-
您的问题可能与this question 中的问题相同。向我们展示更多代码上下文。
-
另外:检查
grainRegion->getBoxSize(nb)在所有进程中返回的值是否相等,否则您可能会在MPI_Bcast调用中得到不匹配的grainSize值。 -
请注意,所有进程的缓冲区必须相同(因为最终每个人都会在缓冲区中持有相同的东西)。如果要向所有进程发送 1 个值,则不需要整个数组。