MPI从处理器

时间:2015-09-23 14:22:36

标签: mpi

这是我的伪代码。假设我有1个主处理器和4个从处理器:

if (id==0)
{
  MPI_Send to x1, x2 to processor 1;
              x3, x4 to processor 2;
              x5, x6 to processor 3;
              x7, x8 to processor 4;
  MPI_Receive y1, y2, ..........., y8 ;
}
if (id != 0)
{
  MPI_Recv x values (each processor receives 2 x values);
  in the input file, modify the certain rows into value of the two x values;
  My function: read the input files and compute two y values;
  MPI send y values to master processor ;
}

问题是,每个处理器会同时读取一个输入文件,这可能会导致错误。我该如何解决这个问题?提前谢谢!

更新

我想要达到的目标是, 每个MPI处理器都将执行我的函数(伪代码)来计算y值。在不同的处理器中,该函数使用不同的x值。因此,在输入读取函数之前,我编写了一些代码来将输入文件修改为x值(x值在不同处理器中不同)。

因此,这会导致问题,每个处理器都在尝试同时修改单个文件,并且每个处理器都在执行该函数来读取修改后的输入文件。这当然导致了错误。

我需要你的帮助!提前致谢!

0 个答案:

没有答案