// Author: William W. Y. Liang // Update: 4/29/1996 #include #include #include #include #include "adsm.h" // standard libray of Adsmith #include "adsmutil.h" // non-standard utilities of Adsmith #include "adsmtime.h" // a timing class void slave(); // system parameters int seqno; int nhost; AdsmBarrier Bsample("sample"); // for barrier synchronization // initial values int zero=0; int deflen=10000; // default length // shared variable int *len; // length of the vector int *vec; // source of the vector unsigned *sum; // result of the sum main(int argc,char *argv[]) { // get my sequence no. and host number seqno=get_seqno(); // get_seqno() and get_nhost() nhost=get_nhost(); // both are in adsmutil.h // initialize content of the vector and spawn child processes if (seqno==0) { // the 1st process // determine the size of vector if (argc>1) deflen=atoi(argv[1]); cout<(*len)) end=(*len); // ready to compute Bsample.barrier(nhost+1); // calculate partial sum int partial=0; for (int i=begin; i