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

C++ pvm_initsend函数代码示例

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

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



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

示例1: main

int main(void){
    int tid; /*this task id */
    int bufid, master, bytes, msgtag, source;
    char * graph_text = NULL;
    int **matrix;
    int degree, edges;
    int len;
    int i;
    int greycodeLength;
    
    tid = pvm_mytid();          /*enroll in pvm */
    master = pvm_parent();      /*get the master id */

    while (1){    
        /*Get the first graph */
        pvm_initsend(PvmDataDefault);
        pvm_pkstr("");                                        /*Just put something in the buffer */
        pvm_send(master, MSGREQTASK);                         /* Request a task */
        bufid = pvm_recv(master, MSGTASK);                    /* Get the task */
        pvm_bufinfo(bufid, &bytes, &msgtag, &source);  /* Get the size of the text */
        graph_text = malloc(bytes);                           
        pvm_upkstr(graph_text);                               /* Unpack the text */

        len = strlen(graph_text);
        if(graph_text[len - 1] == '\n')
            graph_text[len - 1] = '\0';
            

        matrix = create_matrix(graph_text, &degree);          /*Generate the appropriate matrix */
        populate_matrix(graph_text, matrix, &edges, degree);

        greycodeLength = 1 << degree;
        // Initialize code (where the greycode is stored)
        int * vals = calloc(2 * greycodeLength, sizeof(int));
        int ** code = malloc(greycodeLength * sizeof(int *)); 

       for(i = 0; i < greycodeLength; i++){                     /*assign rows within the allocated space */ 
          code[i] = vals + i*2;
        }
	
        /*** DO GREYCODE ALGORITHM ON THE MATRIX ***/
        if(greycode(degree, matrix, code) == 1){                      /*If we found a code */
            pvm_initsend(PvmDataDefault);
            pvm_pkstr(graph_text);
            pvm_send(master, MSGCODE);
        } else{                                               /*Didnt find a code */
            pvm_initsend(PvmDataDefault);
            pvm_pkstr(graph_text);
            pvm_send(master,MSGNOCODE);
        }

        destroy_matrix(matrix);                               /* Free the memory associated with the matrix */
        destroy_matrix(code);
	    free(graph_text);
    }
 
    pvm_exit();
    exit(0);

}
开发者ID:deanaarons,项目名称:graphic-gray-code,代码行数:60,代码来源:worker.c


示例2: 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


示例3: steal

/* steal jobs from other workers */
jobinfo* steal() {
  int i,w,b;
  int len,tid,tag;
  jobinfo *j;
  w = random() % nw;
  for (;;) {
    if (wtid[w] != stid) {
      pvm_initsend(0);
      pvm_send(wtid[w],TAG_REQUEST);
      for (;;) {
        b = pvm_recv(-1,-1);
        pvm_bufinfo(b,&len,&tag,&tid); 
        if (tag == TAG_JOB || tag == TAG_NO_JOB)
          break; 
        else if (tag == TAG_REQUEST) {
          pvm_initsend(0); 
          pvm_send(tid,TAG_NO_JOB);
          }
        else
          p_handle(b);
        }
      if (tag == TAG_JOB)
        break;
      }
    if (++w == nw)
      w = 0;
    }
  
  j = malloc(sizeof(jobinfo));
  upkjobinfo_active(j);
  ha_lookup(ha,&j->s.da,&j->s.p);
  return j;
  }
开发者ID:girving,项目名称:kalah,代码行数:34,代码来源:parallel.c


示例4: 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


示例5: 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


示例6: printf

void BBSClient::start() {
	char* client = 0;
	int tid;
	int n;
	if (started_) { return; }
#if debug
printf("BBSClient start\n");
fflush(stdout);
#endif
	BBSImpl::start();
	mytid_ = pvm_mytid();
	if (mytid_ < 0) { perror("start"); }
	tid = pvm_parent();
	sid_ = tid;
	if (tid == PvmSysErr) {
		perror("start");
	}
	assert(tid > 0);
	{ // a worker
		is_master_ = false;
		pvm_initsend(PvmDataDefault);
		nrnmpi_myid = get(HELLO);
		assert(nrnmpi_myid > 0);
		return;
	}
}
开发者ID:stephanmg,项目名称:neuron,代码行数:26,代码来源:bbsrcli.cpp


示例7: 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


示例8: GARandomSeed

// To initialize this genetic algorithm, we make sure all of our spawns are
// not evolving then we tell them all to initialize themselves.  Then we wait
// and copy their populations into our own.  Update our stats based upon the
// harvested populations.
void
PVMDemeGA::initialize(unsigned int seed) {
  GARandomSeed(seed);

  if(_mid == 0) return;

#ifdef DEBUG
  cerr << "sending initialize command to slaves...\n";
#endif

  for(int j=0; j<_ntid; j++) {
    _status = pvm_initsend(PvmDataDefault);
    _status = pvm_send(_tid[j], MSG_INITIALIZE);
  }

  collect();

  for(int i=0; i<_ntid; i++) {
    pstats[i].reset(*deme[i]);
    pop->individual(i).copy(deme[i]->best());
  }

  pop->touch();
  stats.reset(*pop);
}
开发者ID:distanceModling,项目名称:GAlib,代码行数:29,代码来源:PVMDemeGA.C


示例9: main

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;
}
开发者ID:jucaroha88,项目名称:sudoku,代码行数:60,代码来源:sudokuhub.c


示例10: send_kill

void send_kill(int tid) {
	int bufid;

	bufid = pvm_initsend(PvmDataDefault);
	pvm_send(tid,2);
	pvm_freebuf(bufid);
}
开发者ID:caromk,项目名称:binica,代码行数:7,代码来源:pvmica.c


示例11: 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


示例12: sendEof

void sendEof(FilterPlacement *pFilterP) {
    pvm_initsend(PvmDataRaw);
    int tipo_msg = MSGT_EOF;
    pvm_pkint(&tipo_msg, 1, 1);
    //sends the EOF message for all instances of the filter
    pvm_mcast(pFilterP->tids, pFilterP->numInstances, 0);
}
开发者ID:barroca,项目名称:Anthill,代码行数:7,代码来源:Manager.c


示例13: SendTime

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


示例14: 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


示例15: kill_workers

void kill_workers ()
{
	printf ("INFO: Killing the workers\n") ;
	/* kill all the worker */
	pvm_initsend(PvmDataDefault) ;
	pvm_mcast (Worker_tids,NUMBER_OF_WORKERS,KILL) ;

	/* close the window */
	auxCloseWindow() ;

	/* exit pvm */
	pvm_exit() ;

	/* free the pixel buffer */
	free (Pixel_buffer) ;

	/* free the pixel buffer */
	free (Image_buffer) ;

	/* free the worker tids */
	free (Worker_tids) ;

	/* exit the program */
	auxQuit() ;

}
开发者ID:zoenolan,项目名称:RaycastingFractalTerrain,代码行数:26,代码来源:main.c


示例16: 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


示例17: sendOpNV

//@cindex sendOpNV
void
sendOpNV(OpCode op, GlobalTaskId task, int nelem, 
	 StgWord *datablock, int narg, ...)
{
    va_list ap;
    int i;
    StgWord arg;

    va_start(ap, narg);

    traceSendOp(op, task, 0, 0);
    IF_PAR_DEBUG(trace,
		 fprintf(stderr,"~~ sendOpNV: op = %x (%s), task = %x, narg = %d, nelem = %d",
		       op, getOpName(op), task, narg, nelem));

    pvm_initsend(PvmDataRaw);

    for (i = 0; i < narg; ++i) {
	arg = va_arg(ap, StgWord);
        IF_PAR_DEBUG(trace,
		     fprintf(stderr,"~~ sendOpNV: arg = %d\n",arg));
	PutArgN(i, arg);
    }
    arg = (StgWord) nelem;
    PutArgN(narg, arg);

/*  for (i=0; i < nelem; ++i) fprintf(stderr, "%d ",datablock[i]); */
/*  fprintf(stderr," in sendOpNV\n");*/

    PutArgs(datablock, nelem);
    va_end(ap);

    pvm_send(task, op);
}
开发者ID:Ericson2314,项目名称:lighthouse,代码行数:35,代码来源:LLComms.c


示例18: SendReady

int
SendReady(int tid) {
  int status = 0;
  status = pvm_initsend(PvmDataDefault);
  status = pvm_send(tid, MSG_READY);
  return status;
}
开发者ID:distanceModling,项目名称:GAlib,代码行数:7,代码来源:genome.C


示例19: 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


示例20: init_send

int init_send(int data_packing)
{
   int s_bufid;

   PVM_FUNC(s_bufid, pvm_initsend(PvmDataRaw));

   return(s_bufid);
}
开发者ID:e2bsq,项目名称:Symphony,代码行数:8,代码来源:proccomm.c



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ pvm_pkint函数代码示例发布时间:2022-05-30
下一篇:
C++ pvalue函数代码示例发布时间: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