Parallel-Pvm

 view release on metacpan or  search on metacpan

Pvm.xs  view on Meta::CPAN


int
psend(tid,tag,...)
  int   tid
  int  tag
  PREINIT:
  int i;
  char *str, *po;
  char *buf, *in;
  STRLEN buflen = 0;
  CODE:
  if ( items <= 2 )
     croak("Usage: Parallel::Pvm::psend(@argv)");
  for(i=2;i<items;i++)
  {
    STRLEN len;
    po = (char *)SvPV(ST(i), len);
    buflen += len + 1;
  }
  New(2401, buf, buflen, char);
  in = buf;
  for(i=2;i<items;i++)
  {
    STRLEN len; int j;
    po = (char *)SvPV(ST(i), len);
    for (j=0;j<len;j++) 
      *(in++) = *(po++);
    *(in++) = '\v';
  }
  *(--in) = '\0';               /* we are sure that items > 2 and
                                   therefore in > buf */
  RETVAL = pvm_psend(tid,tag,buf,buflen,PVM_BYTE);
  Safefree(buf);
  OUTPUT:
  RETVAL


int
mcast(...)
  PREINIT:
  int i;
  int tag_num;
  int proc_num;
  int tids[MAXPROCS];
  int tag;
  CODE:
  if ( items < 2 )
    croak("Usage: Parallel::Pvm::pvm_mcast(tids_list,tag)");
  for (i=0;i<items-1;i++)
  {
    tids[i] = SvIV(ST(i));
  }
  proc_num = tag_num = items-1;
  tag = SvIV(ST(tag_num));
  RETVAL = pvm_mcast(tids,proc_num,tag);
  OUTPUT:
  RETVAL


int
pvm_sendsig(tid,sig)
  int	tid
  int	sig

int
pvm_probe(tid=-1,tag=-1)
  int	tid
  int	tag

int
pvm_recv(tid=-1,tag=-1)
  int	tid
  int	tag

int
pvm_nrecv(tid=-1,tag=-1)
  int	tid
  int	tag

int
trecv(tid=-1,tag=-1,sec=1,usec=0)
  int  tid
  int  tag
  int  sec
  int  usec
  PREINIT:
  struct timeval tmout;
  CODE:
  tmout.tv_sec = sec;
  tmout.tv_usec = usec;
  RETVAL = pvm_trecv(tid,tag,&tmout);
  OUTPUT:
  RETVAL
  
  
void
precv(tid=-1,tag=-1,buflen=MAXSTR)
  int   tid
  int   tag
  int   buflen
  PREINIT:
  int info, src, stag, scnt;
  char *buf;
  char *po;
  int type;
  PPCODE:
  New(2401, buf, buflen, char);

  info = pvm_precv(tid,tag,buf,buflen,PVM_BYTE,&src,&stag,&scnt);
  XPUSHs(sv_2mortal(newSViv(info)));
  XPUSHs(sv_2mortal(newSViv(src)));
  XPUSHs(sv_2mortal(newSViv(stag)));
  po = strtok(buf,"\v");
  while ( po != NULL )
  {
	/* Change: Everything is a string 
     * sn@neopoly.com Fri Feb  9 13:41:46 CET 2001 */
    XPUSHs(sv_2mortal(newSVpv(po,0)));
    po = strtok(NULL,"\v");
  }
  Safefree(buf);



( run in 0.930 second using v1.01-cache-2.11-cpan-71847e10f99 )