[mpich-discuss] Problem creating new MPI_DATATYPE
    Sunshine Sunshine 
    sunshine1414 at hotmail.fr
       
    Thu Apr 26 06:05:31 CDT 2012
    
    
  
Good morning,
I want to create a new MPI_DATATYPE for my structure FRAGMENT:
struct elt
{ long ind;
  double val;
};
typedef struct elt elt;
struct Fragment
{ 
  int num;
  elt *elt;
};
typedef struct Fragment  Fragment;
I tried the following code:
MPI_Datatype MPI_elt;
MPI_Datatype typeelt[3] = {MPI_LONG,MPI_DOUBLE};
int l_bloc[2]={1,1};
MPI_Aint dispo[2];
elt ELT;
MPI_Address(&ELT.ind, dispo); 
MPI_Address(&ELT.val, dispo+1); 
MPI_Aint base2 = dispo[0]; 
for (j=0; j <2; j++) dispo[j] -= base2;
MPI_Type_struct(2, l_bloc,dispo,typeelt,&MPI_elt);    
MPI_Type_commit(&MPI_elt);
MPI_Datatype MPI_FRAGMENT
MPI_Datatype typeFRAGMENT[2] = {MPI_INT,MPI_AINT};
int l_bloc3[2]={1,1};
MPI_Aint disposition[2];
Fragment FN;
MPI_Address(&FN.num, disposition); 
MPI_Address(&FN.elt, disposition+1);
MPI_Aint base3 = disposition[0]; 
for (j=0; j <2; j++) disposition[j] -= base3;
MPI_Type_struct(2, l_bloc3,disposition, typeFRAGMENT,&MPI_FRAGMENT);    
MPI_Type_commit(&MPI_FRAGMENT);
And i used MPI_scatter to send data for all processor, 
MPI_Scatter(F, count, MPI_FRAGMENT, &rbuf, count, MPI_FRAGMENT, 0, MPI_COMM_WORLD); 
for(i=0;i<count;i++)
        {printf("%d \n",rbuf[i].num);
         for(j=0;j<rbuf[i].num;j++)
            {printf("%f ",rbuf[i].elt[j].val);}
        }
I get the right value of "rbuf[i].num", but i can't read all values of "elt":
19: 35.000000 
16: 10.000000 
17: 
=====================================================================================
=   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)
Any help please.
Thanks.
 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/mpich-discuss/attachments/20120426/c2606915/attachment.htm>
    
    
More information about the mpich-discuss
mailing list