【发布时间】:2021-05-18 13:03:37
【问题描述】:
我编写了一个 MPI 代码,我正在使用 16 个进程运行该代码,并且我正在打印 4x4 矩阵作为每个进程的输出:
printf("\n This is the output of %d\n",myrank);
for(int i=0;i<count;i++)
{
for(int j=0;j<count;j++)
{
printf("%f ",m[i][j]);
}
printf("\n");
}
但问题是每个流程的输出都会与其他流程混淆。像这样——
This is the output of 3
0.750000 0.750000 0.750000 0.500000
This is the output of 9
1.000000 1.000000 1.000000 1.000000
1.000000 1.000000 1.000000
1.000000 1.000000 1.000000 0.750000
1.000000 1.000000 1.000000 0.750000 1.000000
1.000000 1.000000 1.000000 1.000000
1.000000 1.000000 1.000000 1.000000
1.000000 1.000000 1.000000 0.750000
如何防止这种行为?
【问题讨论】:
标签: c parallel-processing mpi hpc barrier