/***************************************************************************** Finds sum of elements of a given vector. Vector size can be given as input to the program. The program can be ru on a PVM with up to 10 nodes. Also requires the slave node program vecsum_slave.c Vector size is assumed to be evenly divisable by number of nodes in PVM. Written by: S. Dandamudi ****************************************************************************/ #include #include #include "pvm3.h" #define MAX_SIZE 250000 /* max. vector size */ #define NPROCS 10 /* max. number of PVM nodes */ main() { int cc, tid[NPROCS]; long vector[MAX_SIZE]; double sum=0, partial_sum; /* partial sum received from slaves */ long i, vector_size; int nhost, /* actual # of hosts in PVM */ size; /* size of vector to be distributed */ struct timeval start_time, finish_time; long sum_time; printf("Vector size = "); scanf("%ld", &vector_size); for(i=0; i 1) pvm_spawn("vecsum_slave", (char **)0, 0, "", nhost-1, &tid[1]); for (i=1; i