Parallel Computing Program During design, a series of tasks are often assigned to N nodes. For example, in a classic program for calculating pi values
For (I = Myid + 1 ; I <= N; I + = Numprocs)
{
X=H*((Double) I- 0.5);
Sum+ =F (x );
}
Myid appears in the loop design, so that each process (node) has different interpretations of the loop, such as numprocs = 3, n = 15
(1) Node-1/the proc-1's explanation of the loop is
For (I =1; I <15; I + = 3)
{
.....
}
It will generate the following sequence:, 13
(2) Node-2/The proc-2's explanation of the loop is
For (I =2; I <15; I + = 3)
{
.....
}
It will generate the following sequence: 2, 5, 8, 11, 14
(3) Node-1/the proc-1's explanation of the loop is
For (I = 3; I <15; I + = 3)
{
.....
}
It will generate the following sequence: 3, 6, 9, 12, 15
To distribute the files in a directory to numprocs for processing, you can use the following Loop
For (I = myid; I <filenum; I + = numprocs)