=
double a[NRA][NCA];xxxxx¯ double b[NCA][NCB];
xxxxx¯ double c[NRA][NCB];
xx¯ Master:
xxxxxxx¯ initialize matrix A and B;
xxxxxxx¯ foreach worker
xxxxxxxxx¯ send equal share of rows;
xxxxxxx¯ foreach worker
xxxxxxxxx¯ receive into C matrix;
xxxxxxx¯ display results;
xx¯ Slave:
xxxxxxx¯ receive my rows of A and B;
xxxxxxx¯ perform matrix mult on my rows
xxxxxxx¯ send back results;
xxxxxxxx¯
Figure 5: Master-Slave Matrix Multiply
Table 2: Communication performance of matrix multiplication
This is another master-slave style program that performs a standard matrix multiply of two 2-dimensional arrays. (A x B = C) The master first distributes equal portions of the initial A and B arrays to each worker. When the worker tasks receive the array portion, they perform the local computation for their portion. Upon completion, each worker task sends its portion back to the master, and exits. The master collects all the portions from the workers until the operation is finished, then exits. Like Array, Matrix Multiply has a well defined communication phase, computation phase, and communication phase structure. The computational phase is not as trivial as in the array case, and the communication phases inject greater volumes of data into the interconnection network.
The pseudo code is presented in Table 5, while the performance numbers are presented in Table 2. Note that our network module does not simulate the SP-2 well.