void upkjobinfo_active(jobinfo *j) { pvm_upkint(&j->jid,6,1); // jid, tid, pjid, d, a, n pvm_upkint(&j->s.k,4,1); // k,o,r,rd pvm_upkbyte(&j->s.p,2+TPITS,1); pvm_upkbyte(j->s.m,MAXMVC,1); pvm_upkint(j->o,4*PITS,1); // o, js, ctid, cjid }
void unpack(struct msg *incoming_msg) { pvm_upkint(&incoming_msg->tag, 1, 1); pvm_upkint(&incoming_msg->sender_tid, 1, 1); pvm_upkint(&incoming_msg->timestamp, 1, 1); if (incoming_msg->tag != MSG_ACCEPT) pvm_upkint(&incoming_msg->lift_number, 1, 1); }
/** * Description not yet available. * \param */ void pvm_unpack(const dvar_vector& _v) { dvar_vector& v = (dvar_vector&) _v; int imin; int imax; pvm_upkint(&imin,1,1); pvm_upkint(&imax,1,1); if (allocated(v)) { if (v.indexmin()!=imin) { cerr << "Error in min index in " "void pvm_unpack(const dvar_vector& v)" << endl; ad_exit(1); } if (v.indexmax()!=imax) { cerr << "Error in max index in" " void pvm_unpack(const dvar_vector& v)" << endl; ad_exit(1); } } else { v.allocate(imin,imax); } pvm_upkdouble(&(value(v(imin))),imax-imin+1,1); }
/** * Description not yet available. * \param */ void adpvm_unpack(const dvar_matrix & _m) { dvar_matrix& m = (dvar_matrix &) _m; int imin; int imax; pvm_upkint(&imin,1,1); pvm_upkint(&imax,1,1); if (allocated(m)) { if (m.indexmin()!=imin) { cerr << "Error in min index in" " void adpvm_unpack(const dvar_matrix& v)" << endl; ad_exit(1); } if (m.indexmax()!=imax) { cerr << "Error in max index in" " void adpvm_unpack(const dvar_matrix& v)" << endl; ad_exit(1); } } else { m.allocate(imin,imax); } for (int i=imin;i<=imax;i++) adpvm_unpack(m(i)); save_identifier_string("K"); save_int_value(imin); save_int_value(imax); save_identifier_string("L"); gradient_structure::GRAD_STACK1-> set_gradient_stack(adpvm_pack_index_bounds); }
/** * Description not yet available. * \param */ void adpvm_unpack(const dvar_vector& _v) { dvar_vector& v = (dvar_vector&) _v; int imin; int imax; pvm_upkint(&imin,1,1); pvm_upkint(&imax,1,1); if (allocated(v)) { if (v.indexmin()!=imin) { cerr << "Error in min index in " "void adpvm_unpack(const dvar_vector& v)" << endl; ad_exit(1); } if (v.indexmax()!=imax) { cerr << "Error in max index in" " void adpvm_unpack(const dvar_vector& v)" << endl; ad_exit(1); } } else { v.allocate(imin,imax); } pvm_upkdouble(&(value(v(imin))),imax-imin+1,1); save_identifier_string("B"); v.save_dvar_vector_position(); save_identifier_string("D"); gradient_structure::GRAD_STACK1-> set_gradient_stack(adpvm_pack_vector_derivatives); }
int main(int argc, char** argv) { const int minp = 2 ; const int dinp = 0 ; strcpy(myname, name) ; if( minp ) { std::map<int, std::vector<int> > tagbufs ; while(1) { std::vector<int> inputs = get_inputs(minp, dinp, tagbufs) ; //input0 int inp0 ; int inp0buf = inputs[0] ; pvm_setrbuf(inp0buf) ; pvm_upkint(&inp0, 1 ,1 ) ; pvm_freebuf(inp0buf) ; //input1 int inp1 ; int inp1buf = inputs[1] ; pvm_setrbuf(inp1buf) ; pvm_upkint(&inp1, 1 ,1 ) ; pvm_freebuf(inp1buf) ; get_mul(inp0, inp1) ; } } return 0 ; }
/** * Description not yet available. * \param */ void adpvm_unpack(const imatrix & _m) { imatrix& m = (imatrix &) _m; int imin; int imax; pvm_upkint(&imin,1,1); pvm_upkint(&imax,1,1); if (allocated(m)) { if (m.indexmin()!=imin) { cerr << "Error in min index in" "void adpvm_unpack(const imatrix& v)" << endl; ad_exit(1); } if (m.indexmax()!=imax) { cerr << "Error in max index in" "void adpvm_unpack(const imatrix& v)" << endl; ad_exit(1); } } else { m.allocate(imin,imax); } for (int i=imin;i<=imax;i++) { pvm_unpack(m(i)); } }
// Receive the bits from the specified task. Stuff the genome with the data. // Returns a negative number if there was a transmission failure. int UnpackIndividual(GAGenome& g) { GA1DBinaryStringGenome& genome = (GA1DBinaryStringGenome&)g; int length = 0; float score = 0.0; static int nbits = 0; static int* bits = 0; int status = 0; status = pvm_upkint(&length, 1, 1); if(nbits < length){ nbits = length; delete [] bits; bits = new int [nbits]; } status = pvm_upkint(bits, length, 1); genome.length(length); // resize the genome genome = bits; // stuff it with the bits status = pvm_upkfloat(&score, 1, 1); // get the score from process g.score(score); // set the score on the genome return status; }
void main() { /* enroll in pvm */ mytid = pvm_mytid(); master = pvm_parent(); /* receive data from master */ pvm_recv(master, DATA); pvm_upkint(&nproc, 1, 1); pvm_upkdouble(&lower, 1, 1); pvm_upkdouble(&upper, 1, 1); pvm_upkdouble(&delta_x, 1, 1); pvm_upkint(&partitions, 1, 1); pvm_upkint(tids, nproc, 1); /* determine which slave I am (0..nproc-1) */ for(i=0; i<nproc; i++) if(mytid==tids[i]) { mynode = i; break; } /* start timiming */ start = clock(); /* calculate approximation */ partitions_per_slave = partitions / nproc; first = lower + mynode * ((upper-lower)/nproc); last = first + partitions_per_slave * delta_x; x = first + (delta_x/2.0); while(x<last) { approx_result += f(x) * delta_x; x += delta_x; } /* end timing */ elapse = (clock() - start) / clocks_per_sec; avg_time = elapse / partitions; /* send the results back to the master program */ pvm_initsend(PvmDataDefault); pvm_pkdouble(&elapse, 1, 1); pvm_pkdouble(&approx_result, 1, 1); pvm_pkdouble(&avg_time, 1, 1); pvm_send(master, RESULTS); /* exit pvm */ pvm_exit(); }
void UnpackBufferedTree (BufferedTreeT *bt, int support_stuff) { int i; assert (! pvm_upkint (&bt->n_placed_taxa, 1, 1)); assert (! pvm_upkint ((int *)bt->nodes, bt->n_placed_taxa, 1)); assert (! pvm_upkint (bt->placed_taxa_indices, bt->n_placed_taxa, 1)); if (support_stuff) { RECEIVEDWITH++; assert (! pvm_upkint (&bt->n_supported_clades, 1, 1)); LoopBelow (i, bt->n_supported_clades) assert (! pvm_upkint (bt->supported_clades[i], BitVectorWords, 1)); assert (! pvm_upkint (&bt->supported_clades_hash, 1, 1)); } else { RECEIVEDWITHOUT++; bt->n_supported_clades = bt->supported_clades_hash = 0; } assert (! pvm_upkint (&bt->cost, 1, 1)); assert (! pvm_upkint (&bt->generation, 1, 1)); /* { */ /* int i; */ /* fprintf (stderr, "unpacking tree:\n"); */ /* LoopBelow (i, bt->n_placed_taxa) */ /* fprintf (stderr, "%d %d %c\n", */ /* bt->placed_taxa_indices[i], */ /* bt->nodes[i].parent_index, */ /* bt->nodes[i].on_left? 'l': 'r'); */ /* } */ }
int main(int argc, char* argv[]) { int my_tid; int sender_id; int n; int num_of_configs; int config_id; int* config; int config_fit; int master_id = pvm_parent(); //printf("im a kid %d\n", master_id); my_tid = pvm_mytid(); /* -1 for these arguments mean that it matches any task identification * sent to it, and any message tag */ pvm_recv(-1, -1); /* unpackage the information sent to us from the master about how many * configurations will be recieved, and how large they are. */ pvm_upkint(&num_of_configs, 1, 1); pvm_upkint(&n, 1, 1); //printf("tid=%d; %d %d\n", my_tid, num_of_configs, n); //fflush(stdout); config = malloc(sizeof(int) * n); /* takes information about configurations to be recieved and their size * and starts recieving the configurations themselves, with their * identifier as the master knows them. Fitnesses are generated as they * are recieved and and fitness and id are then sent back to the master */ int i; pvm_recv(-1, -1); for (i = 0; i < num_of_configs; i++) { pvm_upkint(&config_id, 1, 1); pvm_upkint(config, n, 1); config_fit = fitness_test(n, config); pvm_initsend(PvmDataDefault); pvm_pkint(&config_id, 1, 1); pvm_pkint(&config_fit, 1, 1); pvm_send(master_id, 0); } pvm_exit(); return 1; }
value Pvm_upkstring(void) { CAMLparam0(); int bufid,bytes,msgtag,tid; char *tab; CAMLlocal1(s); int res,i; res=pvm_upkint(&bytes,1,1); if (res<0) TreatError(res); tab=(char *)malloc(sizeof(char)*bytes); res = pvm_upkbyte(tab,bytes,1); if (res<0) { free(tab); TreatError(res); } s = alloc_string(bytes); for (i=0;i<bytes;i++) Byte(s,i)=tab[i]; free(tab); CAMLreturn(s); }
int main(int argc, char **argv) { int nproc, status; int tids[SLAVENUM], ok, mytid; nproc = pvm_spawn("sort_slave",0,PvmTaskDefault, "LINUX64",SLAVENUM, tids); printf("Master id %d\n", nproc ); //app for sorting do { status = 0; //if 0 - all done //if 1 - continue for(int i = 0; i < SLAVENUM; i++) { int slave_status ; pvm_recv (-1 , TAG_SLAVE); pvm_upkint(&slave_status, 1, 1); if (slave_status == 0) { status = 1; } } for (int i = 0; i < SLAVENUM; ++i) { pvm_initsend( PvmDataRaw ); pvm_pkint(&status, 1, 1); pvm_send( tids[i], TAG_MASTER ); } } while(status == 1); printf("Master end!"); pvm_exit(); }
int main(int argc, char** argv) { const int minp = 1 ; const int dinp = 0 ; strcpy(myname, name) ; mytid = pvm_mytid() ; printf("[gen_x_copy]: hello!\n") ; //просто запускаем функцию и выходим. if( minp ) { std::map<int, std::vector<int> > tagbufs ; while(1) { printf("[gen_x_copy]:waiting for inputs\n") ; std::vector<int> inputs = get_inputs(minp, dinp, tagbufs) ; printf("[gen_x_copy]:inputs are receiving\n") ; int inp0 ; int inp0buf = inputs[0] ; printf("[gen_x_copy]:inp0buf=%d\n", inp0buf) ; pvm_setrbuf(inp0buf) ; pvm_upkint(&inp0, 1 ,1 ) ; printf("[gen_x_copy]:after unpack inp0=%d\n", inp0) ; gen_x(inp0) ; pvm_freebuf(inp0buf) ; } } return 0 ; }
int main(int argc, char **argv){ NodoBusqueda nodo_problema; int mintareas=4, cantidad_tareas, numt, *tids=NULL,i; GList *tareas, *tarptr; NodoBusqueda solucion; int problema[_SUDOK_FILAS][_SUDOK_COLUMNAS] = { {1,0,0,0,0,7,0,9,0}, {0,3,0,0,2,0,0,0,8}, {0,0,9,6,0,0,5,0,0}, {0,0,5,3,0,0,9,0,0}, {0,1,0,0,8,0,0,0,2}, {6,0,0,0,0,4,0,0,0}, {3,0,0,0,0,0,0,1,0}, {0,4,0,0,0,0,0,0,7}, {0,0,7,0,0,0,3,0,0} }; inicializarMatrizAdyacencia(); nodo_problema= nodoInicial(problema); tareas=generarTareas(nodo_problema,mintareas); cantidad_tareas = g_list_length(tareas); tids=malloc(sizeof(int)*cantidad_tareas); numt=pvm_spawn("sudokuterm",NULL,0,"",cantidad_tareas,tids); if(numt<cantidad_tareas){ fprintf(stderr, "ERROR. sudokuhub: no se pudo hacer spawn de todas las tareas"); exit(1); } //iteramos sobre las tareas y les pasamos los datos tarptr=g_list_first(tareas); for(i=0;i<cantidad_tareas;i++){ pvm_initsend(PvmDataDefault); pvm_pkNodoBusqueda((NodoBusqueda*)(tarptr->data)); pvm_send(tids[i],_TIPOMSG_NODOBUSQUEDA); tarptr=tarptr->next; } //esperamos las respuestas y velamos por una solucion for(i=0;i<cantidad_tareas;i++){ int exitofracaso,j; pvm_recv(tids[i],_TIPOMSG_EXITOFRACASO); pvm_upkint(&exitofracaso,1,1); if(exitofracaso==1){ pvm_recv(tids[i],_TIPOMSG_NODOBUSQUEDA); pvm_upkNodoBusqueda(&solucion); printf("\nSE ENCONTRO UNA SOLUCION\n"); printNodoBusqueda(&solucion); for(j=0;j<cantidad_tareas;j++) pvm_kill(tids[j]); pvm_exit(); exit(0); } } printf("\nNO SE ENCONTRO NINGUNA SOLUCION\n"); return 0; }
void sweep(int parent, heur_prob *p) { printf("\nIn sweep....\n\n"); int mytid, info, r_bufid; int i; int vertnum; sweep_data *data; float depotx, depoty; float tempx, tempy; double t=0; mytid = pvm_mytid(); (void) used_time(&t); printf("mytid in sweep.c= %i", pvm_mytid()); /*-----------------------------------------------------------------------*\ | Receive the VRP data | \*-----------------------------------------------------------------------*/ PVM_FUNC(r_bufid, pvm_recv(-1, SWEEP_TRIALS)); PVM_FUNC(info, pvm_upkint(&(p->par.sweep_trials), 1, 1)); printf("\nCheckpoint 1\n"); /*-----------------------------------------------------------------------*/ vertnum = p->vertnum; p->cur_tour = (best_tours *)calloc(1, sizeof(best_tours)); p->cur_tour->tour = (_node *)calloc(vertnum, sizeof(_node)); printf("\nCheckpoint 2\n"); data = (sweep_data *)calloc(vertnum-1, sizeof(sweep_data)); if (p->dist.coordx && p->dist.coordy){ depotx = p->dist.coordx[0]; depoty = p->dist.coordy[0]; printf("\nCheckpoint 3\n"); /*calculate angles for sorting*/ for (i=0; i<vertnum-1; i++){ tempx = p->dist.coordx[i+1] - depotx; tempy = p->dist.coordy[i+1] - depoty; data[i].angle = (float) atan2(tempy, tempx); if (data[i].angle < 0) data[i].angle += 2*M_PI; data[i].cust=i+1; } printf("\nCheckpoint 4\n"); quicksort(data, vertnum-1); printf("\nCheckpoint 5\n"); make_tour(p, data, p->cur_tour); printf("\nCheckpoint 6\n"); /*-----------------------------------------------------------------------*\ | Transmit the tour back to the parent | \*-----------------------------------------------------------------------*/ send_tour(p->cur_tour->tour, p->cur_tour->cost, p->cur_tour->numroutes, SWEEP, used_time(&t), parent, vertnum, 0, NULL); printf("\nCheckpoint 7\n"); } if (data) free((char *) data); printf("\nCheckpoint 8\n"); free_heur_prob(p); }
int BBSDirect::upkint() { int i; // printf("upkint from %d\n", pvm_getrbuf()); if (pvm_upkint(&i, 1, 1)) { perror("upkint"); } // printf("upkint returning %d\n", i); return i; }
char* BBSClient::upkstr() { int len; char* s; if( pvm_upkint(&len, 1, 1)) { perror("upkstr"); } s = new char[len+1]; pvm_upkstr(s); return s; }
int receive_int_array(int *array, int size) { int info; PVM_FUNC(info, pvm_upkint(array, size, 1)); return(info); }
int receive_assign(tassign *assign) { int bufid, tag, dummy, datasize, i, toint[ASSIGN_NINT]; double *tdbl, todbl[ASSIGN_NDBL]; float *tflt; bufid = pvm_recv(-1,-1); pvm_bufinfo(bufid,&dummy,&tag,&dummy); if (tag == 2) return 0; pvm_upkint(toint,ASSIGN_NINT,1); pvm_upkdouble(todbl,ASSIGN_NDBL,1); assign->id = (integer)toint[ASSIGN_ID]; assign->chans = (integer)toint[ASSIGN_CHANS]; assign->frames = (integer)toint[ASSIGN_FRAMES]; assign->epochs = (integer)toint[ASSIGN_EPOCHS]; assign->bias = (integer)toint[ASSIGN_BIAS]; assign->signs = (integer)toint[ASSIGN_SIGNS]; assign->extended = (integer)toint[ASSIGN_EXTENDED]; assign->extblocks = (integer)toint[ASSIGN_EXTBLOCKS]; assign->pdfsize = (integer)toint[ASSIGN_PDFSIZE]; assign->nsub = (integer)toint[ASSIGN_NSUB]; assign->verbose = (integer)toint[ASSIGN_VERBOSE]; assign->block = (integer)toint[ASSIGN_BLOCK]; assign->maxsteps = (integer)toint[ASSIGN_MAXSTEPS]; assign->lrate = (doublereal)todbl[ASSIGN_LRATE]; assign->annealstep = (doublereal)todbl[ASSIGN_ANNEALSTEP]; assign->annealdeg = (doublereal)todbl[ASSIGN_ANNEALDEG]; assign->nochange = (doublereal)todbl[ASSIGN_NOCHANGE]; assign->momentum = (doublereal)todbl[ASSIGN_MOMENTUM]; datasize = assign->chans * assign->frames * assign->epochs; assign->data = (doublereal*)malloc(datasize*sizeof(doublereal)); if (sizeof(float) != sizeof(doublereal)) { tflt = (float*)malloc(datasize*sizeof(float)); pvm_upkfloat(tflt,datasize,1); for (i=0 ; i<datasize ; i++) assign->data[i] = (doublereal)tflt[i]; free(tflt); } else pvm_upkfloat((float*)(assign->data),datasize,1); datasize = assign->chans * assign->chans; assign->weights = (doublereal*)malloc(datasize*sizeof(doublereal)); if (sizeof(double) != sizeof(doublereal)) { tdbl = (double*)malloc(datasize*sizeof(double)); pvm_upkdouble(tdbl,datasize,1); for (i=0 ; i<datasize ; i++) assign->weights[i] = (doublereal)tdbl[i]; free(tdbl); } else pvm_upkdouble((double*)(assign->weights),datasize,1); pvm_freebuf(bufid); return 1; }
char* BBSDirect::upkstr() { int len; char* s; // printf("upkstr from %d\n", pvm_getrbuf()); if( pvm_upkint(&len, 1, 1)) { perror("upkstr"); } s = new char[len+1]; pvm_upkstr(s); // printf("upkstr returning |%s|\n", s); return s; }
int RecvInt(int *IntBuf, int n, int tid, int MsgType) { int info, BufId, NBytes, MsgTag, SenderTid; /*BufId = pvm_recv(-1, MsgType);*/ BufId = pvm_recv(tid, MsgType); /* wences */ info = pvm_bufinfo( BufId, &NBytes, &MsgTag, &SenderTid); pvm_upkint(IntBuf, n, 1); return(SenderTid); }
int RecvFI(float *FloatBuf, int nf, int *IntBuf, int ni, int tid, int MsgType) { int info, BufId, NBytes, MsgTag, SenderTid; BufId = pvm_recv(-1, MsgType); info = pvm_bufinfo( BufId, &NBytes, &MsgTag, &SenderTid); pvm_upkint(IntBuf, ni, 1); pvm_upkbyte((char *)FloatBuf, nf*sizeof(float), 1); return(SenderTid); }
// Receive the configuration data, configure the genome, then do the // initialization. int RecvGenomeInitialize(GAGenome& g) { GA1DBinaryStringGenome& genome = (GA1DBinaryStringGenome&)g; int status = 0; int length = 1; status = pvm_upkint(&length, 1, 1); genome.length(length); genome.initialize(); return status; }
// This assumes that the original population contains at least one individual // from which to grow. If it does not, the data in the buffer will be ignored. int RecvPopulation(GAPopulation& pop) { int status = 0; int psize = 0; status = pvm_upkint(&psize, 1, 1); pop.size(psize); for(int i=0; i<pop.size() && status>=0; i++) status = UnpackIndividual(pop.individual(i)); return status; }
// Receive the bits from the specified task. Stuff the genome with the data. // Returns a negative number if there was a transmission failure. int RecvGenomeData(GAGenome& g) { GA1DBinaryStringGenome& genome = (GA1DBinaryStringGenome&)g; int length = 0; static int nbits = 0; static int* bits = 0; int status = 0; status = pvm_upkint(&length, 1, 1); if(nbits < length){ nbits = length; delete [] bits; bits = new int [nbits]; } status = pvm_upkint(bits, length, 1); genome.length(length); // resize the genome genome = bits; // stuff it with the bits return status; }
int receive(heur_prob *p) { int r_bufid, info, bytes, msgtag, parent; PVM_FUNC(r_bufid, pvm_recv(-1, VRP_BROADCAST_DATA)); PVM_FUNC(info, pvm_bufinfo(r_bufid, &bytes, &msgtag, &parent)); PVM_FUNC(info, pvm_upkint(&(p->dist.wtype), 1, 1)); PVM_FUNC(info, pvm_upkint(&(p->vertnum), 1, 1)); PVM_FUNC(info, pvm_upkint(&(p->depot), 1, 1)); PVM_FUNC(info, pvm_upkint(&p->capacity, 1, 1)); p->demand = (int *) calloc (p->vertnum, sizeof(int)); PVM_FUNC(info, pvm_upkint(p->demand, p->vertnum, 1)); p->edgenum = p->vertnum*(p->vertnum-1)/2; if (p->dist.wtype){ /* not EXPLICIT */ p->dist.coordx = (double *) calloc(p->vertnum, sizeof(double)); p->dist.coordy = (double *) calloc(p->vertnum, sizeof(double)); PVM_FUNC(info, pvm_upkdouble(p->dist.coordx, p->vertnum, 1)); PVM_FUNC(info, pvm_upkdouble(p->dist.coordy, p->vertnum, 1)); if ((p->dist.wtype == _EUC_3D) || (p->dist.wtype == _MAX_3D) || (p->dist.wtype == _MAN_3D)){ p->dist.coordz = (double *) calloc(p->vertnum, sizeof(double)); PVM_FUNC(info, pvm_upkdouble(p->dist.coordz, p->vertnum, 1)); } } else{ /* EXPLICIT */ p->dist.cost = (int *) malloc (p->edgenum*sizeof(int)); PVM_FUNC(info, pvm_upkint(p->dist.cost, (int)p->edgenum, 1)); } PVM_FUNC(info, pvm_freebuf(r_bufid)); return(parent); }
main(){ long clock_sec, clock_usec ; struct timeval tv ; mytid = pvm_mytid(); pvm_recv( -1, MSG_MSTR); //Dostajemy Tids wszystkich pvm_upkint(&tid_master,1,1); pvm_upkint(tids_rycerze, RYCERZE, 1 ); init_kolejka(); SendMessagetoMaster("Zaczynamy"); Algorytm(); pvm_exit(); }
/** * Description not yet available. * \param */ void pvm_unpack(const dvar5_array & _m) { dvar5_array& m = (dvar5_array &) _m; int imin; int imax; pvm_upkint(&imin,1,1); pvm_upkint(&imax,1,1); if (allocated(m)) { if (m.indexmin()!=imin) { cerr << "Error in min index in" " void pvm_unpack(const dvector& v)" << endl; ad_exit(1); } if (m.indexmax()!=imax) { cerr << "Error in max index in" " void pvm_unpack(const dvector& v)" << endl; ad_exit(1); } } else { m.allocate(imin,imax); } for (int i=imin;i<=imax;i++) pvm_unpack(m(i)); }
int main() { int in, out, diameter, total; int mytid = pvm_mytid(); // Init messages (1) pvm_recv(-1, 1); pvm_upkint(&total, 1, 1); pvm_upkint(&diameter, 1, 1); pvm_upkint(&in, 1, 1); pvm_upkint(&out, 1, 1); // get output nodes int outNodes[out]; memset(outNodes, -1, out * sizeof(int)); pvm_upkint(outNodes, out, 1); // Election message (2) int max = mytid; int i; for (i = 0 ; i < diameter ; ++i) { // Advertise my max to everybody int j; for(j = 0 ; j < out ; j++){ pvm_initsend(PvmDataRaw); pvm_pkint(&max, 1, 1); pvm_send(outNodes[j], 2); } // Get max from the neighbors for(j = 0 ; j < in ; j++){ int tmp = 0; pvm_recv( -1, 2); pvm_upkint(&tmp, 1, 1); if(tmp>max) max = tmp; } } // Send my max to the parent pvm_initsend(PvmDataRaw); pvm_pkint(&max, 1, 1); pvm_send(pvm_parent(), 3); pvm_exit(); }