• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ pvm_pkint函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: bcast_request_msg

void bcast_request_msg(struct state_info info) {
	int tag = MSG_REQUEST;
	*info.local_clock += 1;
	pvm_initsend(PvmDataDefault);
	pvm_pkint(&tag, 1, 1);
	pvm_pkint(&info.mytid, 1, 1);
	pvm_pkint(info.local_clock, 1, 1);
	pvm_pkint(info.my_lift_number, 1, 1);
	pvm_bcast(GROUP, MSG_REQUEST);

	*info.my_request_timestamp = *info.local_clock;

	char diag[200];
	sprintf(diag, "bcast MSG_REQUEST [timestamp=%d, lift_number=%s]", *info.local_clock, stringify(*info.my_lift_number));
	diag_msg(info.mstrtid, info.mytid, diag);
}
开发者ID:vincentvanbush,项目名称:ski-lift,代码行数:16,代码来源:skier.c


示例17: defined

void BBSClient::save_args(int userid) {
#if defined(HAVE_PKMESG)
#if defined(HAVE_STL)
	int bufid = pvm_setsbuf(pvm_mkbuf(PvmDataDefault));
	pvm_pkmesgbody(bufid);
	keepargs_->insert(
		pair<const int, int>(userid, bufid)
	);
	
#endif
	post_todo(working_id_);
#else
	int index, os;
	os = pvm_setsbuf(pvm_mkbuf(PvmDataDefault));
	pvm_pkint(&working_id_, 1, 1);
	pvm_send(sid_, CRAY_POST_TODO);
	os = pvm_setsbuf(os);
	index = pvm_send(sid_, CRAY_POST_TODO);
	os = pvm_setsbuf(os);
#if defined(HAVE_STL)
	keepargs_->insert(
		pair<const int, int>(userid, os)
	);
	
#endif
#endif
}
开发者ID:stephanmg,项目名称:neuron,代码行数:27,代码来源:bbsrcli.cpp


示例18: mbusAck

/*--------------------------------------------------------------------------
**  MBUSACK --  Send an ACK to the message bus.
**/
int
mbusAck (int tid, int tag)
{
    int ack = OK, info;


    pvm_initsend (PvmDataDefault);
    pvm_pkint (&ack, 1, 1);

    if (MB_DEBUG) 
	fprintf (stderr, "Sending ACK to %d about %d: ", tid, tag);

    if ((info = pvm_send (tid, tag)) < 0) {
	switch (info) {
	case PvmBadParam:
	    fprintf (stderr, "ACK to %d fails, bad tid or msgtag\n", tid);
	    return (ERR);
	case PvmSysErr:
	    fprintf (stderr, "ACK to %d fails, pvmd not responding\n", tid);
	    return (ERR);
	case PvmNoBuf:
	    fprintf (stderr, "ACK to %d fails, no active buffer\n", tid);
	    return (ERR);
	}
   }

    if (MB_DEBUG) 
	fprintf (stderr, "status=%d\n", info);

   return (info);
}
开发者ID:rlseaman,项目名称:kdhs_test,代码行数:34,代码来源:mbAck.c


示例19: SendRepeat

void
SendRepeat(ArgStruct *p, int rpt)
{
    pvm_initsend( PVMDATA );
    pvm_pkint( &rpt, 1, 1 );
    pvm_send( p->prot.othertid, 1);
}
开发者ID:andreimironenko,项目名称:ltp-full,代码行数:7,代码来源:PVM.c


示例20: main

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();
}
开发者ID:metjka,项目名称:pvmSort,代码行数:27,代码来源:sort_master.c



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ pwarn函数代码示例发布时间:2022-05-30
下一篇:
C++ pvm_initsend函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap