/****************************************************************************** * PVM TEMPLATE CODES * FILE: pvm.ex1.master.c * OTHER FILES: pvm.ex1.worker.c make.pvm.ex1.c * DESCRIPTION: C Language version of PVM example 1 master component. * In this simple example, the master component initiates a specified number of * instances of the worker component. It then distributes an equal portion of * an array to each instance of the worker component. Each instance of the * worker component receives its portion of the array, and performs a simple * value assignment to each of its elements. The value assigned to each * element is simply that element's index in the array+1. Each worker component * then sends its portion of the array back to the master component. As the * master receives back each portion of the array, selected elements are * displayed. Note that the order in which the worker components finish is * non-deterministic so that different portions of the array may display * "out of order". * PVM VERSION: 2.4 * AUTHOR: Blaise Barney * LAST REVISED: 6/27/93 bbarney ******************************************************************************/ #include #define NUM_INSTANCES 6 #define ARRAYSIZE 60000 #define FROMMASTER_MSG 1 #define FROMWORKER_MSG 2 main() { int i, index, bytes, instance, msgtype, rc, inst[NUM_INSTANCES], chunksize; char component[16]; float data[ARRAYSIZE], result[ARRAYSIZE]; /******************* enroll this component in pvm ***************************/ printf("\n*********** Starting PVM Example 1 ************\n"); rc = enroll("ex1.m"); if (rc < 0) { printf("MASTER: Unable to enroll this component.\n"); printf(" Return code= %d\n", rc); printf(" Quitting.\n"); exit(0); } else printf("MASTER: Component enrolled as instance = %d\n", rc); /******************* initiate worker processes ******************************/ printf("MASTER: Initiating worker components...\n"); for (i=0; i