Here is my pseudo-code. Say I have 1 master processor and 4 slave processors:
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 ;
}
The problem is, every processor would read one single input file at the same time which could cause error. How do I solve this problem ? Thanks in advance!
Update:
What I want to achieve is,
every MPI processor will execute my function (in pseudo code) to compute y
values. In a different processor, the function uses different x
values. So I wrote some codes to modify the input file to the x
values (x
values are different in different processors) before the input reading of the function.
So this causes a problem, every processor is trying to modify a single file at the same time and every processor is executing the function to read the modified input file. This of course resulted in errors.
I need your help! Thanks in advance!