[mpich-discuss] help me rectify this mpi error please

Mohammad Zulqurnain prodigiousguy at hotmail.com
Sun Oct 30 03:22:13 CDT 2011


i am unable to detect an error in this code can someone please help me with this:Following error is encountered when i execute this code:======================================================================================   BAD TERMINATION OF ONE OF YOUR APPLICATION PROCESSES=   EXIT CODE: 11=   CLEANING UP REMAINING PROCESSES=   YOU CAN IGNORE THE BELOW CLEANUP MESSAGES=====================================================================================APPLICATION TERMINATED WITH THE EXIT STRING: Segmentation fault (signal 11)

code:long fitness(    /* The chromosome to be judged */    chromosome_t* c,    /* Historic prices */    unsigned int* h  ){ int rank = MPI::COMM_WORLD.Get_rank();    int size = MPI::COMM_WORLD.Get_size();    long total_price = 0;    long avg_price;    long price;    long shares = 0;    long cash = 0;    unsigned int t;     MPI_Status status;      /*we apply parallelism here*/if(rank!=0){    for(int t=((rank-1)*(HISTORY_LENGTH/size)); t<((rank)*( HISTORY_LENGTH/size)); t++)    {        price = h[t];        total_price += price;        avg_price = total_price / (t + 1);
        /* Make price relative to average */        price -= avg_price;
        /* Convert price to percentage value */        price = price * 100 / avg_price;
        if(-price >= (long)Gray_to_bin(c->buy_price))        {            /* Buy another share */            ++shares;            cash -= (long)h[t];        }        else if(price >= (long)Gray_to_bin(c->sell_price))        {            /* Sell another share */            --shares;            cash += (long)h[t];        }    }	/* Cash out of holdings at the end for comparisons */    cash += shares * (long)h[t-1];printf("processor %d gave cash= %d .\n",rank,cash);//sendCash(0, 0,0,cash);   MPI_Send(&cash,1,MPI_LONG,0,0, MPI_COMM_WORLD);
}//MPI_Barrier(MPI_COMM_WORLD);if(rank==0){
long recieved_cash;for(int i=1; i<size; i++)    	{
           long cash_recieved;		  //	cash+=recieveCash(i, 0,0,recieved_cash);          MPI_Recv(&cash_recieved,1,  MPI_LONG,i, 0, MPI_COMM_WORLD, &status);          cash+=cash_recieved;			 printf("master processor is taking  cash from the slave processor %d ",i);
    	}      MPI_Barrier(MPI_COMM_WORLD);}


 // MPI_Barrier(MPI_COMM_WORLD);    return cash;} 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/mpich-discuss/attachments/20111030/fe46e8ce/attachment.htm>


More information about the mpich-discuss mailing list