Newsgroups: comp.parallel.pvm
From: salil@ccs.neu.edu (Salil V Pradhan)
Subject: ILLEGAL INSTRUCTION !!HELP!!
Organization: College of Computer Science, Northeastern University.
Date: 18 Nov 1994 18:35:02 GMT
Message-ID: <3ais4m$dco@narnia.ccs.neu.edu>

********************************************************************
I'm getting a illegal instruction error when I run the following program
(master)
**********************************************************************

#include <stdio.h>
#include "pvm3.h"
#define SLAVENAME "slave1"
#define SLAVES 10
#define MAX 20

int h[MAX];
int  k[MAX];
int l[MAX] ;
long index = 0 ; 



#define DEGREE 3    /* for computing triplets */
long tbuf[DEGREE] ;
#define FIN  "Input.inv"   /* Input data file */
#define FOUT "Output.inv"  /* Processed output */



int SendJobToSlave() ;
long * NextTask() ;



long  LoadTable(char *fname)
{

FILE *n ;


float n1,n2 ;
char tmp[80] ;


n = fopen(fname, "r") ;
if (n==NULL)
  {
    printf("Unable to open file %s\n", fname) ;
    abort() ;
  }
while (fgets(tmp, 80, n))
{
    if (sscanf(tmp,"%d %d %d %f %f", &h[index], &k[index], &l[index], &n1, &n2)<5) break;
    
    index++ ;    
}
return ;
}  


main()
{
    int mytid;                  /* my task id */
    int tids[SLAVES];				/* slave task ids */
    int n, nproc, i, who, msgtype;
    float data[100], result[32];
    long *nTask ;
    int freeSlave, mstat ;
     printf("hi\n") ;
     
    /* enroll in pvm */
    mytid = pvm_mytid(); 
    
    LoadTable("/home/salil/pvm3/inv/amide.hkl") ;
      

    if (pvm_spawn(SLAVENAME, (char**)0, 0, "", SLAVES, tids) >0)
      printf("Started slaves\n");
      

    for (i=0; i<SLAVES ; i++ ){
      SendJobToSlave( tids[i], NextTask() ) ;

    }
    
    while ( nTask =(long *) NextTask()) {
      freeSlave = GetResultFromSlave() ;
      SendJobToSlave(freeSlave, nTask) ;
    }
    printf("Computation of triplets over : results in %s\n",FOUT) ;
    
    for (i=0; i<SLAVES ; i++ ){
      pvm_kill( tids[i]) ;

    }
    pvm_exit() ;
	 



}

int SendJobToSlave(slaveId, tsk)
int slaveId ;
long* tsk ;
{
   printf("Sending job to slave\n") ; 
   pvm_initsend(PvmDataDefault) ;
   pvm_pklong(tsk, 3, 1) ; 
   pvm_send(slaveId, 1) ;
  
  }

int   GetResultFromSlave()
  {
    static int matches ;
    long tsk[DEGREE] ;
    int bytes, type, source ;
    
    pvm_bufinfo(pvm_recv( -1, 2 ), &bytes, &type, &source);
    pvm_upklong(tsk, 3, 1 );
    
    printf("HEY: got a value from a slave\n") ;
   
    if (tsk[0]!=-1)
      printf("Got Values from slave - %ld\t %ld\t %ld  ** Matches - %d\n",tsk[0],tsk[1],tsk[2],++matches) ; 
    
    return source ;
  }

long * NextTask() 
  {

    static long x, y ;

    if (y>index) 
                  y = ++x + 1;
      
    tbuf[0] = h[x] + h[y];
    tbuf[1] = k[x] + k[y];
    tbuf[2] = l[x] + l[y];

    if (x == index ) return NULL ;	 
    return tbuf;

  }




--------------------------------

The error occurs while executing pvm_mytid(). I tried running other programs 
they work fine..

What could be wrong????

--Salil



--
Salil Pradhan			|	75, St. Alphonsus St.
Graduate Student, CCS		|	Apt #1112, Boston MA 02120
Northeastern University   	|	Tel. (617)730-5993
Boston, MA 02115        	|	salil@ccs.neu.edu
Tel. (617)373-4607		|	http://www.ccs.neu.edu/home/salil

