#include "mult.hh" // does the job of calculating the row void DoJob (const TransmitMatrices &Matrices, int Row, DoubleVector &Result) { Result = DoubleVector (Matrices.ColumnsB); for (int Column = 0; Column < Matrices.ColumnsB; ++Column) { for (int i = 0; i < Matrices.ColumnsA_RowsB; ++i) { Result[Column] += Matrices.MatrixA[Row][i] * Matrices.MatrixB[i][Column]; } } } int main () { TransmitMatrices Matrices; Pvm::Task Parent = Pvm::Pvm ().I ().Parent (); Matrices.ReceiveFrom (Parent); TransmitCoords Coords; // waiting for new job or for request of end. Pvm::StructSet Awaited; Awaited.insert (Coords); Awaited.insert (JobCompleted); while (1) { Pvm::StructId Id = Awaited.ReceiveFrom (Parent); if (Id == CompletedId) // leave the infinite loop, if the job is completed break; // Id == CoordsId --> do the job for the given coordinates TransmitResult Result; Result.Row = Coords.Row; DoJob (Matrices, Result.Row, Result.Result); Result.Send (Parent); } }