[mpich-discuss] custom defined mpi data type

Sufeng Niu sniu at hawk.iit.edu
Mon Jul 15 16:32:40 CDT 2013


Hi,

I try to broadcast a self-defined data type struct, but I found that every
time the last value I cannot send it out. ex:
my data struct is:
typedef struct image_info_type{
        int width;
        int length;
        int page_num;
        int buffer_width;
        int buffer_length;
        long int buffer_size;
        long int image_size;
} image_info_type;

in my MPI program:
        ...............
        int count = 7;
        MPI_Datatype MPI_Imageinfo;
        MPI_Datatype types[7] = {MPI_INT, MPI_INT, MPI_INT, MPI_INT,
MPI_INT, MPI_LONG, MPI_LONG};
        int len[7] = {1, 1, 1, 1, 1, 1, 1};
        MPI_Aint disp[7];
        long int base;
        MPI_Address(image_info, disp);
        MPI_Address(&(image_info->width), disp+1);
        MPI_Address(&(image_info->length), disp+2);
        MPI_Address(&(image_info->page_num), disp+3);
        MPI_Address(&(image_info->buffer_width), disp+4);
        MPI_Address(&(image_info->buffer_length), disp+5);
        MPI_Address(&(image_info->buffer_size), disp+6);
        base = disp[0];
        for(i=0; i<7; i++)
                disp[i] -= base;

        MPI_Type_struct(count, len, disp, types, &MPI_Imageinfo);
        MPI_Type_commit(&MPI_Imageinfo);
        ...................

However, when I print out every information on each rank. the image_size is
always 0. I cannot figure out anything wrong with my program. I would
appreicate that if any one can give any suggestions. Thank you!


-- 
Best Regards,
Sufeng Niu
ECASP lab, ECE department, Illinois Institute of Technology
Tel: 312-731-7219
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mpich.org/pipermail/discuss/attachments/20130715/6bceb8ed/attachment.html>


More information about the discuss mailing list