/****************************************************************************** * PVM Matrix Multiply - C Version * Master Program * FILE: pvm_mm.master.c * OTHER FILES: pvm_mm.worker.c, make.mm.c * DESCRIPTION: PVM matrix multiply example code master task. C version. * In this example code, the master program acts as the parent and spawns * NPROC worker tasks. The first worker task is spawned on a specific machine. * The master program performs the matrix multiply by sending all of matrix B * to every worker task and then partitioning rows of matrix A among the * workers. The worker tasks perform the actual multiplications and send back * to the master task their respective results. * NOTE1: C and Fortran versions of this code differ because of the way * arrays are stored/passed. C arrays are row-major order but Fortran * arrays are column-major order. * PVM VERSION: 3.x * AUTHOR: Roslyn Leibensperger * LAST REVISED: 4/18/94 Blaise Barney ******************************************************************************/ #include #include "pvm3.h" /* PVM version 3.0 include file */ #define NPROC 4 /* number of PVM worker tasks to spawn */ #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 */ main() { int mtid, /* PVM task id of master task */ wtids[NPROC], /* array of PVM task ids for worker tasks */ mtype, /* PVM message type */ rows, /* rows of matrix A sent to each worker */ averow, extra, offset, /* used to determine rows sent to each worker */ rcode, i, j; /* misc */ double a[NRA][NCA], /* matrix A to be multiplied */ b[NCA][NCB], /* matrix B to be multiplied */ c[NRA][NCB]; /* result matrix C */ char thishost[35]; /* name of selected master */ /* enroll this task in PVM */ mtid = pvm_mytid(); /* The master task now spawns worker tasks by calling pvm_spawn. The unique */ /* worker task ids are stored in the wtids array. The first worker task is */ /* spawned on a specific machine. The return code tells the number of tasks */ /* successfully spawned, and in this example, is not checked for errors. */ for (i=0; i