/* $OpenXM: OpenXM/src/kan96xx/plugin/sm1pvm.c,v 1.4 2003/08/22 16:08:22 ohara Exp $ */ #include #include "pvm3.h" #define SLAVENAME "slave3" #include "datatype.h" #include "stackm.h" #include "extern.h" #include "extern2.h" /* #include "lookup.h" */ #include "matrix.h" #include "gradedset.h" #include "sm1pvm.h" static int KpvmVerbose = 0; /* 1 is for outputting debug messages. */ /* KSstart(); */ int KpvmStartSlaves(char *name,int n); int KpvmStopSlaves(void); int KpvmChangeStateOfSlaves(int k); int KpvmMcast(char *comm); struct object KpvmJobPool(struct object obj); #define MAXHOSTS 32 static int PvmStarted = 0; static int Mytid; /* my task id */ static int Tids[MAXHOSTS+1]; /* slave ids */ static int Nproc; static struct pvmhostinfo *Hostp[MAXHOSTS+1]; KpvmStartSlaves(char *name,int nproc) { int numt,i,info; /* enroll in pvm */ Nproc = nproc; Mytid = pvm_mytid(); if (Nproc > MAXHOSTS) { Nproc = MAXHOSTS-1; fprintf(stderr,"Too many tasks. It is set to %d\n",Nproc); } /* start up slave tasks */ numt=pvm_spawn(name, (char**)0, 0, "", Nproc, Tids); if( numt < Nproc ){ fprintf(stderr,"Trouble spawning slaves. Aborting. Error codes are:\n"); for( i=numt ; i= 0) { if (KpvmVerbose) printf("Waiting for msgtype=5.\n"); info = pvm_recv( -1, msgtype ); pvm_bufinfo(info,&bytes,&tag,&rtid); pvm_upkint(&dataId,1,1); pvm_upkstr(ans); if (strlen(ans) == 0) { /* slave is ready. */ if (KpvmVerbose) printf("Slave %d is ready.",rtid); }else{ ansp -- ; aarray[dataId] = (char *) GC_malloc(sizeof(char)*(strlen(ans)+2)); strcpy(aarray[dataId],ans); if (KpvmVerbose) printf("[%d] %s from %d.\n",dataId,ans,rtid); if (ansp <= 0) break; } if (remaining > 0) { remaining--; pvm_initsend(PvmDataDefault); /* Always necessary to flush the old data. */ pvm_pkint(&remaining,1,1); pvm_pkstr(darray[remaining]); if (KpvmVerbose) printf("Sending the message <<%s>> of the type 10.\n",darray[remaining]); pvm_send(rtid, 10); } } printf("-------------------------------\n"); for (i=0; i