#include #include "pvm3.h" #define SLAVENAME "worker" main() { int mytid; /* my task id */ int tids[32]; /* slave task ids */ int n, nproc, numt, i, who, msgtype, nhost, narch; float data[100], result[32]; struct pvmhostinfo *hostp[32]; /* enroll in pvm */ mytid = pvm_mytid(); /* Set number of slaves to start */ /* Can not do stdin from spawned task */ if( pvm_parent() == PvmNoParent ){ puts("How many slave programs (1-32)?"); scanf("%d", &nproc); } else{ pvm_config( &nhost, &narch, hostp ); nproc = nhost; if( nproc > 32 ) nproc = 32 ; } /* start up slave tasks */ numt=pvm_spawn(SLAVENAME, (char**)0, 0, "", nproc, tids); if( numt < nproc ){ printf("Trouble spawning slaves. Aborting. Error codes are:\n"); for( i=numt ; i