当前位置: 首页>>代码示例>>C++>>正文


C++ pvm_pkint函数代码示例

本文整理汇总了C++中pvm_pkint函数的典型用法代码示例。如果您正苦于以下问题:C++ pvm_pkint函数的具体用法?C++ pvm_pkint怎么用?C++ pvm_pkint使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了pvm_pkint函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: PackIndividual

// Send the bits of the genome to the task that requested them.  First we send
// the number of bits, then we send the bits themselves.  Note that we can 
// handle genomes of varying lengths with this setup.  We also pack the score
// and stuff that in as well (so that they don't have to do an eval at the
// other end).  If we did this as a member function we could save the hassle
// of an extra copy of the bits...
//   Returns negative number (error code) if failure.
int
PackIndividual(GAGenome& g) {
  GA1DBinaryStringGenome& genome = (GA1DBinaryStringGenome&)g;
  static int* bits = 0;
  static int nbits = 0;
  int status = 0;;

  if(nbits < genome.length()){
    nbits = genome.length();
    delete [] bits;
    bits = new int [nbits];
  }

  int length = genome.length();
  for(int i=0; i<length; i++)
    bits[i] = genome.gene(i);

  status = pvm_pkint(&length, 1, 1);
  status = pvm_pkint(bits, length, 1);

  float score = g.score();
  status = pvm_pkfloat(&score, 1, 1);

  return status;
}
开发者ID:distanceModling,项目名称:GAlib,代码行数:32,代码来源:genome.C

示例2: pkjobinfo_active

/* data packing functions */
void pkjobinfo_active(jobinfo *j) {
  pvm_pkint(&j->jid,6,1);        // jid, tid, pjid, d, a, n
  pvm_pkint(&j->s.k,4,1);        // k,o,r,rd
  pvm_pkbyte(&j->s.p,2+TPITS,1);
  pvm_pkbyte(j->s.m,MAXMVC,1);
  pvm_pkint(j->o,4*PITS,1);      // o, js, ctid, cjid
  }
开发者ID:girving,项目名称:kalah,代码行数:8,代码来源:parallel.c

示例3: main

int main(int argc, char **argv){
	int bufid,ptid;
	NodoBusqueda nodo_inicial, *resul;
	int exito=1,fracaso=0;

	ptid=pvm_parent();
	bufid=pvm_recv(ptid,_TIPOMSG_NODOBUSQUEDA);
	pvm_upkNodoBusqueda(&nodo_inicial);

	resul=resolverRecursivo(nodo_inicial);

	if(resul){
		//enviamos que tuvimos exito, para luego enviar el NodoBusqueda
		pvm_initsend(PvmDataDefault);
		pvm_pkint(&exito,1,1);
		pvm_send(ptid,_TIPOMSG_EXITOFRACASO);

		pvm_initsend(PvmDataDefault);
		pvm_pkNodoBusqueda(resul);
		pvm_send(ptid,_TIPOMSG_NODOBUSQUEDA);
	}else{
		//enviar mensaje de que no se alcanzo solucion por esta rama
		pvm_initsend(PvmDataDefault);
		pvm_pkint(&fracaso,1,1);
		pvm_send(ptid,_TIPOMSG_EXITOFRACASO);
	}
	pvm_exit();
	exit(0);
}
开发者ID:jucaroha88,项目名称:sudoku,代码行数:29,代码来源:sudokuterm.c

示例4: send_tour

void send_tour(_node *tour, int cost, int numroutes, int algorithm,
	       double cpu_time, int parent, int vertnum, int routes,
	       route_data *route_info)
{ 
   int s_bufid, info;
   
   PVM_FUNC(s_bufid, pvm_initsend(PvmDataRaw));
   PVM_FUNC(info, pvm_pkbyte((char *)tour, (vertnum)*sizeof(_node), 1));
   PVM_FUNC(info, pvm_pkint(&cost, 1, 1));
   PVM_FUNC(info, pvm_pkint(&numroutes, 1, 1));
   PVM_FUNC(info, pvm_pkint(&algorithm, 1, 1));
   PVM_FUNC(info, pvm_pkdouble(&cpu_time, 1, 1));
   if (routes){
      PVM_FUNC(info, pvm_pkbyte((char *)route_info, 
				(numroutes+1)*sizeof(route_data), 1));
      PVM_FUNC(info, pvm_send(parent, HEUR_TOUR_WITH_ROUTES));
      printf("\nSent HEUR_TOUR_WITH_ROUTES\n\n");
   }
   else{
      PVM_FUNC(info, pvm_send(parent, HEUR_TOUR));
      printf("\nSent HEUR_TOUR\n\n");
   }
   PVM_FUNC(info, pvm_freebuf(s_bufid));

   return;
}
开发者ID:e2bsq,项目名称:Symphony,代码行数:26,代码来源:heur_routines.c

示例5: mcast_accept_msg

void mcast_accept_msg(struct state_info info) {
	char diag[200];
	GQueue *waiting_req_q = (*info.my_lift_number == LIFT_1) ? info.waiting_req_q1 : info.waiting_req_q2;
	int len = g_queue_get_length(waiting_req_q);
	// diag_msg(info.mstrtid, info.mytid, "*** 0");
	int *tids = malloc(len * sizeof(int));
	int i = 0;
	sprintf(diag, "*** %d processes awaiting accepts", g_queue_get_length(info.waiting_req_q));
	diag_msg(info.mstrtid, info.mytid, diag);
	while (!g_queue_is_empty(waiting_req_q)) {
		int *tid = g_queue_pop_head(waiting_req_q);
		int *sender_weight_ptr = g_hash_table_lookup(info.skiers_weights, tid);
		int *lift_free = (*info.my_lift_number == LIFT_1) ? info.lift1_free : info.lift2_free;
		*lift_free -= *sender_weight_ptr;
		tids[i] = *tid;
		i++;
		sprintf(diag, "*** mcast MSG_ACCEPT to %d [weight=%d]", *tid, *sender_weight_ptr);
		diag_msg(info.mstrtid, info.mytid, diag);
	}
	*info.local_clock += 1;

	int tag = MSG_ACCEPT;
	pvm_initsend(PvmDataDefault);
	pvm_pkint(&tag, 1, 1);
	pvm_pkint(&info.mytid, 1, 1);
	pvm_pkint(info.local_clock, 1, 1);
	pvm_mcast(tids, len, tag);

	sprintf(diag, "mcast MSG_ACCEPT to %d waiting processes [timestamp=%d]", len, *info.local_clock);
	diag_msg(info.mstrtid, info.mytid, diag);
}
开发者ID:vincentvanbush,项目名称:ski-lift,代码行数:31,代码来源:skier.c

示例6: gen_x

void gen_x(int num)
{
	copy_request("get_mul", 1) ;
	sleep(1) ;
	int mul_tid = get_tid("get_mul_copy", 1) ;
	int mynum = copynum(myname, mytid) ;
	int mul_inpnum ;
	if(mynum == 1)
		mul_inpnum = 0;
	else if(mynum == 2)
		mul_inpnum = 1 ;
	else
	{
		printf("[%s][gen_x]:my copy num=%d, but conditions are only for 1 and 2\n",myname, mynum) ;
		pvm_exit() ;
		exit(0) ;
	}
	for(int i = 0 ; i < num; ++i)
	{
		pvm_initsend(PvmDataDefault) ;
		pvm_pkint(&mul_inpnum, 1, 1) ;
		int num = i + 1 ;
		pvm_pkint(&num, 1 ,1) ;
		pvm_send(mul_tid, i) ;
	}
return ;
}
开发者ID:Mityuha,项目名称:gspp,代码行数:27,代码来源:gen_x_copy.c

示例7: pvm_initsend

void Semafor::sendAllow(int who, int turn) { //wyslanie zgody
int type = SEM_ALLOW;
pvm_initsend(PvmDataDefault);
pvm_pkint(&mytid,1,1);
pvm_pkint(&type,1,1);
pvm_pkint(&turn,1,1); //tutaj ta tura to nie jest tura tego obiektu, to tura odebrana z zadania do wejscia do sekcji
pvm_pkint(&my_id,1,1);
pvm_send(who, my_id);
}
开发者ID:maciejasembler,项目名称:DistributedMonitor,代码行数:9,代码来源:semafor.cpp

示例8: pvm_pack

/**
 * Description not yet available.
 * \param
 */
void pvm_pack(const dvar_vector& _v)
{
  dvar_vector& v =(dvar_vector&) _v;
  int imin=v.indexmin();
  int imax=v.indexmax();
  pvm_pkint(&imin,1,1);
  pvm_pkint(&imax,1,1);
  pvm_pkdouble(&(value(v(imin))),imax-imin+1,1);
}
开发者ID:colemonnahan,项目名称:admb,代码行数:13,代码来源:adpvm2.cpp

示例9: adpvm_pack

/**
 * Description not yet available.
 * \param
 */
void adpvm_pack(const ivector& _v)
{
  ivector& v =(ivector&) _v;
  int imin=v.indexmin();
  int imax=v.indexmax();
  pvm_pkint(&imin,1,1);
  pvm_pkint(&imax,1,1);
  pvm_pkint(&(v(imin)),imax-imin+1,1);
}
开发者ID:colemonnahan,项目名称:admb,代码行数:13,代码来源:adpvm2.cpp

示例10: PackFile

void PackFile (int fd) {
  int n;
  char buf[PACKFILEBUFFERSIZE];
  while ((n = read (fd, buf, sizeof (buf))) > 0) {
    assert (! pvm_pkint (&n, 1, 1));
    assert (! pvm_pkbyte (buf, n, 1));
  }
  n = 0;
  assert (! pvm_pkint (&n, 1, 1));
}
开发者ID:amnh,项目名称:malign,代码行数:10,代码来源:pvm.c

示例11: send_result

void send_result(int tid, tresult *result) {
	int    *tint, bufid, datasize, i, toint[RESULT_NINT];
	double *tdbl, todbl[RESULT_NDBL];

	toint[RESULT_ID]    = (int)(result->id);
	toint[RESULT_CHANS] = (int)(result->chans);
	toint[RESULT_BIAS]  = (int)(result->bias != NULL);
	toint[RESULT_SIGNS] = (int)(result->signs != NULL);

	todbl[RESULT_LRATE] = (double)(result->lrate);
	
	bufid = pvm_initsend(PvmDataDefault);
	pvm_pkint(toint,RESULT_NINT,1);
	pvm_pkdouble(todbl,RESULT_NDBL,1);

	datasize = result->chans * result->chans;
	if (sizeof(double) != sizeof(doublereal)) {
		tdbl = (double*)malloc(datasize*sizeof(double));
		for (i=0 ; i<datasize ; i++) tdbl[i] = (double)(result->weights[i]);
		pvm_pkdouble(tdbl,datasize,1);
		free(tdbl);
	}
	else
		pvm_pkdouble((double*)(result->weights),datasize,1);

	if (result->bias != NULL) {
		datasize = result->chans;
		if (sizeof(double) != sizeof(doublereal)) {
			tdbl = (double*)malloc(datasize*sizeof(double));
			for (i=0 ; i<datasize ; i++) tdbl[i] = (double)(result->bias[i]);
			pvm_pkdouble(tdbl,datasize,1);
			free(tdbl);
		}
		else
			pvm_pkdouble((double*)(result->bias),datasize,1);
	}

	if (result->signs != NULL) {
		datasize = result->chans;
		if (sizeof(int) != sizeof(integer)) {
			tint = (int*)malloc(datasize*sizeof(int));
			for (i=0 ; i<datasize ; i++) tint[i] = (int)(result->signs[i]);
			pvm_pkint(tint,datasize,1);
			free(tint);
		}
		else
			pvm_pkint((int*)(result->signs),datasize,1);
	}
	
	pvm_send(tid,1);
	pvm_freebuf(bufid);
}
开发者ID:caromk,项目名称:binica,代码行数:52,代码来源:pvmica.c

示例12: PackBufferedTree

void PackBufferedTree (BufferedTreeT *bt, int support_stuff) {
  int i;
/*   { */
/*     int i; */
/*     fprintf (stderr, "packing 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'); */
/*   } */
  assert (! pvm_pkint (&bt->n_placed_taxa, 1, 1));
  assert (! pvm_pkint ((int *)bt->nodes, bt->n_placed_taxa, 1));
  assert (! pvm_pkint (bt->placed_taxa_indices, bt->n_placed_taxa, 1));
  if (support_stuff) {
    SENTWITH++;
    assert (! pvm_pkint (&bt->n_supported_clades, 1, 1));
    LoopBelow (i, bt->n_supported_clades)
      assert (! pvm_pkint (bt->supported_clades[i], BitVectorWords, 1));
    assert (! pvm_pkint (&bt->supported_clades_hash, 1, 1));
  } else {
    SENTWITHOUT++;
    bt->n_supported_clades = bt->supported_clades_hash = 0;
  }
  assert (! pvm_pkint (&bt->cost, 1, 1));
  assert (! pvm_pkint (&bt->generation, 1, 1));
}
开发者ID:amnh,项目名称:malign,代码行数:27,代码来源:pvm.c

示例13: pvm_initsend

void Buffer::broadcast_update(int newval) {
int i;
int info = newval;
int typ = BUFFER_UPDATE;
for (i=0;i<nproc;i++) {
if (tids[i]!=mytid) {
pvm_initsend(PvmDataDefault);
pvm_pkint(&mytid,1,1);
pvm_pkint(&typ,1,1);
pvm_pkint(&info,1,1);
pvm_pkint(&my_id,1,1);
pvm_send(tids[i],my_id);
}
}
}
开发者ID:maciejasembler,项目名称:DistributedMonitor,代码行数:15,代码来源:buffer.cpp

示例14: main

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();
}
开发者ID:cwayembergh,项目名称:north-american-octo-batman,代码行数:48,代码来源:slave.c

示例15: main

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;	
}
开发者ID:allnightdiner,项目名称:parallel_ga,代码行数:48,代码来源:slave_fit.c


注:本文中的pvm_pkint函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。