/****************************************************************************** * PVM Matrix Multiply - C Version * Worker Program * FILE: pvm_mm.worker.c * DESCRIPTION: See pvm_mm.master.c * PVM VERSION: 3.x * LAST REVISED: 4/18/94 Blaise Barney ******************************************************************************/ #include #include #include "pvm3.h" /* PVM version 3.0 include file */ #define NRA 62 /* number of rows in matrix A */ #define NCA 15 /* number of columns in matrix A */ #define NCB 7 /* number of columns in matrix B */ int main(){ int wtid, /* PVM task id of this worker program */ mtid, /* PVM task id of parent master program */ mtype, /* PVM message type */ rows, /* number of rows in matrix a sent to worker */ offset, /* starting position in matrix */ rcode, i, j, k; /* misc */ double a[NRA][NCA], /* matrix A to be multiplied */ b[NCA][NCB], /* matrix B to be multiplied */ c[NRA][NCB]; /* result matrix C */ /* enroll worker task */ wtid = pvm_mytid(); /* Receive message from master */ mtype = 1; /* set message type */ mtid = pvm_parent(); /* get task id for master process */ rcode = pvm_recv(mtid, mtype); /* wait to receive message from master*/ rcode = pvm_upkint(&offset, 1, 1); /* start pos. in A and C matrices */ rcode = pvm_upkint(&rows, 1, 1); /* #rows in matrix A sent */ rcode = pvm_upkdouble(&a[0][0], rows*NCA, 1); /* our share of matrix A */ rcode = pvm_upkdouble(&b[0][0], NCA*NCB, 1); /* contents of matrix B */ printf("worker task id = %d received %d rows from A\n", wtid, rows); /* do matrix multiply */ for (k=0; k